From a27193eaee145ddc545be01396df60983cd3d9f1 Mon Sep 17 00:00:00 2001 From: Sakura Ryoko Date: Tue, 10 Dec 2024 23:01:17 -0500 Subject: [PATCH] Make browsing the files a bit faster by disabling the Data Fixers. --- .../schematic/LitematicaSchematic.java | 14 +++++++++++++ .../schematic/SchematicaSchematic.java | 20 +++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/fi/dy/masa/litematica/schematic/LitematicaSchematic.java b/src/main/java/fi/dy/masa/litematica/schematic/LitematicaSchematic.java index 7ff9c83b4b..88989d612c 100644 --- a/src/main/java/fi/dy/masa/litematica/schematic/LitematicaSchematic.java +++ b/src/main/java/fi/dy/masa/litematica/schematic/LitematicaSchematic.java @@ -2516,20 +2516,34 @@ public static Pair readMetadataAndVersionFro case SPONGE_SCHEMATIC -> { LitematicaSchematic schem = new LitematicaSchematic(file, type); + DataFixerMode dataFixer = (DataFixerMode) Configs.Generic.DATAFIXER_MODE.getOptionListValue(); + Configs.Generic.DATAFIXER_MODE.setOptionListValue(DataFixerMode.NEVER); if (schem.readFromSpongeSchematic(fileName, nbt)) { + Configs.Generic.DATAFIXER_MODE.setOptionListValue(dataFixer); return Pair.of(schem.getMetadata().getSchematicSchema(), schem.getMetadata()); } + else + { + Configs.Generic.DATAFIXER_MODE.setOptionListValue(dataFixer); + } } case VANILLA_STRUCTURE -> { LitematicaSchematic schem = new LitematicaSchematic(file, type); + DataFixerMode dataFixer = (DataFixerMode) Configs.Generic.DATAFIXER_MODE.getOptionListValue(); + Configs.Generic.DATAFIXER_MODE.setOptionListValue(DataFixerMode.NEVER); if (schem.readFromVanillaStructure(fileName, nbt)) { + Configs.Generic.DATAFIXER_MODE.setOptionListValue(dataFixer); return Pair.of(schem.getMetadata().getSchematicSchema(), schem.getMetadata()); } + else + { + Configs.Generic.DATAFIXER_MODE.setOptionListValue(dataFixer); + } } } } diff --git a/src/main/java/fi/dy/masa/litematica/schematic/SchematicaSchematic.java b/src/main/java/fi/dy/masa/litematica/schematic/SchematicaSchematic.java index 248ffe3b78..27e0d8afdc 100644 --- a/src/main/java/fi/dy/masa/litematica/schematic/SchematicaSchematic.java +++ b/src/main/java/fi/dy/masa/litematica/schematic/SchematicaSchematic.java @@ -304,16 +304,20 @@ private void addEntitiesToWorld(World world, BlockPos posStart, StructurePlaceme for (NbtCompound tag : this.entities) { Vec3d relativePos = NbtUtils.readEntityPositionFromTag(tag); - Vec3d transformedRelativePos = Vec3d.of(PositionUtils.getTransformedPosition(relativePos.toVanilla(), mirror, rotation)); - Vec3d realPos = transformedRelativePos.add(posStart.getX(), posStart.getY(), posStart.getZ()); - Entity entity = EntityUtils.createEntityAndPassengersFromNBT(tag, world); - if (entity != null) + if (relativePos != null) { - float rotationYaw = entity.applyMirror(mirror); - rotationYaw = rotationYaw + (entity.getYaw() - entity.applyRotation(rotation)); - entity.refreshPositionAndAngles(realPos.x, realPos.y, realPos.z, rotationYaw, entity.getPitch()); - EntityUtils.spawnEntityAndPassengersInWorld(entity, world); + Vec3d transformedRelativePos = Vec3d.of(PositionUtils.getTransformedPosition(relativePos.toVanilla(), mirror, rotation)); + Vec3d realPos = transformedRelativePos.add(posStart.getX(), posStart.getY(), posStart.getZ()); + Entity entity = EntityUtils.createEntityAndPassengersFromNBT(tag, world); + + if (entity != null) + { + float rotationYaw = entity.applyMirror(mirror); + rotationYaw = rotationYaw + (entity.getYaw() - entity.applyRotation(rotation)); + entity.refreshPositionAndAngles(realPos.x, realPos.y, realPos.z, rotationYaw, entity.getPitch()); + EntityUtils.spawnEntityAndPassengersInWorld(entity, world); + } } } }