Search in sources :

Example 1 with WorkOrderBuildBuilding

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());
}
Also used : WorkOrderBuildBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding) AbstractTileEntityColonyBuilding(com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Example 2 with WorkOrderBuildBuilding

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;
        }
    }
}
Also used : WorkOrderBuild(com.minecolonies.coremod.colony.workorders.WorkOrderBuild) WorkOrderBuildBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkOrderBuildRemoval(com.minecolonies.coremod.colony.workorders.WorkOrderBuildRemoval) ICitizenData(com.minecolonies.api.colony.ICitizenData) BlockPos(net.minecraft.util.math.BlockPos) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with WorkOrderBuildBuilding

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;
        }
    }
}
Also used : WorkOrderBuild(com.minecolonies.coremod.colony.workorders.WorkOrderBuild) WorkOrderBuildBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkOrderBuildRemoval(com.minecolonies.coremod.colony.workorders.WorkOrderBuildRemoval) ICitizenData(com.minecolonies.api.colony.ICitizenData) BlockPos(net.minecraft.util.math.BlockPos) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with WorkOrderBuildBuilding

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();
}
Also used : WorkOrderBuild(com.minecolonies.coremod.colony.workorders.WorkOrderBuild) WorkOrderBuildBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkOrderBuildRemoval(com.minecolonies.coremod.colony.workorders.WorkOrderBuildRemoval) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with WorkOrderBuildBuilding

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());
}
Also used : WorkOrderBuildBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding) AbstractTileEntityColonyBuilding(com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Aggregations

WorkOrderBuildBuilding (com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding)8 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)6 WorkOrderBuild (com.minecolonies.coremod.colony.workorders.WorkOrderBuild)4 WorkOrderBuildRemoval (com.minecolonies.coremod.colony.workorders.WorkOrderBuildRemoval)4 BlockPos (net.minecraft.util.math.BlockPos)4 NotNull (org.jetbrains.annotations.NotNull)4 StructureName (com.ldtteam.structurize.management.StructureName)2 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)2 ICitizenData (com.minecolonies.api.colony.ICitizenData)2 AbstractTileEntityColonyBuilding (com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding)2 AbstractAssignedCitizenModule (com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule)2 Predicate (java.util.function.Predicate)2 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 ItemStack (net.minecraft.item.ItemStack)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)2 InvWrapper (net.minecraftforge.items.wrapper.InvWrapper)2 Nullable (org.jetbrains.annotations.Nullable)2