From 3eb8c7a8fca3f22475d53e30f0b90a6737f313fa Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 24 May 2018 15:53:20 -0400 Subject: Initial commit --- .../java/fyresmodjam/worldgen/FyresWorldData.java | 555 +++++++++++++++++++++ .../main/java/fyresmodjam/worldgen/PillarGen.java | 99 ++++ .../fyresmodjam/worldgen/WorldGenMoreDungeons.java | 25 + .../worldgen/WorldGenTrapsTowersAndMore.java | 478 ++++++++++++++++++ 4 files changed, 1157 insertions(+) create mode 100755 YWD/src/main/java/fyresmodjam/worldgen/FyresWorldData.java create mode 100755 YWD/src/main/java/fyresmodjam/worldgen/PillarGen.java create mode 100755 YWD/src/main/java/fyresmodjam/worldgen/WorldGenMoreDungeons.java create mode 100755 YWD/src/main/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java (limited to 'YWD/src/main/java/fyresmodjam/worldgen') diff --git a/YWD/src/main/java/fyresmodjam/worldgen/FyresWorldData.java b/YWD/src/main/java/fyresmodjam/worldgen/FyresWorldData.java new file mode 100755 index 0000000..07cbd84 --- /dev/null +++ b/YWD/src/main/java/fyresmodjam/worldgen/FyresWorldData.java @@ -0,0 +1,555 @@ +package fyresmodjam.worldgen; + +import java.awt.Color; +import java.util.HashMap; + +import cpw.mods.fml.common.FMLCommonHandler; +import fyresmodjam.ModjamMod; +import fyresmodjam.misc.ConfigData; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; +import net.minecraft.world.storage.MapStorage; + +public class FyresWorldData extends WorldSavedData { + + /* + * @formatter:off + */ + public static String[] validDisadvantages = { + "Tougher Mobs", + "Weak", + "Explosive Traps", + "Increased Mob Spawn", + //"Neverending Rain", + //"Neverending Night", + "Permadeath", + "Trigger-happy", + "Diabolic", + "Organized Foes" + }; + + public static String[] disadvantageDescriptions = { + "Hostile enemies takes 25% less damage", + "-25% melee damage", + "Traps also trigger explosions when set off", + "+33% hostile mob spawn rate", + //"Constantly rains", + //"Constant night", + "Items dropped upon death are permanently lost", + "Mobs have a chance to explode on death", + "All mobs have a chance to recieve a random blessing", + "Mobs spawn with armor and weapons, increasing with level" + }; + + public static String[] validTasks = { + "Kill", + "Burn" + }; + + /* + * @formatter:on + */ + + public static String key = "FyresWorldData"; + + public int[] potionValues = null; + public int[] potionDurations = null; + + public int[][] mushroomColors = null; + + public String currentDisadvantage = null; + + public String currentTask = null; + public int currentTaskID = -1; + public int currentTaskAmount = 0; + public int progress = 0; + public int tasksCompleted = 0; + public int rewardLevels = -1; + + public boolean enderDragonKilled = false; + + // TODO pull these into a class instead of using parallel arrays + @SuppressWarnings("rawtypes") + public static Class[] validMobs = { + EntityDragon.class, EntityGhast.class, + EntityWither.class + }; + public static String[] validMobNames = { + "Ender Dragon", "Ghast", "Wither" + }; + public static int[][] mobNumbers = { + new int[] { + 1, 1 + }, new int[] { + 5, 15 + }, new int[] { + 1, 1 + } + }; + + public HashMap blessingByPlayer = new HashMap(); + public HashMap potionKnowledgeByPlayer = new HashMap(); + + public HashMap killStatsByPlayer = new HashMap(); + public HashMap weaponStatsByPlayer = new HashMap(); + public HashMap craftingStatsByPlayer = new HashMap(); + + public static ItemStack[] validItems = { + new ItemStack(Blocks.diamond_block), + new ItemStack(Blocks.gold_block), + new ItemStack(Blocks.emerald_block), + new ItemStack(Blocks.lapis_block), + new ItemStack(Items.diamond), + new ItemStack(Items.emerald), + new ItemStack(Items.gold_ingot), + new ItemStack(Items.nether_star), + new ItemStack(Items.ghast_tear) + }; + + public FyresWorldData() { + super(key); + } + + public FyresWorldData(String key) { + super(key); + } + + public static FyresWorldData forWorld(World world) { + + MapStorage storage = world.perWorldStorage; + FyresWorldData result = (FyresWorldData) storage + .loadData(FyresWorldData.class, key); + + if (result == null) { + result = new FyresWorldData(); + + storage.setData(key, result); + + result.checkWorldData(); + } + + return result; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + if (nbttagcompound.hasKey("values")) { + potionValues = nbttagcompound + .getIntArray("values"); + } + if (nbttagcompound.hasKey("durations")) { + potionDurations = nbttagcompound + .getIntArray("durations"); + } + if (nbttagcompound.hasKey("currentDisadvantage")) { + currentDisadvantage = nbttagcompound + .getString("currentDisadvantage"); + } + + if (nbttagcompound.hasKey("currentTask")) { + currentTask = nbttagcompound + .getString("currentTask"); + } + if (nbttagcompound.hasKey("currentTaskID")) { + currentTaskID = nbttagcompound + .getInteger("currentTaskID"); + } + if (nbttagcompound.hasKey("currentTaskAmount")) { + currentTaskAmount = nbttagcompound + .getInteger("currentTaskAmount"); + } + if (nbttagcompound.hasKey("progress")) { + progress = nbttagcompound.getInteger("progress"); + } + if (nbttagcompound.hasKey("tasksCompleted")) { + tasksCompleted = nbttagcompound + .getInteger("tasksCompleted"); + } + + if (nbttagcompound.hasKey("enderDragonKilled")) { + enderDragonKilled = nbttagcompound + .getBoolean("enderDragonKilled"); + } + + if (nbttagcompound.hasKey("rewardLevels")) { + rewardLevels = nbttagcompound + .getInteger("rewardLevels"); + } + + mushroomColors = new int[13][]; + for (int i = 0; i < 13; i++) { + if (nbttagcompound.hasKey( + "mushroomColors_" + (i + 1))) { + mushroomColors[i] = nbttagcompound + .getIntArray("mushroomColors_" + + (i + 1)); + } + } + + if (nbttagcompound.hasKey("TempPlayerStats")) { + NBTTagCompound tempStats = nbttagcompound + .getCompoundTag("TempPlayerStats"); + + for (Object o : tempStats.func_150296_c()) { + if (o == null || !(o instanceof NBTTagCompound)) { + continue; + } + NBTTagCompound player = (NBTTagCompound) o; + + blessingByPlayer.put( + player.getString("Name"), + player.getString( + "Blessing")); + potionKnowledgeByPlayer.put( + player.getString("Name"), + player.getIntArray( + "PotionKnowledge")); + + if (player.hasKey("KillStats")) { + killStatsByPlayer.put(player + .getString("Name"), + player.getCompoundTag( + "KillStats")); + } + if (player.hasKey("WeaponStats")) { + weaponStatsByPlayer.put(player + .getString("Name"), + player.getCompoundTag( + "WeaponStats")); + } + if (player.hasKey("CraftingStats")) { + craftingStatsByPlayer.put(player + .getString("Name"), + player.getCompoundTag( + "CraftingStats")); + } + } + } + + checkWorldData(); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + checkWorldData(); + + nbttagcompound.setIntArray("values", potionValues); + nbttagcompound.setIntArray("durations", potionDurations); + nbttagcompound.setString("currentDisadvantage", + currentDisadvantage); + + nbttagcompound.setString("currentTask", currentTask); + nbttagcompound.setInteger("currentTaskID", currentTaskID); + nbttagcompound.setInteger("currentTaskAmount", + currentTaskAmount); + nbttagcompound.setInteger("progress", progress); + nbttagcompound.setInteger("tasksCompleted", + tasksCompleted); + + nbttagcompound.setBoolean("enderDragonKilled", + enderDragonKilled); + + nbttagcompound.setInteger("rewardLevels", rewardLevels); + + for (int i = 0; i < 13; i++) { + nbttagcompound.setIntArray( + "mushroomColors_" + (i + 1), + mushroomColors[i]); + } + + fillBlessingsByPlayer(nbttagcompound); + } + + private void fillBlessingsByPlayer(NBTTagCompound nbttagcompound) { + if (!blessingByPlayer.isEmpty()) { + NBTTagCompound tempPlayerStats = new NBTTagCompound(); + + for (String s : blessingByPlayer.keySet()) { + if (s == null) { + continue; + } + + NBTTagCompound player = new NBTTagCompound(); + + player.setString("Name", s); + player.setString("Blessing", + blessingByPlayer.get(s)); + player.setIntArray("PotionKnowledge", + potionKnowledgeByPlayer + .get(s)); + + if (killStatsByPlayer.containsKey(s)) { + player.setTag("KillStats", + killStatsByPlayer + .get(s)); + } + if (weaponStatsByPlayer.containsKey(s)) { + player.setTag("WeaponStats", + weaponStatsByPlayer + .get(s)); + } + if (craftingStatsByPlayer.containsKey(s)) { + player.setTag("CraftingStats", + craftingStatsByPlayer + .get(s)); + } + + tempPlayerStats.setTag(s, player); + } + + nbttagcompound.setTag("TempPlayerStats", + tempPlayerStats); + } + } + + private void checkWorldData() { + checkPotionValues(); + + if (mushroomColors == null) { + mushroomColors = new int[13][2]; + + for (int i = 0; i < 13; i++) { + mushroomColors[i][0] = randomRGBColor(); + mushroomColors[i][1] = randomRGBColor(); + } + } + + checkDisadvantage(); + + checkTasks(); + + if (rewardLevels == -1) { + rewardLevels = getRewardLevels(); + } + } + + private void checkTasks() { + if (currentTask == null) { + giveNewTask(); + } else { + boolean changeTask = true; + + // Change invalid tasks + for (String s : validTasks) { + if (s.equals(currentTask)) { + changeTask = false; + break; + } + } + + boolean alreadyKilledDragon = currentTask != null + && currentTask.equals("Kill") + && currentTaskID == 0 + && enderDragonKilled; + + if (changeTask || alreadyKilledDragon) { + giveNewTask(); + } else { + if (currentTask.equals("Kill")) { + // Make sure mob type is valid + currentTaskID %= validMobs.length; + } + } + } + } + + private void checkDisadvantage() { + boolean changeDisadvantage = true; + + if (currentDisadvantage != null) { + boolean valid = validateDisadvantage(); + + changeDisadvantage = !valid && !currentDisadvantage + .equals("None"); + } + + if (changeDisadvantage) { + currentDisadvantage = chooseDisadvantage(); + + MinecraftServer server = FMLCommonHandler + .instance() + .getMinecraftServerInstance(); + + boolean permadeathOnHardcore = server.isHardcore() + && currentDisadvantage.equals( + "Permadeath"); + + while (server != null && permadeathOnHardcore) { + currentDisadvantage = chooseDisadvantage(); + } + } + } + + private void checkPotionValues() { + if (potionValues == null) { + potionValues = new int[] { + -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1 + }; + + for (int i = 0; i < 13 - 1; i++) { + int randPotionID = getRandomPotionID(); + + boolean stop = false; + while (potionIDIsValid(randPotionID) + || !stop) { + stop = true; + randPotionID = getRandomPotionID(); + + for (int i3 = 0; i3 < 13 - 1; i3++) { + if (potionValues[i3] == randPotionID) { + stop = false; + break; + } + } + } + + potionValues[i] = randPotionID; + } + } else { + for (int i = 0; i < 13 - 1; i++) { + if (Potion.potionTypes[potionValues[i]] == null) { + int randPotionID = getRandomPotionID(); + + while (potionIDIsValid( + randPotionID)) { + randPotionID = getRandomPotionID(); + } + + potionValues[i] = randPotionID; + } + } + } + + if (potionDurations == null) { + potionDurations = new int[13 - 1]; + } + for (int i = 0; i < 13 - 1; i++) { + if (potionDurations[i] != 0) { + continue; + } + + potionDurations[i] = getPotionDurations(); + } + } + + private int getPotionDurations() { + return 5 + ModjamMod.r.nextInt(26); + } + + private boolean potionIDIsValid(int randPotionID) { + return Potion.potionTypes[randPotionID] == null; + } + + private int getRandomPotionID() { + return ModjamMod.r.nextInt(Potion.potionTypes.length); + } + + private int randomRGBColor() { + return Color.HSBtoRGB(ModjamMod.r.nextFloat(), + ModjamMod.r.nextFloat(), + ModjamMod.r.nextFloat()); + } + + private boolean validateDisadvantage() { + boolean valid = false; + + for (String s : validDisadvantages) { + if (s.equals(currentDisadvantage)) { + valid = true; + break; + } + } + return valid; + } + + private String chooseDisadvantage() { + return validDisadvantages[ModjamMod.r + .nextInt(validDisadvantages.length)]; + } + + public void giveNewTask() { + progress = 0; + + currentTask = getTaskType(); + + if (currentTask.equals("Kill")) { + currentTaskID = getTaskMob(enderDragonKilled); + + int baseMobNumber = mobNumbers[currentTaskID][0]; + + currentTaskAmount = baseMobNumber + + getMobNumberAdjuster(); + } else if (currentTask.equals("Burn")) { + currentTaskID = getTaskItem(); + + setTaskItemCount(); + } + + rewardLevels = getRewardLevels(); + + markDirty(); + } + + private int getRewardLevels() { + return 5 + ModjamMod.r.nextInt(6); + } + + private int setTaskItemCount() { + boolean isNetherStar = validItems[currentTaskID] + .getItem() == Items.nether_star; + + boolean isBlock = validItems[currentTaskID] + .getItem() instanceof ItemBlock; + + int taskAmount; + + if (isNetherStar) { + taskAmount = 1; + } else { + taskAmount = 5 + ModjamMod.r.nextInt(28); + } + + if (isBlock) { + return taskAmount / 4; + } else { + return taskAmount; + } + } + + private int getTaskItem() { + return ModjamMod.r.nextInt(validItems.length); + } + + private int getMobNumberAdjuster() { + return ModjamMod.r.nextInt(mobNumbers[currentTaskID][1]); + } + + private String getTaskType() { + return validTasks[ModjamMod.r.nextInt(validTasks.length)]; + } + + private int getTaskMob(boolean dragonKilled) { + if (!dragonKilled) { + return ModjamMod.r.nextInt(validMobs.length); + } else { + return 1 + ModjamMod.r + .nextInt(validMobs.length - 1); + } + } + + public String getDisadvantage() { + return ConfigData.disableDisadvantages ? "None" + : currentDisadvantage; + } +} diff --git a/YWD/src/main/java/fyresmodjam/worldgen/PillarGen.java b/YWD/src/main/java/fyresmodjam/worldgen/PillarGen.java new file mode 100755 index 0000000..d76af7c --- /dev/null +++ b/YWD/src/main/java/fyresmodjam/worldgen/PillarGen.java @@ -0,0 +1,99 @@ +package fyresmodjam.worldgen; + +import java.util.Random; + +import cpw.mods.fml.common.IWorldGenerator; +import fyresmodjam.ModjamMod; +import fyresmodjam.misc.ConfigData; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public class PillarGen implements IWorldGenerator { + @Override + public void generate(Random random, int chunkX, int chunkZ, + World world, IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + if (ConfigData.spawnRandomPillars + && world.provider.dimensionId == 0 + && random.nextInt( + ConfigData.pillarGenChance) == 0) { + boolean placed = false; + + int max = random.nextInt( + ConfigData.maxPillarsPerChunk) + 1; + + for (int y = 127, added = 0; y > 30 && !placed + && added < max; y--) { + for (int x = chunkX * 16; x < chunkX * 16 + + 16 && !placed + && added < max; x++) { + for (int z = chunkZ + * 16; z < chunkZ * 16 + + 16 + && !placed + && added < max; z++) { + if (random.nextInt(15) != 0 + || world.isAirBlock( + x, + y, + z) + || world.getBlock( + x, + y, + z) + .isReplaceable(world, + x, + y, + z) + || world.getBlock( + x, + y, + z) == ModjamMod.blockTrap + || world.getBlock( + x, + y, + z) == Blocks.leaves) { + continue; + } + + Block block = ModjamMod.blockPillar; + + if (block.canPlaceBlockAt( + world, x, + y + 1, + z)) { + world.setBlock(x, y + + 1, + z, + block); + world.setBlockMetadataWithNotify( + x, + y + 1, + z, + 0, + 0); + + world.setBlock(x, y + + 2, + z, + block); + world.setBlockMetadataWithNotify( + x, + y + 2, + z, + 1, + 0); + + placed = random.nextBoolean(); + + y -= 10; + added++; + } + } + } + } + } + } +} diff --git a/YWD/src/main/java/fyresmodjam/worldgen/WorldGenMoreDungeons.java b/YWD/src/main/java/fyresmodjam/worldgen/WorldGenMoreDungeons.java new file mode 100755 index 0000000..79a4378 --- /dev/null +++ b/YWD/src/main/java/fyresmodjam/worldgen/WorldGenMoreDungeons.java @@ -0,0 +1,25 @@ +package fyresmodjam.worldgen; + +import java.util.Random; + +import cpw.mods.fml.common.IWorldGenerator; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenDungeons; + +public class WorldGenMoreDungeons extends WorldGenDungeons + implements IWorldGenerator { + + @Override + public void generate(Random random, int chunkX, int chunkZ, + World world, IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + for (int k1 = 0; k1 < 24; ++k1) { + int l1 = chunkX * 16 + random.nextInt(16) + 8; + int i2 = random.nextInt(128); + int j2 = chunkZ * 16 + random.nextInt(16) + 8; + super.generate(world, random, l1, i2, j2); + } + } + +} diff --git a/YWD/src/main/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java b/YWD/src/main/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java new file mode 100755 index 0000000..d2a5a54 --- /dev/null +++ b/YWD/src/main/java/fyresmodjam/worldgen/WorldGenTrapsTowersAndMore.java @@ -0,0 +1,478 @@ +package fyresmodjam.worldgen; + +import java.util.Random; + +import cpw.mods.fml.common.IWorldGenerator; +import fyresmodjam.ModjamMod; +import fyresmodjam.blocks.BlockTrap; +import fyresmodjam.misc.ConfigData; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.DungeonHooks; + +public class WorldGenTrapsTowersAndMore implements IWorldGenerator { + + public static final WeightedRandomChestContent[] field_111189_a = new WeightedRandomChestContent[] { + new WeightedRandomChestContent(Items.iron_ingot, 0, + 1, 4, 10), + new WeightedRandomChestContent(Items.bread, 0, 1, + 1, 10), + new WeightedRandomChestContent(Items.wheat, 0, 1, + 4, 10), + new WeightedRandomChestContent(Items.gunpowder, 0, + 1, 4, 10), + new WeightedRandomChestContent(Items.string, 0, 1, + 4, 10), + new WeightedRandomChestContent(Items.bucket, 0, 1, + 1, 10), + new WeightedRandomChestContent(Items.redstone, 0, + 1, 4, 10), + new WeightedRandomChestContent(Items.name_tag, 0, + 1, 1, 10), + }; + + public static boolean genning = false; + + public static final String TOWER_CHESTS = "towerChests"; + + public static ChestGenHooks chestGenInfo = new ChestGenHooks( + TOWER_CHESTS, field_111189_a, 8, 8); + + @Override + public void generate(Random random, int chunkX, int chunkZ, + World world, IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + + genning = true; + + boolean addedDungeon = !ConfigData.spawnTowers || random + .nextInt(ConfigData.towerGenChance) != 0; + + for (int y = 1; y < 127; y++) { + for (int x = chunkX * 16; x < chunkX * 16 + + 16; x++) { + for (int z = chunkZ * 16; z < chunkZ * 16 + + 16; z++) { + if ((world.isAirBlock(x, y, z) + || (world.getBlock( + x, + y, + z) + .isReplaceable(world, + x, + y, + z) + && world.getBlock( + x, + y, + z) != Blocks.water + && world.getBlock( + x, + y, + z) != Blocks.flowing_water + && world.getBlock( + x, + y, + z) != Blocks.lava + && world.getBlock( + x, + y, + z) != Blocks.flowing_lava)) + && (!world.isAirBlock( + x, + y - 1, + z) + && world.getBlock( + x, + y - 1, + z) != ModjamMod.blockTrap + && !world.getBlock( + x, + y - 1, + z) + .isReplaceable(world, + x, + y - 1, + z)) + && random.nextInt( + ConfigData.trapGenChance) == 0) { + boolean skip = ConfigData.trapsBelowGroundOnly + && (world.getBlock( + x, + y - 1, + z) == Blocks.grass + || world.getBlock( + x, + y - 1, + z) == Blocks.sand + || world.getBlock( + x, + y - 1, + z) == Blocks.log + || world.getBlock( + x, + y - 1, + z) == Blocks.log2 + || world.canBlockSeeTheSky( + x, + y, + z)); + if (!skip && ModjamMod.blockTrap + .canPlaceBlockAt( + world, + x, + y, + z)) { + world.setBlock(x, + y, + z, + ModjamMod.blockTrap, + random.nextInt(BlockTrap.trapTypes), + 0); + } + } + + if ((world.getBlock(x, y, + z) == Blocks.brown_mushroom + || world.getBlock( + x, + y, + z) == Blocks.red_mushroom) + && random.nextInt( + ConfigData.mushroomReplaceChance) == 0) { + world.setBlock(x, y, z, + ModjamMod.mysteryMushroomBlock, + random.nextInt(13), + 0); + } + + if (!addedDungeon && ((world + .getBlock(x, y, z) == Blocks.grass + || ((world.getBlock( + x, + y, + z) == Blocks.sand + || world.getBlock( + x, + y, + z) == Blocks.netherrack + || world.getBlock( + x, + y, + z) == Blocks.soul_sand + || world.getBlock( + x, + y, + z) == Blocks.gravel) + && world.isAirBlock( + x, + y + 1, + z)))) + && world.getBlock( + x, + y + 1, + z) != Blocks.water + && world.getBlock( + x, + y + 1, + z) != Blocks.flowing_water + && world.getBlock( + x, + y + 1, + z) != Blocks.lava + && world.getBlock( + x, + y + 1, + z) != Blocks.flowing_lava + && ModjamMod.r.nextInt( + 100) == 0) { + + boolean obsidian = !world.provider.isHellWorld + && ModjamMod.r.nextInt( + 100) == 0; + + y--; + + int floors = 3 + random + .nextInt(6); + + for (int y2 = 0; y2 <= floors + * 6; y2++) { + for (int x2 = -5; x2 <= 5; x2++) { + for (int z2 = -5; z2 <= 5; z2++) { + + if (((y2 / 6) % 2 == 0 + ^ y2 % 6 < 2) + && x2 == -2 + && z2 == -5 + && y2 > 1 + && y2 <= floors * 6 + - 5) { + world.setBlock(x + x2, + y + y2, + z + z2 + 2, + Blocks.ladder, + 3, + 0); + } + + if (((y2 / 6) % 2 == 1 + ^ y2 % 6 < 2) + && x2 == 2 + && z2 == 5 + && y2 > 1 + && y2 <= floors * 6 + - 5) { + world.setBlock(x + x2, + y + y2, + z + z2 - 2, + Blocks.ladder, + 2, + 0); + } + + if ((x2 * x2 + z2 + * z2 <= 25) + && ((y2 % 6 == 0 || y2 + % 6 == 1) + || z2 > 3 + (y2 < 6 + ? 1 + : 0) + || z2 < -3 + || Math.abs(x2) > 3 + + (y2 < 5 ? 1 + : 0))) { + if (world.getBlock( + x + x2, + y + y2, + z + z2) != Blocks.ladder + && world.getBlock( + x + x2, + y + y2, + z + z2) != Blocks.obsidian) { + if (!obsidian && Math + .abs(x2) <= 1 + && Math.abs(z2) <= 1 + && y2 != floors * 6 + && y2 != 1 + && y2 % 6 == 1) { + world.setBlock(x + x2, + y + y2, + z + z2, + Blocks.obsidian); + } else { + world.setBlock(x + x2, + y + y2, + z + z2, + !world.provider.isHellWorld + ? (!obsidian ? (random + .nextBoolean() ? Blocks.mossy_cobblestone + : Blocks.cobblestone) + : Blocks.obsidian) + : Blocks.nether_brick); + } + } + } else if (y2 % 6 == 2 + && x2 == 0 + && z2 == ((y2 / 6) + % 2 == 1 ? 3 + : -3) + && (y2 / 6 >= floors + - 1 + || random.nextInt( + 3) == 0) + && y2 >= 5) { + world.setBlock(x + x2, + y + y2, + z + z2, + Blocks.chest, + 0, + 2); + + boolean b = (y2 / 6) + % 2 == 1; + + TileEntityChest tileentitychest = (TileEntityChest) world + .getTileEntity(x + x2, + y + y2, + z + z2); + + if (tileentitychest != null) { + WeightedRandomChestContent + .generateChestContents( + random, + ((y2 / 6 >= floors + - 1 + || obsidian) ? ChestGenHooks + .getInfo(ChestGenHooks.DUNGEON_CHEST) + : chestGenInfo).getItems( + random), + tileentitychest, + chestGenInfo.getCount( + random)); + } + + if (!obsidian) { + world.setBlock(x + x2, + y + y2 - 1, + z + z2, + Blocks.obsidian); + world.setBlock(x + x2, + y + y2 + 2, + z + z2, + Blocks.obsidian); + world.setBlock(x + x2, + y + y2, + z + z2 + (b ? 1 + : -1), + Blocks.obsidian); + world.setBlock(x + x2, + y + y2 + 1, + z + z2 + (b ? 1 + : -1), + Blocks.obsidian); + world.setBlock(x + x2 + + 1, + y + y2, + z + z2, + Blocks.obsidian); + world.setBlock(x + x2 + - 1, + y + y2, + z + z2, + Blocks.obsidian); + world.setBlock(x + x2 + + 1, + y + y2 + 1, + z + z2, + Blocks.obsidian); + world.setBlock(x + x2 + - 1, + y + y2 + 1, + z + z2, + Blocks.obsidian); + } + } else if (y2 % 6 == 2 + && x2 == 0 + && z2 == 0) { + if (y2 != 2) { + world.setBlock(x + x2, + y + y2, + z + z2, + Blocks.mob_spawner, + 0, + 2); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner) world + .getTileEntity(x + x2, + y + y2, + z + z2); + + if (tileentitymobspawner != null) { + tileentitymobspawner + .func_145881_a() + .setEntityName(DungeonHooks + .getRandomDungeonMob( + ModjamMod.r)); + ; + } + } else { + world.setBlock(x + x2, + y + y2, + z + z2, + ModjamMod.blockPillar); + world.setBlockMetadataWithNotify( + x + x2, + y + y2, + z + z2, + 0, + 0); + + world.setBlock(x + x2, + y + y2 + 1, + z + z2, + ModjamMod.blockPillar); + world.setBlockMetadataWithNotify( + x + x2, + y + y2 + 1, + z + z2, + 1, + 0); + } + } else if ((x2 * x2 + + z2 * z2 <= 25) + && world.getBlock( + x + x2, + y + y2, + z + z2) != ModjamMod.blockPillar + && world.getBlock( + x + x2, + y + y2, + z + z2) != Blocks.mob_spawner + && world.getBlock( + x + x2, + y + y2, + z + z2) != Blocks.ladder + && world.getBlock( + x + x2, + y + y2, + z + z2) != Blocks.chest + && world.getBlock( + x + x2, + y + y2, + z + z2) != Blocks.obsidian) { + world.setBlockToAir( + x + x2, + y + y2, + z + z2); + } + + } + } + } + + int changes = 0, y2 = -1; + + do { + changes = 0; + + for (int x2 = -5; x2 <= 5; x2++) { + for (int z2 = -5; z2 <= 5; z2++) { + if (x2 * x2 + z2 * z2 <= 25 + && world.isAirBlock( + x + x2, + y + y2, + z + z2)) { + world.setBlock(x + x2, + y + y2, + z + z2, + !obsidian ? (random + .nextBoolean() ? Blocks.mossy_cobblestone + : Blocks.cobblestone) + : Blocks.obsidian); + changes++; + } + } + } + + y2--; + } while (changes != 0 && y + + y2 >= 0); + + addedDungeon = true; + + y++; + } + } + } + } + + genning = false; + } + +} -- cgit v1.2.3