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;
}
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);
}
Aggregations