diff options
author | Blood-Asp <bloodasphendrik@gmail.com> | 2017-01-19 12:38:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-19 12:38:37 +0100 |
commit | 1cf283afa82bf92ec6232b3a665fb1c78dc4e841 (patch) | |
tree | b0aa32b1084fc89ed0345a31fc074812ddaa71b7 | |
parent | e95e832aba77c951d419394feb239a1398eaed2d (diff) | |
parent | 5af9a6718cec09a5955b88aefd7142e16bc040c8 (diff) | |
download | GT5-Unofficial-1cf283afa82bf92ec6232b3a665fb1c78dc4e841.tar.gz GT5-Unofficial-1cf283afa82bf92ec6232b3a665fb1c78dc4e841.tar.bz2 GT5-Unofficial-1cf283afa82bf92ec6232b3a665fb1c78dc4e841.zip |
Merge pull request #857 from vlad20012/fix-816
Fix #816 obfuscated field name
-rw-r--r-- | src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 60e918de4c..3b2f37085a 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -66,6 +66,26 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE private String mOwnerName = ""; private NBTTagCompound mRecipeStuff = new NBTTagCompound(); + private static final Field ENTITY_ITEM_HEALTH_FIELD; + static + { + Field f = null; + + try { + f = EntityItem.class.getDeclaredField("field_70291_e"); + f.setAccessible(true); + } catch (Exception e1) { + try { + f = EntityItem.class.getDeclaredField("health"); + f.setAccessible(true); + } catch (Exception e2) { + e1.printStackTrace(); + e2.printStackTrace(); + } + } + ENTITY_ITEM_HEALTH_FIELD = f; + } + public BaseMetaTileEntity() { } @@ -1144,10 +1164,9 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE tItemEntity.hurtResistantTime = 999999; tItemEntity.lifespan = 60000; try { - Field tField = tItemEntity.getClass().getDeclaredField("health"); - tField.setAccessible(true); - tField.setInt(tItemEntity, 99999999); - } catch (Exception e) {e.printStackTrace();} + if(ENTITY_ITEM_HEALTH_FIELD != null) + ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999); + } catch (Exception ignored) {} this.worldObj.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; } |