@Override public void addHackable( Class<? extends Entity> entityClazz, Class<? extends IHackableEntity> iHackable) { if (entityClazz == null) throw new NullPointerException("Entity class is null!"); if (iHackable == null) throw new NullPointerException("IHackableEntity is null!"); if (Entity.class.isAssignableFrom(iHackable)) { Log.warning( "Entities that implement IHackableEntity shouldn't be registered as hackable! Registering entity: " + entityClazz.getCanonicalName()); } else { try { IHackableEntity hackableEntity = iHackable.newInstance(); if (hackableEntity.getId() != null) stringToEntityHackables.put(hackableEntity.getId(), iHackable); hackableEntities.put(entityClazz, iHackable); } catch (InstantiationException e) { Log.error( "Not able to register hackable entity: " + iHackable.getName() + ". Does the class have a parameterless constructor?"); e.printStackTrace(); } catch (IllegalAccessException e) { Log.error( "Not able to register hackable entity: " + iHackable.getName() + ". Is the class a public class?"); e.printStackTrace(); } } }
@Override public void addHackable(Block block, Class<? extends IHackableBlock> iHackable) { if (block == null) throw new NullPointerException("Block is null!"); if (iHackable == null) throw new NullPointerException("IHackableBlock is null!"); if (Block.class.isAssignableFrom(iHackable)) { Log.warning( "Blocks that implement IHackableBlock shouldn't be registered as hackable! Registering block: " + block.getLocalizedName()); } else { try { IHackableBlock hackableBlock = iHackable.newInstance(); if (hackableBlock.getId() != null) stringToBlockHackables.put(hackableBlock.getId(), iHackable); hackableBlocks.put(block, iHackable); } catch (InstantiationException e) { Log.error( "Not able to register hackable block: " + iHackable.getName() + ". Does the class have a parameterless constructor?"); e.printStackTrace(); } catch (IllegalAccessException e) { Log.error( "Not able to register hackable block: " + iHackable.getName() + ". Is the class a public class?"); e.printStackTrace(); } } }
@Override public IProgWidget getOutputWidget(IDroneBase drone, List<IProgWidget> allWidgets) { if (evaluator != null) { return ProgWidgetJump.jumpToLabel(allWidgets, this, evaluate(drone, this)); } else { Log.error("Shouldn't be happening! ProgWidgetCondition"); return super.getOutputWidget(drone, allWidgets); } }
public boolean isAcknowledged() { if (acknowledged == null) acknowledged = ReflectionHelper.findField( ItemInWorldManager.class, "field_73097_j", "receivedFinishDiggingPacket"); try { return acknowledged.getBoolean(this); } catch (Exception e) { Log.error("Drone FakePlayerItemInWorldManager failed with reflection (Acknowledge get)!"); e.printStackTrace(); return true; } }
public boolean isDigging() { if (isDigging == null) isDigging = ReflectionHelper.findField( ItemInWorldManager.class, "field_73088_d", "isDestroyingBlock"); try { return isDigging.getBoolean(this); } catch (Exception e) { Log.error("Drone FakePlayerItemInWorldManager failed with reflection (Digging)!"); e.printStackTrace(); return true; } }