use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.
the class WindowBuildTool method commonStructureUpdate.
/**
* Changes the current structure.
*/
public static void commonStructureUpdate() {
final String sname = Settings.instance.getStructureName();
if (sname == null) {
return;
}
final StructureName structureName = new StructureName(sname);
final String md5 = Structures.getMD5(structureName.toString());
final IStructureHandler structure = new CreativeStructureHandler(Minecraft.getInstance().level, new BlockPos(0, 0, 0), structureName.toString(), new PlacementSettings(Settings.instance.getMirror(), BlockUtils.getRotation(Settings.instance.getRotation())), true);
if (!structure.hasBluePrint() || !structure.isCorrectMD5(md5)) {
if (!structure.hasBluePrint()) {
Log.getLogger().info("Blueprint structure " + structureName + " missing");
} else {
Log.getLogger().info("structure " + structureName + " md5 error");
}
Log.getLogger().info("Request To Server for structure " + structureName);
if (ServerLifecycleHooks.getCurrentServer() == null) {
Network.getNetwork().sendToServer(new SchematicRequestMessage(structureName.toString()));
return;
} else {
Log.getLogger().error("WindowBuildTool: Need to download schematic on a standalone client/server. This should never happen");
}
}
Settings.instance.setStructureName(structureName.toString());
Settings.instance.setActiveSchematic(structure.getBluePrint());
}
use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.
the class StructurePlacementUtils method loadAndPlaceStructureWithRotation.
/**
* Load a structure into this world
* and place it in the right position and rotation.
*
* @param worldObj the world to load it in
* @param name the structures name
* @param pos coordinates
* @param rotation the rotation.
* @param mirror the mirror used.
* @param fancyPlacement if fancy or complete.
* @param player the placing player.
*/
public static void loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final String name, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, final ServerPlayerEntity player) {
try {
@NotNull final IStructureHandler structure = new CreativeStructureHandler(worldObj, pos, name, new PlacementSettings(mirror, rotation), fancyPlacement);
structure.getBluePrint().rotateWithMirror(rotation, mirror, worldObj);
@NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
} catch (final IllegalStateException e) {
Log.getLogger().warn("Could not load structure!", e);
}
}
use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.
the class StructurePlacementUtils method unloadStructure.
/**
* Unload a structure at a certain location.
*
* @param world the world.
* @param startPos the position.
* @param name the name.
* @param rotation the rotation.
* @param mirror the mirror.
*/
public static void unloadStructure(@NotNull final World world, @NotNull final BlockPos startPos, @NotNull final String name, final Rotation rotation, @NotNull final Mirror mirror) {
@NotNull final IStructureHandler structure = new CreativeStructureHandler(world, startPos, name, new PlacementSettings(mirror, rotation), false);
structure.getBluePrint().rotateWithMirror(rotation, mirror, world);
@NotNull final StructurePlacer placer = new StructurePlacer(structure);
placer.executeStructureStep(world, null, new BlockPos(0, 0, 0), StructurePlacer.Operation.BLOCK_REMOVAL, () -> placer.getIterator().increment((info, pos, handler) -> handler.getWorld().getBlockState(pos).getBlock() instanceof AirBlock), true);
}
use of com.ldtteam.structurize.placement.structure.CreativeStructureHandler in project Structurize by ldtteam.
the class StructurePlacementUtils method loadAndPlaceStructureWithRotation.
/**
* Load a structure into this world
* and place it in the right position and rotation.
*
* @param worldObj the world to load it in
* @param blueprint the structures blueprint
* @param pos coordinates
* @param rotation the rotation.
* @param mirror the mirror used.
* @param fancyPlacement if fancy or complete.
* @param player the placing player.
*/
public static void loadAndPlaceStructureWithRotation(final World worldObj, @NotNull final Blueprint blueprint, @NotNull final BlockPos pos, final Rotation rotation, @NotNull final Mirror mirror, final boolean fancyPlacement, final ServerPlayerEntity player) {
try {
@NotNull final IStructureHandler structure = new CreativeStructureHandler(worldObj, pos, blueprint, new PlacementSettings(mirror, rotation), fancyPlacement);
if (fancyPlacement) {
structure.fancyPlacement();
}
structure.getBluePrint().rotateWithMirror(rotation, mirror, worldObj);
@NotNull final StructurePlacer instantPlacer = new StructurePlacer(structure);
Manager.addToQueue(new TickedWorldOperation(instantPlacer, player));
} catch (final IllegalStateException e) {
Log.getLogger().warn("Could not load structure!", e);
}
}
Aggregations