Search in sources :

Example 1 with AbstractJobStructure

use of com.minecolonies.coremod.colony.jobs.AbstractJobStructure in project minecolonies by Minecolonies.

the class AbstractEntityAIStructure method loadStructure.

/**
 * Loads the structure given the name, rotation and position.
 *
 * @param name        the name to retrieve  it.
 * @param rotateTimes number of times to rotateWithMirror it.
 * @param position    the position to set it.
 * @param isMirrored  is the structure mirroed?
 */
public void loadStructure(@NotNull final String name, final int rotateTimes, final BlockPos position, final boolean isMirrored) {
    if (job instanceof AbstractJobStructure) {
        rotation = rotateTimes;
        try {
            final StructureWrapper wrapper = new StructureWrapper(world, name);
            ((AbstractJobStructure) job).setStructure(wrapper);
            currentStructure = new Structure(world, wrapper, Structure.Stage.CLEAR);
        } catch (final IllegalStateException e) {
            Log.getLogger().warn(String.format("StructureProxy: (%s) does not exist - removing build request", name), e);
            ((AbstractJobStructure) job).setStructure(null);
        }
        try {
            ((AbstractJobStructure) job).getStructure().rotate(rotateTimes, world, position, isMirrored ? Mirror.FRONT_BACK : Mirror.NONE);
            ((AbstractJobStructure) job).getStructure().setPosition(position);
        } catch (final NullPointerException ex) {
            handleSpecificCancelActions();
            ((AbstractJobStructure) job).setStructure(null);
            Log.getLogger().warn("Structure couldn't be found which caused an NPE, removed workOrder, more details in log", ex);
        }
    }
}
Also used : StructureWrapper(com.minecolonies.coremod.util.StructureWrapper) AbstractJobStructure(com.minecolonies.coremod.colony.jobs.AbstractJobStructure) Structure(com.minecolonies.coremod.entity.ai.util.Structure) AbstractJobStructure(com.minecolonies.coremod.colony.jobs.AbstractJobStructure)

Aggregations

AbstractJobStructure (com.minecolonies.coremod.colony.jobs.AbstractJobStructure)1 Structure (com.minecolonies.coremod.entity.ai.util.Structure)1 StructureWrapper (com.minecolonies.coremod.util.StructureWrapper)1