Changes to Rift Regeneration
Moved a little of the regeneration code to BlockRift to reduce duplicate code. Changed RiftRegenerator to iterate over loaded worlds instead of all worlds. Removed forced rift generation call in EventHookContainer.onWorldLoad() - I feel it would have minimal benefits. Rifts now drop World Thread upon regeneration. Generally cleaned up the code in FastRiftRegenerator and RiftRegenerator.
This commit is contained in:
@@ -43,7 +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_PROBABILITY = 10;
|
||||
private static final int WORLD_THREAD_CHANCE = 5;
|
||||
private static final int MAX_WORLD_THREAD_CHANCE = 100;
|
||||
|
||||
private final DDProperties properties;
|
||||
private final ArrayList<Integer> blocksImmuneToRift;
|
||||
@@ -191,30 +192,25 @@ public class BlockRift extends Block implements ITileEntityProvider
|
||||
if (!isBlockImmune(world, current.getX(), current.getY(), current.getZ()) &&
|
||||
random.nextInt(MAX_BLOCK_DESTRUCTION_CHANCE) < BLOCK_DESTRUCTION_CHANCE)
|
||||
{
|
||||
this.spawnWorldThread(world.getBlockId(current.getX(), current.getY(), current.getZ()), world, x, y, z);
|
||||
this.spawnWorldThread(world.getBlockId(current.getX(), current.getY(), current.getZ()), world, x, y, z, random);
|
||||
world.destroyBlock(current.getX(), current.getY(), current.getZ(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void spawnWorldThread(int blockID,World worldObj,int x,int y,int z )
|
||||
|
||||
private void spawnWorldThread(int blockID, World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if(blockID == 0||!(worldObj.rand.nextInt(100)<this.WORLD_THREAD_PROBABILITY))
|
||||
if (blockID != 0 && (random.nextInt(MAX_WORLD_THREAD_CHANCE) < WORLD_THREAD_CHANCE)
|
||||
&& !(Block.blocksList[blockID] instanceof BlockFlowing ||
|
||||
Block.blocksList[blockID] instanceof BlockFluid ||
|
||||
Block.blocksList[blockID] instanceof IFluidBlock))
|
||||
{
|
||||
return;
|
||||
ItemStack thread = new ItemStack(mod_pocketDim.itemWorldThread, 1);
|
||||
world.spawnEntityInWorld(new EntityItem(world, x, y, z, thread));
|
||||
}
|
||||
if(Block.blocksList[blockID] instanceof BlockFlowing||
|
||||
Block.blocksList[blockID] instanceof BlockFluid||
|
||||
Block.blocksList[blockID] instanceof IFluidBlock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack thread = new ItemStack(mod_pocketDim.itemWorldThread,1);
|
||||
EntityItem threadEntity = new EntityItem(worldObj, x,y,z, thread);
|
||||
worldObj.spawnEntityInWorld(threadEntity);
|
||||
|
||||
}
|
||||
|
||||
private void addAdjacentBlocks(int x, int y, int z, int distance, HashMap<Point3D, Integer> pointDistances, Queue<Point3D> points)
|
||||
{
|
||||
Point3D[] neighbors = new Point3D[] {
|
||||
@@ -234,6 +230,16 @@ public class BlockRift extends Block implements ITileEntityProvider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void regenerateRift(World world, int x, int y, int z, Random random)
|
||||
{
|
||||
if (!this.isBlockImmune(world, x, y, z) && world.getChunkProvider().chunkExists(x >> 4, z >> 4))
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
world.setBlock(x, y, z, properties.RiftBlockID);
|
||||
this.spawnWorldThread(blockID, world, x, y, z, random);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets pistons push through rifts, destroying them
|
||||
|
||||
Reference in New Issue
Block a user