Search in sources :

Example 1 with GenerateAndSaveMessage

use of com.ldtteam.structurize.network.messages.GenerateAndSaveMessage 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()));
}
Also used : GenerateAndSaveMessage(com.ldtteam.structurize.network.messages.GenerateAndSaveMessage) StructureName(com.ldtteam.structurize.management.StructureName) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

StructureName (com.ldtteam.structurize.management.StructureName)1 GenerateAndSaveMessage (com.ldtteam.structurize.network.messages.GenerateAndSaveMessage)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1