Search in sources :

Example 16 with StructureName

use of com.ldtteam.structurize.management.StructureName in project minecolonies by Minecolonies.

the class AbstractSchematicProvider method unsafeUpdateTEDataFromSchematic.

/**
 * Load the schematic data from the TE schematic name, if it's a reattempt, calculate the name from the building (backup).
 * Might throw exceptions if data is invalid.
 */
private void unsafeUpdateTEDataFromSchematic(final TileEntityColonyBuilding te) {
    final String structureName;
    if (te.getSchematicName().isEmpty()) {
        structureName = new StructureName(Structures.SCHEMATICS_PREFIX, style, this.getSchematicName() + Math.max(1, buildingLevel)).toString();
    } else {
        structureName = new StructureName(Structures.SCHEMATICS_PREFIX, style, te.getSchematicName()).toString();
    }
    final LoadOnlyStructureHandler structure = new LoadOnlyStructureHandler(colony.getWorld(), getPosition(), structureName, new PlacementSettings(), true);
    final Blueprint blueprint = structure.getBluePrint();
    blueprint.rotateWithMirror(BlockPosUtil.getRotationFromRotations(getRotation()), isMirrored() ? Mirror.FRONT_BACK : Mirror.NONE, colony.getWorld());
    final BlockInfo info = blueprint.getBlockInfoAsMap().getOrDefault(blueprint.getPrimaryBlockOffset(), null);
    if (info.getTileEntityData() != null) {
        te.readSchematicDataFromNBT(info.getTileEntityData());
    }
}
Also used : Blueprint(com.ldtteam.structures.blueprints.v1.Blueprint) BlockInfo(com.ldtteam.structurize.util.BlockInfo) StructureName(com.ldtteam.structurize.management.StructureName) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Example 17 with StructureName

use of com.ldtteam.structurize.management.StructureName in project minecolonies by Minecolonies.

the class WorkOrderBuildDecoration method onCompleted.

@Override
public void onCompleted(final IColony colony, ICitizenData citizen) {
    super.onCompleted(colony, citizen);
    final StructureName structureName = new StructureName(getStructureName());
    if (this instanceof WorkOrderBuildBuilding) {
        final int level = ((WorkOrderBuildBuilding) this).getUpgradeLevel();
        AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.COMPLETE_BUILD_REQUEST.trigger(player, structureName, level));
    } else {
        AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.COMPLETE_BUILD_REQUEST.trigger(player, structureName, 0));
    }
}
Also used : StructureName(com.ldtteam.structurize.management.StructureName)

Example 18 with StructureName

use of com.ldtteam.structurize.management.StructureName in project minecolonies by Minecolonies.

the class WindowMinecoloniesShapeTool method place.

@Override
protected void place() {
    final StructureName sn = save();
    // rotation/mirroring already happened server side
    final BuildToolPlaceMessage msg = new BuildToolPlaceMessage(sn.toString(), Settings.instance.getShape().toString(), Settings.instance.getPosition(), 0, false, Mirror.NONE, Blocks.AIR.defaultBlockState());
    Minecraft.getInstance().tell(new WindowBuildDecoration(msg, Settings.instance.getPosition(), sn)::open);
}
Also used : BuildToolPlaceMessage(com.minecolonies.coremod.network.messages.server.BuildToolPlaceMessage) StructureName(com.ldtteam.structurize.management.StructureName)

Example 19 with StructureName

use of com.ldtteam.structurize.management.StructureName in project minecolonies by Minecolonies.

the class AbstractSchematicProvider method deserializerStructureInformationFrom.

