diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java index bfe6cf8..b03e35f 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/EventHookContainer.java @@ -89,7 +89,7 @@ public class EventHookContainer if (stack != null) { Item item = stack.getItem(); - if (item instanceof ItemDoor && !(item instanceof BaseItemDoor)) + if (item instanceof ItemDoor) { Block doorToPlace = null; if (stack.itemID == Item.doorIron.itemID) @@ -105,19 +105,22 @@ public class EventHookContainer doorToPlace = mod_pocketDim.goldenDimensionalDoor; } - // SenseiKiwi: Why do we have a condition like this? And the event isn't cancelled if we take the else portion. - // Comments would have been very helpful. - if (mod_pocketDim.itemDimensionalDoor.tryPlacingDoor(doorToPlace, world, event.entityPlayer, stack)) + if (doorToPlace != null) { - if (!event.entityPlayer.capabilities.isCreativeMode) + // SenseiKiwi: Why do we have a condition like this? And the event isn't cancelled if we take the else portion. + // Comments would have been very helpful. + if (mod_pocketDim.itemDimensionalDoor.tryPlacingDoor(doorToPlace, world, event.entityPlayer, stack)) { - stack.stackSize--; + if (!event.entityPlayer.capabilities.isCreativeMode) + { + stack.stackSize--; + } + event.setCanceled(true); + } + else + { + BaseItemDoor.tryItemUse(doorToPlace, stack, event.entityPlayer, world, event.x, event.y, event.z, event.face, true, true); } - event.setCanceled(true); - } - else - { - BaseItemDoor.tryItemUse(doorToPlace, stack, event.entityPlayer, world, event.x, event.y, event.z, event.face, true, true); } } } @@ -198,8 +201,7 @@ public class EventHookContainer player.extinguish(); player.clearActivePotions(); player.setHealth(player.getMaxHealth()); - ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand); - Point4D destination = new Point4D((int) (coords.posX + player.posX), coords.posY, (int) (coords.posZ + player.posZ ), mod_pocketDim.properties.LimboDimensionID); + Point4D destination = LimboProvider.getLimboSkySpawn(player, properties); DDTeleporter.teleportEntity(player, destination, false); } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java index cc15c9f..ada00b6 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java @@ -43,8 +43,8 @@ public class BlockRift extends Block implements ITileEntityProvider private static final int BLOCK_SEARCH_CHANCE = 50; private static final int MAX_BLOCK_DESTRUCTION_CHANCE = 100; private static final int BLOCK_DESTRUCTION_CHANCE = 50; - private static final int WORLD_THREAD_CHANCE = 5; - private static final int MAX_WORLD_THREAD_CHANCE = 100; + + public static final int MAX_WORLD_THREAD_DROP_CHANCE = 1000; private final DDProperties properties; private final ArrayList blocksImmuneToRift; @@ -173,7 +173,7 @@ public class BlockRift extends Block implements ITileEntityProvider { if (random.nextInt(MAX_BLOCK_DESTRUCTION_CHANCE) < BLOCK_DESTRUCTION_CHANCE) { - spawnWorldThread(world.getBlockId(target.getX(), target.getY(), target.getZ()), world, x, y, z, random); + dropWorldThread(world.getBlockId(target.getX(), target.getY(), target.getZ()), world, x, y, z, random); world.destroyBlock(target.getX(), target.getY(), target.getZ(), false); } } @@ -220,9 +220,9 @@ public class BlockRift extends Block implements ITileEntityProvider return targets; } - private void spawnWorldThread(int blockID, World world, int x, int y, int z, Random random) + private void dropWorldThread(int blockID, World world, int x, int y, int z, Random random) { - if (blockID != 0 && (random.nextInt(MAX_WORLD_THREAD_CHANCE) < WORLD_THREAD_CHANCE) + if (blockID != 0 && (random.nextInt(MAX_WORLD_THREAD_DROP_CHANCE) < properties.WorldThreadDropChance) && !(Block.blocksList[blockID] instanceof BlockFlowing || Block.blocksList[blockID] instanceof BlockFluid || Block.blocksList[blockID] instanceof IFluidBlock)) @@ -258,7 +258,7 @@ public class BlockRift extends Block implements ITileEntityProvider { int blockID = world.getBlockId(x, y, z); if (world.setBlock(x, y, z, properties.RiftBlockID)) - spawnWorldThread(blockID, world, x, y, z, random); + dropWorldThread(blockID, world, x, y, z, random); } } @@ -284,7 +284,7 @@ public class BlockRift extends Block implements ITileEntityProvider if (world.setBlock(x, y, z, properties.RiftBlockID)) { dimension.createChildLink(x, y, z, parent); - spawnWorldThread(blockID, world, x, y, z, random); + dropWorldThread(blockID, world, x, y, z, random); return true; } } diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/config/DDProperties.java b/src/main/java/StevenDimDoors/mod_pocketDim/config/DDProperties.java index 67b1b11..3aaa69a 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/config/DDProperties.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/config/DDProperties.java @@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.config; import java.io.File; import net.minecraftforge.common.Configuration; +import StevenDimDoors.mod_pocketDim.blocks.BlockRift; import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator; import StevenDimDoors.mod_pocketDim.world.fortresses.DDStructureNetherBridgeStart; import StevenDimDoors.mod_pocketDim.world.gateways.GatewayGenerator; @@ -107,6 +108,8 @@ public class DDProperties public final int GatewayGenerationChance; public final int FortressGatewayGenerationChance; public final int MonolithSpawningChance; + public final int WorldThreadDropChance; + public final int LimboEntryRange; public final int LimboReturnRange; public final int WorldThreadRequirementLevel; public final String CustomSchematicDirectory; @@ -166,8 +169,10 @@ public class DDProperties "Sets whether players keep their inventories upon dying and respawning in Limbo").getBoolean(true); HardcoreLimboEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Hardcore Limbo", false, "Sets whether players that die in Limbo will respawn there").getBoolean(false); + LimboEntryRange = config.get(Configuration.CATEGORY_GENERAL, "Limbo Entry Range", 500, + "Sets the farthest distance that players may be moved at random when sent to Limbo. Must be greater than or equal to 0.").getInt(); LimboReturnRange = config.get(Configuration.CATEGORY_GENERAL, "Limbo Return Range", 500, - "Sets the farthest distance that Limbo can send you upon returning to the Overworld").getInt(); + "Sets the farthest distance that players may be moved at random when sent from Limbo to the Overworld. Must be greater than or equal to 0.").getInt(); DoorRenderingEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Door Rendering", true).getBoolean(true); TNFREAKINGT_Enabled = config.get(Configuration.CATEGORY_GENERAL, "EXPLOSIONS!!???!!!?!?!!", false).getBoolean(false); @@ -227,6 +232,10 @@ public class DDProperties FortressGatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Fortress Gateway Generation Chance", 33, "Sets the chance (out of " + DDStructureNetherBridgeStart.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " + "generate as part of a Nether Fortress. The default chance is 33.").getInt(); + + WorldThreadDropChance = config.get(Configuration.CATEGORY_GENERAL, "World Thread Drop Chance", 50, + "Sets the chance (out of " + BlockRift.MAX_WORLD_THREAD_DROP_CHANCE + ") that a rift will " + + "drop World Thread when it destroys a block. The default chance is 50.").getInt(); LimboBiomeID = config.get(CATEGORY_BIOME, "Limbo Biome ID", 251).getInt(); PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt(); diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java index ae1f7cc..36df4dc 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/ticking/MobMonolith.java @@ -195,8 +195,7 @@ public class MobMonolith extends EntityFlying implements IMob } else if (!this.worldObj.isRemote && properties.MonolithTeleportationEnabled && !entityPlayer.capabilities.isCreativeMode) { - ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(entityPlayer.worldObj.rand); - Point4D destination = new Point4D((int) (coords.posX+entityPlayer.posX), coords.posY, (int) (coords.posZ+entityPlayer.posZ ), mod_pocketDim.properties.LimboDimensionID); + Point4D destination = LimboProvider.getLimboSkySpawn(entityPlayer, properties); DDTeleporter.teleportEntity(entityPlayer, destination, false); this.aggro = 0; diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/world/LimboProvider.java b/src/main/java/StevenDimDoors/mod_pocketDim/world/LimboProvider.java index 3be9520..76ae6cb 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/world/LimboProvider.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/world/LimboProvider.java @@ -3,8 +3,10 @@ package StevenDimDoors.mod_pocketDim.world; import java.util.Random; import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.WorldProvider; import net.minecraft.world.biome.BiomeGenBase; @@ -15,6 +17,7 @@ import StevenDimDoors.mod_pocketDim.CloudRenderBlank; import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.config.DDProperties; import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator; +import StevenDimDoors.mod_pocketDim.util.Point4D; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -174,26 +177,18 @@ public class LimboProvider extends WorldProvider return false; } - public static ChunkCoordinates getLimboSkySpawn(Random rand) + public static Point4D getLimboSkySpawn(EntityPlayer player, DDProperties properties) { - ChunkCoordinates var5 = new ChunkCoordinates(0,0,0); - - - int spawnFuzz = 1000; - int spawnFuzzHalf = spawnFuzz / 2; - - { - var5.posX += rand.nextInt(spawnFuzz) - spawnFuzzHalf; - var5.posZ += rand.nextInt(spawnFuzz) - spawnFuzzHalf; - var5.posY = 700; - } - - return var5; + int x = (int) (player.posX) + MathHelper.getRandomIntegerInRange(player.worldObj.rand, -properties.LimboEntryRange, properties.LimboEntryRange); + int z = (int) (player.posZ) + MathHelper.getRandomIntegerInRange(player.worldObj.rand, -properties.LimboEntryRange, properties.LimboEntryRange); + return new Point4D(x, 700, z, properties.LimboDimensionID); } @Override public ChunkCoordinates getRandomizedSpawnPoint() { - return getLimboSkySpawn(this.worldObj.rand); + int x = MathHelper.getRandomIntegerInRange(this.worldObj.rand, -500, 500); + int z = MathHelper.getRandomIntegerInRange(this.worldObj.rand, -500, 500); + return new ChunkCoordinates(x, 700, z); } } \ No newline at end of file