use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding in project minecolonies by Minecolonies.
the class AbstractBuilding method calculateCorners.
@Override
public void calculateCorners() {
final AbstractTileEntityColonyBuilding te = getTileEntity();
if (te != null && !te.getSchematicName().isEmpty()) {
setCorners(te.getInWorldCorners().getA(), te.getInWorldCorners().getB());
return;
}
final WorkOrderBuildBuilding workOrder = new WorkOrderBuildBuilding(this, Math.max(1, getBuildingLevel()));
final LoadOnlyStructureHandler wrapper = new LoadOnlyStructureHandler(colony.getWorld(), getPosition(), workOrder.getStructureName(), new PlacementSettings(), true);
if (!wrapper.hasBluePrint()) {
setCorners(getPosition(), getPosition());
return;
}
final Tuple<BlockPos, BlockPos> corners = ColonyUtils.calculateCorners(this.getPosition(), colony.getWorld(), wrapper.getBluePrint(), workOrder.getRotation(colony.getWorld()), workOrder.isMirrored());
this.setCorners(corners.getA(), corners.getB());
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding in project minecolonies by Minecolonies.
the class AbstractBuilding method removeWorkOrder.
/**
* Remove the work order for the building.
* <p>
* Remove either the upgrade or repair work order
*/
@Override
public void removeWorkOrder() {
for (@NotNull final WorkOrderBuild o : colony.getWorkManager().getWorkOrdersOfType(WorkOrderBuild.class)) {
if (o.getSchematicLocation().equals(getID()) && (o instanceof WorkOrderBuildBuilding || o instanceof WorkOrderBuildRemoval)) {
colony.getWorkManager().removeWorkOrder(o.getID());
markDirty();
final BlockPos buildingPos = o.getClaimedBy();
final IBuilding building = colony.getBuildingManager().getBuilding(buildingPos);
if (building != null) {
for (final AbstractAssignedCitizenModule module : building.getModules(AbstractAssignedCitizenModule.class)) {
for (final ICitizenData citizen : module.getAssignedCitizen()) {
building.cancelAllRequestsOfCitizen(citizen);
}
}
}
return;
}
}
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding in project minecolonies by ldtteam.
the class AbstractBuilding method removeWorkOrder.
/**
* Remove the work order for the building.
* <p>
* Remove either the upgrade or repair work order
*/
@Override
public void removeWorkOrder() {
for (@NotNull final WorkOrderBuild o : colony.getWorkManager().getWorkOrdersOfType(WorkOrderBuild.class)) {
if (o.getSchematicLocation().equals(getID()) && (o instanceof WorkOrderBuildBuilding || o instanceof WorkOrderBuildRemoval)) {
colony.getWorkManager().removeWorkOrder(o.getID());
markDirty();
final BlockPos buildingPos = o.getClaimedBy();
final IBuilding building = colony.getBuildingManager().getBuilding(buildingPos);
if (building != null) {
for (final AbstractAssignedCitizenModule module : building.getModules(AbstractAssignedCitizenModule.class)) {
for (final ICitizenData citizen : module.getAssignedCitizen()) {
building.cancelAllRequestsOfCitizen(citizen);
}
}
}
return;
}
}
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding in project minecolonies by ldtteam.
the class AbstractBuilding method requestWorkOrder.
/**
* Adds work orders to the {@link Colony#getWorkManager()}.
*
* @param level Desired level.
* @param builder the assigned builder.
*/
protected void requestWorkOrder(final int level, final BlockPos builder, final boolean removal) {
for (@NotNull final WorkOrderBuildBuilding o : colony.getWorkManager().getWorkOrdersOfType(WorkOrderBuildBuilding.class)) {
if (o.getSchematicLocation().equals(getID())) {
return;
}
}
WorkOrderBuild workOrder;
if (removal) {
if (!canDeconstruct()) {
LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), "entity.builder.cantdeconstruct");
return;
}
workOrder = new WorkOrderBuildRemoval(this, level);
} else {
workOrder = new WorkOrderBuildBuilding(this, level);
}
if (!removal && !canBeBuiltByBuilder(level) && !workOrder.canBeResolved(colony, level)) {
LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), "entity.builder.messagebuildernecessary", Integer.toString(level));
return;
}
if (workOrder.tooFarFromAnyBuilder(colony, level) && builder.equals(BlockPos.ZERO)) {
LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), "entity.builder.messagebuilderstoofar");
return;
}
if (getCorners().getA().getY() >= MAX_BUILD_HEIGHT || getCorners().getB().getY() >= MAX_BUILD_HEIGHT) {
LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), "entity.builder.messagebuildtoohigh");
return;
} else if (getPosition().getY() <= MIN_BUILD_HEIGHT) {
LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), "entity.builder.messagebuildtoolow");
return;
}
if (!builder.equals(BlockPos.ZERO)) {
final IBuilding building = colony.getBuildingManager().getBuilding(builder);
if (building instanceof AbstractBuildingStructureBuilder && (building.getBuildingLevel() >= level || canBeBuiltByBuilder(level))) {
workOrder.setClaimedBy(builder);
} else {
LanguageHandler.sendPlayersMessage(colony.getMessagePlayerEntities(), "entity.builder.messagebuildernecessary", Integer.toString(level));
return;
}
}
colony.getWorkManager().addWorkOrder(workOrder, false);
colony.getProgressManager().progressWorkOrderPlacement(workOrder);
if (workOrder.getID() != 0) {
LanguageHandler.sendPlayersMessage(colony.getImportantMessageEntityPlayers(), "com.minecolonies.coremod.workorderadded", workOrder.getDisplayName(), colony.getName(), workOrder.getSchematicLocation().getX(), workOrder.getSchematicLocation().getY(), workOrder.getSchematicLocation().getZ());
}
markDirty();
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding in project minecolonies by ldtteam.
the class AbstractBuilding method calculateCorners.
@Override
public void calculateCorners() {
final AbstractTileEntityColonyBuilding te = getTileEntity();
if (te != null && !te.getSchematicName().isEmpty()) {
setCorners(te.getInWorldCorners().getA(), te.getInWorldCorners().getB());
return;
}
final WorkOrderBuildBuilding workOrder = new WorkOrderBuildBuilding(this, Math.max(1, getBuildingLevel()));
final LoadOnlyStructureHandler wrapper = new LoadOnlyStructureHandler(colony.getWorld(), getPosition(), workOrder.getStructureName(), new PlacementSettings(), true);
if (!wrapper.hasBluePrint()) {
setCorners(getPosition(), getPosition());
return;
}
final Tuple<BlockPos, BlockPos> corners = ColonyUtils.calculateCorners(this.getPosition(), colony.getWorld(), wrapper.getBluePrint(), workOrder.getRotation(colony.getWorld()), workOrder.isMirrored());
this.setCorners(corners.getA(), corners.getB());
}
Aggregations