From 33025dabe6ac5e6cfdec355178af461a7f10e383 Mon Sep 17 00:00:00 2001 From: George Gooden Date: Tue, 29 Jul 2014 20:44:15 +0800 Subject: [PATCH] Added redstone support for vacuum hopper --- .../tileentity/TileEntityVacuumHopper.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/openblocks/common/tileentity/TileEntityVacuumHopper.java b/src/main/java/openblocks/common/tileentity/TileEntityVacuumHopper.java index 632e96421..108a5c142 100644 --- a/src/main/java/openblocks/common/tileentity/TileEntityVacuumHopper.java +++ b/src/main/java/openblocks/common/tileentity/TileEntityVacuumHopper.java @@ -47,7 +47,8 @@ public class TileEntityVacuumHopper extends SyncedTileEntity implements IInvento private SyncableTank tank; public SyncableDirs xpOutputs; public SyncableDirs itemOutputs; - public SyncableBoolean vacuumDisabled; + public SyncableBoolean redstoneDisabled; + public SyncableBoolean userDisabled; private final GenericInventory inventory = registerInventoryCallback(new GenericInventory("vacuumhopper", true, 10)); @@ -62,7 +63,8 @@ protected void createSyncedFields() { tank = new SyncableTank(TANK_CAPACITY, OpenBlocks.XP_FLUID); xpOutputs = new SyncableDirs(); itemOutputs = new SyncableDirs(); - vacuumDisabled = new SyncableBoolean(); + redstoneDisabled = new SyncableBoolean(); + userDisabled = new SyncableBoolean(); } public TileEntityVacuumHopper() { @@ -105,11 +107,17 @@ public boolean isEntityApplicable(Entity entity) { return false; } + private boolean isPowered() { + return worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + } + @Override public void updateEntity() { super.updateEntity(); - if (vacuumDisabled.get()) return; + redstoneDisabled.set(isPowered()); + + if (redstoneDisabled.get() || userDisabled.get()) return; if (worldObj.isRemote) { worldObj.spawnParticle("portal", xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, worldObj.rand.nextDouble() - 0.5, worldObj.rand.nextDouble() - 1.0, worldObj.rand.nextDouble() - 0.5); @@ -189,7 +197,7 @@ public boolean canOpenGui(EntityPlayer player) { public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (player.isSneaking()) { if (player.inventory.getStackInSlot(player.inventory.currentItem) == null) { - vacuumDisabled.toggle(); + userDisabled.toggle(); return true; } }