Try to place block once item is available
This commit is contained in:
parent
d824edd688
commit
42d038e89f
@ -31,13 +31,18 @@ public abstract class TileEntityBlockManipulator extends OpenTileEntity implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isPowered)
|
if (isPowered)
|
||||||
triggerBreakBlock(newState);
|
triggerBlockAction(newState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerBreakBlock(IBlockState newState) {
|
protected void triggerBlockAction() {
|
||||||
final EnumFacing direction = getFront(newState);
|
final IBlockState state = worldObj.getBlockState(getPos());
|
||||||
|
triggerBlockAction(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void triggerBlockAction(IBlockState state) {
|
||||||
|
final EnumFacing direction = getFront(state);
|
||||||
final BlockPos target = pos.offset(direction);
|
final BlockPos target = pos.offset(direction);
|
||||||
|
|
||||||
if (worldObj.isBlockLoaded(target)) {
|
if (worldObj.isBlockLoaded(target)) {
|
||||||
|
@ -16,6 +16,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
|||||||
import openblocks.client.gui.GuiBlockPlacer;
|
import openblocks.client.gui.GuiBlockPlacer;
|
||||||
import openblocks.common.container.ContainerBlockPlacer;
|
import openblocks.common.container.ContainerBlockPlacer;
|
||||||
import openmods.api.IHasGui;
|
import openmods.api.IHasGui;
|
||||||
|
import openmods.api.IInventoryCallback;
|
||||||
import openmods.fakeplayer.FakePlayerPool;
|
import openmods.fakeplayer.FakePlayerPool;
|
||||||
import openmods.fakeplayer.UseItemAction;
|
import openmods.fakeplayer.UseItemAction;
|
||||||
import openmods.include.IncludeInterface;
|
import openmods.include.IncludeInterface;
|
||||||
@ -27,7 +28,14 @@ public class TileEntityBlockPlacer extends TileEntityBlockManipulator implements
|
|||||||
|
|
||||||
static final int BUFFER_SIZE = 9;
|
static final int BUFFER_SIZE = 9;
|
||||||
|
|
||||||
private final GenericInventory inventory = registerInventoryCallback(new TileEntityInventory(this, "blockPlacer", false, BUFFER_SIZE));
|
private final GenericInventory inventory = new TileEntityInventory(this, "blockPlacer", false, BUFFER_SIZE)
|
||||||
|
.addCallback(new IInventoryCallback() {
|
||||||
|
@Override
|
||||||
|
public void onInventoryChanged(IInventory inventory, int slotNumber) {
|
||||||
|
markUpdated();
|
||||||
|
triggerBlockAction();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canWork(IBlockState targetState, BlockPos target, EnumFacing direction) {
|
protected boolean canWork(IBlockState targetState, BlockPos target, EnumFacing direction) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user