3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 00:00:33 +01:00

Fix 1.16->1.15 lightning

Closes ViaVersion/ViaVersion#2309
Dieser Commit ist enthalten in:
KennyTV 2021-02-01 16:17:53 +01:00
Ursprung 0da5b65858
Commit 0166d1a3b1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
3 geänderte Dateien mit 44 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -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.types.MetaType1_14;
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.type.Type;
@ -37,17 +38,21 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
map(Type.BYTE); // 6 - Pitch
map(Type.BYTE); // 7 - Yaw
map(Type.INT); // 8 - Data
handler(wrapper -> {
EntityType entityType = setOldEntityId(wrapper);
if (entityType == fallingBlockType) {
int blockState = wrapper.get(Type.INT, 0);
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
}
});
handler(getSpawnTracketWithDataHandler(fallingBlockType));
}
});
}
public PacketHandler getSpawnTracketWithDataHandler(EntityType fallingBlockType) {
return wrapper -> {
EntityType entityType = setOldEntityId(wrapper);
if (entityType == fallingBlockType) {
int blockState = wrapper.get(Type.INT, 0);
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
}
};
}
public void registerSpawnTracker(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override

Datei anzeigen

@ -44,7 +44,37 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
@Override
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);
protocol.registerOutgoing(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {

Datei anzeigen

@ -76,7 +76,7 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>LATEST</version>
<version>7.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>