Various Updates #138
@@ -135,11 +135,6 @@ public class EventHookContainer
|
|||||||
PocketManager.load();
|
PocketManager.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PocketManager.isLoaded())
|
|
||||||
{
|
|
||||||
RiftRegenerator.regenerateRiftsInAllWorlds();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.world != null)
|
if (event.world != null)
|
||||||
{
|
{
|
||||||
this.playMusicForDim(event.world);
|
this.playMusicForDim(event.world);
|
||||||
|
|||||||
@@ -43,7 +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_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 DDProperties properties;
|
||||||
private final ArrayList<Integer> blocksImmuneToRift;
|
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()) &&
|
if (!isBlockImmune(world, current.getX(), current.getY(), current.getZ()) &&
|
||||||
random.nextInt(MAX_BLOCK_DESTRUCTION_CHANCE) < BLOCK_DESTRUCTION_CHANCE)
|
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);
|
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)
|
private void addAdjacentBlocks(int x, int y, int z, int distance, HashMap<Point3D, Integer> pointDistances, Queue<Point3D> points)
|
||||||
{
|
{
|
||||||
Point3D[] neighbors = new Point3D[] {
|
Point3D[] neighbors = new Point3D[] {
|
||||||
@@ -235,6 +231,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
|
* Lets pistons push through rifts, destroying them
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.ticking;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
@@ -12,7 +13,9 @@ import StevenDimDoors.mod_pocketDim.util.Point4D;
|
|||||||
|
|
||||||
public class FastRiftRegenerator implements IRegularTickReceiver {
|
public class FastRiftRegenerator implements IRegularTickReceiver {
|
||||||
|
|
||||||
private static final int RIFT_REGENERATION_INTERVAL = 10; //Regenerate random rifts every 10 ticks
|
private static final int RIFT_REGENERATION_INTERVAL = 10; //Regenerate scheduled rifts every 10 ticks
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
private ArrayList<Point4D> locationsToRegen = new ArrayList<Point4D>();
|
private ArrayList<Point4D> locationsToRegen = new ArrayList<Point4D>();
|
||||||
|
|
||||||
public FastRiftRegenerator(IRegularTickSender sender)
|
public FastRiftRegenerator(IRegularTickSender sender)
|
||||||
@@ -23,31 +26,24 @@ public class FastRiftRegenerator implements IRegularTickReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void notifyTick()
|
public void notifyTick()
|
||||||
{
|
{
|
||||||
regenerateRiftsInAllWorlds();
|
regenerateScheduledRifts();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void regenerateRiftsInAllWorlds()
|
public void regenerateScheduledRifts()
|
||||||
{
|
{
|
||||||
if (this.locationsToRegen.isEmpty())
|
if (!locationsToRegen.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<Integer> loadedWorlds = (List<Integer>) Arrays.asList(DimensionManager.getIDs());
|
List<Integer> loadedWorlds = (List<Integer>) Arrays.asList(DimensionManager.getIDs());
|
||||||
|
for (Point4D point: locationsToRegen)
|
||||||
for (Point4D point: this.locationsToRegen)
|
|
||||||
{
|
{
|
||||||
if (loadedWorlds.contains(point.getDimension()) && PocketManager.getLink(point) != null)
|
if (loadedWorlds.contains(point.getDimension()) && PocketManager.getLink(point) != null)
|
||||||
{
|
{
|
||||||
World world = DimensionManager.getWorld(point.getDimension());
|
World world = DimensionManager.getWorld(point.getDimension());
|
||||||
|
mod_pocketDim.blockRift.regenerateRift(world, point.getX(), point.getY(), point.getZ(), random);
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, point.getX(), point.getY(), point.getZ())
|
|
||||||
&& world.getChunkProvider().chunkExists(point.getX() >> 4, point.getZ() >> 4))
|
|
||||||
{
|
|
||||||
world.setBlock(point.getX(), point.getY(), point.getZ(), mod_pocketDim.blockRift.blockID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
locationsToRegen.clear();
|
||||||
}
|
}
|
||||||
this.locationsToRegen.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerRiftForRegen(int x, int y, int z, int dimID)
|
public void registerRiftForRegen(int x, int y, int z, int dimID)
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.ticking;
|
package StevenDimDoors.mod_pocketDim.ticking;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
@@ -13,6 +16,7 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||||||
|
|
||||||
private static final int RIFT_REGENERATION_INTERVAL = 200; //Regenerate random rifts every 200 ticks
|
private static final int RIFT_REGENERATION_INTERVAL = 200; //Regenerate random rifts every 200 ticks
|
||||||
private static final int RIFTS_REGENERATED_PER_DIMENSION = 5;
|
private static final int RIFTS_REGENERATED_PER_DIMENSION = 5;
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
public RiftRegenerator(IRegularTickSender sender)
|
public RiftRegenerator(IRegularTickSender sender)
|
||||||
{
|
{
|
||||||
@@ -22,16 +26,17 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void notifyTick()
|
public void notifyTick()
|
||||||
{
|
{
|
||||||
regenerateRiftsInAllWorlds();
|
regenerateRiftsInLoadedWorlds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void regenerateRiftsInAllWorlds()
|
private static void regenerateRiftsInLoadedWorlds()
|
||||||
{
|
{
|
||||||
//Regenerate rifts that have been replaced (not permanently removed) by players
|
// Regenerate rifts that have been replaced (not permanently removed) by players
|
||||||
DDProperties properties = DDProperties.instance();
|
// Only do this in dimensions that are currently loaded
|
||||||
|
List<Integer> loadedWorlds = (List<Integer>) Arrays.asList(DimensionManager.getIDs());
|
||||||
for (NewDimData dimension : PocketManager.getDimensions())
|
for (Integer dimensionID : loadedWorlds)
|
||||||
{
|
{
|
||||||
|
NewDimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||||
if (dimension.linkCount() > 0)
|
if (dimension.linkCount() > 0)
|
||||||
{
|
{
|
||||||
World world = DimensionManager.getWorld(dimension.id());
|
World world = DimensionManager.getWorld(dimension.id());
|
||||||
@@ -42,10 +47,7 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||||||
{
|
{
|
||||||
DimLink link = dimension.getRandomLink();
|
DimLink link = dimension.getRandomLink();
|
||||||
Point4D source = link.source();
|
Point4D source = link.source();
|
||||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, source.getX(), source.getY(), source.getZ())&& world.getChunkProvider().chunkExists(source.getX() >> 4, source.getZ() >> 4))
|
mod_pocketDim.blockRift.regenerateRift(world, source.getX(), source.getY(), source.getZ(), random);
|
||||||
{
|
|
||||||
world.setBlock(source.getX(), source.getY(), source.getZ(), properties.RiftBlockID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user