use of com.minecolonies.api.tileentities.AbstractTileEntityRack in project minecolonies by ldtteam.
the class BlockMinecoloniesRack method updateShape.
@NotNull
@Override
public BlockState updateShape(@NotNull final BlockState stateIn, final Direction facing, final BlockState state, final IWorld worldIn, final BlockPos currentPos, final BlockPos pos) {
if (state.getBlock() instanceof BlockMinecoloniesRack || stateIn.getBlock() instanceof BlockMinecoloniesRack) {
final TileEntity rack = worldIn.getBlockEntity(pos);
if (rack instanceof TileEntityRack) {
((AbstractTileEntityRack) rack).neighborChanged(currentPos);
}
final TileEntity rack2 = worldIn.getBlockEntity(currentPos);
if (rack2 instanceof TileEntityRack) {
((AbstractTileEntityRack) rack2).neighborChanged(pos);
}
}
return super.updateShape(stateIn, facing, state, worldIn, currentPos, pos);
}
use of com.minecolonies.api.tileentities.AbstractTileEntityRack in project minecolonies by ldtteam.
the class BlockMinecoloniesRack method spawnAfterBreak.
@Override
public void spawnAfterBreak(final BlockState state, final ServerWorld worldIn, final BlockPos pos, final ItemStack stack) {
final TileEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof TileEntityRack) {
final IItemHandler handler = ((AbstractTileEntityRack) tileentity).getInventory();
InventoryUtils.dropItemHandler(handler, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
super.spawnAfterBreak(state, worldIn, pos, stack);
}
use of com.minecolonies.api.tileentities.AbstractTileEntityRack in project minecolonies by Minecolonies.
the class TileEntityWareHouse method searchMostEmptyRack.
/**
* Search for the chest with the least items in it.
*
* @return the tileEntity of this chest.
*/
@Nullable
private TileEntity searchMostEmptyRack() {
int freeSlots = 0;
TileEntity emptiestChest = null;
for (@NotNull final BlockPos pos : getBuilding().getContainers()) {
final TileEntity entity = getLevel().getBlockEntity(pos);
if (entity instanceof TileEntityRack) {
if (((AbstractTileEntityRack) entity).isEmpty()) {
return entity;
}
final int tempFreeSlots = ((AbstractTileEntityRack) entity).getFreeSlots();
if (tempFreeSlots > freeSlots) {
freeSlots = tempFreeSlots;
emptiestChest = entity;
}
}
}
return emptiestChest;
}
use of com.minecolonies.api.tileentities.AbstractTileEntityRack in project minecolonies by Minecolonies.
the class BlockMinecoloniesRack method updateShape.
@NotNull
@Override
public BlockState updateShape(@NotNull final BlockState stateIn, final Direction facing, final BlockState state, final IWorld worldIn, final BlockPos currentPos, final BlockPos pos) {
if (state.getBlock() instanceof BlockMinecoloniesRack || stateIn.getBlock() instanceof BlockMinecoloniesRack) {
final TileEntity rack = worldIn.getBlockEntity(pos);
if (rack instanceof TileEntityRack) {
((AbstractTileEntityRack) rack).neighborChanged(currentPos);
}
final TileEntity rack2 = worldIn.getBlockEntity(currentPos);
if (rack2 instanceof TileEntityRack) {
((AbstractTileEntityRack) rack2).neighborChanged(pos);
}
}
return super.updateShape(stateIn, facing, state, worldIn, currentPos, pos);
}
use of com.minecolonies.api.tileentities.AbstractTileEntityRack in project minecolonies by Minecolonies.
the class BlockMinecoloniesRack method spawnAfterBreak.
@Override
public void spawnAfterBreak(final BlockState state, final ServerWorld worldIn, final BlockPos pos, final ItemStack stack) {
final TileEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity instanceof TileEntityRack) {
final IItemHandler handler = ((AbstractTileEntityRack) tileentity).getInventory();
InventoryUtils.dropItemHandler(handler, worldIn, pos.getX(), pos.getY(), pos.getZ());
}
super.spawnAfterBreak(state, worldIn, pos, stack);
}
Aggregations