Search in sources :

Example 1 with SchematicRequestMessage

use of com.minecolonies.coremod.network.messages.SchematicRequestMessage in project minecolonies by Minecolonies.

the class WindowBuildTool method changeSchematic.

/*
     * ---------------- Miscellaneous ----------------
     */
/**
     * Changes the current structure.
     * Set to button position at that time
     */
private void changeSchematic() {
    final String sname = schematics.get(schematicsDropDownList.getSelectedIndex());
    final Structures.StructureName structureName = new Structures.StructureName(sname);
    final Structure structure = new Structure(null, structureName.toString(), new PlacementSettings().setRotation(BlockUtils.getRotation(Settings.instance.getRotation())).setMirror(Settings.instance.getMirror()));
    final String md5 = Structures.getMD5(structureName.toString());
    if (structure.isTemplateMissing() || !structure.isCorrectMD5(md5)) {
        if (structure.isTemplateMissing()) {
            Log.getLogger().info("Template structure " + structureName + " missing");
        } else {
            Log.getLogger().info("structure " + structureName + " md5 error");
        }
        Log.getLogger().info("Request To Server for structure " + structureName);
        if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) {
            MineColonies.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);
    if (Settings.instance.getPosition() == null) {
        Settings.instance.setPosition(this.pos);
    }
}
Also used : SchematicRequestMessage(com.minecolonies.coremod.network.messages.SchematicRequestMessage) Structures(com.minecolonies.coremod.colony.Structures) Structure(com.minecolonies.structures.helpers.Structure) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings)

Aggregations

Structures (com.minecolonies.coremod.colony.Structures)1 SchematicRequestMessage (com.minecolonies.coremod.network.messages.SchematicRequestMessage)1 Structure (com.minecolonies.structures.helpers.Structure)1 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)1