diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java index e78bff9..c0e70e1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java @@ -312,7 +312,7 @@ public class REntity { private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(craftItemStack, "asNMSCopy", itemStack, ItemStack.class); private Object getEquipmentPacket(String slot, ItemStack stack){ Object packet = equipmentConstructor.invoke(); - equipmentEntity.set(0, entityId); + equipmentEntity.set(packet, entityId); BountifulWrapper.impl.setEquipmentPacketSlot(packet, slot); equipmentStack.set(packet, asNMSCopy.invoke(null, stack)); return packet; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java index ae5a6ef..f93a567 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java @@ -143,12 +143,13 @@ public class TechHider extends StateDependent { private static final UnaryOperator multiBlockChangeCloner = ProtocolAPI.shallowCloneGenerator(multiBlockChangePacket); private static final Class chunkCoordinateIntPair = Reflection.getClass("{nms}.ChunkCoordIntPair"); private static final Reflection.FieldAccessor multiBlockChangeChunk = Reflection.getField(multiBlockChangePacket, chunkCoordinateIntPair, 0); - private static final Reflection.FieldAccessor chunkCoordinateX = Reflection.getField(baseBlockPosition, int.class, 0); - private static final Reflection.FieldAccessor chunkCoordinateZ = Reflection.getField(baseBlockPosition, int.class, 1); + private static final Reflection.FieldAccessor chunkCoordinateX = Reflection.getField(chunkCoordinateIntPair, int.class, 0); + private static final Reflection.FieldAccessor chunkCoordinateZ = Reflection.getField(chunkCoordinateIntPair, int.class, 1); private static final Class multiBlockChangeInfo = Reflection.getClass("{nms}.PacketPlayOutMultiBlockChange$MultiBlockChangeInfo"); - private static final UnaryOperator multiBlockChangeInfoCloner = ProtocolAPI.shallowCloneGenerator(multiBlockChangeInfo); + private static final Reflection.ConstructorInvoker multiBlockChangeInfoConstructor = Reflection.getConstructor(multiBlockChangeInfo, multiBlockChangePacket, short.class, iBlockData); private static final BiFunction, Object> multiBlockChangeInfoArrayCloner = ProtocolAPI.arrayCloneGenerator(multiBlockChangeInfo); private static final Reflection.FieldAccessor multiBlockChangeInfoBlock = Reflection.getField(multiBlockChangeInfo, iBlockData, 0); + private static final Reflection.FieldAccessor multiBlockChangeInfoPos = Reflection.getField(multiBlockChangeInfo, short.class, 0); private static final Class multiBlockChangeInfoArray = Reflection.getClass("[L{nms}.PacketPlayOutMultiBlockChange$MultiBlockChangeInfo;"); private static final Reflection.FieldAccessor multiBlockChangeInfos = Reflection.getField(multiBlockChangePacket, multiBlockChangeInfoArray, 0); private Object multiBlockChangeHider(Player p, Object packet) { @@ -156,15 +157,13 @@ public class TechHider extends StateDependent { if(bypass(p, chunkCoordinateX.get(chunkCoords), chunkCoordinateZ.get(chunkCoords))) return packet; - packet = multiBlockChangeCloner.apply(packet); - multiBlockChangeInfos.set(packet, multiBlockChangeInfoArrayCloner.apply(multiBlockChangeInfos.get(packet), mbci -> { - if(Config.HiddenBlocks.contains(getMaterialByIBlockData(multiBlockChangeInfoBlock.get(mbci)).name().toLowerCase())) { - mbci = multiBlockChangeInfoCloner.apply(mbci); - multiBlockChangeInfoBlock.set(mbci, obfuscateIBlockData); - } + Object modpacket = multiBlockChangeCloner.apply(packet); + multiBlockChangeInfos.set(modpacket, multiBlockChangeInfoArrayCloner.apply(multiBlockChangeInfos.get(modpacket), mbci -> { + if(Config.HiddenBlocks.contains(getMaterialByIBlockData(multiBlockChangeInfoBlock.get(mbci)).name().toLowerCase())) + return multiBlockChangeInfoConstructor.invoke(modpacket, multiBlockChangeInfoPos.get(mbci), obfuscateIBlockData); return mbci; })); - return packet; + return modpacket; } private static final Class blockChangePacket = Reflection.getClass("{nms}.PacketPlayOutBlockChange");