mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-26 04:12:22 +00:00
Add #setAccessible call to access to private fields
This commit is contained in:
parent
5efdb35c15
commit
b256015c29
@ -29,10 +29,13 @@ public class FakeArmorStandImpl extends FakeEntityImpl<String> implements FakeAr
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
final Field dataSharedFlagsId = Entity.class.getDeclaredField("Z"); // DATA_SHARED_FLAGS_ID
|
final Field dataSharedFlagsId = Entity.class.getDeclaredField("Z"); // DATA_SHARED_FLAGS_ID
|
||||||
|
dataSharedFlagsId.setAccessible(true);
|
||||||
DATA_SHARED_FLAGS_ID = FakeEntityImpl.forceCast(dataSharedFlagsId.get(null));
|
DATA_SHARED_FLAGS_ID = FakeEntityImpl.forceCast(dataSharedFlagsId.get(null));
|
||||||
final Field dataCustomNameField = Entity.class.getDeclaredField("aJ"); // DATA_CUSTOM_NAME
|
final Field dataCustomNameField = Entity.class.getDeclaredField("aJ"); // DATA_CUSTOM_NAME
|
||||||
|
dataCustomNameField.setAccessible(true);
|
||||||
DATA_CUSTOM_NAME = FakeEntityImpl.forceCast(dataCustomNameField.get(null));
|
DATA_CUSTOM_NAME = FakeEntityImpl.forceCast(dataCustomNameField.get(null));
|
||||||
final Field dataCustomNameVisibleField = Entity.class.getDeclaredField("aK"); // DATA_CUSTOM_NAME_VISIBLE
|
final Field dataCustomNameVisibleField = Entity.class.getDeclaredField("aK"); // DATA_CUSTOM_NAME_VISIBLE
|
||||||
|
dataCustomNameVisibleField.setAccessible(true);
|
||||||
DATA_CUSTOM_NAME_VISIBLE = FakeEntityImpl.forceCast(dataCustomNameVisibleField.get(null));
|
DATA_CUSTOM_NAME_VISIBLE = FakeEntityImpl.forceCast(dataCustomNameVisibleField.get(null));
|
||||||
} catch (ReflectiveOperationException e){
|
} catch (ReflectiveOperationException e){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -30,12 +30,16 @@ public abstract class FakeEntityImpl<T> implements FakeEntity {
|
|||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
final Field entityCounterField = Entity.class.getDeclaredField("b"); // ENTITY_COUNTER
|
final Field entityCounterField = Entity.class.getDeclaredField("b"); // ENTITY_COUNTER
|
||||||
|
entityCounterField.setAccessible(true);
|
||||||
ENTITY_COUNTER = (AtomicInteger) entityCounterField.get(null);
|
ENTITY_COUNTER = (AtomicInteger) entityCounterField.get(null);
|
||||||
final Field dataNoGravityField = Entity.class.getDeclaredField("aM"); // DATA_NO_GRAVITY
|
final Field dataNoGravityField = Entity.class.getDeclaredField("aM"); // DATA_NO_GRAVITY
|
||||||
|
dataNoGravityField.setAccessible(true);
|
||||||
DATA_NO_GRAVITY = forceCast(dataNoGravityField.get(null));
|
DATA_NO_GRAVITY = forceCast(dataNoGravityField.get(null));
|
||||||
final Field dataSilentField = Entity.class.getDeclaredField("aL"); // DATA_SILENT
|
final Field dataSilentField = Entity.class.getDeclaredField("aL"); // DATA_SILENT
|
||||||
|
dataSilentField.setAccessible(true);
|
||||||
DATA_SILENT = forceCast(dataSilentField.get(null));
|
DATA_SILENT = forceCast(dataSilentField.get(null));
|
||||||
packedItemField = ClientboundSetEntityDataPacket.class.getDeclaredField("b"); // packedItems
|
packedItemField = ClientboundSetEntityDataPacket.class.getDeclaredField("b"); // packedItems
|
||||||
|
packedItemField.setAccessible(true);
|
||||||
}catch (ReflectiveOperationException e){
|
}catch (ReflectiveOperationException e){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user