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());
}
}
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));
}
}
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);
}
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";
}
}
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;
}
Aggregations