use of com.minecolonies.api.tileentities.TileEntityColonyBuilding in project minecolonies by ldtteam.
the class BlockStash method createTileEntity.
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
final TileEntityColonyBuilding building = (TileEntityColonyBuilding) MinecoloniesTileEntities.STASH.create();
building.registryName = this.getBuildingEntry().getRegistryName();
return building;
}
use of com.minecolonies.api.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class AbstractBlockHut method createTileEntity.
@Nullable
@Override
public TileEntity createTileEntity(final BlockState state, final IBlockReader world) {
final TileEntityColonyBuilding building = (TileEntityColonyBuilding) MinecoloniesTileEntities.BUILDING.create();
building.registryName = this.getBuildingEntry().getRegistryName();
return building;
}
use of com.minecolonies.api.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class AbstractBlockHut method setPlacedBy.
@Override
public void setPlacedBy(@NotNull final World worldIn, @NotNull final BlockPos pos, final BlockState state, final LivingEntity placer, final ItemStack stack) {
super.setPlacedBy(worldIn, pos, state, placer, stack);
/*
Only work on server side
*/
if (worldIn.isClientSide) {
return;
}
final TileEntity tileEntity = worldIn.getBlockEntity(pos);
if (tileEntity instanceof TileEntityColonyBuilding) {
@NotNull final TileEntityColonyBuilding hut = (TileEntityColonyBuilding) tileEntity;
if (hut.getBuildingName() != getBuildingEntry().getRegistryName()) {
hut.registryName = getBuildingEntry().getRegistryName();
}
@Nullable final IColony colony = IColonyManager.getInstance().getColonyByPosFromWorld(worldIn, hut.getPosition());
if (colony != null) {
colony.getBuildingManager().addNewBuilding(hut, worldIn);
colony.getProgressManager().progressBuildingPlacement(this);
}
}
}
use of com.minecolonies.api.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class ItemResourceScroll method useOn.
/**
* Used when clicking on block in world.
*
* @param ctx the context of use.
* @return the result
*/
@Override
@NotNull
public ActionResultType useOn(ItemUseContext ctx) {
final ItemStack scroll = ctx.getPlayer().getItemInHand(ctx.getHand());
final CompoundNBT compound = checkForCompound(scroll);
TileEntity entity = ctx.getLevel().getBlockEntity(ctx.getClickedPos());
if (entity instanceof TileEntityColonyBuilding) {
final AbstractTileEntityColonyBuilding buildingEntity = (AbstractTileEntityColonyBuilding) entity;
if (buildingEntity.getBuilding() instanceof BuildingBuilder) {
compound.putInt(TAG_COLONY_ID, buildingEntity.getColonyId());
BlockPosUtil.write(compound, TAG_BUILDER, buildingEntity.getPosition());
if (!ctx.getLevel().isClientSide) {
MessageUtils.format(COM_MINECOLONIES_SCROLL_BUILDING_SET, buildingEntity.getColony().getName()).sendTo(ctx.getPlayer());
}
} else if (buildingEntity instanceof TileEntityWareHouse) {
if (ctx.getLevel().isClientSide) {
openWindow(compound, ctx.getPlayer(), buildingEntity.getPosition());
}
} else {
if (!ctx.getLevel().isClientSide) {
final IFormattableTextComponent buildingTypeComponent = MessageUtils.format(buildingEntity.getBuilding().getBuildingType().getTranslationKey()).create();
MessageUtils.format(COM_MINECOLONIES_SCROLL_WRONG_BUILDING, buildingTypeComponent, buildingEntity.getColony().getName()).sendTo(ctx.getPlayer());
}
}
} else if (ctx.getLevel().isClientSide) {
openWindow(compound, ctx.getPlayer(), null);
}
return ActionResultType.SUCCESS;
}
use of com.minecolonies.api.tileentities.TileEntityColonyBuilding in project minecolonies by Minecolonies.
the class BlockStash method createTileEntity.
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
final TileEntityColonyBuilding building = (TileEntityColonyBuilding) MinecoloniesTileEntities.STASH.create();
building.registryName = this.getBuildingEntry().getRegistryName();
return building;
}
Aggregations