/** Recharges electric item. */ @Override public void recharge(ItemStack itemStack) { if (itemStack != null) { if (itemStack.getItem() instanceof IItemElectric) { super.recharge(itemStack); } else if (Compatibility.isIndustrialCraft2Loaded() && itemStack.getItem() instanceof ISpecialElectricItem) { ISpecialElectricItem electricItem = (ISpecialElectricItem) itemStack.getItem(); IElectricItemManager manager = electricItem.getManager(itemStack); float energy = Math.max(this.getProvide(ForgeDirection.UNKNOWN) * Compatibility.IC2_RATIO, 0); energy = manager.charge(itemStack, (int) (energy * Compatibility.TO_IC2_RATIO), 0, false, false) * Compatibility.IC2_RATIO; this.provideElectricity(energy, true); } else if (GCCoreCompatibilityManager.isTELoaded() && itemStack.getItem() instanceof IChargeableItem) { float accepted = ((IChargeableItem) itemStack.getItem()) .receiveEnergy( itemStack, this.getProvide(ForgeDirection.UNKNOWN) * Compatibility.BC3_RATIO, true); this.provideElectricity(accepted, true); } } }
@Override public void updateEntity() { super.updateEntity(); // Register to the IC2 Network if (!this.worldObj.isRemote) { if (!this.isAddedToEnergyNet) { this.initIC(); } if (this.bcPowerHandler == null) { this.initBuildCraft(); } if (Compatibility.isBuildcraftLoaded()) { PowerHandler handler = (PowerHandler) this.bcPowerHandler; if (handler.getEnergyStored() > 0) { /** Cheat BuildCraft powerHandler and always empty energy inside of it. */ this.receiveElectricity(handler.getEnergyStored() * Compatibility.BC3_RATIO, true); handler.setEnergy(0); } } } }
@Override public void onChunkUnload() { this.unloadTileIC2(); super.onChunkUnload(); }
@Override public void invalidate() { this.unloadTileIC2(); super.invalidate(); }
@Override public void initiate() { super.initiate(); this.initBuildCraft(); }