From b256015c297b59cfcb3195d78f36fe89a0986431 Mon Sep 17 00:00:00 2001 From: Flowsqy <47575244+Flowsqy@users.noreply.github.com> Date: Wed, 29 Dec 2021 15:43:57 +0100 Subject: [PATCH] Add #setAccessible call to access to private fields --- .../epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java | 3 +++ .../de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java index 5f9f6e5..926210f 100644 --- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java +++ b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeArmorStandImpl.java @@ -29,10 +29,13 @@ public class FakeArmorStandImpl extends FakeEntityImpl implements FakeAr static { try { final Field dataSharedFlagsId = Entity.class.getDeclaredField("Z"); // DATA_SHARED_FLAGS_ID + dataSharedFlagsId.setAccessible(true); DATA_SHARED_FLAGS_ID = FakeEntityImpl.forceCast(dataSharedFlagsId.get(null)); final Field dataCustomNameField = Entity.class.getDeclaredField("aJ"); // DATA_CUSTOM_NAME + dataCustomNameField.setAccessible(true); DATA_CUSTOM_NAME = FakeEntityImpl.forceCast(dataCustomNameField.get(null)); final Field dataCustomNameVisibleField = Entity.class.getDeclaredField("aK"); // DATA_CUSTOM_NAME_VISIBLE + dataCustomNameVisibleField.setAccessible(true); DATA_CUSTOM_NAME_VISIBLE = FakeEntityImpl.forceCast(dataCustomNameVisibleField.get(null)); } catch (ReflectiveOperationException e){ throw new RuntimeException(e); diff --git a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java index 221b582..f40539a 100644 --- a/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java +++ b/nms/v1_17_R1/src/main/java/de/epiceric/shopchest/nms/v1_17_R1/FakeEntityImpl.java @@ -30,12 +30,16 @@ public abstract class FakeEntityImpl implements FakeEntity { static { try { final Field entityCounterField = Entity.class.getDeclaredField("b"); // ENTITY_COUNTER + entityCounterField.setAccessible(true); ENTITY_COUNTER = (AtomicInteger) entityCounterField.get(null); final Field dataNoGravityField = Entity.class.getDeclaredField("aM"); // DATA_NO_GRAVITY + dataNoGravityField.setAccessible(true); DATA_NO_GRAVITY = forceCast(dataNoGravityField.get(null)); final Field dataSilentField = Entity.class.getDeclaredField("aL"); // DATA_SILENT + dataSilentField.setAccessible(true); DATA_SILENT = forceCast(dataSilentField.get(null)); packedItemField = ClientboundSetEntityDataPacket.class.getDeclaredField("b"); // packedItems + packedItemField.setAccessible(true); }catch (ReflectiveOperationException e){ throw new RuntimeException(e); }