Fix double effect register

This commit is contained in:
Nassim Jahnke 2021-12-02 20:17:24 +01:00
parent 5e6d87c8fd
commit ae4f837091
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 41 additions and 41 deletions

View File

@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.data.MappingDataBase;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
@ -38,7 +39,6 @@ import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.WorldPac
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
@ -144,45 +144,6 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
}
});
registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Effect Id
map(Type.POSITION); // Location
map(Type.INT); // Data
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.INT, 0);
if (id == 2000) { // Smoke
int data = wrapper.get(Type.INT, 1);
switch (data) {
case 1: // North
wrapper.set(Type.INT, 1, 2); // North
break;
case 0: // North-West
case 3: // West
case 6: // South-West
wrapper.set(Type.INT, 1, 4); // West
break;
case 2: // North-East
case 5: // East
case 8: // South-East
wrapper.set(Type.INT, 1, 5); // East
break;
case 7: // South
wrapper.set(Type.INT, 1, 3); // South
break;
default: // Self and other directions
wrapper.set(Type.INT, 1, 0); // Down
break;
}
}
}
});
}
});
new TagRewriter(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
new StatisticsRewriter(this).register(ClientboundPackets1_13.STATISTICS);
}

View File

@ -57,7 +57,46 @@ public class WorldPackets {
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001);
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Effect Id
map(Type.POSITION); // Location
map(Type.INT); // Data
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
if (id == 2000) { // Smoke
int data = wrapper.get(Type.INT, 1);
switch (data) {
case 1: // North
wrapper.set(Type.INT, 1, 2); // North
break;
case 0: // North-West
case 3: // West
case 6: // South-West
wrapper.set(Type.INT, 1, 4); // West
break;
case 2: // North-East
case 5: // East
case 8: // South-East
wrapper.set(Type.INT, 1, 5); // East
break;
case 7: // South
wrapper.set(Type.INT, 1, 3); // South
break;
default: // Self and other directions
wrapper.set(Type.INT, 1, 0); // Down
break;
}
} else if (id == 1010) { // Play record
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(wrapper.get(Type.INT, 1)));
} else if (id == 2001) { // Block break + block break sound
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.INT, 1)));
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
@Override