From 3d279ad8f6c67d7cd81f585fd27fd425d844d0d6 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 1 Mar 2023 22:02:19 +0100 Subject: [PATCH] Fix 1.19.3 IRegistry --- SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java | 2 +- SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java index e0eb2ea..5ed2b45 100644 --- a/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java +++ b/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java @@ -328,7 +328,7 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper private static final Class registryBlocks = Reflection.getClass("{nms.core}.RegistryBlocks"); private static final Class entityTypes = Reflection.getClass("{nms.world.entity}.EntityTypes"); - private static final Object entityTypesRegistry = Reflection.getField(Reflection.getClass("{nms.core}.IRegistry"), registryBlocks, 0, entityTypes).get(null); + private static final Object entityTypesRegistry = Reflection.getField(Reflection.getClass(Core.getVersion() > 18 ? "net.minecraft.core.registries.BuiltInRegistries" : "{nms.core}.IRegistry"), registryBlocks, 0, entityTypes).get(null); private static final Reflection.MethodInvoker get = Reflection.getMethod(registryBlocks, null, Reflection.getClass("{nms.resources}.MinecraftKey")); private static final Reflection.FieldAccessor spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0); private static final Reflection.FieldAccessor spawnLivingType = Core.getVersion() > 18 ? spawnType : Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); diff --git a/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java b/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java index 9dde1ad..b847d1b 100644 --- a/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java +++ b/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java @@ -20,6 +20,7 @@ package de.steamwar.techhider; import com.comphenix.tinyprotocol.Reflection; +import de.steamwar.core.Core; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import net.minecraft.core.IRegistry; @@ -77,7 +78,7 @@ public class ChunkHider18 implements ChunkHider { public static final Class tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$a"); protected static final Reflection.FieldAccessor entityType = Reflection.getField(tileEntity, TileEntityTypes.class, 0); - private static final IRegistry tileEntityTypes = Reflection.getField(IRegistry.class, IRegistry.class, 0, TileEntityTypes.class).get(null); + private static final IRegistry tileEntityTypes = Reflection.getField(Core.getVersion() > 18 ? Reflection.getClass("net.minecraft.core.registries.BuiltInRegistries") : IRegistry.class, IRegistry.class, 0, TileEntityTypes.class).get(null); private static final Reflection.MethodInvoker getKey = Reflection.getTypedMethod(IRegistry.class, null, MinecraftKey.class, Object.class); private static final Reflection.MethodInvoker getName = Reflection.getTypedMethod(MinecraftKey.class, null, String.class); protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) {