Fixed Slow Rift Regeneration and Various Improvements #173
@@ -9,7 +9,7 @@ import net.minecraft.util.Icon;
|
|||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
|
import StevenDimDoors.mod_pocketDim.world.LimboDecay;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class ChunkLoaderHelper implements LoadingCallback
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadChunkForcedWorlds(FMLServerStartingEvent event)
|
public static void loadForcedChunkWorlds(FMLServerStartingEvent event)
|
||||||
{
|
{
|
||||||
for (NewDimData data : PocketManager.getDimensions())
|
for (NewDimData data : PocketManager.getDimensions())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import StevenDimDoors.mod_pocketDim.items.ItemWorldThread;
|
|||||||
import StevenDimDoors.mod_pocketDim.items.itemRiftRemover;
|
import StevenDimDoors.mod_pocketDim.items.itemRiftRemover;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
|
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.FastRiftRegenerator;
|
import StevenDimDoors.mod_pocketDim.ticking.FastRiftRegenerator;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.LimboDecay;
|
import StevenDimDoors.mod_pocketDim.ticking.LimboDecayScheduler;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
import StevenDimDoors.mod_pocketDim.ticking.MobMonolith;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
import StevenDimDoors.mod_pocketDim.ticking.RiftRegenerator;
|
||||||
import StevenDimDoors.mod_pocketDim.ticking.ServerTickHandler;
|
import StevenDimDoors.mod_pocketDim.ticking.ServerTickHandler;
|
||||||
@@ -65,6 +65,7 @@ import StevenDimDoors.mod_pocketDim.tileentities.TileEntityTransTrapdoor;
|
|||||||
import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo;
|
import StevenDimDoors.mod_pocketDim.world.BiomeGenLimbo;
|
||||||
import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket;
|
import StevenDimDoors.mod_pocketDim.world.BiomeGenPocket;
|
||||||
import StevenDimDoors.mod_pocketDim.world.DDBiomeGenBase;
|
import StevenDimDoors.mod_pocketDim.world.DDBiomeGenBase;
|
||||||
|
import StevenDimDoors.mod_pocketDim.world.LimboDecay;
|
||||||
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
import StevenDimDoors.mod_pocketDim.world.LimboProvider;
|
||||||
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
import StevenDimDoors.mod_pocketDim.world.PocketProvider;
|
||||||
import StevenDimDoors.mod_pocketDim.world.gateways.GatewayGenerator;
|
import StevenDimDoors.mod_pocketDim.world.gateways.GatewayGenerator;
|
||||||
@@ -142,9 +143,13 @@ public class mod_pocketDim
|
|||||||
public static DDProperties properties;
|
public static DDProperties properties;
|
||||||
public static DDWorldProperties worldProperties;
|
public static DDWorldProperties worldProperties;
|
||||||
public static CustomLimboPopulator spawner; //Added this field temporarily. Will be refactored out later.
|
public static CustomLimboPopulator spawner; //Added this field temporarily. Will be refactored out later.
|
||||||
|
private static RiftRegenerator riftRegenerator;
|
||||||
public static FastRiftRegenerator fastRiftRegenerator;
|
public static FastRiftRegenerator fastRiftRegenerator;
|
||||||
public static GatewayGenerator gatewayGenerator;
|
public static GatewayGenerator gatewayGenerator;
|
||||||
public static DeathTracker deathTracker;
|
public static DeathTracker deathTracker;
|
||||||
|
private static ServerTickHandler serverTickHandler;
|
||||||
|
private static LimboDecayScheduler limboDecayScheduler;
|
||||||
|
private static LimboDecay limboDecay;
|
||||||
private static EventHookContainer hooks;
|
private static EventHookContainer hooks;
|
||||||
|
|
||||||
//TODO this is a temporary workaround for saving data
|
//TODO this is a temporary workaround for saving data
|
||||||
@@ -182,16 +187,14 @@ public class mod_pocketDim
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInitialization(FMLInitializationEvent event)
|
public void onInitialization(FMLInitializationEvent event)
|
||||||
{
|
{
|
||||||
ServerTickHandler commonTickHandler = new ServerTickHandler();
|
// Initialize ServerTickHandler instance
|
||||||
TickRegistry.registerTickHandler(commonTickHandler, Side.SERVER);
|
serverTickHandler = new ServerTickHandler();
|
||||||
|
TickRegistry.registerTickHandler(serverTickHandler, Side.SERVER);
|
||||||
|
|
||||||
//MonolithSpawner should be initialized before any provider instances are created
|
// Initialize LimboDecay instance: required for BlockLimbo
|
||||||
//Register the other regular tick receivers as well
|
limboDecay = new LimboDecay(properties);
|
||||||
spawner = new CustomLimboPopulator(commonTickHandler, properties);
|
|
||||||
new RiftRegenerator(commonTickHandler); //No need to store the reference
|
|
||||||
LimboDecay decay = new LimboDecay(commonTickHandler, properties);
|
|
||||||
fastRiftRegenerator = new FastRiftRegenerator(commonTickHandler);
|
|
||||||
|
|
||||||
|
// Initialize blocks and items
|
||||||
transientDoor = new TransientDoor(properties.TransientDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("transientDoor");
|
transientDoor = new TransientDoor(properties.TransientDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("transientDoor");
|
||||||
goldenDimensionalDoor = new BlockGoldDimDoor(properties.GoldenDimensionalDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorGold");
|
goldenDimensionalDoor = new BlockGoldDimDoor(properties.GoldenDimensionalDoorID, Material.iron, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorGold");
|
||||||
|
|
||||||
@@ -200,7 +203,7 @@ public class mod_pocketDim
|
|||||||
blockDimWallPerm = (new BlockDimWallPerm(properties.PermaFabricBlockID, 0, Material.iron)).setLightValue(1.0F).setBlockUnbreakable().setResistance(6000000.0F).setUnlocalizedName("blockDimWallPerm");
|
blockDimWallPerm = (new BlockDimWallPerm(properties.PermaFabricBlockID, 0, Material.iron)).setLightValue(1.0F).setBlockUnbreakable().setResistance(6000000.0F).setUnlocalizedName("blockDimWallPerm");
|
||||||
warpDoor = new WarpDoor(properties.WarpDoorID, Material.wood, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");
|
warpDoor = new WarpDoor(properties.WarpDoorID, Material.wood, properties).setHardness(1.0F) .setUnlocalizedName("dimDoorWarp");
|
||||||
blockRift = (BlockRift) (new BlockRift(properties.RiftBlockID, 0, Material.air, properties).setHardness(1.0F) .setUnlocalizedName("rift"));
|
blockRift = (BlockRift) (new BlockRift(properties.RiftBlockID, 0, Material.air, properties).setHardness(1.0F) .setUnlocalizedName("rift"));
|
||||||
blockLimbo = new BlockLimbo(properties.LimboBlockID, 15, Material.iron, properties.LimboDimensionID, decay).setHardness(.2F).setUnlocalizedName("BlockLimbo").setLightValue(.0F);
|
blockLimbo = new BlockLimbo(properties.LimboBlockID, 15, Material.iron, properties.LimboDimensionID, limboDecay).setHardness(.2F).setUnlocalizedName("BlockLimbo").setLightValue(.0F);
|
||||||
unstableDoor = (new UnstableDoor(properties.UnstableDoorID, Material.iron, properties).setHardness(.2F).setUnlocalizedName("chaosDoor").setLightValue(.0F) );
|
unstableDoor = (new UnstableDoor(properties.UnstableDoorID, Material.iron, properties).setHardness(.2F).setUnlocalizedName("chaosDoor").setLightValue(.0F) );
|
||||||
dimensionalDoor = (DimensionalDoor) (new DimensionalDoor(properties.DimensionalDoorID, Material.iron, properties).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor"));
|
dimensionalDoor = (DimensionalDoor) (new DimensionalDoor(properties.DimensionalDoorID, Material.iron, properties).setHardness(1.0F).setResistance(2000.0F) .setUnlocalizedName("dimDoor"));
|
||||||
transTrapdoor = (TransTrapdoor) (new TransTrapdoor(properties.TransTrapdoorID, Material.wood).setHardness(1.0F) .setUnlocalizedName("dimHatch"));
|
transTrapdoor = (TransTrapdoor) (new TransTrapdoor(properties.TransTrapdoorID, Material.wood).setHardness(1.0F) .setUnlocalizedName("dimHatch"));
|
||||||
@@ -317,7 +320,11 @@ public class mod_pocketDim
|
|||||||
deathTracker.writeToFile();
|
deathTracker.writeToFile();
|
||||||
deathTracker = null;
|
deathTracker = null;
|
||||||
worldProperties = null;
|
worldProperties = null;
|
||||||
this.currrentSaveRootDirectory=null;
|
currrentSaveRootDirectory = null;
|
||||||
|
|
||||||
|
// Unregister all tick receivers from serverTickHandler to avoid leaking
|
||||||
|
// scheduled tasks between single-player game sessions
|
||||||
|
serverTickHandler.unregisterReceivers();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -336,6 +343,13 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
// Initialize a new DeathTracker
|
// Initialize a new DeathTracker
|
||||||
deathTracker = new DeathTracker(currrentSaveRootDirectory + "/DimensionalDoors/data/deaths.txt");
|
deathTracker = new DeathTracker(currrentSaveRootDirectory + "/DimensionalDoors/data/deaths.txt");
|
||||||
|
|
||||||
|
// Register regular tick receivers
|
||||||
|
// CustomLimboPopulator should be initialized before any provider instances are created
|
||||||
|
spawner = new CustomLimboPopulator(serverTickHandler, properties);
|
||||||
|
riftRegenerator = new RiftRegenerator(serverTickHandler);
|
||||||
|
limboDecayScheduler = new LimboDecayScheduler(serverTickHandler, limboDecay);
|
||||||
|
fastRiftRegenerator = new FastRiftRegenerator(serverTickHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -353,7 +367,7 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ChunkLoaderHelper.loadChunkForcedWorlds(event);
|
ChunkLoaderHelper.loadForcedChunkWorlds(event);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||||||
{
|
{
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.locations = new ConcurrentLinkedQueue<ChunkLocation>();
|
this.locations = new ConcurrentLinkedQueue<ChunkLocation>();
|
||||||
sender.registerForTicking(this, MONOLITH_SPAWNING_INTERVAL, false);
|
sender.registerReceiver(this, MONOLITH_SPAWNING_INTERVAL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class FastRiftRegenerator implements IRegularTickReceiver {
|
|||||||
|
|
||||||
public FastRiftRegenerator(IRegularTickSender sender)
|
public FastRiftRegenerator(IRegularTickSender sender)
|
||||||
{
|
{
|
||||||
sender.registerForTicking(this, RIFT_REGENERATION_INTERVAL, false);
|
sender.registerReceiver(this, RIFT_REGENERATION_INTERVAL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -33,6 +33,7 @@ public class FastRiftRegenerator implements IRegularTickReceiver {
|
|||||||
{
|
{
|
||||||
if (!locationsToRegen.isEmpty())
|
if (!locationsToRegen.isEmpty())
|
||||||
{
|
{
|
||||||
|
@SuppressWarnings("cast")
|
||||||
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: locationsToRegen)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.ticking;
|
|||||||
|
|
||||||
public interface IRegularTickSender {
|
public interface IRegularTickSender {
|
||||||
|
|
||||||
public void registerForTicking(IRegularTickReceiver receiver, int interval, boolean onTickStart);
|
public void registerReceiver(IRegularTickReceiver receiver, int interval, boolean onTickStart);
|
||||||
|
public void unregisterReceivers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package StevenDimDoors.mod_pocketDim.ticking;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.world.LimboDecay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles scheduling of periodic fast Limbo decay operations.
|
||||||
|
*/
|
||||||
|
public class LimboDecayScheduler implements IRegularTickReceiver {
|
||||||
|
|
||||||
|
private static final int LIMBO_DECAY_INTERVAL = 10; //Apply fast decay every 10 ticks
|
||||||
|
|
||||||
|
private LimboDecay decay;
|
||||||
|
|
||||||
|
public LimboDecayScheduler(IRegularTickSender tickSender, LimboDecay decay)
|
||||||
|
{
|
||||||
|
this.decay = decay;
|
||||||
|
tickSender.registerReceiver(this, LIMBO_DECAY_INTERVAL, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies fast Limbo decay periodically.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void notifyTick()
|
||||||
|
{
|
||||||
|
decay.applyRandomFastDecay();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
|||||||
|
|
||||||
public RiftRegenerator(IRegularTickSender sender)
|
public RiftRegenerator(IRegularTickSender sender)
|
||||||
{
|
{
|
||||||
sender.registerForTicking(this, RIFT_REGENERATION_INTERVAL, false);
|
sender.registerReceiver(this, RIFT_REGENERATION_INTERVAL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -14,19 +14,24 @@ public class ServerTickHandler implements ITickHandler, IRegularTickSender
|
|||||||
private int tickCount = 0;
|
private int tickCount = 0;
|
||||||
private ArrayList<RegularTickReceiverInfo> receivers;
|
private ArrayList<RegularTickReceiverInfo> receivers;
|
||||||
|
|
||||||
|
|
||||||
public ServerTickHandler()
|
public ServerTickHandler()
|
||||||
{
|
{
|
||||||
this.receivers = new ArrayList<RegularTickReceiverInfo>();
|
this.receivers = new ArrayList<RegularTickReceiverInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerForTicking(IRegularTickReceiver receiver, int interval, boolean onTickStart)
|
public void registerReceiver(IRegularTickReceiver receiver, int interval, boolean onTickStart)
|
||||||
{
|
{
|
||||||
RegularTickReceiverInfo info = new RegularTickReceiverInfo(receiver, interval, onTickStart);
|
RegularTickReceiverInfo info = new RegularTickReceiverInfo(receiver, interval, onTickStart);
|
||||||
receivers.add(info);
|
receivers.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterReceivers()
|
||||||
|
{
|
||||||
|
receivers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.ticking;
|
package StevenDimDoors.mod_pocketDim.world;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -13,13 +13,12 @@ import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
|||||||
* Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo
|
* Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo
|
||||||
* naturally change into stone, then cobble, then gravel, and finally Unraveled Fabric as time passes.
|
* naturally change into stone, then cobble, then gravel, and finally Unraveled Fabric as time passes.
|
||||||
*/
|
*/
|
||||||
public class LimboDecay implements IRegularTickReceiver {
|
public class LimboDecay {
|
||||||
|
|
||||||
private static final int MAX_DECAY_SPREAD_CHANCE = 100;
|
private static final int MAX_DECAY_SPREAD_CHANCE = 100;
|
||||||
private static final int DECAY_SPREAD_CHANCE = 50;
|
private static final int DECAY_SPREAD_CHANCE = 50;
|
||||||
private static final int CHUNK_SIZE = 16;
|
private static final int CHUNK_SIZE = 16;
|
||||||
private static final int SECTION_HEIGHT = 16;
|
private static final int SECTION_HEIGHT = 16;
|
||||||
private static final int LIMBO_DECAY_INTERVAL = 10; //Apply spread decay every 10 ticks
|
|
||||||
|
|
||||||
//Provides a reversed list of the block IDs that blocks cycle through during decay.
|
//Provides a reversed list of the block IDs that blocks cycle through during decay.
|
||||||
private final int[] decaySequence;
|
private final int[] decaySequence;
|
||||||
@@ -28,7 +27,7 @@ public class LimboDecay implements IRegularTickReceiver {
|
|||||||
private final DDProperties properties;
|
private final DDProperties properties;
|
||||||
private final int[] blocksImmuneToDecay;
|
private final int[] blocksImmuneToDecay;
|
||||||
|
|
||||||
public LimboDecay(IRegularTickSender tickSender, DDProperties properties)
|
public LimboDecay(DDProperties properties)
|
||||||
{
|
{
|
||||||
decaySequence = new int[] {
|
decaySequence = new int[] {
|
||||||
properties.LimboBlockID,
|
properties.LimboBlockID,
|
||||||
@@ -51,16 +50,6 @@ public class LimboDecay implements IRegularTickReceiver {
|
|||||||
|
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.random = new Random();
|
this.random = new Random();
|
||||||
tickSender.registerForTicking(this, LIMBO_DECAY_INTERVAL, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies fast Limbo decay periodically.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void notifyTick()
|
|
||||||
{
|
|
||||||
applyRandomFastDecay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +77,7 @@ public class LimboDecay implements IRegularTickReceiver {
|
|||||||
* Picks random blocks from each active chunk in Limbo and, if decay is applicable, converts them directly to Unraveled Fabric.
|
* Picks random blocks from each active chunk in Limbo and, if decay is applicable, converts them directly to Unraveled Fabric.
|
||||||
* This decay method is designed to stop players from avoiding Limbo decay by building floating structures.
|
* This decay method is designed to stop players from avoiding Limbo decay by building floating structures.
|
||||||
*/
|
*/
|
||||||
private void applyRandomFastDecay()
|
public void applyRandomFastDecay()
|
||||||
{
|
{
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
int sectionY;
|
int sectionY;
|
||||||
Reference in New Issue
Block a user