Skip to content

Added redstone support for vacuum hopper #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 1.7.10
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
Expand Down