Skip to content

Commit

Permalink
BlockHelper TileEntity minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 2, 2019
1 parent 522e3a3 commit e402c96
Showing 1 changed file with 15 additions and 6 deletions.
Expand Up @@ -35,6 +35,20 @@

public class BlockHelperImpl implements BlockHelper {

public static final Field craftBlockEntityState_tileEntity;

static {
Field f = null;
try {
f = CraftBlockEntityState.class.getDeclaredField("tileEntity");
f.setAccessible(true);
}
catch (NoSuchFieldException e) {
Debug.echoError(e);
}
craftBlockEntityState_tileEntity = f;
}

@Override
public List<Location> getBlocksList(PortalCreateEvent event) {
List<Location> blocks = new ArrayList<>();
Expand All @@ -46,16 +60,11 @@ public List<Location> getBlocksList(PortalCreateEvent event) {

public <T extends TileEntity> T getTE(CraftBlockEntityState<T> cbs) {
try {
Field f = CraftBlockEntityState.class.getDeclaredField("tileEntity");
f.setAccessible(true);
return (T) f.get(cbs);
return (T) craftBlockEntityState_tileEntity.get(cbs);
}
catch (IllegalAccessException e) {
Debug.echoError(e);
}
catch (NoSuchFieldException e) {
Debug.echoError(e);
}
return null;
}

Expand Down

0 comments on commit e402c96

Please sign in to comment.