use of com.minecolonies.coremod.blocks.BlockHutTownHall in project minecolonies by Minecolonies.
the class BuildToolPlaceMessage method handleHut.
/**
* Handles the placement of huts.
*
* @param world World the hut is being placed into.
* @param player Who placed the hut.
* @param sn The name of the structure.
* @param workOrderName The name of the work order.
* @param rotation The number of times the structure should be rotated.
* @param buildPos The location the hut is being placed.
* @param mirror Whether or not the strcture is mirrored.
*/
private static void handleHut(@NotNull final World world, @NotNull final EntityPlayer player, final Structures.StructureName sn, final int rotation, @NotNull final BlockPos buildPos, final boolean mirror) {
final String hut = sn.getSection();
final Block block = Block.getBlockFromName(Constants.MOD_ID + ":blockHut" + hut);
final Colony tempColony = ColonyManager.getClosestColony(world, buildPos);
if (tempColony != null && (!tempColony.getPermissions().hasPermission(player, Action.MANAGE_HUTS) && !(block instanceof BlockHutTownHall && BlockPosUtil.getDistance2D(tempColony.getCenter(), buildPos) >= Configurations.workingRangeTownHall * 2 + Configurations.townHallPadding))) {
return;
}
if (block != null && player.inventory.hasItemStack(new ItemStack(block))) {
if (EventHandler.onBlockHutPlaced(world, player, block, buildPos)) {
world.destroyBlock(buildPos, true);
world.setBlockState(buildPos, block.getDefaultState().withRotation(BlockUtils.getRotation(rotation)));
((AbstractBlockHut) block).onBlockPlacedByBuildTool(world, buildPos, world.getBlockState(buildPos), player, null, mirror, sn.getStyle());
player.inventory.clearMatchingItems(Item.getItemFromBlock(block), -1, 1, null);
setupBuilding(world, player, sn, rotation, buildPos, mirror);
}
} else {
LanguageHandler.sendPlayerMessage(player, BuildToolPlaceMessage.NO_HUT_IN_INVENTORY);
}
}
use of com.minecolonies.coremod.blocks.BlockHutTownHall in project minecolonies by Minecolonies.
the class BuildToolPlaceMessage method handleHut.
/**
* Handles the placement of huts.
*
* @param world World the hut is being placed into.
* @param player Who placed the hut.
* @param sn The name of the structure.
* @param rotation The number of times the structure should be rotated.
* @param buildPos The location the hut is being placed.
* @param mirror Whether or not the strcture is mirrored.
*/
private static void handleHut(@NotNull final World world, @NotNull final EntityPlayer player, final StructureName sn, final int rotation, @NotNull final BlockPos buildPos, final boolean mirror) {
final String hut = sn.getSection();
final Block block = Block.getBlockFromName(Constants.MOD_ID + ":blockHut" + hut);
final Colony tempColony = ColonyManager.getClosestColony(world, buildPos);
if (tempColony != null && (!tempColony.getPermissions().hasPermission(player, Action.MANAGE_HUTS) && !(block instanceof BlockHutTownHall && !ColonyManager.isTooCloseToColony(world, buildPos)))) {
return;
}
if (block != null && player.inventory.hasItemStack(new ItemStack(block))) {
if (EventHandler.onBlockHutPlaced(world, player, block, buildPos)) {
world.destroyBlock(buildPos, true);
world.setBlockState(buildPos, block.getDefaultState().withRotation(BlockUtils.getRotation(rotation)));
((AbstractBlockHut) block).onBlockPlacedByBuildTool(world, buildPos, world.getBlockState(buildPos), player, null, mirror, sn.getStyle());
player.inventory.clearMatchingItems(Item.getItemFromBlock(block), -1, 1, null);
setupBuilding(world, player, sn, rotation, buildPos, mirror);
}
} else {
LanguageHandler.sendPlayerMessage(player, BuildToolPlaceMessage.NO_HUT_IN_INVENTORY);
}
}
Aggregations