diff --git a/src/main/java/StevenDimDoors/experimental/MazeBuilder.java b/src/main/java/StevenDimDoors/experimental/MazeBuilder.java index 3069b4a8..60455d2b 100644 --- a/src/main/java/StevenDimDoors/experimental/MazeBuilder.java +++ b/src/main/java/StevenDimDoors/experimental/MazeBuilder.java @@ -224,7 +224,7 @@ public class MazeBuilder extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky); chunk.getBlockStorageArray()[cY] = extBlockStorage; } - extBlockStorage.setExtBlockID(localX, y & 15, localZ, block); + extBlockStorage.func_150818_a(localX, y & 15, localZ, block); extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata); chunk.setChunkModified(); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java index 460a9c70..684f44a4 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/DungeonSchematic.java @@ -9,6 +9,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Random; import java.util.TreeMap; + +import StevenDimDoors.mod_pocketDim.mod_pocketDim; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; @@ -37,15 +39,6 @@ import StevenDimDoors.mod_pocketDim.util.Point4D; public class DungeonSchematic extends Schematic { - private static final short MAX_VANILLA_BLOCK_ID = 173; - private static final short STANDARD_FABRIC_OF_REALITY_ID = 1973; - private static final short STANDARD_ETERNAL_FABRIC_ID = 220; - private static final short STANDARD_WARP_DOOR_ID = 1975; - private static final short STANDARD_DIMENSIONAL_DOOR_ID = 1970; - private static final short STANDARD_TRANSIENT_DOOR_ID = 1979; - - private static final short MONOLITH_SPAWN_MARKER_ID = (short) Block.endPortalFrame.blockID; - private static final short EXIT_DOOR_MARKER_ID = (short) Block.sandStone.blockID; private static final int NETHER_DIMENSION_ID = -1; private int orientation; @@ -53,18 +46,17 @@ public class DungeonSchematic extends Schematic { private ArrayList exitDoorLocations; private ArrayList dimensionalDoorLocations; private ArrayList monolithSpawnLocations; - - private static final short[] MOD_BLOCK_FILTER_EXCEPTIONS = new short[] { - STANDARD_FABRIC_OF_REALITY_ID, - STANDARD_ETERNAL_FABRIC_ID, - STANDARD_WARP_DOOR_ID, - STANDARD_DIMENSIONAL_DOOR_ID, - STANDARD_TRANSIENT_DOOR_ID - }; - + private ArrayList modBlockFilterExceptions; + private DungeonSchematic(Schematic source) { super(source); + modBlockFilterExceptions = new ArrayList(5); + modBlockFilterExceptions.add(mod_pocketDim.blockDimWall); + modBlockFilterExceptions.add(mod_pocketDim.blockDimWallPerm); + modBlockFilterExceptions.add(mod_pocketDim.warpDoor); + modBlockFilterExceptions.add(mod_pocketDim.dimensionalDoor); + modBlockFilterExceptions.add(mod_pocketDim.transientDoor); } public int getOrientation() @@ -109,8 +101,8 @@ public class DungeonSchematic extends Schematic { public void applyImportFilters(DDProperties properties) { //Search for special blocks (warp doors, dim doors, and end portal frames that mark Monolith spawn points) - SpecialBlockFinder finder = new SpecialBlockFinder(STANDARD_WARP_DOOR_ID, STANDARD_DIMENSIONAL_DOOR_ID, - MONOLITH_SPAWN_MARKER_ID, EXIT_DOOR_MARKER_ID); + SpecialBlockFinder finder = new SpecialBlockFinder(mod_pocketDim.warpDoor, mod_pocketDim.dimensionalDoor, + Blocks.end_portal_frame, Blocks.sandstone); applyFilter(finder); //Flip the entrance's orientation to get the dungeon's orientation @@ -123,19 +115,10 @@ public class DungeonSchematic extends Schematic { //Filter out mod blocks except some of our own CompoundFilter standardizer = new CompoundFilter(); - standardizer.addFilter(new ModBlockFilter(MAX_VANILLA_BLOCK_ID, MOD_BLOCK_FILTER_EXCEPTIONS, - (short) properties.FabricBlockID, (byte) 0)); + standardizer.addFilter(new ModBlockFilter(modBlockFilterExceptions, + mod_pocketDim.blockDimWall, (byte) 0)); //Also convert standard DD block IDs to local versions - Map mapping = getAssignedToStandardIDMapping(properties); - - for (Entry entry : mapping.entrySet()) - { - if (entry.getKey() != entry.getValue()) - { - standardizer.addFilter(new ReplacementFilter(entry.getValue(), entry.getKey())); - } - } applyFilter(standardizer); } @@ -144,36 +127,15 @@ public class DungeonSchematic extends Schematic { //Check if some block IDs assigned by Forge differ from our standard IDs //If so, change the IDs to standard values CompoundFilter standardizer = new CompoundFilter(); - Map mapping = getAssignedToStandardIDMapping(properties); - - for (Entry entry : mapping.entrySet()) - { - if (entry.getKey() != entry.getValue()) - { - standardizer.addFilter(new ReplacementFilter(entry.getKey(), entry.getValue())); - } - } //Filter out mod blocks except some of our own //This comes after ID standardization because the mod block filter relies on standardized IDs - standardizer.addFilter(new ModBlockFilter(MAX_VANILLA_BLOCK_ID, MOD_BLOCK_FILTER_EXCEPTIONS, - STANDARD_FABRIC_OF_REALITY_ID, (byte) 0)); + standardizer.addFilter(new ModBlockFilter(modBlockFilterExceptions, + mod_pocketDim.blockDimWall, (byte) 0)); applyFilter(standardizer); } - - private static Map getAssignedToStandardIDMapping(DDProperties properties) - { - //If we ever need this broadly or support other mods, this should be moved to a separate class - TreeMap mapping = new TreeMap(); - mapping.put((short) properties.FabricBlockID, STANDARD_FABRIC_OF_REALITY_ID); - mapping.put((short) properties.PermaFabricBlockID, STANDARD_ETERNAL_FABRIC_ID); - mapping.put((short) properties.WarpDoorID, STANDARD_WARP_DOOR_ID); - mapping.put((short) properties.DimensionalDoorID, STANDARD_DIMENSIONAL_DOOR_ID); - mapping.put((short) properties.TransientDoorID, STANDARD_TRANSIENT_DOOR_ID); - return mapping; - } - + public static DungeonSchematic copyFromWorld(World world, int x, int y, int z, short width, short height, short length, boolean doCompactBounds) { return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds)); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/ModBlockFilter.java b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/ModBlockFilter.java index 5e3270ec..11af89ff 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/ModBlockFilter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/ModBlockFilter.java @@ -3,33 +3,33 @@ package StevenDimDoors.mod_pocketDim.dungeon; import net.minecraft.block.Block; import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter; +import java.util.List; + public class ModBlockFilter extends SchematicFilter { - private short maxVanillaBlockID; - private short[] exceptions; + private List exceptions; private Block replacementBlock; private byte replacementMetadata; - public ModBlockFilter(short maxVanillaBlockID, short[] exceptions, Block replacementBlock, byte replacementMetadata) + public ModBlockFilter(List exceptions, Block replacementBlock, byte replacementMetadata) { super("ModBlockFilter"); - this.maxVanillaBlockID = maxVanillaBlockID; this.exceptions = exceptions; this.replacementBlock = replacementBlock; this.replacementMetadata = replacementMetadata; } @Override - protected boolean applyToBlock(int index, short[] blocks, byte[] metadata) + protected boolean applyToBlock(int index, Block[] blocks, byte[] metadata) { int k; - short currentID = blocks[index]; - if (currentID > maxVanillaBlockID || (currentID != 0 && Block.blocksList[currentID] == null)) + Block current = blocks[index]; + if (!Block.blockRegistry.getNameForObject(current).startsWith("minecraft:")) { //This might be a mod block. Check if an exception exists. - for (k = 0; k < exceptions.length; k++) + for (k = 0; k < exceptions.size(); k++) { - if (currentID == exceptions[k]) + if (current == exceptions.get(k)) { //Exception found, not considered a mod block return false; diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/SpecialBlockFinder.java b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/SpecialBlockFinder.java index ff8fffba..3c32e057 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/SpecialBlockFinder.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/dungeon/SpecialBlockFinder.java @@ -5,13 +5,14 @@ import java.util.ArrayList; import StevenDimDoors.mod_pocketDim.Point3D; import StevenDimDoors.mod_pocketDim.schematic.Schematic; import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter; +import net.minecraft.block.Block; public class SpecialBlockFinder extends SchematicFilter { - private short warpDoorID; - private short dimensionalDoorID; - private short monolithSpawnMarkerID; - private short exitMarkerID; + private Block warpDoor; + private Block dimensionalDoor; + private Block monolithSpawnMarker; + private Block exitMarker; private int entranceOrientation; private Schematic schematic; private Point3D entranceDoorLocation; @@ -19,13 +20,13 @@ public class SpecialBlockFinder extends SchematicFilter { private ArrayList dimensionalDoorLocations; private ArrayList monolithSpawnLocations; - public SpecialBlockFinder(short warpDoorID, short dimensionalDoorID, short monolithSpawnMarkerID, short exitMarkerID) + public SpecialBlockFinder(Block warpDoor, Block dimensionalDoor, Block monolithSpawn, Block exitDoor) { super("SpecialBlockFinder"); - this.warpDoorID = warpDoorID; - this.dimensionalDoorID = dimensionalDoorID; - this.monolithSpawnMarkerID = monolithSpawnMarkerID; - this.exitMarkerID = exitMarkerID; + this.warpDoor = warpDoor; + this.dimensionalDoor = dimensionalDoor; + this.monolithSpawnMarker = monolithSpawn; + this.exitMarker = exitDoor; this.entranceDoorLocation = null; this.entranceOrientation = 0; this.exitDoorLocations = new ArrayList(); @@ -55,27 +56,27 @@ public class SpecialBlockFinder extends SchematicFilter { } @Override - protected boolean initialize(Schematic schematic, short[] blocks, byte[] metadata) + protected boolean initialize(Schematic schematic, Block[] blocks, byte[] metadata) { this.schematic = schematic; return true; } @Override - protected boolean applyToBlock(int index, short[] blocks, byte[] metadata) + protected boolean applyToBlock(int index, Block[] blocks, byte[] metadata) { int indexBelow; int indexDoubleBelow; - if (blocks[index] == monolithSpawnMarkerID) + if (blocks[index] == monolithSpawnMarker) { monolithSpawnLocations.add(schematic.calculatePoint(index)); return true; } - if (blocks[index] == dimensionalDoorID) + if (blocks[index] == dimensionalDoor) { indexBelow = schematic.calculateIndexBelow(index); - if (indexBelow >= 0 && blocks[indexBelow] == dimensionalDoorID) + if (indexBelow >= 0 && blocks[indexBelow] == dimensionalDoor) { dimensionalDoorLocations.add(schematic.calculatePoint(index)); return true; @@ -85,13 +86,13 @@ public class SpecialBlockFinder extends SchematicFilter { return false; } } - if (blocks[index] == warpDoorID) + if (blocks[index] == warpDoor) { indexBelow = schematic.calculateIndexBelow(index); - if (indexBelow >= 0 && blocks[indexBelow] == warpDoorID) + if (indexBelow >= 0 && blocks[indexBelow] == warpDoor) { indexDoubleBelow = schematic.calculateIndexBelow(indexBelow); - if (indexDoubleBelow >= 0 && blocks[indexDoubleBelow] == exitMarkerID) + if (indexDoubleBelow >= 0 && blocks[indexDoubleBelow] == exitMarker) { exitDoorLocations.add(schematic.calculatePoint(index)); return true; diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/ChunkBlockSetter.java b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/ChunkBlockSetter.java index a7e9268f..a98f35db 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/ChunkBlockSetter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/ChunkBlockSetter.java @@ -39,7 +39,7 @@ public class ChunkBlockSetter implements IBlockSetter extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky); chunk.getBlockStorageArray()[cY] = extBlockStorage; } - extBlockStorage.setExtBlockID(localX, y & 15, localZ, block); + extBlockStorage.func_150818_a(localX, y & 15, localZ, block); extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata); chunk.setChunkModified(); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/CompoundFilter.java b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/CompoundFilter.java index 882faa5e..5bae47ce 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/CompoundFilter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/CompoundFilter.java @@ -1,5 +1,7 @@ package StevenDimDoors.mod_pocketDim.schematic; +import net.minecraft.block.Block; + import java.util.ArrayList; public class CompoundFilter extends SchematicFilter { @@ -18,7 +20,7 @@ public class CompoundFilter extends SchematicFilter { } @Override - protected boolean initialize(Schematic schematic, short[] blocks, byte[] metadata) + protected boolean initialize(Schematic schematic,Block[] blocks, byte[] metadata) { for (SchematicFilter filter : filters) { @@ -44,7 +46,7 @@ public class CompoundFilter extends SchematicFilter { } @Override - protected boolean applyToBlock(int index, short[] blocks, byte[] metadata) + protected boolean applyToBlock(int index, Block[] blocks, byte[] metadata) { for (SchematicFilter filter : filters) { diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java index b3754840..76e815dd 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/Schematic.java @@ -400,7 +400,7 @@ public class Schematic { count = tileEntities.tagCount(); for (index = 0; index < count; index++) { - NBTTagCompound tileTag = (NBTTagCompound) tileEntities.tagAt(index); + NBTTagCompound tileTag = (NBTTagCompound) tileEntities.getCompoundTagAt(index); //Rewrite its location to be in world coordinates dx = tileTag.getInteger("x") + x; dy = tileTag.getInteger("y") + y; @@ -409,7 +409,7 @@ public class Schematic { tileTag.setInteger("y", dy); tileTag.setInteger("z", dz); //Load the tile entity and put it in the world - world.setBlockTileEntity(dx, dy, dz, TileEntity.createAndLoadEntity(tileTag)); + world.setTileEntity(dx, dy, dz, TileEntity.createAndLoadEntity(tileTag)); } } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/SchematicFilter.java b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/SchematicFilter.java index 105a28c7..491cf77c 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/SchematicFilter.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/SchematicFilter.java @@ -1,5 +1,7 @@ package StevenDimDoors.mod_pocketDim.schematic; +import net.minecraft.block.Block; + public class SchematicFilter { private String name; @@ -14,7 +16,7 @@ public class SchematicFilter { return name; } - public boolean apply(Schematic schematic, short[] blocks, byte[] metadata) + public boolean apply(Schematic schematic, Block[] blocks, byte[] metadata) { if (!initialize(schematic, blocks, metadata)) return false; @@ -28,12 +30,12 @@ public class SchematicFilter { return finish(); } - protected boolean initialize(Schematic schematic, short[] blocks, byte[] metadata) + protected boolean initialize(Schematic schematic, Block[] blocks, byte[] metadata) { return true; } - protected boolean applyToBlock(int index, short[] blocks, byte[] metadata) + protected boolean applyToBlock(int index, Block[] blocks, byte[] metadata) { return true; } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/WorldCopyOperation.java b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/WorldCopyOperation.java index 04fab498..0c8220dc 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/schematic/WorldCopyOperation.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/schematic/WorldCopyOperation.java @@ -1,5 +1,6 @@ package StevenDimDoors.mod_pocketDim.schematic; +import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; @@ -11,14 +12,14 @@ public class WorldCopyOperation extends WorldOperation private int originY; private int originZ; private int index; - private short[] blockIDs; + private Block[] blocks; private byte[] metadata; private NBTTagList tileEntities; public WorldCopyOperation() { super("WorldCopyOperation"); - blockIDs = null; + blocks = null; metadata = null; tileEntities = null; } @@ -30,7 +31,7 @@ public class WorldCopyOperation extends WorldOperation originX = x; originY = y; originZ = z; - blockIDs = new short[width * height * length]; + blocks = new Block[width * height * length]; metadata = new byte[width * height * length]; tileEntities = new NBTTagList(); return true; @@ -39,7 +40,7 @@ public class WorldCopyOperation extends WorldOperation @Override protected boolean applyToBlock(World world, int x, int y, int z) { - blockIDs[index] = (short) world.getBlockId(x, y, z); + blocks[index] = world.getBlock(x, y, z); metadata[index] = (byte) world.getBlockMetadata(x, y, z); TileEntity tileEntity = world.getTileEntity(x, y, z); @@ -59,9 +60,9 @@ public class WorldCopyOperation extends WorldOperation return true; } - public short[] getBlockIDs() + public Block[] getBlocks() { - return blockIDs; + return blocks; } public byte[] getMetadata() diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java index d0b4555d..d7f97c9b 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/PocketBuilder.java @@ -547,7 +547,7 @@ public class PocketBuilder extBlockStorage = new ExtendedBlockStorage(cY << 4, !world.provider.hasNoSky); chunk.getBlockStorageArray()[cY] = extBlockStorage; } - extBlockStorage.setExtBlockID(localX, y & 15, localZ, block); + extBlockStorage.func_150818_a(localX, y & 15, localZ, block); extBlockStorage.setExtBlockMetadata(localX, y & 15, localZ, metadata); chunk.setChunkModified(); }