use of com.minecolonies.coremod.placementhandlers.IPlacementHandler in project minecolonies by Minecolonies.
the class AbstractEntityAIStructure method placeBlockAt.
private boolean placeBlockAt(@NotNull final IBlockState blockState, @NotNull final BlockPos coords) {
final ItemStack item = BlockUtils.getItemStackFromBlockState(blockState);
worker.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, item == null ? ItemStackUtils.EMPTY : item);
final IBlockState decrease;
for (final IPlacementHandler handlers : PlacementHandlers.handlers) {
final Object result = handlers.handle(world, coords, blockState, this, Configurations.gameplay.builderInfiniteResources, false);
if (result instanceof IPlacementHandler.ActionProcessingResult) {
if (result == ACCEPT) {
return true;
}
if (result == DENY) {
return false;
}
continue;
}
if (result instanceof IBlockState) {
decrease = (IBlockState) result;
decreaseInventory(coords, decrease.getBlock(), decrease);
connectBlockToBuildingIfNecessary(decrease, coords);
worker.swingArm(worker.getActiveHand());
worker.addExperience(XP_EACH_BLOCK);
return true;
}
}
Log.getLogger().warn("Couldn't handle block: " + blockState.getBlock().getUnlocalizedName());
return true;
}
use of com.minecolonies.coremod.placementhandlers.IPlacementHandler in project minecolonies by Minecolonies.
the class StructureWrapper method handleBlockPlacement.
private void handleBlockPlacement(final BlockPos pos, final IBlockState localState, final boolean complete) {
for (final IPlacementHandler handlers : PlacementHandlers.handlers) {
final Object result = handlers.handle(world, pos, localState, null, true, complete);
if (result instanceof IBlockState) {
final IBlockState blockState = (IBlockState) result;
final Colony colony = ColonyManager.getColony(world, pos);
if (colony != null) {
final AbstractBuilding building = colony.getBuildingManager().getBuilding(position);
if (building != null) {
building.registerBlockPosition(blockState, pos, world);
}
}
return;
} else if (!(result instanceof IPlacementHandler.ActionProcessingResult) || result != IGNORE) {
return;
}
}
}
Aggregations