use of com.minecolonies.coremod.entity.ai.util.Structure 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);
}
}
}
Aggregations