Added Settings and Minor Preemptive Fix
Added a setting to DDProperties for controlling the max distance that players can be moved randomly when they're sent to Limbo. We previously had a setting for the same except for leaving Limbo. Cleaned up some of the related code a little. Added another setting for the chance of rifts dropping World Thread on block destruction. Also fixed a potential NPE in EventHookContainer that could arise theoretically arise if a non-Vanilla door was attached to a rift.
This commit is contained in:
@@ -89,7 +89,7 @@ public class EventHookContainer
|
|||||||
if (stack != null)
|
if (stack != null)
|
||||||
{
|
{
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if (item instanceof ItemDoor && !(item instanceof BaseItemDoor))
|
if (item instanceof ItemDoor)
|
||||||
{
|
{
|
||||||
Block doorToPlace = null;
|
Block doorToPlace = null;
|
||||||
if (stack.itemID == Item.doorIron.itemID)
|
if (stack.itemID == Item.doorIron.itemID)
|
||||||
@@ -105,19 +105,22 @@ public class EventHookContainer
|
|||||||
doorToPlace = mod_pocketDim.goldenDimensionalDoor;
|
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.
|
if (doorToPlace != null)
|
||||||
// Comments would have been very helpful.
|
|
||||||
if (mod_pocketDim.itemDimensionalDoor.tryPlacingDoor(doorToPlace, world, event.entityPlayer, stack))
|
|
||||||
{
|
{
|
||||||
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.extinguish();
|
||||||
player.clearActivePotions();
|
player.clearActivePotions();
|
||||||
player.setHealth(player.getMaxHealth());
|
player.setHealth(player.getMaxHealth());
|
||||||
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(player.worldObj.rand);
|
Point4D destination = LimboProvider.getLimboSkySpawn(player, properties);
|
||||||
Point4D destination = new Point4D((int) (coords.posX + player.posX), coords.posY, (int) (coords.posZ + player.posZ ), mod_pocketDim.properties.LimboDimensionID);
|
|
||||||
DDTeleporter.teleportEntity(player, destination, false);
|
DDTeleporter.teleportEntity(player, destination, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ public class BlockRift extends Block implements ITileEntityProvider
|
|||||||
private static final int BLOCK_SEARCH_CHANCE = 50;
|
private static final int BLOCK_SEARCH_CHANCE = 50;
|
||||||
private static final int MAX_BLOCK_DESTRUCTION_CHANCE = 100;
|
private static final int MAX_BLOCK_DESTRUCTION_CHANCE = 100;
|
||||||
private static final int BLOCK_DESTRUCTION_CHANCE = 50;
|
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 DDProperties properties;
|
||||||
private final ArrayList<Integer> blocksImmuneToRift;
|
private final ArrayList<Integer> blocksImmuneToRift;
|
||||||
@@ -173,7 +173,7 @@ public class BlockRift extends Block implements ITileEntityProvider
|
|||||||
{
|
{
|
||||||
if (random.nextInt(MAX_BLOCK_DESTRUCTION_CHANCE) < BLOCK_DESTRUCTION_CHANCE)
|
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);
|
world.destroyBlock(target.getX(), target.getY(), target.getZ(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,9 +220,9 @@ public class BlockRift extends Block implements ITileEntityProvider
|
|||||||
return targets;
|
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 BlockFlowing ||
|
||||||
Block.blocksList[blockID] instanceof BlockFluid ||
|
Block.blocksList[blockID] instanceof BlockFluid ||
|
||||||
Block.blocksList[blockID] instanceof IFluidBlock))
|
Block.blocksList[blockID] instanceof IFluidBlock))
|
||||||
@@ -258,7 +258,7 @@ public class BlockRift extends Block implements ITileEntityProvider
|
|||||||
{
|
{
|
||||||
int blockID = world.getBlockId(x, y, z);
|
int blockID = world.getBlockId(x, y, z);
|
||||||
if (world.setBlock(x, y, z, properties.RiftBlockID))
|
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))
|
if (world.setBlock(x, y, z, properties.RiftBlockID))
|
||||||
{
|
{
|
||||||
dimension.createChildLink(x, y, z, parent);
|
dimension.createChildLink(x, y, z, parent);
|
||||||
spawnWorldThread(blockID, world, x, y, z, random);
|
dropWorldThread(blockID, world, x, y, z, random);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.config;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import net.minecraftforge.common.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
|
import StevenDimDoors.mod_pocketDim.blocks.BlockRift;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
|
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
|
||||||
import StevenDimDoors.mod_pocketDim.world.fortresses.DDStructureNetherBridgeStart;
|
import StevenDimDoors.mod_pocketDim.world.fortresses.DDStructureNetherBridgeStart;
|
||||||
import StevenDimDoors.mod_pocketDim.world.gateways.GatewayGenerator;
|
import StevenDimDoors.mod_pocketDim.world.gateways.GatewayGenerator;
|
||||||
@@ -107,6 +108,8 @@ public class DDProperties
|
|||||||
public final int GatewayGenerationChance;
|
public final int GatewayGenerationChance;
|
||||||
public final int FortressGatewayGenerationChance;
|
public final int FortressGatewayGenerationChance;
|
||||||
public final int MonolithSpawningChance;
|
public final int MonolithSpawningChance;
|
||||||
|
public final int WorldThreadDropChance;
|
||||||
|
public final int LimboEntryRange;
|
||||||
public final int LimboReturnRange;
|
public final int LimboReturnRange;
|
||||||
public final int WorldThreadRequirementLevel;
|
public final int WorldThreadRequirementLevel;
|
||||||
public final String CustomSchematicDirectory;
|
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);
|
"Sets whether players keep their inventories upon dying and respawning in Limbo").getBoolean(true);
|
||||||
HardcoreLimboEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Hardcore Limbo", false,
|
HardcoreLimboEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Hardcore Limbo", false,
|
||||||
"Sets whether players that die in Limbo will respawn there").getBoolean(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,
|
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);
|
DoorRenderingEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Door Rendering", true).getBoolean(true);
|
||||||
|
|
||||||
TNFREAKINGT_Enabled = config.get(Configuration.CATEGORY_GENERAL, "EXPLOSIONS!!???!!!?!?!!", false).getBoolean(false);
|
TNFREAKINGT_Enabled = config.get(Configuration.CATEGORY_GENERAL, "EXPLOSIONS!!???!!!?!?!!", false).getBoolean(false);
|
||||||
@@ -228,6 +233,10 @@ public class DDProperties
|
|||||||
"Sets the chance (out of " + DDStructureNetherBridgeStart.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
|
"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();
|
"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();
|
LimboBiomeID = config.get(CATEGORY_BIOME, "Limbo Biome ID", 251).getInt();
|
||||||
PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt();
|
PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt();
|
||||||
|
|
||||||
|
|||||||
@@ -195,8 +195,7 @@ public class MobMonolith extends EntityFlying implements IMob
|
|||||||
}
|
}
|
||||||
else if (!this.worldObj.isRemote && properties.MonolithTeleportationEnabled && !entityPlayer.capabilities.isCreativeMode)
|
else if (!this.worldObj.isRemote && properties.MonolithTeleportationEnabled && !entityPlayer.capabilities.isCreativeMode)
|
||||||
{
|
{
|
||||||
ChunkCoordinates coords = LimboProvider.getLimboSkySpawn(entityPlayer.worldObj.rand);
|
Point4D destination = LimboProvider.getLimboSkySpawn(entityPlayer, properties);
|
||||||
Point4D destination = new Point4D((int) (coords.posX+entityPlayer.posX), coords.posY, (int) (coords.posZ+entityPlayer.posZ ), mod_pocketDim.properties.LimboDimensionID);
|
|
||||||
DDTeleporter.teleportEntity(entityPlayer, destination, false);
|
DDTeleporter.teleportEntity(entityPlayer, destination, false);
|
||||||
|
|
||||||
this.aggro = 0;
|
this.aggro = 0;
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package StevenDimDoors.mod_pocketDim.world;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.util.ChunkCoordinates;
|
import net.minecraft.util.ChunkCoordinates;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.WorldProvider;
|
import net.minecraft.world.WorldProvider;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
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.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
|
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
|
||||||
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@@ -174,26 +177,18 @@ public class LimboProvider extends WorldProvider
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChunkCoordinates getLimboSkySpawn(Random rand)
|
public static Point4D getLimboSkySpawn(EntityPlayer player, DDProperties properties)
|
||||||
{
|
{
|
||||||
ChunkCoordinates var5 = new ChunkCoordinates(0,0,0);
|
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);
|
||||||
int spawnFuzz = 1000;
|
|
||||||
int spawnFuzzHalf = spawnFuzz / 2;
|
|
||||||
|
|
||||||
{
|
|
||||||
var5.posX += rand.nextInt(spawnFuzz) - spawnFuzzHalf;
|
|
||||||
var5.posZ += rand.nextInt(spawnFuzz) - spawnFuzzHalf;
|
|
||||||
var5.posY = 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
return var5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkCoordinates getRandomizedSpawnPoint()
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user