use of com.minecolonies.coremod.blocks.BlockDecorationController in project minecolonies by ldtteam.
the class DecorationBuildRequestMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final IColony colony = IColonyManager.getInstance().getColonyByPosFromDim(dimension, pos);
if (colony == null) {
return;
}
final PlayerEntity player = ctxIn.getSender();
// Verify player has permission to change this huts settings
if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
final TileEntity entity = player.getCommandSenderWorld().getBlockEntity(pos);
if (entity instanceof TileEntityDecorationController) {
final Optional<Map.Entry<Integer, IWorkOrder>> wo = colony.getWorkManager().getWorkOrders().entrySet().stream().filter(entry -> entry.getValue() instanceof WorkOrderBuildDecoration).filter(entry -> ((WorkOrderBuildDecoration) entry.getValue()).getSchematicLocation().equals(pos)).findFirst();
if (wo.isPresent()) {
colony.getWorkManager().removeWorkOrder(wo.get().getKey());
return;
}
int difference = 0;
final LoadOnlyStructureHandler structure = new LoadOnlyStructureHandler(colony.getWorld(), this.pos, name + level, new PlacementSettings(), true);
final Blueprint blueprint = structure.getBluePrint();
if (blueprint != null) {
final BlockState structureState = structure.getBluePrint().getBlockInfoAsMap().get(structure.getBluePrint().getPrimaryBlockOffset()).getState();
if (structureState != null) {
if (!(structureState.getBlock() instanceof BlockDecorationController)) {
Log.getLogger().error(String.format("Schematic %s doesn't have a correct Primary Offset", name + level));
return;
}
final int structureRotation = structureState.getValue(BlockDecorationController.FACING).get2DDataValue();
final int worldRotation = colony.getWorld().getBlockState(this.pos).getValue(BlockDecorationController.FACING).get2DDataValue();
if (structureRotation <= worldRotation) {
difference = worldRotation - structureRotation;
} else {
difference = 4 + worldRotation - structureRotation;
}
}
}
final BlockState state = player.getCommandSenderWorld().getBlockState(pos);
final WorkOrderBuildDecoration order = new WorkOrderBuildDecoration(name + level, name + level, difference, pos, state.getValue(BlockDecorationController.MIRROR));
if (level != ((TileEntityDecorationController) entity).getTier()) {
order.setLevelUp();
}
colony.getWorkManager().addWorkOrder(order, false);
}
}
use of com.minecolonies.coremod.blocks.BlockDecorationController in project minecolonies by Minecolonies.
the class AbstractPathJob method isPassable.
/**
* Is the space passable.
*
* @param block the block we are checking.
* @return true if the block does not block movement.
*/
protected boolean isPassable(@NotNull final BlockState block, final BlockPos pos, final Node parent) {
if (block.getMaterial() != Material.AIR) {
final VoxelShape shape = block.getCollisionShape(world, pos);
if (block.getMaterial().blocksMotion() && !(shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1)) {
if (block.getBlock() instanceof TrapDoorBlock) {
final BlockPos parentPos = parent == null ? start : parent.pos;
final BlockPos dir = pos.subtract(parentPos);
if (dir.getY() != 0 && dir.getX() == 0 && dir.getZ() == 0) {
return true;
}
final Direction facing = block.getValue(TrapDoorBlock.FACING);
if (dir.getX() != 0) {
return facing == Direction.NORTH || facing == Direction.SOUTH;
}
return facing == Direction.EAST || facing == Direction.WEST;
} else {
return pathingOptions.canEnterDoors() && (block.getBlock() instanceof DoorBlock || block.getBlock() instanceof FenceGateBlock) || block.getBlock() instanceof AbstractBlockMinecoloniesConstructionTape || block.getBlock() instanceof PressurePlateBlock || block.getBlock() instanceof BlockDecorationController || block.getBlock() instanceof AbstractSignBlock || block.getBlock() instanceof AbstractBannerBlock;
}
} else if (block.getBlock() instanceof FireBlock || block.getBlock() instanceof SweetBerryBushBlock) {
return false;
} else {
if (isLadder(block.getBlock(), pos)) {
return true;
}
if (shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1 && !isLiquid((block)) && (block.getBlock() != Blocks.SNOW || block.getValue(SnowBlock.LAYERS) == 1)) {
final PathNodeType pathType = block.getAiPathNodeType(world, pos);
if (pathType == null || pathType.getDanger() == null) {
return true;
}
}
return false;
}
}
return true;
}
use of com.minecolonies.coremod.blocks.BlockDecorationController in project minecolonies by Minecolonies.
the class DecorationBuildRequestMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final IColony colony = IColonyManager.getInstance().getColonyByPosFromDim(dimension, pos);
if (colony == null) {
return;
}
final PlayerEntity player = ctxIn.getSender();
// Verify player has permission to change this huts settings
if (!colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
final TileEntity entity = player.getCommandSenderWorld().getBlockEntity(pos);
if (entity instanceof TileEntityDecorationController) {
final Optional<Map.Entry<Integer, IWorkOrder>> wo = colony.getWorkManager().getWorkOrders().entrySet().stream().filter(entry -> entry.getValue() instanceof WorkOrderBuildDecoration).filter(entry -> ((WorkOrderBuildDecoration) entry.getValue()).getSchematicLocation().equals(pos)).findFirst();
if (wo.isPresent()) {
colony.getWorkManager().removeWorkOrder(wo.get().getKey());
return;
}
int difference = 0;
final LoadOnlyStructureHandler structure = new LoadOnlyStructureHandler(colony.getWorld(), this.pos, name + level, new PlacementSettings(), true);
final Blueprint blueprint = structure.getBluePrint();
if (blueprint != null) {
final BlockState structureState = structure.getBluePrint().getBlockInfoAsMap().get(structure.getBluePrint().getPrimaryBlockOffset()).getState();
if (structureState != null) {
if (!(structureState.getBlock() instanceof BlockDecorationController)) {
Log.getLogger().error(String.format("Schematic %s doesn't have a correct Primary Offset", name + level));
return;
}
final int structureRotation = structureState.getValue(BlockDecorationController.FACING).get2DDataValue();
final int worldRotation = colony.getWorld().getBlockState(this.pos).getValue(BlockDecorationController.FACING).get2DDataValue();
if (structureRotation <= worldRotation) {
difference = worldRotation - structureRotation;
} else {
difference = 4 + worldRotation - structureRotation;
}
}
}
final BlockState state = player.getCommandSenderWorld().getBlockState(pos);
final WorkOrderBuildDecoration order = new WorkOrderBuildDecoration(name + level, name + level, difference, pos, state.getValue(BlockDecorationController.MIRROR));
if (level != ((TileEntityDecorationController) entity).getTier()) {
order.setLevelUp();
}
colony.getWorkManager().addWorkOrder(order, false);
}
}
use of com.minecolonies.coremod.blocks.BlockDecorationController in project minecolonies by ldtteam.
the class AbstractPathJob method isPassable.
/**
* Is the space passable.
*
* @param block the block we are checking.
* @return true if the block does not block movement.
*/
protected boolean isPassable(@NotNull final BlockState block, final BlockPos pos, final Node parent) {
if (block.getMaterial() != Material.AIR) {
final VoxelShape shape = block.getCollisionShape(world, pos);
if (block.getMaterial().blocksMotion() && !(shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1)) {
if (block.getBlock() instanceof TrapDoorBlock) {
final BlockPos parentPos = parent == null ? start : parent.pos;
final BlockPos dir = pos.subtract(parentPos);
if (dir.getY() != 0 && dir.getX() == 0 && dir.getZ() == 0) {
return true;
}
final Direction facing = block.getValue(TrapDoorBlock.FACING);
if (dir.getX() != 0) {
return facing == Direction.NORTH || facing == Direction.SOUTH;
}
return facing == Direction.EAST || facing == Direction.WEST;
} else {
return pathingOptions.canEnterDoors() && (block.getBlock() instanceof DoorBlock || block.getBlock() instanceof FenceGateBlock) || block.getBlock() instanceof AbstractBlockMinecoloniesConstructionTape || block.getBlock() instanceof PressurePlateBlock || block.getBlock() instanceof BlockDecorationController || block.getBlock() instanceof AbstractSignBlock || block.getBlock() instanceof AbstractBannerBlock;
}
} else if (block.getBlock() instanceof FireBlock || block.getBlock() instanceof SweetBerryBushBlock) {
return false;
} else {
if (isLadder(block.getBlock(), pos)) {
return true;
}
if (shape.isEmpty() || shape.max(Direction.Axis.Y) <= 0.1 && !isLiquid((block)) && (block.getBlock() != Blocks.SNOW || block.getValue(SnowBlock.LAYERS) == 1)) {
final PathNodeType pathType = block.getAiPathNodeType(world, pos);
if (pathType == null || pathType.getDanger() == null) {
return true;
}
}
return false;
}
}
return true;
}
Aggregations