use of com.ldtteam.structurize.management.StructureName in project minecolonies by Minecolonies.
the class BuildToolPlaceMessage method onExecute.
@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer) {
final PlayerEntity player = ctxIn.getSender();
final StructureName sn = new StructureName(structureName);
if (!Structures.hasMD5(sn)) {
MessageUtils.format(new StringTextComponent("Can not build " + workOrderName + ": schematic missing!")).sendTo(player);
return;
}
if (isHut) {
handleHut(CompatibilityUtils.getWorldFromEntity(player), player, sn, rotation, pos, mirror, state);
} else {
handleDecoration(CompatibilityUtils.getWorldFromEntity(player), player, sn, workOrderName, rotation, pos, mirror, builder);
}
}
use of com.ldtteam.structurize.management.StructureName in project Structurize by ldtteam.
the class ClientStructureWrapper method handleSaveScanMessage.
/**
* Handles the save message of scans.
*
* @param CompoundNBT compound to store.
* @param fileName milli seconds for fileName.
*/
public static void handleSaveScanMessage(final CompoundNBT CompoundNBT, final String fileName) {
final StructureName structureName = new StructureName(Structures.SCHEMATICS_SCAN, "new", fileName);
final File file = new File(new File(Minecraft.getInstance().gameDirectory, Constants.MOD_ID), structureName.toString() + Structures.SCHEMATIC_EXTENSION_NEW);
Utils.checkDirectory(file.getParentFile());
try (final OutputStream outputstream = new FileOutputStream(file)) {
CompressedStreamTools.writeCompressed(CompoundNBT, outputstream);
} catch (final IOException e) {
LanguageHandler.sendPlayerMessage(Minecraft.getInstance().player, "item.scepterSteel.scanFailure");
Log.getLogger().warn("Exception while trying to scan.", e);
return;
}
LanguageHandler.sendPlayerMessage(Minecraft.getInstance().player, "item.scepterSteel.scanSuccess", file);
Settings.instance.setStructureName(structureName.toString());
}
use of com.ldtteam.structurize.management.StructureName in project Structurize by ldtteam.
the class WindowShapeTool method save.
/**
* Saves the current shape to the server.
* @return A name that can be used to place it.
*/
protected StructureName save() {
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
BlueprintUtil.writeToStream(stream, Settings.instance.getActiveStructure());
// cache it locally...
Structures.handleSaveSchematicMessage(stream.toByteArray(), true);
if (!Minecraft.getInstance().hasSingleplayerServer()) {
// and also on the server if needed
Network.getNetwork().sendToServer(new GenerateAndSaveMessage(Settings.instance.getPosition(), Settings.instance.getLength(), Settings.instance.getWidth(), Settings.instance.getHeight(), Settings.instance.getFrequency(), Settings.instance.getEquation(), Settings.instance.getShape(), Settings.instance.getBlock(true), Settings.instance.getBlock(false), Settings.instance.isHollow(), BlockUtils.getRotation(Settings.instance.getRotation()), Settings.instance.getMirror()));
}
// hopefully that is true, since they should be using the same algorithm to do it...
return new StructureName(Structures.SCHEMATICS_CACHE + Structures.SCHEMATICS_SEPARATOR + StructureUtils.calculateMD5(stream.toByteArray()));
}
use of com.ldtteam.structurize.management.StructureName in project Structurize by ldtteam.
the class WindowStructureNameEntry method onButtonClicked.
@Override
public void onButtonClicked(@NotNull final Button button) {
if (button.getID().equals(BUTTON_DONE)) {
final String name = inputName.getText();
if (!name.isEmpty()) {
final StructureName newStructureName = Structures.renameScannedStructure(structureName, name);
if (newStructureName != null) {
Settings.instance.setStructureName(newStructureName.toString());
}
}
} else if (!button.getID().equals(BUTTON_CANCEL)) {
return;
}
close();
Structurize.proxy.openBuildToolWindow(null, GROUNDSTYLE_RELATIVE);
}
use of com.ldtteam.structurize.management.StructureName in project Structurize by ldtteam.
the class WindowBuildTool method updateSchematics.
/**
* Update the list a available schematics.
*/
private void updateSchematics() {
String schematic = "";
if (schematicsDropDownList.getSelectedIndex() > -1 && schematicsDropDownList.getSelectedIndex() < schematics.size()) {
schematic = schematics.get(schematicsDropDownList.getSelectedIndex());
}
final String currentSchematic = schematic.isEmpty() ? "" : (new StructureName(schematic)).getSchematic();
final String section = sections.get(sectionsDropDownList.getSelectedIndex());
final String style = styles.get(stylesDropDownList.getSelectedIndex());
schematics = Structures.getSchematicsFor(section, style);
int newIndex = -1;
for (int i = 0; i < schematics.size(); i++) {
final StructureName sn = new StructureName(schematics.get(i));
if (sn.getSchematic().equals(currentSchematic)) {
newIndex = i;
break;
}
}
if (newIndex == -1) {
newIndex = 0;
}
final boolean enabled;
enabled = schematics.size() > 1;
findPaneOfTypeByID(BUTTON_PREVIOUS_SCHEMATIC_ID, Button.class).setEnabled(enabled);
findPaneOfTypeByID(DROPDOWN_SCHEMATIC_ID, DropDownList.class).setEnabled(enabled);
findPaneOfTypeByID(BUTTON_NEXT_SCHEMATIC_ID, Button.class).setEnabled(enabled);
schematicsDropDownList.setSelectedIndex(newIndex);
}
Aggregations