Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
Ursprung
0da5b65858
Commit
0166d1a3b1
@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
|||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
@ -37,15 +38,19 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
|||||||
map(Type.BYTE); // 6 - Pitch
|
map(Type.BYTE); // 6 - Pitch
|
||||||
map(Type.BYTE); // 7 - Yaw
|
map(Type.BYTE); // 7 - Yaw
|
||||||
map(Type.INT); // 8 - Data
|
map(Type.INT); // 8 - Data
|
||||||
handler(wrapper -> {
|
handler(getSpawnTracketWithDataHandler(fallingBlockType));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketHandler getSpawnTracketWithDataHandler(EntityType fallingBlockType) {
|
||||||
|
return wrapper -> {
|
||||||
EntityType entityType = setOldEntityId(wrapper);
|
EntityType entityType = setOldEntityId(wrapper);
|
||||||
if (entityType == fallingBlockType) {
|
if (entityType == fallingBlockType) {
|
||||||
int blockState = wrapper.get(Type.INT, 0);
|
int blockState = wrapper.get(Type.INT, 0);
|
||||||
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
|
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSpawnTracker(ClientboundPacketType packetType) {
|
public void registerSpawnTracker(ClientboundPacketType packetType) {
|
||||||
|
@ -44,7 +44,37 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK);
|
protocol.registerOutgoing(ClientboundPackets1_16.SPAWN_ENTITY, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
|
map(Type.DOUBLE); // 3 - X
|
||||||
|
map(Type.DOUBLE); // 4 - Y
|
||||||
|
map(Type.DOUBLE); // 5 - Z
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Type.BYTE); // 7 - Yaw
|
||||||
|
map(Type.INT); // 8 - Data
|
||||||
|
handler(wrapper -> {
|
||||||
|
EntityType entityType = getTypeFromId(wrapper.get(Type.VAR_INT, 1));
|
||||||
|
if (entityType == Entity1_16Types.EntityType.LIGHTNING_BOLT) {
|
||||||
|
// Map to old weather entity packet
|
||||||
|
wrapper.cancel();
|
||||||
|
|
||||||
|
PacketWrapper spawnLightningPacket = wrapper.create(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY.ordinal());
|
||||||
|
spawnLightningPacket.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0)); // Entity id
|
||||||
|
spawnLightningPacket.write(Type.BYTE, (byte) 1); // Lightning type
|
||||||
|
spawnLightningPacket.write(Type.DOUBLE, wrapper.get(Type.DOUBLE, 0)); // X
|
||||||
|
spawnLightningPacket.write(Type.DOUBLE, wrapper.get(Type.DOUBLE, 1)); // Y
|
||||||
|
spawnLightningPacket.write(Type.DOUBLE, wrapper.get(Type.DOUBLE, 2)); // Z
|
||||||
|
spawnLightningPacket.send(Protocol1_15_2To1_16.class, true, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
handler(getSpawnTracketWithDataHandler(Entity1_16Types.EntityType.FALLING_BLOCK));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
registerSpawnTracker(ClientboundPackets1_16.SPAWN_MOB);
|
registerSpawnTracker(ClientboundPackets1_16.SPAWN_MOB);
|
||||||
|
|
||||||
protocol.registerOutgoing(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {
|
protocol.registerOutgoing(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spongepowered</groupId>
|
<groupId>org.spongepowered</groupId>
|
||||||
<artifactId>spongeapi</artifactId>
|
<artifactId>spongeapi</artifactId>
|
||||||
<version>LATEST</version>
|
<version>7.3.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren