From 8de50d4a6f782a2cc812b881f55177cf93077f6b Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Fri, 21 Jun 2013 07:10:36 -0400 Subject: [PATCH 1/9] Dungeon preview for Jaitsu Committing custom dungeon for testing and love --- .../ComplexHall_HiddenStairs_open_100.schematic | Bin 0 -> 2427 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 schematics/ComplexHall_HiddenStairs_open_100.schematic diff --git a/schematics/ComplexHall_HiddenStairs_open_100.schematic b/schematics/ComplexHall_HiddenStairs_open_100.schematic new file mode 100644 index 0000000000000000000000000000000000000000..8133ec0836637f2d21ceb7d514d0c3d62ee4275d GIT binary patch literal 2427 zcmb7FYgCfi8rE86)8)7(kJ;p)lb*6HYgy(6uj8ns6^=;Mp_HTD6f?>|4Mm!nT8)|# zqEsSMe4-)};{`2Ltjy7LtiFlMp+d`S=0hYB#S5q$S~atpU+0|tXYc3P?`7}(zR%jO zh0AO{4Bd-_Q_jjSmcH~ZE1a!(dsjc2R7x%`{1V~=t=Kf$IrSG%MU*6MmgOqC|2LR{29gV<=sayA;STMyM8;D z!heEoLeIZyyPcx-c+1sME{ATmsp@_!YdH)WVK5Pd8Qk(^B!Rb>c)U5gUzm7MpQ^iR{j zEP{42%-=_Q6Uo2{Q}d-@Pie}gD{`5$M2Q!On=MNV;s15HuQ?7WJ zr2gytU}g1hBJ9r*-8@X=d|hw`H#Xhp7l&XKEI8!;AW$M+O6L02Fs2Z8gOnV=wgMWa zx4F`?qGJ8Qi(&b{`73^m{hd@~)GJ&qCkHFR7u(z|UhRUymQ8ZR~ak zzW(GlY?4Y{Kzxv^_iqn z$9OuJ-QK1+dN>Hw#)gIBYl$+J1LYm~Es`i7_xd8;l6oq5D9a}h3``3Ek&}SN!{Qfc?cy5&BOV{2?%}2dO&)aOyU0ClXb$!#c83t{x&8B-Kdyy zhlBf~>@18VvW(-9;JdsMif*DiPzr#XY^Z)L!VeYzdiak{=Wn~?yE$NlQ4KT_Y+3Fe zzR;h-qS$6S7#4+W22+a~<1!bfr(LNFr?1YRrc;cMX`DgJJFU8>jiwLntbpm` zrfR5^+^p&K=FAE<)uL%_?aY0YIJc1S&}q?M8tuPLnI)rcJb+iu zBQ}?!oi@X~SnweI$8RMZbwA3C(P%8;vI z9y%c1&u15$k|^c`Et$Cf?YjGCPb$Et!&;etS$c3s9Xjsc&Gd@EnXE3iLfRR@9`gTTngEkKi6|85^@Hjgh9 z$dmEoC<1Pl$zx^(;8Aq(Z_XTrE^U03*Ar0HIPesf5RUiTUnZ2+>Eb=p14%hKhh}R3 zA(pgev9d)$Etr$IoGL>n1i2F@D|M{B2_iWBdY@~~F8MV-Z2__>Iqf~uAUce2b(brr z(mR14`0XP=S4eUY53py}rBy$ZNhl1yoUkzvjx*xn`?26E1$OXfz6J{FRDh_SSfd0` zYauD%G=S#xE#i-57>BFiCcIq0m%Wj28AC~<%DxGf#(+7SjI-zbc(Poa6Dqk-ir!cE z7)F^XEgszG#p3&tn(#vr2wdVVDxM1`k;Hk_?F|aKspGzEy4WOk@#V<%X$$$adBxUN z7RZ`MfRHf(%jz8MRn89~F-Ao__S?5FPVg5&bH*K*4h5H+hB}wnh6#C|tCJd39^uyJ zg9Y+{RupXj&5}epF1D^1q+glE+K<5L}d}~vB1WHZ`&oyS^{yFt@jG1FREBm0N$@THh z%4Qy4^R|pY!V9=8k>hjaeUjl8?W4Y&t4oyE1W!6Aj^b4U3qN|^-*S7KBX&!RsP~T; z#4dC_fU_eTeJQa?a*$;GQyVCemB7ac_SgEp>42NJx1^y&PSmcj6;=s2p0hqsOkH7V wamaDJQ5l)V#1p1JGEDscCUeq|^$OM@thTDKv=mK Date: Fri, 21 Jun 2013 15:10:59 -0400 Subject: [PATCH 2/9] Removed dungeon preview Removed dungeon preview --- .../ComplexHall_HiddenStairs_open_100.schematic | Bin 2427 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 schematics/ComplexHall_HiddenStairs_open_100.schematic diff --git a/schematics/ComplexHall_HiddenStairs_open_100.schematic b/schematics/ComplexHall_HiddenStairs_open_100.schematic deleted file mode 100644 index 8133ec0836637f2d21ceb7d514d0c3d62ee4275d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2427 zcmb7FYgCfi8rE86)8)7(kJ;p)lb*6HYgy(6uj8ns6^=;Mp_HTD6f?>|4Mm!nT8)|# zqEsSMe4-)};{`2Ltjy7LtiFlMp+d`S=0hYB#S5q$S~atpU+0|tXYc3P?`7}(zR%jO zh0AO{4Bd-_Q_jjSmcH~ZE1a!(dsjc2R7x%`{1V~=t=Kf$IrSG%MU*6MmgOqC|2LR{29gV<=sayA;STMyM8;D z!heEoLeIZyyPcx-c+1sME{ATmsp@_!YdH)WVK5Pd8Qk(^B!Rb>c)U5gUzm7MpQ^iR{j zEP{42%-=_Q6Uo2{Q}d-@Pie}gD{`5$M2Q!On=MNV;s15HuQ?7WJ zr2gytU}g1hBJ9r*-8@X=d|hw`H#Xhp7l&XKEI8!;AW$M+O6L02Fs2Z8gOnV=wgMWa zx4F`?qGJ8Qi(&b{`73^m{hd@~)GJ&qCkHFR7u(z|UhRUymQ8ZR~ak zzW(GlY?4Y{Kzxv^_iqn z$9OuJ-QK1+dN>Hw#)gIBYl$+J1LYm~Es`i7_xd8;l6oq5D9a}h3``3Ek&}SN!{Qfc?cy5&BOV{2?%}2dO&)aOyU0ClXb$!#c83t{x&8B-Kdyy zhlBf~>@18VvW(-9;JdsMif*DiPzr#XY^Z)L!VeYzdiak{=Wn~?yE$NlQ4KT_Y+3Fe zzR;h-qS$6S7#4+W22+a~<1!bfr(LNFr?1YRrc;cMX`DgJJFU8>jiwLntbpm` zrfR5^+^p&K=FAE<)uL%_?aY0YIJc1S&}q?M8tuPLnI)rcJb+iu zBQ}?!oi@X~SnweI$8RMZbwA3C(P%8;vI z9y%c1&u15$k|^c`Et$Cf?YjGCPb$Et!&;etS$c3s9Xjsc&Gd@EnXE3iLfRR@9`gTTngEkKi6|85^@Hjgh9 z$dmEoC<1Pl$zx^(;8Aq(Z_XTrE^U03*Ar0HIPesf5RUiTUnZ2+>Eb=p14%hKhh}R3 zA(pgev9d)$Etr$IoGL>n1i2F@D|M{B2_iWBdY@~~F8MV-Z2__>Iqf~uAUce2b(brr z(mR14`0XP=S4eUY53py}rBy$ZNhl1yoUkzvjx*xn`?26E1$OXfz6J{FRDh_SSfd0` zYauD%G=S#xE#i-57>BFiCcIq0m%Wj28AC~<%DxGf#(+7SjI-zbc(Poa6Dqk-ir!cE z7)F^XEgszG#p3&tn(#vr2wdVVDxM1`k;Hk_?F|aKspGzEy4WOk@#V<%X$$$adBxUN z7RZ`MfRHf(%jz8MRn89~F-Ao__S?5FPVg5&bH*K*4h5H+hB}wnh6#C|tCJd39^uyJ zg9Y+{RupXj&5}epF1D^1q+glE+K<5L}d}~vB1WHZ`&oyS^{yFt@jG1FREBm0N$@THh z%4Qy4^R|pY!V9=8k>hjaeUjl8?W4Y&t4oyE1W!6Aj^b4U3qN|^-*S7KBX&!RsP~T; z#4dC_fU_eTeJQa?a*$;GQyVCemB7ac_SgEp>42NJx1^y&PSmcj6;=s2p0hqsOkH7V wamaDJQ5l)V#1p1JGEDscCUeq|^$OM@thTDKv=mK Date: Sat, 22 Jun 2013 14:27:59 -0400 Subject: [PATCH 3/9] Fixed Bugs in DungeonHelper 1. Added converting dungeon type names to lowercase before adding them to dungeonTypeMapping (a HashMap that associates dungeon type strings with their lists). Keeping the original casing was causing a NullPointerException when the HashMap returned null and we expected to receive a non-null list. 2. Added code to strip out the file extension of a schematic in validateSchematicName(). The extension was getting dragged along with the dungeon's weight, which would cause parsing to fail and the name was considered invalid. This means that none of the custom dungeons were being registered for generation since the system saw them as badly tagged. They also wouldn't generate Monoliths even if tagged as closed because we would ignore the tags. 3. Changed a comparison for the "open" tag to be case insensitive. 4. Minor changes --- .../mod_pocketDim/helpers/DungeonHelper.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index f833e11..f471e5e 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -91,14 +91,15 @@ public class DungeonHelper } //Add all the basic dungeon types to dungeonTypeMapping + //Dungeon type names must be passed in lowercase to make matching easier. dungeonTypeMapping = new HashMap>(); - dungeonTypeMapping.put(SIMPLE_HALL_DUNGEON_TYPE, simpleHalls); - dungeonTypeMapping.put(COMPLEX_HALL_DUNGEON_TYPE, complexHalls); - dungeonTypeMapping.put(HUB_DUNGEON_TYPE, hubs); - dungeonTypeMapping.put(EXIT_DUNGEON_TYPE, exits); - dungeonTypeMapping.put(DEAD_END_DUNGEON_TYPE, deadEnds); - dungeonTypeMapping.put(MAZE_DUNGEON_TYPE, mazes); - dungeonTypeMapping.put(TRAP_DUNGEON_TYPE, pistonTraps); + dungeonTypeMapping.put(SIMPLE_HALL_DUNGEON_TYPE.toLowerCase(), simpleHalls); + dungeonTypeMapping.put(COMPLEX_HALL_DUNGEON_TYPE.toLowerCase(), complexHalls); + dungeonTypeMapping.put(HUB_DUNGEON_TYPE.toLowerCase(), hubs); + dungeonTypeMapping.put(EXIT_DUNGEON_TYPE.toLowerCase(), exits); + dungeonTypeMapping.put(DEAD_END_DUNGEON_TYPE.toLowerCase(), deadEnds); + dungeonTypeMapping.put(MAZE_DUNGEON_TYPE.toLowerCase(), mazes); + dungeonTypeMapping.put(TRAP_DUNGEON_TYPE.toLowerCase(), pistonTraps); //Load our reference to the DDProperties singleton if (properties == null) @@ -162,13 +163,17 @@ public class DungeonHelper public boolean isCustomDungeon(int dimensionID) { - //TODO: Should we simply treat all pocket dimensions as valid custom dungeons? ~SenseiKiwi return customDungeonStatus.containsKey(dimensionID); } public boolean validateSchematicName(String name) { - String[] dungeonData = name.split("_"); + String[] dungeonData; + + if (!name.endsWith(SCHEMATIC_FILE_EXTENSION)) + return false; + + dungeonData = name.substring(0, name.length() - SCHEMATIC_FILE_EXTENSION.length()).split("_"); //Check for a valid number of parts if (dungeonData.length < 3 || dungeonData.length > 4) @@ -210,17 +215,17 @@ public class DungeonHelper String path = schematicFile.getAbsolutePath(); try { - if (name.endsWith(SCHEMATIC_FILE_EXTENSION) && validateSchematicName(name)) + if (validateSchematicName(name)) { //Strip off the file extension while splitting the file name String[] dungeonData = name.substring(0, name.length() - SCHEMATIC_FILE_EXTENSION.length()).split("_"); String dungeonType = dungeonData[0].toLowerCase(); - boolean open = dungeonData[2].equals("open"); + boolean isOpen = dungeonData[2].equalsIgnoreCase("open"); int weight = (dungeonData.length == 4) ? Integer.parseInt(dungeonData[3]) : DEFAULT_DUNGEON_WEIGHT; //Add this custom dungeon to the list corresponding to its type - DungeonGenerator generator = new DungeonGenerator(weight, path, open); + DungeonGenerator generator = new DungeonGenerator(weight, path, isOpen); dungeonTypeMapping.get(dungeonType).add(generator); registeredDungeons.add(generator); -- 2.39.5 From 82b8c93c8b5068d1f860c6436bd5249940aadd3b Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sat, 22 Jun 2013 19:14:17 -0400 Subject: [PATCH 4/9] Minor Change to DungeonHelper Minor change to DungeonHelper. Added the dash character to the characters allowed in schematic names. --- StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index f471e5e..a996a3b 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -31,7 +31,7 @@ public class DungeonHelper { private static DungeonHelper instance = null; private static DDProperties properties = null; - public static final Pattern NamePattern = Pattern.compile("[A-Za-z0-9_]+"); + public static final Pattern NamePattern = Pattern.compile("[A-Za-z0-9_\\-]+"); private static final String SCHEMATIC_FILE_EXTENSION = ".schematic"; private static final int DEFAULT_DUNGEON_WEIGHT = 100; -- 2.39.5 From 0a6f6c96159deee0e36f7f7ab750732dd17ba984 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 23 Jun 2013 02:49:25 -0400 Subject: [PATCH 5/9] Cleaned up PocketGenerator Cleaned up some of the code in PocketGenerator. Seeded the generation of Monoliths as a function of the world seed. All of our randomized selections should be functions of the world seed so people can exchange seeds with cool DD features. I will rename the file to have proper capitalization in the next commit. Then I have to fix Monolith spawning. Also, don't use recursion as a way to loop functions if you could simply have a loop. I'm referring to the way PocketGenerator.populate() calls itself. Completely unnecessary. --- .../mod_pocketDim/world/pocketGenerator.java | 160 +++++++----------- 1 file changed, 65 insertions(+), 95 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/world/pocketGenerator.java b/StevenDimDoors/mod_pocketDim/world/pocketGenerator.java index ced0c7f..1951ea1 100644 --- a/StevenDimDoors/mod_pocketDim/world/pocketGenerator.java +++ b/StevenDimDoors/mod_pocketDim/world/pocketGenerator.java @@ -1,15 +1,8 @@ package StevenDimDoors.mod_pocketDim.world; -import java.util.ArrayList; import java.util.List; import java.util.Random; -import StevenDimDoors.mod_pocketDim.DimData; -import StevenDimDoors.mod_pocketDim.mod_pocketDim; -import StevenDimDoors.mod_pocketDim.helpers.dimHelper; -import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper; -import StevenDimDoors.mod_pocketDim.ticking.MobObelisk; - import net.minecraft.entity.Entity; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.ChunkPosition; @@ -17,150 +10,127 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderGenerate; +import StevenDimDoors.mod_pocketDim.DimData; +import StevenDimDoors.mod_pocketDim.mod_pocketDim; +import StevenDimDoors.mod_pocketDim.helpers.dimHelper; +import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper; +import StevenDimDoors.mod_pocketDim.ticking.MobObelisk; public class pocketGenerator extends ChunkProviderGenerate implements IChunkProvider { - private World worldObj; - private Random rand = new Random(); + private World worldObj; public pocketGenerator(World par1World, long par2, boolean par4) { - super(par1World, par2, par4); - // TODO Auto-generated constructor stub - this.worldObj=par1World; + this.worldObj = par1World; } + @Override public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte) - { - - } - - public boolean unloadQueuedChunks() - { - return true; - } - - + { + + } + + public boolean unloadQueuedChunks() + { + return true; + } @Override - public Chunk provideChunk(int par1, int par2) - { - - byte[] var3 = new byte[32768]; - - Chunk var4 = new Chunk(this.worldObj, var3, par1, par2); - - return var4; - } + public Chunk provideChunk(int chunkX, int chunkZ) + { + byte[] var3 = new byte[32768]; + Chunk chunk = new Chunk(worldObj, var3, chunkX, chunkZ); + + return chunk; + } @Override public Chunk loadChunk(int var1, int var2) { - // TODO Auto-generated method stub return super.loadChunk(var1, var2); } @Override - public void populate(IChunkProvider var1, int var2, int var3) + public void populate(IChunkProvider chunkProvider, int chunkX, int chunkZ) { - if(dimHelper.dimList.containsKey(worldObj.provider.dimensionId)) - { - if(dimHelper.dimList.get(worldObj.provider.dimensionId).dungeonGenerator==null) - { - return; - } - else - { - if(dimHelper.dimList.get(worldObj.provider.dimensionId).dungeonGenerator.isOpen) - { - return; - } - } - } - int y =0; - int x = var2*16 + rand.nextInt(16); - int z = var3*16 + rand.nextInt(16); - int yTest; + //Check whether we want to populate this chunk with Monoliths. + DimData dimData = dimHelper.dimList.get(worldObj.provider.dimensionId); + + if (dimData == null || + dimData.dungeonGenerator == null || + dimData.dungeonGenerator.isOpen) + { + return; + } + + //The following initialization code is based on code from ChunkProviderGenerate. + //It makes our generation depend on the world seed. + Random random = new Random(worldObj.getSeed()); + long factorA = random.nextLong() / 2L * 2L + 1L; + long factorB = random.nextLong() / 2L * 2L + 1L; + random.setSeed((long)chunkX * factorA + (long)chunkZ * factorB ^ worldObj.getSeed()); + + int y = 0; + int x = chunkX * 16 + random.nextInt(16); + int z = chunkZ * 16 + random.nextInt(16); do { - - x = var2*16 + rand.nextInt(32)-8; - z = var3*16 + rand.nextInt(32)-8; - - while(this.worldObj.getBlockId(x, y, z)==0&&y<255) + x = chunkX * 16 + random.nextInt(32) - 8; + z = chunkZ * 16 + random.nextInt(32) - 8; + while (worldObj.getBlockId(x, y, z) == 0 && y < 255) { y++; } - y = yCoordHelper.getFirstUncovered(this.worldObj,x , y+2, z); - - if(this.worldObj.getBlockId(x, y-1, z)!=mod_pocketDim.blockDimWall.blockID) + y = yCoordHelper.getFirstUncovered(worldObj,x , y+2, z); + + if (worldObj.getBlockId(x, y-1, z) != mod_pocketDim.blockDimWall.blockID) { - y= y+rand.nextInt(4)+2; + y = y + random.nextInt(4)+2; } - - if(y>245) + if (y > 245) { return; } - - Entity mob = new MobObelisk(this.worldObj); + Entity mob = new MobObelisk(worldObj); mob.setLocationAndAngles(x, y, z, 1, 1); - this.worldObj.spawnEntityInWorld(mob); - + worldObj.spawnEntityInWorld(mob); } - while( yCoordHelper.getFirstUncovered(this.worldObj,x , y, z)>y); - - if(rand.nextBoolean()) + while (yCoordHelper.getFirstUncovered(worldObj,x , y, z) > y); + + if (random.nextBoolean()) { - this.populate(var1, var2, var3); + populate(chunkProvider, chunkX, chunkZ); } - - - - - // TODO Auto-generated method stub - } - - - - - - - @Override - public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, - int var4) + public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4) { DimData data = dimHelper.dimList.get(this.worldObj.provider.dimensionId); - if(data!=null) + if (data != null) { - if(data.dungeonGenerator!=null) + if (data.dungeonGenerator != null) { - if(data.isDimRandomRift&&data.isPocket&&!data.dungeonGenerator.isOpen) + if (data.isDimRandomRift && data.isPocket && !data.dungeonGenerator.isOpen) { - ArrayList list = new ArrayList(); - return this.worldObj.getBiomeGenForCoords(var2, var3).getSpawnableList(var1); } } } - // TODO Auto-generated method stub return null; } @Override - public ChunkPosition findClosestStructure(World var1, String var2, - int var3, int var4, int var5) { - // TODO Auto-generated method stub + public ChunkPosition findClosestStructure(World var1, String var2, int var3, int var4, int var5) + { return null; } - + } \ No newline at end of file -- 2.39.5 From c6e6ff6db288a11eae6bb3a0367e99f8b6d6a8ed Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 23 Jun 2013 02:53:10 -0400 Subject: [PATCH 6/9] Minor Change Just need to make an intermediate commit for renaming PocketGenerator. Technical issues... --- .../world/{pocketGenerator.java => PocketGeneratorX.java} | 4 ++-- StevenDimDoors/mod_pocketDim/world/pocketProvider.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename StevenDimDoors/mod_pocketDim/world/{pocketGenerator.java => PocketGeneratorX.java} (96%) diff --git a/StevenDimDoors/mod_pocketDim/world/pocketGenerator.java b/StevenDimDoors/mod_pocketDim/world/PocketGeneratorX.java similarity index 96% rename from StevenDimDoors/mod_pocketDim/world/pocketGenerator.java rename to StevenDimDoors/mod_pocketDim/world/PocketGeneratorX.java index 1951ea1..01e62b1 100644 --- a/StevenDimDoors/mod_pocketDim/world/pocketGenerator.java +++ b/StevenDimDoors/mod_pocketDim/world/PocketGeneratorX.java @@ -16,11 +16,11 @@ import StevenDimDoors.mod_pocketDim.helpers.dimHelper; import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper; import StevenDimDoors.mod_pocketDim.ticking.MobObelisk; -public class pocketGenerator extends ChunkProviderGenerate implements IChunkProvider +public class PocketGenerator extends ChunkProviderGenerate implements IChunkProvider { private World worldObj; - public pocketGenerator(World par1World, long par2, boolean par4) + public PocketGenerator(World par1World, long par2, boolean par4) { super(par1World, par2, par4); this.worldObj = par1World; diff --git a/StevenDimDoors/mod_pocketDim/world/pocketProvider.java b/StevenDimDoors/mod_pocketDim/world/pocketProvider.java index b72c720..9f61609 100644 --- a/StevenDimDoors/mod_pocketDim/world/pocketProvider.java +++ b/StevenDimDoors/mod_pocketDim/world/pocketProvider.java @@ -79,7 +79,7 @@ public class pocketProvider extends WorldProvider @Override public IChunkProvider createChunkGenerator() { - return new pocketGenerator(worldObj, dimensionId, false); + return new PocketGenerator(worldObj, dimensionId, false); } @Override -- 2.39.5 From ffcb3aa74a9b3aa116c5bc355f438cb26ffb9d07 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 23 Jun 2013 02:54:28 -0400 Subject: [PATCH 7/9] Minor Change Completed renaming pocketGenerator as PocketGenerator. --- .../world/{PocketGeneratorX.java => PocketGenerator.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename StevenDimDoors/mod_pocketDim/world/{PocketGeneratorX.java => PocketGenerator.java} (100%) diff --git a/StevenDimDoors/mod_pocketDim/world/PocketGeneratorX.java b/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java similarity index 100% rename from StevenDimDoors/mod_pocketDim/world/PocketGeneratorX.java rename to StevenDimDoors/mod_pocketDim/world/PocketGenerator.java -- 2.39.5 From 1ca11f4df3f001871b901cc0290d48ef65a2fcf8 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 23 Jun 2013 03:03:40 -0400 Subject: [PATCH 8/9] Removed Recursion from PocketGenerator Rewrote PocketGenerator.populate() to remove the recursive call to itself. --- .../mod_pocketDim/world/PocketGenerator.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java b/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java index 01e62b1..1e61c0c 100644 --- a/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java +++ b/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java @@ -73,18 +73,18 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv long factorB = random.nextLong() / 2L * 2L + 1L; random.setSeed((long)chunkX * factorA + (long)chunkZ * factorB ^ worldObj.getSeed()); - int y = 0; - int x = chunkX * 16 + random.nextInt(16); - int z = chunkZ * 16 + random.nextInt(16); + int x, y, z; do { x = chunkX * 16 + random.nextInt(32) - 8; z = chunkZ * 16 + random.nextInt(32) - 8; + y = 0; + while (worldObj.getBlockId(x, y, z) == 0 && y < 255) { y++; } - y = yCoordHelper.getFirstUncovered(worldObj,x , y+2, z); + y = yCoordHelper.getFirstUncovered(worldObj,x , y + 2, z); if (worldObj.getBlockId(x, y-1, z) != mod_pocketDim.blockDimWall.blockID) { @@ -98,12 +98,7 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv mob.setLocationAndAngles(x, y, z, 1, 1); worldObj.spawnEntityInWorld(mob); } - while (yCoordHelper.getFirstUncovered(worldObj,x , y, z) > y); - - if (random.nextBoolean()) - { - populate(chunkProvider, chunkX, chunkZ); - } + while (yCoordHelper.getFirstUncovered(worldObj, x , y, z) > y || random.nextBoolean()); } @Override @@ -128,9 +123,4 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv { return null; } - - - - - } \ No newline at end of file -- 2.39.5 From 7a90dcb28be4808c4b02219ca660dee84b85e296 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sun, 23 Jun 2013 16:17:04 -0400 Subject: [PATCH 9/9] Improved PocketGenerator Improved code in PocketGenerator. Restricted Monolith generation to the chunk in which populate() is being applied. We should not be generating Monoliths outside that chunk. Changed condition that would exit the function if the next available space for a Monolith was above Y = 245. Exiting the function at that point made no sense. I've realized that this placement algorithm has probably been patched up several times and that's resulted in nonsensical code. For instance, the loop continues as long as you continue finding higher points to place Monoliths. That would suggest you intended to make columns of them. But since the loop chooses random columns on each iteration goes back to Y = 0, you're really just jumping around and placing Monoliths in random places, while using irrelevant checks to decide whether to continue. I really recommend coming up with a different algorithm. I haven't replaced it completely in case it would break something. --- .../mod_pocketDim/world/PocketGenerator.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java b/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java index 1e61c0c..e33d68b 100644 --- a/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java +++ b/StevenDimDoors/mod_pocketDim/world/PocketGenerator.java @@ -20,6 +20,9 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv { private World worldObj; + private static final int MAX_MONOLITH_SPAWN_Y = 245; + private static final int CHUNK_SIZE = 16; + public PocketGenerator(World par1World, long par2, boolean par4) { super(par1World, par2, par4); @@ -72,12 +75,13 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv long factorA = random.nextLong() / 2L * 2L + 1L; long factorB = random.nextLong() / 2L * 2L + 1L; random.setSeed((long)chunkX * factorA + (long)chunkZ * factorB ^ worldObj.getSeed()); - + int x, y, z; do { - x = chunkX * 16 + random.nextInt(32) - 8; - z = chunkZ * 16 + random.nextInt(32) - 8; + //Select a random column within the chunk + x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE); + z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE); y = 0; while (worldObj.getBlockId(x, y, z) == 0 && y < 255) @@ -86,17 +90,16 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv } y = yCoordHelper.getFirstUncovered(worldObj,x , y + 2, z); - if (worldObj.getBlockId(x, y-1, z) != mod_pocketDim.blockDimWall.blockID) + if (worldObj.getBlockId(x, y - 1, z) != mod_pocketDim.blockDimWall.blockID) { - y = y + random.nextInt(4)+2; + y += random.nextInt(4) + 2; } - if (y > 245) + if (y <= MAX_MONOLITH_SPAWN_Y) { - return; + Entity mob = new MobObelisk(worldObj); + mob.setLocationAndAngles(x, y, z, 1, 1); + worldObj.spawnEntityInWorld(mob); } - Entity mob = new MobObelisk(worldObj); - mob.setLocationAndAngles(x, y, z, 1, 1); - worldObj.spawnEntityInWorld(mob); } while (yCoordHelper.getFirstUncovered(worldObj, x , y, z) > y || random.nextBoolean()); } -- 2.39.5