Fix use-new-effect-indicator option for 1.13+ clients (#3127)

This commit is contained in:
F 2022-10-27 10:30:03 +02:00 committed by GitHub
parent 10efba31cf
commit 955b76f599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@
*/
package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
@ -146,6 +147,25 @@ public class EntityPackets {
}
});
protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Entity id
map(Type.BYTE); // Effect id
map(Type.BYTE); // Amplifier
map(Type.VAR_INT); // Duration
handler(packetWrapper -> {
byte flags = packetWrapper.read(Type.BYTE); // Input Flags
if (Via.getConfig().isNewEffectIndicator())
flags |= 0x04;
packetWrapper.write(Type.BYTE, flags);
});
}
});
metadataRewriter.registerRemoveEntities(ClientboundPackets1_12_1.DESTROY_ENTITIES);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_12_1.ENTITY_METADATA, Types1_12.METADATA_LIST, Types1_13.METADATA_LIST);
}