diff --git a/src/main/java/org/dimdev/dimdoors/DimDoors.java b/src/main/java/org/dimdev/dimdoors/DimDoors.java index aed348a0..d6519a8d 100644 --- a/src/main/java/org/dimdev/dimdoors/DimDoors.java +++ b/src/main/java/org/dimdev/dimdoors/DimDoors.java @@ -69,7 +69,7 @@ public class DimDoors { @Mod.EventHandler public void onInitialization(FMLInitializationEvent event) { proxy.onInitialization(event); - gatewayGenerator = new GatewayGenerator(); + gatewayGenerator = new GatewayGenerator(); //TODO put this in a proxy and structure this modularly instead of writing whole new classes per gateway type... GameRegistry.registerWorldGenerator(gatewayGenerator, 0); } diff --git a/src/main/java/org/dimdev/dimdoors/shared/pockets/PocketTemplate.java b/src/main/java/org/dimdev/dimdoors/shared/pockets/PocketTemplate.java index 4fcb9192..98a97b29 100644 --- a/src/main/java/org/dimdev/dimdoors/shared/pockets/PocketTemplate.java +++ b/src/main/java/org/dimdev/dimdoors/shared/pockets/PocketTemplate.java @@ -57,16 +57,16 @@ public class PocketTemplate { } } - public void replacePlaceholders() { // TODO: it should be possible to place a schematic without replacing placeholders + public static void replacePlaceholders(Schematic parSchematic) { // TODO: it should be possible to place a schematic without replacing placeholders // Replace placeholders (some schematics will contain them) List tileEntities = new ArrayList<>(); - for (NBTTagCompound tileEntityNBT : schematic.tileEntities) { + for (NBTTagCompound tileEntityNBT : parSchematic.tileEntities) { if (tileEntityNBT.hasKey("placeholder")) { int x = tileEntityNBT.getInteger("x"); int y = tileEntityNBT.getInteger("y"); int z = tileEntityNBT.getInteger("z"); - IBlockState state = schematic.palette.get(schematic.blockData[x][y][z]); + IBlockState state = parSchematic.palette.get(parSchematic.blockData[x][y][z]); NBTTagCompound newNBT; switch (tileEntityNBT.getString("placeholder")) { @@ -115,11 +115,11 @@ public class PocketTemplate { tileEntities.add(tileEntityNBT); } } - schematic.tileEntities = tileEntities; + parSchematic.tileEntities = tileEntities; List entities = new ArrayList<>(); - for (NBTTagCompound entitiesNBT : schematic.entities) { + for (NBTTagCompound entitiesNBT : parSchematic.entities) { if (entitiesNBT.hasKey("placeholder")) { double x = entitiesNBT.getDouble("x"); double y = entitiesNBT.getDouble("y"); @@ -143,7 +143,7 @@ public class PocketTemplate { entities.add(entitiesNBT); } } - schematic.entities = entities; + parSchematic.entities = entities; } public void place(Pocket pocket) { diff --git a/src/main/java/org/dimdev/dimdoors/shared/pockets/SchematicHandler.java b/src/main/java/org/dimdev/dimdoors/shared/pockets/SchematicHandler.java index 810c9de7..4f4c6bda 100644 --- a/src/main/java/org/dimdev/dimdoors/shared/pockets/SchematicHandler.java +++ b/src/main/java/org/dimdev/dimdoors/shared/pockets/SchematicHandler.java @@ -82,7 +82,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or try { Schematic schematic = Schematic.loadFromNBT(CompressedStreamTools.readCompressed(new FileInputStream(file))); PocketTemplate template = new PocketTemplate(SAVED_POCKETS_GROUP_NAME, file.getName(), null, null, null, schematic, -1, 0); - template.replacePlaceholders(); + template.replacePlaceholders(schematic); templates.add(template); } catch (IOException e) { DimDoors.log.error("Error reading schematic " + file.getName() + ": " + e); @@ -156,7 +156,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or DimDoors.log.warn("Schematic " + template.getId() + " was bigger than specified in its json file and therefore wasn't loaded"); } template.setSchematic(schematic); - template.replacePlaceholders(); + template.replacePlaceholders(schematic); } return validTemplates; } diff --git a/src/main/java/org/dimdev/dimdoors/shared/world/gateways/BaseSchematicGateway.java b/src/main/java/org/dimdev/dimdoors/shared/world/gateways/BaseSchematicGateway.java index 1e7ad5b0..6b167166 100644 --- a/src/main/java/org/dimdev/dimdoors/shared/world/gateways/BaseSchematicGateway.java +++ b/src/main/java/org/dimdev/dimdoors/shared/world/gateways/BaseSchematicGateway.java @@ -9,6 +9,7 @@ import net.minecraft.world.World; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; +import org.dimdev.dimdoors.shared.pockets.PocketTemplate; public abstract class BaseSchematicGateway extends BaseGateway { private Schematic schematic; @@ -35,6 +36,7 @@ public abstract class BaseSchematicGateway extends BaseGateway { try { schematicNBT = CompressedStreamTools.readCompressed(schematicDataStream); schematic = Schematic.loadFromNBT(schematicNBT); + PocketTemplate.replacePlaceholders(schematic); schematicDataStream.close(); } catch (IOException ex) { DimDoors.log.error("Schematic file for " + id + " could not be read as a valid schematic NBT file.", ex);