Search in sources :

Example 6 with TileEntityColonyBuilding

use of com.minecolonies.coremod.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.

the class AbstractBuilding method getTileEntity.

/**
     * Returns the tile entity that belongs to the colony building.
     *
     * @return {@link TileEntityColonyBuilding} object of the building.
     */
public TileEntityColonyBuilding getTileEntity() {
    if ((tileEntity == null || tileEntity.isInvalid()) && colony.getWorld().getBlockState(location).getBlock() != null) {
        final TileEntity te = getColony().getWorld().getTileEntity(location);
        if (te instanceof TileEntityColonyBuilding) {
            tileEntity = (TileEntityColonyBuilding) te;
            if (tileEntity.getBuilding() == null) {
                tileEntity.setColony(colony);
                tileEntity.setBuilding(this);
            }
        }
    }
    return tileEntity;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityColonyBuilding(com.minecolonies.coremod.tileentities.TileEntityColonyBuilding)

Example 7 with TileEntityColonyBuilding

use of com.minecolonies.coremod.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.

the class AbstractBuilding method onDestroyed.

/**
     * Method to do things when a block is destroyed.
     */
public void onDestroyed() {
    final TileEntityColonyBuilding tileEntityNew = this.getTileEntity();
    final World world = colony.getWorld();
    final Block block = world.getBlockState(this.location).getBlock();
    if (tileEntityNew != null) {
        InventoryHelper.dropInventoryItems(world, this.location, (IInventory) tileEntityNew);
        world.updateComparatorOutputLevel(this.location, block);
    }
    ConstructionTapeHelper.removeConstructionTape(this, world);
}
Also used : TileEntityColonyBuilding(com.minecolonies.coremod.tileentities.TileEntityColonyBuilding) Block(net.minecraft.block.Block) World(net.minecraft.world.World)

Aggregations

TileEntityColonyBuilding (com.minecolonies.coremod.tileentities.TileEntityColonyBuilding)7 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemStack (net.minecraft.item.ItemStack)2 InvWrapper (net.minecraftforge.items.wrapper.InvWrapper)2 InventoryUtils (com.minecolonies.api.util.InventoryUtils)1 Colony (com.minecolonies.coremod.colony.Colony)1 AbstractBuildingWorker (com.minecolonies.coremod.colony.buildings.AbstractBuildingWorker)1 Block (net.minecraft.block.Block)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemArmor (net.minecraft.item.ItemArmor)1 ItemFood (net.minecraft.item.ItemFood)1 TileEntityChest (net.minecraft.tileentity.TileEntityChest)1 World (net.minecraft.world.World)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 Before (org.junit.Before)1