private void deserializerStructureInformationFrom(final CompoundNBT compound) {
    final String md5 = compound.getString(TAG_SCHEMATIC_MD5);
    final int testLevel = buildingLevel == 0 ? 1 : buildingLevel;
    final StructureName sn = new StructureName(Structures.SCHEMATICS_PREFIX, style, this.getSchematicName() + testLevel);
    if (!Structures.hasMD5(sn)) {
        final StructureName newStructureName = Structures.getStructureNameByMD5(md5);
        if (newStructureName != null && newStructureName.getPrefix().equals(sn.getPrefix()) && newStructureName.getSchematic().equals(sn.getSchematic())) {
            // We found the new location for the schematic, update the style accordingly
            style = newStructureName.getStyle();
            Log.getLogger().warn(String.format("AbstractBuilding.readFromNBT: %s have been moved to %s", sn, newStructureName));
        }
    }
    if (style.isEmpty()) {
        Log.getLogger().warn("Loaded empty style, setting to wooden");
        style = "wooden";
    }
}
Also used : StructureName(com.ldtteam.structurize.management.StructureName) IAltersBuildingFootprint(com.minecolonies.api.colony.buildings.modules.IAltersBuildingFootprint) Blueprint(com.ldtteam.structures.blueprints.v1.Blueprint)

Example 20 with StructureName

use of com.ldtteam.structurize.management.StructureName in project minecolonies by Minecolonies.

the class AbstractSchematicProvider method serializeNBT.

@Override
public CompoundNBT serializeNBT() {
    final CompoundNBT compound = new CompoundNBT();
    BlockPosUtil.write(compound, TAG_LOCATION, location);
    final StructureName structureName = new StructureName(Structures.SCHEMATICS_PREFIX, style, this.getSchematicName() + buildingLevel);
    if (Structures.hasMD5(structureName)) {
        compound.putString(TAG_SCHEMATIC_MD5, Structures.getMD5(structureName.toString()));
    }
    compound.putInt(TAG_SCHEMATIC_LEVEL, buildingLevel);
    compound.putString(TAG_STYLE, style);
    compound.putBoolean(TAG_MIRROR, isBuildingMirrored);
    getCorners();
    BlockPosUtil.write(compound, TAG_CORNER1, this.lowerCorner);
    BlockPosUtil.write(compound, TAG_CORNER2, this.higherCorner);
    compound.putInt(TAG_HEIGHT, this.height);
    compound.putInt(TAG_ROTATION, getRotation());
    compound.putBoolean(TAG_DECONSTRUCTED, isDeconstructed);
    BlockPosUtil.write(compound, TAG_PARENT_SCHEM, parentSchematic);
    BlockPosUtil.writePosListToNBT(compound, TAG_CHILD_SCHEM, new ArrayList<>(childSchematics));
    return compound;
}
Also used : CompoundNBT(net.minecraft.nbt.CompoundNBT) StructureName(com.ldtteam.structurize.management.StructureName)

Aggregations

StructureName (com.ldtteam.structurize.management.StructureName)43 Blueprint (com.ldtteam.structures.blueprints.v1.Blueprint)14 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)10 BlockPos (net.minecraft.util.math.BlockPos)9 LoadOnlyStructureHandler (com.minecolonies.api.util.LoadOnlyStructureHandler)7 Nullable (org.jetbrains.annotations.Nullable)6 SchematicRequestMessage (com.ldtteam.structurize.network.messages.SchematicRequestMessage)5 IStructureHandler (com.ldtteam.structurize.placement.structure.IStructureHandler)5 TileEntity (net.minecraft.tileentity.TileEntity)5 DropDownList (com.ldtteam.blockout.views.DropDownList)4 IBlueprintDataProvider (com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider)4 AbstractBlockHut (com.minecolonies.api.blocks.AbstractBlockHut)4 IColonyView (com.minecolonies.api.colony.IColonyView)4 IBuildingView (com.minecolonies.api.colony.buildings.views.IBuildingView)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 StringTextComponent (net.minecraft.util.text.StringTextComponent)4 Button (com.ldtteam.blockout.controls.Button)3 IAltersBuildingFootprint (com.minecolonies.api.colony.buildings.modules.IAltersBuildingFootprint)3 Log (com.minecolonies.api.util.Log)3 Predicate (java.util.function.Predicate)3