use of com.minecolonies.coremod.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class AbstractEntityAIGuard method goToBuilding.
/**
* Goes back to the building and tries to take armour from it when he hasn't in his inventory.
*
* @return the next state to go to.
*/
protected AIState goToBuilding() {
if (walkToBuilding()) {
return GUARD_RESTOCK;
}
final AbstractBuildingWorker workBuilding = getOwnBuilding();
if (workBuilding != null) {
final TileEntityColonyBuilding chest = workBuilding.getTileEntity();
for (int i = 0; i < workBuilding.getTileEntity().getSizeInventory(); i++) {
final ItemStack stack = chest.getStackInSlot(i);
if (ItemStackUtils.isEmpty(stack)) {
continue;
}
if (stack.getItem() instanceof ItemArmor && worker.getItemStackFromSlot(((ItemArmor) stack.getItem()).armorType) == null) {
final int emptySlot = InventoryUtils.findFirstSlotInItemHandlerWith(new InvWrapper(worker.getInventoryCitizen()), ItemStackUtils::isEmpty);
if (emptySlot != -1) {
new InvWrapper(worker.getInventoryCitizen()).insertItem(emptySlot, stack, false);
chest.setInventorySlotContents(i, ItemStackUtils.EMPTY);
}
}
dumpAfterActions = DUMP_BASE * workBuilding.getBuildingLevel();
}
}
attacksExecuted = 0;
return GUARD_SEARCH_TARGET;
}
use of com.minecolonies.coremod.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class AbstractBlockHut method onBlockPlacedByBuildTool.
/**
* Event-Handler for placement of this block.
* <p>
* Override for custom logic.
*
* @param worldIn the word we are in.
* @param pos the position where the block was placed.
* @param state the state the placed block is in.
* @param placer the player placing the block.
* @param stack the itemstack from where the block was placed.
* @param mirror the mirror used.
* @param style the style of the building
* @see Block#onBlockPlacedBy(World, BlockPos, IBlockState,
* EntityLivingBase, ItemStack)
*/
public void onBlockPlacedByBuildTool(@NotNull final World worldIn, @NotNull final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack, final boolean mirror, final String style) {
final TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileEntityColonyBuilding) {
((TileEntityColonyBuilding) tileEntity).setMirror(mirror);
((TileEntityColonyBuilding) tileEntity).setStyle(style);
}
onBlockPlacedBy(worldIn, pos, state, placer, stack);
}
use of com.minecolonies.coremod.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class InventoryTest method setupInventories.
@Before
public void setupInventories() {
final TileEntityColonyBuilding buildingTileEntity = new TileEntityColonyBuilding();
buildingTileEntity.setBuilding(building);
this.inventory = buildingTileEntity;
}
Aggregations