Fixed Slow Rift Regeneration and Various Improvements #173
@@ -7,13 +7,14 @@ import java.util.Random;
|
|||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.watcher.ClientLinkData;
|
||||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||||
|
|
||||||
public abstract class NewDimData
|
public abstract class NewDimData
|
||||||
@@ -134,6 +135,9 @@ public abstract class NewDimData
|
|||||||
protected boolean modified;
|
protected boolean modified;
|
||||||
public IUpdateWatcher<ClientLinkData> linkWatcher;
|
public IUpdateWatcher<ClientLinkData> linkWatcher;
|
||||||
|
|
||||||
|
// Don't write this field to a file - it should be recreated on startup
|
||||||
|
private Map<ChunkCoordIntPair, List<InnerDimLink>> chunkMapping;
|
||||||
|
|
||||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
||||||
IUpdateWatcher<ClientLinkData> linkWatcher)
|
IUpdateWatcher<ClientLinkData> linkWatcher)
|
||||||
{
|
{
|
||||||
@@ -204,23 +208,20 @@ public abstract class NewDimData
|
|||||||
|
|
||||||
public DimLink findNearestRift(World world, int range, int x, int y, int z)
|
public DimLink findNearestRift(World world, int range, int x, int y, int z)
|
||||||
{
|
{
|
||||||
//TODO: Rewrite this later to use an octtree
|
// Sanity check...
|
||||||
|
|
||||||
//Sanity check...
|
|
||||||
if (world.provider.dimensionId != id)
|
if (world.provider.dimensionId != id)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
|
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note: Only detect rifts at a distance > 1, so we ignore the rift
|
// Note: Only detect rifts at a distance > 0, so we ignore the rift
|
||||||
//that called this function and any adjacent rifts.
|
// at the center of the search space.
|
||||||
|
|
||||||
DimLink nearest = null;
|
|
||||||
DimLink link;
|
DimLink link;
|
||||||
|
DimLink nearest = null;
|
||||||
|
|
||||||
|
int i, j, k;
|
||||||
int distance;
|
int distance;
|
||||||
int minDistance = Integer.MAX_VALUE;
|
int minDistance = Integer.MAX_VALUE;
|
||||||
int i, j, k;
|
|
||||||
DDProperties properties = DDProperties.instance();
|
DDProperties properties = DDProperties.instance();
|
||||||
|
|
||||||
for (i = -range; i <= range; i++)
|
for (i = -range; i <= range; i++)
|
||||||
@@ -232,7 +233,7 @@ public abstract class NewDimData
|
|||||||
distance = getAbsoluteSum(i, j, k);
|
distance = getAbsoluteSum(i, j, k);
|
||||||
if (distance > 0 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
if (distance > 0 && distance < minDistance && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
||||||
{
|
{
|
||||||
link = getLink(x+i, y+j, z+k);
|
link = getLink(x + i, y + j, z + k);
|
||||||
if (link != null)
|
if (link != null)
|
||||||
{
|
{
|
||||||
nearest = link;
|
nearest = link;
|
||||||
@@ -248,23 +249,19 @@ public abstract class NewDimData
|
|||||||
|
|
||||||
public ArrayList<DimLink> findRiftsInRange(World world, int range, int x, int y, int z)
|
public ArrayList<DimLink> findRiftsInRange(World world, int range, int x, int y, int z)
|
||||||
{
|
{
|
||||||
ArrayList<DimLink> links = new ArrayList<DimLink>();
|
// Sanity check...
|
||||||
//TODO: Rewrite this later to use an octtree
|
|
||||||
|
|
||||||
//Sanity check...
|
|
||||||
if (world.provider.dimensionId != id)
|
if (world.provider.dimensionId != id)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
|
throw new IllegalArgumentException("Attempted to search for links in a World instance for a different dimension!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Note: Only detect rifts at a distance > 1, so we ignore the rift
|
// Note: Only detect rifts at a distance > 0, so we ignore the rift
|
||||||
//that called this function and any adjacent rifts.
|
// at the center of the search space.
|
||||||
|
|
||||||
DimLink link;
|
|
||||||
|
|
||||||
int distance;
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
int distance;
|
||||||
|
DimLink link;
|
||||||
DDProperties properties = DDProperties.instance();
|
DDProperties properties = DDProperties.instance();
|
||||||
|
ArrayList<DimLink> links = new ArrayList<DimLink>();
|
||||||
|
|
||||||
for (i = -range; i <= range; i++)
|
for (i = -range; i <= range; i++)
|
||||||
{
|
{
|
||||||
@@ -275,7 +272,7 @@ public abstract class NewDimData
|
|||||||
distance = getAbsoluteSum(i, j, k);
|
distance = getAbsoluteSum(i, j, k);
|
||||||
if (distance > 0 && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
if (distance > 0 && world.getBlockId(x + i, y + j, z + k) == properties.RiftBlockID)
|
||||||
{
|
{
|
||||||
link = getLink(x+i, y+j, z+k);
|
link = getLink(x + i, y + j, z + k);
|
||||||
if (link != null)
|
if (link != null)
|
||||||
{
|
{
|
||||||
links.add(link);
|
links.add(link);
|
||||||
|
|||||||
Reference in New Issue
Block a user