Skip to content

Commit

Permalink
Fix scanning of inventories in the wrong neighbours of the Interface …
Browse files Browse the repository at this point in the history
…and Browser blocks.
  • Loading branch information
gigaherz committed Apr 23, 2016
1 parent 0aef61a commit 4164ee0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 22 deletions.
16 changes: 0 additions & 16 deletions src/main/java/gigaherz/enderRift/blocks/BlockInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,6 @@ public boolean isOpaqueCube(IBlockState state)
return false;
}

@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
TileEntity te = worldIn.getTileEntity(pos);
if (te != null)
te.markDirty();
}

@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
{
IBlockState state = world.getBlockState(pos);
if (neighbor.equals(pos.offset(state.getValue(FACING))))
world.getTileEntity(pos).markDirty();
}

@Override
public boolean hasTileEntity(IBlockState state)
{
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/gigaherz/enderRift/blocks/TileBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ public class TileBrowser extends TileEntity implements IBrowserExtension
{
private int changeCount = 1;

EnumFacing facing = null;
public EnumFacing getFacing()
{
if(facing == null)
{
IBlockState state = worldObj.getBlockState(pos);
if(state.getBlock() == EnderRiftMod.browser)
{
facing = state.getValue(BlockInterface.FACING).getOpposite();
}
}
return facing;
}

public IInventoryAutomation getAutomation()
{
AutomationAggregator aggregator = new AutomationAggregator();
Expand Down Expand Up @@ -82,6 +96,7 @@ public IInventoryAutomation getAutomation()
public void markDirty()
{
changeCount++;
facing = null;
super.markDirty();
}

Expand All @@ -99,6 +114,10 @@ public void markDirty(Set<BlockPos> scanned, int distance, Queue<Pair<BlockPos,
@Override
public void gatherNeighbours(Queue<Triple<BlockPos, EnumFacing, Integer>> pending, EnumFacing faceFrom, int distance)
{
pending.add(Triple.of(this.pos.offset(faceFrom.getOpposite()), faceFrom, distance));
EnumFacing f = getFacing();
if (f != null)
{
pending.add(Triple.of(this.pos.offset(f.getOpposite()), faceFrom, distance));
}
}
}
35 changes: 30 additions & 5 deletions src/main/java/gigaherz/enderRift/blocks/TileInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ protected void onContentsChanged(int slot)
}
};

EnumFacing facing = null;
public EnumFacing getFacing()
{
if(facing == null)
{
IBlockState state = worldObj.getBlockState(pos);
if(state.getBlock() == EnderRiftMod.riftInterface)
{
facing = state.getValue(BlockInterface.FACING).getOpposite();
}
}
return facing;
}

public IItemHandler inventoryOutputs()
{
return outputs;
Expand All @@ -58,16 +72,22 @@ public IItemHandler inventoryFilter()
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing facing)
{
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return true;
if (facing == getFacing())
{
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return true;
}
return super.hasCapability(capability, facing);
}

@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing)
{
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(outputs);
if (facing == getFacing())
{
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(outputs);
}
return super.getCapability(capability, facing);
}

Expand Down Expand Up @@ -131,6 +151,7 @@ public IInventoryAutomation getAutomation()
public void markDirty()
{
super.markDirty();
facing = null;
}

@Override
Expand All @@ -142,7 +163,11 @@ public void markDirty(Set<BlockPos> scanned, int distance, Queue<Pair<BlockPos,
@Override
public void gatherNeighbours(Queue<Triple<BlockPos, EnumFacing, Integer>> pending, EnumFacing faceFrom, int distance)
{
pending.add(Triple.of(this.pos.offset(faceFrom.getOpposite()), faceFrom, distance));
EnumFacing f = getFacing();
if (f != null)
{
pending.add(Triple.of(this.pos.offset(f.getOpposite()), faceFrom, distance));
}
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
"1.9-recommended": "0.12.2"
},
"1.9": {
"0.13.0": "Removed remaining IInventory uses. Fixed interface/browser scanning directions.",
"0.12.2": "Fixed interacting with the rift browser in complex situations such as with the Storage Drawers.",
"0.12.1": "Protect TileEntities from calls to worldObj.getBlockState returning "air", during the tick when the block has been broken, but the TE is still being used by something else.",
"0.12.0": "Rework the structure assembly process to allow having blocks in the \"holes\". Fix dismantling structures when a structure block breaks. Fix structure block bounding boxes.",
"0.11.3": "Update Checker support"
}.
"1.8.9": {
"0.13.0": "Removed remaining IInventory uses. Fixed interface/browser scanning directions.",
"0.12.2": "Update checker support backported along with other improvements"
}
}

0 comments on commit 4164ee0

Please sign in to comment.