use of com.minecolonies.coremod.blocks.BlockMinecoloniesRack in project minecolonies by Minecolonies.
the class BuildingWareHouse method registerBlockPosition.
@Override
public void registerBlockPosition(@NotNull final Block block, @NotNull final BlockPos pos, @NotNull final World world) {
if ((block instanceof BlockContainer || block instanceof BlockMinecoloniesRack) && world != null) {
final TileEntity entity = getColony().getWorld().getTileEntity(pos);
if (entity instanceof TileEntityChest) {
handleBuildingOverChest(pos, (TileEntityChest) entity, world);
}
addContainerPosition(pos);
}
}
use of com.minecolonies.coremod.blocks.BlockMinecoloniesRack in project minecolonies by Minecolonies.
the class TileEntityRack method neighborChanged.
/**
* On neighbor changed this will be called from the block.
*
* @param newNeighbor the blockPos which has changed.
*/
public void neighborChanged(final BlockPos newNeighbor) {
final TileEntity entity = world.getTileEntity(newNeighbor);
if (!this.neighbor.equals(BlockPos.ORIGIN) && this.neighbor.distanceSq(this.pos) > 1 && entity instanceof TileEntityRack) {
softReset();
}
if (this.neighbor.equals(BlockPos.ORIGIN) && world.getBlockState(newNeighbor).getBlock() instanceof BlockMinecoloniesRack && !(entity instanceof TileEntityRack && ((TileEntityRack) entity).getOtherChest() != null)) {
this.neighbor = newNeighbor;
single = false;
if (entity instanceof TileEntityRack && !((TileEntityRack) entity).isMain()) {
this.main = true;
((TileEntityRack) entity).setMain(false);
}
((TileEntityRack) entity).setNeighbor(this.getPos());
entity.markDirty();
updateItemStorage();
this.markDirty();
} else if (this.neighbor.equals(newNeighbor) && !(world.getBlockState(newNeighbor).getBlock() instanceof BlockMinecoloniesRack)) {
this.neighbor = BlockPos.ORIGIN;
single = true;
this.main = false;
updateItemStorage();
}
}
use of com.minecolonies.coremod.blocks.BlockMinecoloniesRack in project minecolonies by Minecolonies.
the class TileEntityRack method updateBlockState.
/**
* Update the blockState of the rack.
* Switch between connected, single, full and empty texture.
*/
private void updateBlockState() {
if (world != null && world.getBlockState(pos).getBlock() instanceof BlockMinecoloniesRack && (main || single)) {
final IBlockState typeHere;
final IBlockState typeNeighbor;
if (content.isEmpty() && (getOtherChest() == null || getOtherChest().isEmpty())) {
if (getOtherChest() != null && world.getBlockState(neighbor).getBlock() instanceof BlockMinecoloniesRack) {
typeHere = world.getBlockState(pos).withProperty(BlockMinecoloniesRack.VARIANT, RackType.EMPTYAIR);
typeNeighbor = world.getBlockState(neighbor).withProperty(BlockMinecoloniesRack.VARIANT, RackType.DEFAULTDOUBLE).withProperty(BlockMinecoloniesRack.FACING, BlockPosUtil.getFacing(pos, neighbor));
} else {
typeHere = world.getBlockState(pos).withProperty(BlockMinecoloniesRack.VARIANT, RackType.DEFAULT);
typeNeighbor = null;
}
} else {
if (getOtherChest() != null && world.getBlockState(neighbor).getBlock() instanceof BlockMinecoloniesRack) {
typeHere = world.getBlockState(pos).withProperty(BlockMinecoloniesRack.VARIANT, RackType.EMPTYAIR);
typeNeighbor = world.getBlockState(neighbor).withProperty(BlockMinecoloniesRack.VARIANT, RackType.FULLDOUBLE).withProperty(BlockMinecoloniesRack.FACING, BlockPosUtil.getFacing(pos, neighbor));
} else {
typeHere = world.getBlockState(pos).withProperty(BlockMinecoloniesRack.VARIANT, RackType.FULL);
typeNeighbor = null;
}
}
world.setBlockState(pos, typeHere);
if (typeNeighbor != null) {
world.setBlockState(neighbor, typeNeighbor);
}
}
}
Aggregations