Rewrote All the Things #81
@@ -16,7 +16,8 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||
@@ -312,7 +313,7 @@ public class DDTeleporter
|
||||
* @param link - the link the player is using to teleport; sends the player to its destination
|
||||
* @param player - the instance of the player to be teleported
|
||||
*/
|
||||
public static void traverseDimDoor(World world, IDimLink link, Entity entity)
|
||||
public static void traverseDimDoor(World world, DimLink link, Entity entity)
|
||||
{
|
||||
if (world == null)
|
||||
{
|
||||
@@ -349,7 +350,7 @@ public class DDTeleporter
|
||||
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
private static boolean initializeDestination(IDimLink link, DDProperties properties)
|
||||
private static boolean initializeDestination(DimLink link, DDProperties properties)
|
||||
{
|
||||
//FIXME: Change this later to support rooms that have been wiped and must be regenerated.
|
||||
if (link.hasDestination())
|
||||
@@ -362,11 +363,11 @@ public class DDTeleporter
|
||||
//FIXME: Add code for restoring the destination-side door.
|
||||
switch (link.linkType())
|
||||
{
|
||||
case IDimLink.TYPE_DUNGEON:
|
||||
case LinkTypes.DUNGEON:
|
||||
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
||||
case IDimLink.TYPE_POCKET:
|
||||
case LinkTypes.POCKET:
|
||||
return PocketBuilder.generateNewPocket(link, properties);
|
||||
case IDimLink.TYPE_NORMAL:
|
||||
case LinkTypes.NORMAL:
|
||||
return true;
|
||||
default:
|
||||
throw new IllegalArgumentException("link has an unrecognized link type.");
|
||||
|
||||
@@ -20,7 +20,8 @@ import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
@@ -59,7 +60,7 @@ public class DimensionalDoor extends BlockContainer
|
||||
{
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
|
||||
IDimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity);
|
||||
@@ -169,10 +170,10 @@ public class DimensionalDoor extends BlockContainer
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
IDimLink link = dimension.getLink(x, y, z);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
dimension.createLink(x, y, z, IDimLink.TYPE_POCKET);
|
||||
dimension.createLink(x, y, z, LinkTypes.POCKET);
|
||||
}
|
||||
}
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -66,7 +66,7 @@ public class TransientDoor extends WarpDoor
|
||||
{
|
||||
this.onPoweredBlockChange(world, x, y, z, false);
|
||||
|
||||
IDimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
DimLink link = PocketManager.getLink(x, y, z, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
DDTeleporter.traverseDimDoor(world, link, entity);
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -54,7 +54,7 @@ public class UnstableDoor extends DimensionalDoor
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
dimension.createLink(x, y, z, IDimLink.TYPE_RANDOM);
|
||||
dimension.createLink(x, y, z, LinkTypes.RANDOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -38,10 +39,10 @@ public class WarpDoor extends DimensionalDoor
|
||||
if (!world.isRemote && world.getBlockId(x, y - 1, z) == this.blockID)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
IDimLink link = dimension.getLink(x, y, z);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (link == null)
|
||||
{
|
||||
dimension.createLink(x, y, z, IDimLink.TYPE_SAFE_EXIT);
|
||||
dimension.createLink(x, y, z, LinkTypes.SAFE_EXIT);
|
||||
}
|
||||
}
|
||||
world.setBlockTileEntity(x, y, z, this.createNewTileEntity(world));
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
@@ -55,7 +55,7 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
}
|
||||
else
|
||||
{
|
||||
IDimLink link;
|
||||
DimLink link;
|
||||
DungeonData result;
|
||||
int x = MathHelper.floor_double(sender.posX);
|
||||
int y = MathHelper.floor_double(sender.posY);
|
||||
|
||||
77
StevenDimDoors/mod_pocketDim/core/DimLink.java
Normal file
77
StevenDimDoors/mod_pocketDim/core/DimLink.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public abstract class DimLink
|
||||
{
|
||||
private static final int EXPECTED_CHILDREN = 2;
|
||||
|
||||
protected Point4D source;
|
||||
protected DimLink parent;
|
||||
protected LinkTail tail;
|
||||
protected ArrayList<DimLink> children;
|
||||
|
||||
public DimLink(Point4D source, DimLink parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.source = source;
|
||||
this.tail = parent.tail;
|
||||
this.children = new ArrayList<DimLink>(EXPECTED_CHILDREN);
|
||||
parent.children.add(this);
|
||||
}
|
||||
|
||||
public DimLink(Point4D source, int linkType)
|
||||
{
|
||||
if (linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX)
|
||||
{
|
||||
throw new IllegalArgumentException("The specified link type is invalid.");
|
||||
}
|
||||
|
||||
this.parent = null;
|
||||
this.source = source;
|
||||
this.tail = new LinkTail(linkType, null);
|
||||
this.children = new ArrayList<DimLink>(EXPECTED_CHILDREN);
|
||||
}
|
||||
|
||||
public Point4D source()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
public Point4D destination()
|
||||
{
|
||||
return tail.getDestination();
|
||||
}
|
||||
|
||||
public boolean hasDestination()
|
||||
{
|
||||
return (tail.getDestination() != null);
|
||||
}
|
||||
|
||||
public Iterable<DimLink> children()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
public int childCount()
|
||||
{
|
||||
return children.size();
|
||||
}
|
||||
|
||||
public DimLink parent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public int linkType()
|
||||
{
|
||||
return tail.getLinkType();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return source + " -> " + (hasDestination() ? destination() : "");
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
|
||||
public interface IDimLink
|
||||
{
|
||||
public final int TYPE_ENUM_MIN = 0;
|
||||
public final int TYPE_ENUM_MAX = 8;
|
||||
|
||||
public final int TYPE_NORMAL = 0;
|
||||
public final int TYPE_LIMBO = 1;
|
||||
public final int TYPE_POCKET = 2;
|
||||
public final int TYPE_DUNGEON = 3;
|
||||
public final int TYPE_RANDOM = 4;
|
||||
public final int TYPE_DUNGEON_EXIT = 5;
|
||||
public final int TYPE_SAFE_EXIT = 6;
|
||||
public final int TYPE_UNSAFE_EXIT = 7;
|
||||
public final int TYPE_RANDOM_DUNGEON = 8;
|
||||
|
||||
public Point4D source();
|
||||
public Point4D destination();
|
||||
public boolean hasDestination();
|
||||
public Iterable<IDimLink> children();
|
||||
public int childCount();
|
||||
public IDimLink parent();
|
||||
public int linkType();
|
||||
}
|
||||
19
StevenDimDoors/mod_pocketDim/core/LinkTypes.java
Normal file
19
StevenDimDoors/mod_pocketDim/core/LinkTypes.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
public class LinkTypes
|
||||
{
|
||||
private LinkTypes() { }
|
||||
|
||||
public static final int ENUM_MIN = 0;
|
||||
public static final int ENUM_MAX = 8;
|
||||
|
||||
public static final int NORMAL = 0;
|
||||
public static final int LIMBO = 1;
|
||||
public static final int POCKET = 2;
|
||||
public static final int DUNGEON = 3;
|
||||
public static final int RANDOM = 4;
|
||||
public static final int DUNGEON_EXIT = 5;
|
||||
public static final int SAFE_EXIT = 6;
|
||||
public static final int UNSAFE_EXIT = 7;
|
||||
public static final int RANDOM_DUNGEON = 8;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
package StevenDimDoors.mod_pocketDim.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -15,92 +16,29 @@ import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
|
||||
public abstract class NewDimData
|
||||
{
|
||||
private static class DimLink implements IDimLink
|
||||
private static class InnerDimLink extends DimLink
|
||||
{
|
||||
//DimLink is an inner class here to make it immutable to code outside NewDimData
|
||||
|
||||
private static final int EXPECTED_CHILDREN = 2;
|
||||
|
||||
private Point4D source;
|
||||
private DimLink parent;
|
||||
private LinkTail tail;
|
||||
private ArrayList<IDimLink> children;
|
||||
|
||||
public DimLink(Point4D source, DimLink parent)
|
||||
public InnerDimLink(Point4D source, DimLink parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.source = source;
|
||||
this.tail = parent.tail;
|
||||
this.children = new ArrayList<IDimLink>(EXPECTED_CHILDREN);
|
||||
parent.children.add(this);
|
||||
super(source, parent);
|
||||
}
|
||||
|
||||
public DimLink(Point4D source, int linkType)
|
||||
public InnerDimLink(Point4D source, int linkType)
|
||||
{
|
||||
if (linkType < IDimLink.TYPE_ENUM_MIN || linkType > IDimLink.TYPE_ENUM_MAX)
|
||||
{
|
||||
throw new IllegalArgumentException("The specified link type is invalid.");
|
||||
}
|
||||
|
||||
this.parent = null;
|
||||
this.source = source;
|
||||
this.tail = new LinkTail(linkType, null);
|
||||
this.children = new ArrayList<IDimLink>(EXPECTED_CHILDREN);
|
||||
super(source, linkType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4D source()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point4D destination()
|
||||
{
|
||||
return tail.getDestination();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDestination()
|
||||
{
|
||||
return (tail.getDestination() != null);
|
||||
}
|
||||
|
||||
public void setDestination(int x, int y, int z, NewDimData dimension)
|
||||
{
|
||||
tail.setDestination(new Point4D(x, y, z, dimension.id()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IDimLink> children()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int childCount()
|
||||
{
|
||||
return children.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDimLink parent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int linkType()
|
||||
{
|
||||
return tail.getLinkType();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
//Release children
|
||||
for (IDimLink child : children)
|
||||
for (DimLink child : children)
|
||||
{
|
||||
((DimLink) child).parent = null;
|
||||
((InnerDimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
@@ -115,7 +53,7 @@ public abstract class NewDimData
|
||||
tail = new LinkTail(0, null);
|
||||
}
|
||||
|
||||
public void overwrite(DimLink nextParent)
|
||||
public boolean overwrite(InnerDimLink nextParent)
|
||||
{
|
||||
if (nextParent == null)
|
||||
{
|
||||
@@ -125,13 +63,13 @@ public abstract class NewDimData
|
||||
if (this == nextParent)
|
||||
{
|
||||
//Ignore this request silently
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//Release children
|
||||
for (IDimLink child : children)
|
||||
for (DimLink child : children)
|
||||
{
|
||||
((DimLink) child).parent = null;
|
||||
((InnerDimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
@@ -145,14 +83,15 @@ public abstract class NewDimData
|
||||
parent = nextParent;
|
||||
tail = nextParent.tail;
|
||||
nextParent.children.add(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void overwrite(int linkType)
|
||||
{
|
||||
//Release children
|
||||
for (IDimLink child : children)
|
||||
for (DimLink child : children)
|
||||
{
|
||||
((DimLink) child).parent = null;
|
||||
((InnerDimLink) child).parent = null;
|
||||
}
|
||||
children.clear();
|
||||
|
||||
@@ -166,12 +105,6 @@ public abstract class NewDimData
|
||||
parent = null;
|
||||
tail = new LinkTail(linkType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return source + " -> " + (hasDestination() ? destination() : "");
|
||||
}
|
||||
|
||||
public IOpaqueMessage toMessage()
|
||||
{
|
||||
@@ -187,8 +120,8 @@ public abstract class NewDimData
|
||||
private static Random random = new Random();
|
||||
|
||||
private final int id;
|
||||
private final Map<Point4D, DimLink> linkMapping;
|
||||
private final List<DimLink> linkList;
|
||||
private final Map<Point4D, InnerDimLink> linkMapping;
|
||||
private final List<InnerDimLink> linkList;
|
||||
private final boolean isDungeon;
|
||||
private boolean isFilled;
|
||||
private final int depth;
|
||||
@@ -216,8 +149,8 @@ public abstract class NewDimData
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.linkMapping = new TreeMap<Point4D, DimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<DimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.children = new ArrayList<NewDimData>();
|
||||
this.parent = parent;
|
||||
this.packDepth = 0;
|
||||
@@ -247,7 +180,7 @@ public abstract class NewDimData
|
||||
protected abstract IOpaqueMessage toMessage();
|
||||
protected abstract IOpaqueMessage toKey();
|
||||
|
||||
public IDimLink 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
|
||||
|
||||
@@ -260,8 +193,8 @@ public abstract class NewDimData
|
||||
//Note: Only detect rifts at a distance > 1, so we ignore the rift
|
||||
//that called this function and any adjacent rifts.
|
||||
|
||||
IDimLink nearest = null;
|
||||
IDimLink link;
|
||||
DimLink nearest = null;
|
||||
DimLink link;
|
||||
|
||||
int distance;
|
||||
int minDistance = Integer.MAX_VALUE;
|
||||
@@ -296,18 +229,18 @@ public abstract class NewDimData
|
||||
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
||||
}
|
||||
|
||||
public IDimLink createLink(int x, int y, int z, int linkType)
|
||||
public DimLink createLink(int x, int y, int z, int linkType)
|
||||
{
|
||||
return createLink(new Point4D(x, y, z, id), linkType);
|
||||
}
|
||||
|
||||
private IDimLink createLink(Point4D source, int linkType)
|
||||
private DimLink createLink(Point4D source, int linkType)
|
||||
{
|
||||
//Return an existing link if there is one to avoid creating multiple links starting at the same point.
|
||||
DimLink link = linkMapping.get(source);
|
||||
InnerDimLink link = linkMapping.get(source);
|
||||
if (link == null)
|
||||
{
|
||||
link = new DimLink(source, linkType);
|
||||
link = new InnerDimLink(source, linkType);
|
||||
linkMapping.put(source, link);
|
||||
linkList.add(link);
|
||||
}
|
||||
@@ -320,44 +253,49 @@ public abstract class NewDimData
|
||||
return link;
|
||||
}
|
||||
|
||||
public IDimLink createChildLink(int x, int y, int z, IDimLink parent)
|
||||
public DimLink createChildLink(int x, int y, int z, DimLink parent)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
throw new IllegalArgumentException("parent cannot be null.");
|
||||
}
|
||||
|
||||
return createChildLink(new Point4D(x, y, z, id), (DimLink) parent);
|
||||
return createChildLink(new Point4D(x, y, z, id), (InnerDimLink) parent);
|
||||
}
|
||||
|
||||
private IDimLink createChildLink(Point4D source, DimLink parent)
|
||||
private DimLink createChildLink(Point4D source, InnerDimLink parent)
|
||||
{
|
||||
//To avoid having multiple links at a single point, if we find an existing link then we overwrite
|
||||
//its destination data instead of creating a new instance.
|
||||
|
||||
DimLink link = linkMapping.get(source);
|
||||
InnerDimLink link = linkMapping.get(source);
|
||||
if (link == null)
|
||||
{
|
||||
link = new DimLink(source, parent);
|
||||
link = new InnerDimLink(source, parent);
|
||||
linkMapping.put(source, link);
|
||||
linkList.add(link);
|
||||
|
||||
//Link created!
|
||||
linkWatcher.onCreated(link.toMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
link.overwrite(parent);
|
||||
if (link.overwrite(parent))
|
||||
{
|
||||
//Link created!
|
||||
linkWatcher.onCreated(link.toMessage());
|
||||
}
|
||||
}
|
||||
//Link created!
|
||||
linkWatcher.onCreated(link.toMessage());
|
||||
return link;
|
||||
}
|
||||
|
||||
public boolean deleteLink(IDimLink link)
|
||||
public boolean deleteLink(DimLink link)
|
||||
{
|
||||
if (link.source().getDimension() != id)
|
||||
{
|
||||
throw new IllegalArgumentException("Attempted to delete a link from another dimension.");
|
||||
}
|
||||
DimLink target = linkMapping.remove(link.source());
|
||||
InnerDimLink target = linkMapping.remove(link.source());
|
||||
if (target != null)
|
||||
{
|
||||
linkList.remove(target);
|
||||
@@ -371,7 +309,7 @@ public abstract class NewDimData
|
||||
public boolean deleteLink(int x, int y, int z)
|
||||
{
|
||||
Point4D location = new Point4D(x, y, z, id);
|
||||
DimLink target = linkMapping.remove(location);
|
||||
InnerDimLink target = linkMapping.remove(location);
|
||||
if (target != null)
|
||||
{
|
||||
linkList.remove(target);
|
||||
@@ -382,13 +320,13 @@ public abstract class NewDimData
|
||||
return (target != null);
|
||||
}
|
||||
|
||||
public IDimLink getLink(int x, int y, int z)
|
||||
public DimLink getLink(int x, int y, int z)
|
||||
{
|
||||
Point4D location = new Point4D(x, y, z, id);
|
||||
return linkMapping.get(location);
|
||||
}
|
||||
|
||||
public IDimLink getLink(Point4D location)
|
||||
public DimLink getLink(Point4D location)
|
||||
{
|
||||
if (location.getDimension() != id)
|
||||
return null;
|
||||
@@ -396,9 +334,9 @@ public abstract class NewDimData
|
||||
return linkMapping.get(location);
|
||||
}
|
||||
|
||||
public ArrayList<IDimLink> getAllLinks()
|
||||
public ArrayList<DimLink> getAllLinks()
|
||||
{
|
||||
ArrayList<IDimLink> results = new ArrayList<IDimLink>(linkMapping.size());
|
||||
ArrayList<DimLink> results = new ArrayList<DimLink>(linkMapping.size());
|
||||
results.addAll(linkMapping.values());
|
||||
return results;
|
||||
}
|
||||
@@ -480,7 +418,7 @@ public abstract class NewDimData
|
||||
return children;
|
||||
}
|
||||
|
||||
public void initializeDungeon(int originX, int originY, int originZ, int orientation, IDimLink incoming, DungeonData dungeon)
|
||||
public void initializeDungeon(int originX, int originY, int originZ, int orientation, DimLink incoming, DungeonData dungeon)
|
||||
{
|
||||
if (!isDungeon)
|
||||
{
|
||||
@@ -532,7 +470,7 @@ public abstract class NewDimData
|
||||
}
|
||||
}
|
||||
|
||||
public void initializePocket(int originX, int originY, int originZ, int orientation, IDimLink incoming)
|
||||
public void initializePocket(int originX, int originY, int originZ, int orientation, DimLink incoming)
|
||||
{
|
||||
if (!isPocketDimension())
|
||||
{
|
||||
@@ -550,15 +488,15 @@ public abstract class NewDimData
|
||||
dimWatcher.onUpdated(this.toMessage());
|
||||
}
|
||||
|
||||
public void setDestination(IDimLink incoming, int x, int y, int z)
|
||||
public void setDestination(DimLink incoming, int x, int y, int z)
|
||||
{
|
||||
DimLink link = (DimLink) incoming;
|
||||
InnerDimLink link = (InnerDimLink) incoming;
|
||||
link.setDestination(x, y, z, this);
|
||||
//Raise update event
|
||||
linkWatcher.onUpdated(link.toMessage());
|
||||
}
|
||||
|
||||
public IDimLink getRandomLink()
|
||||
public DimLink getRandomLink()
|
||||
{
|
||||
if (linkMapping.isEmpty())
|
||||
{
|
||||
|
||||
@@ -259,7 +259,7 @@ public class PocketManager
|
||||
//Does not actually unregister the rift data, see deleteRift for that.
|
||||
|
||||
NewDimData dimension = getDimensionData(world);
|
||||
IDimLink nearest = dimension.findNearestRift(world, range, x, y, z);
|
||||
DimLink nearest = dimension.findNearestRift(world, range, x, y, z);
|
||||
|
||||
if (nearest != null)
|
||||
{
|
||||
@@ -339,12 +339,12 @@ public class PocketManager
|
||||
return dimensionData.values();
|
||||
}
|
||||
|
||||
public static IDimLink getLink(int x, int y, int z, World world)
|
||||
public static DimLink getLink(int x, int y, int z, World world)
|
||||
{
|
||||
return getLink(x, y, z, world.provider.dimensionId);
|
||||
}
|
||||
|
||||
public static IDimLink getLink(int x, int y, int z, int dimensionID)
|
||||
public static DimLink getLink(int x, int y, int z, int dimensionID)
|
||||
{
|
||||
NewDimData dimension = dimensionData.get(dimensionID);
|
||||
if (dimension != null)
|
||||
|
||||
@@ -17,7 +17,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||
@@ -167,7 +168,7 @@ public class DungeonSchematic extends Schematic {
|
||||
return new DungeonSchematic(Schematic.copyFromWorld(world, x, y, z, width, height, length, doCompactBounds));
|
||||
}
|
||||
|
||||
public void copyToWorld(World world, Point3D pocketCenter, int dungeonOrientation, IDimLink entryLink, Random random)
|
||||
public void copyToWorld(World world, Point3D pocketCenter, int dungeonOrientation, DimLink entryLink, Random random)
|
||||
{
|
||||
//TODO: This function is an improvised solution so we can get the release moving. In the future,
|
||||
//we should generalize block transformations and implement support for them at the level of Schematic,
|
||||
@@ -224,7 +225,7 @@ public class DungeonSchematic extends Schematic {
|
||||
setUpDungeon(PocketManager.getDimensionData(world), world, pocketCenter, turnAngle, entryLink, random);
|
||||
}
|
||||
|
||||
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, IDimLink entryLink, Random random)
|
||||
private void setUpDungeon(NewDimData dimension, World world, Point3D pocketCenter, int turnAngle, DimLink entryLink, Random random)
|
||||
{
|
||||
//Transform dungeon corners
|
||||
Point3D minCorner = new Point3D(0, 0, 0);
|
||||
@@ -282,9 +283,9 @@ public class DungeonSchematic extends Schematic {
|
||||
}
|
||||
}
|
||||
|
||||
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, IDimLink entryLink)
|
||||
private static void createEntranceReverseLink(NewDimData dimension, Point3D pocketCenter, DimLink entryLink)
|
||||
{
|
||||
IDimLink link = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), IDimLink.TYPE_NORMAL);
|
||||
DimLink link = dimension.createLink(pocketCenter.getX(), pocketCenter.getY(), pocketCenter.getZ(), LinkTypes.NORMAL);
|
||||
Point4D destination = link.source();
|
||||
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||
prevDim.setDestination(link, destination.getX(), destination.getY(), destination.getZ());
|
||||
@@ -295,7 +296,7 @@ public class DungeonSchematic extends Schematic {
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
Point3D location = point.clone();
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), IDimLink.TYPE_DUNGEON_EXIT);
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON_EXIT);
|
||||
}
|
||||
|
||||
private static void createDimensionalDoorLink(NewDimData dimension, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
|
||||
@@ -303,7 +304,7 @@ public class DungeonSchematic extends Schematic {
|
||||
//Transform the door's location to the pocket coordinate system
|
||||
Point3D location = point.clone();
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), IDimLink.TYPE_DUNGEON);
|
||||
dimension.createLink(location.getX(), location.getY(), location.getZ(), LinkTypes.DUNGEON);
|
||||
}
|
||||
|
||||
private static void spawnMonolith(World world, Point3D point, Point3D entrance, int rotation, Point3D pocketCenter)
|
||||
|
||||
@@ -21,7 +21,8 @@ import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
@@ -274,11 +275,11 @@ public class DungeonHelper
|
||||
return pack;
|
||||
}
|
||||
|
||||
public IDimLink createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
public DimLink createCustomDungeonDoor(World world, int x, int y, int z)
|
||||
{
|
||||
//Create a link above the specified position. Link to a new pocket dimension.
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
IDimLink link = dimension.createLink(x, y + 1, z, IDimLink.TYPE_POCKET);
|
||||
DimLink link = dimension.createLink(x, y + 1, z, LinkTypes.POCKET);
|
||||
|
||||
//Place a Warp Door linked to that pocket
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 3, mod_pocketDim.warpDoor);
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public abstract class BaseItemDoor extends ItemDoor
|
||||
@@ -114,7 +114,7 @@ public abstract class BaseItemDoor extends ItemDoor
|
||||
{
|
||||
if (world.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
|
||||
{
|
||||
IDimLink link = PocketManager.getLink(hit.blockX, hit.blockY, hit.blockZ, world.provider.dimensionId);
|
||||
DimLink link = PocketManager.getLink(hit.blockX, hit.blockY, hit.blockZ, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
int x = hit.blockX;
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -187,7 +187,7 @@ public class ItemRiftBlade extends ItemSword
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
if (!dimension.isPocketDimension() && dimension.getLink(x, y + 1, z) == null)
|
||||
{
|
||||
dimension.createLink(x, y + 1, z, IDimLink.TYPE_POCKET);
|
||||
dimension.createLink(x, y + 1, z, LinkTypes.POCKET);
|
||||
player.worldObj.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, orientation, mod_pocketDim.transientDoor);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
@@ -66,8 +67,8 @@ public class ItemRiftSignature extends Item
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
IDimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), IDimLink.TYPE_NORMAL);
|
||||
IDimLink reverse = destinationDimension.createLink(x, y, z, IDimLink.TYPE_NORMAL);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL);
|
||||
DimLink reverse = destinationDimension.createLink(x, y, z, LinkTypes.NORMAL);
|
||||
destinationDimension.setDestination(link, x, y, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||
@@ -46,7 +46,7 @@ public class RiftRegenerator implements IRegularTickReceiver {
|
||||
{
|
||||
for (int count = 0; count < RIFTS_REGENERATED_PER_DIMENSION; count++)
|
||||
{
|
||||
IDimLink link = dimension.getRandomLink();
|
||||
DimLink link = dimension.getRandomLink();
|
||||
Point4D source = link.source();
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, source.getX(), source.getY(), source.getZ()))
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
@@ -38,7 +38,7 @@ public class TileEntityRift extends TileEntity
|
||||
public int age = 0;
|
||||
|
||||
public HashMap<Integer, double[]> renderingCenters = new HashMap<Integer, double[]>();
|
||||
public IDimLink nearestRiftData;
|
||||
public DimLink nearestRiftData;
|
||||
public int spawnedEndermenID=0;
|
||||
DataWatcher watcher = new DataWatcher();
|
||||
|
||||
@@ -240,7 +240,7 @@ public class TileEntityRift extends TileEntity
|
||||
if (growCount < 100)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(worldObj);
|
||||
IDimLink link = dimension.getLink(xCoord, yCoord, zCoord);
|
||||
DimLink link = dimension.getLink(xCoord, yCoord, zCoord);
|
||||
if (link != null)
|
||||
{
|
||||
if (!this.hasGrownRifts && random.nextInt(3) == 0)
|
||||
|
||||
@@ -9,7 +9,8 @@ import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||
@@ -57,7 +58,7 @@ public class GatewayGenerator implements IWorldGenerator
|
||||
int attempts;
|
||||
int correction;
|
||||
boolean valid;
|
||||
IDimLink link;
|
||||
DimLink link;
|
||||
NewDimData dimension;
|
||||
|
||||
//Check if we're generating things in the Nether
|
||||
@@ -97,7 +98,7 @@ public class GatewayGenerator implements IWorldGenerator
|
||||
if (link == null)
|
||||
{
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z, IDimLink.TYPE_POCKET);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.POCKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -132,7 +133,7 @@ public class GatewayGenerator implements IWorldGenerator
|
||||
{
|
||||
//Create a partial link to a dungeon.
|
||||
dimension = PocketManager.getDimensionData(world);
|
||||
link = dimension.createLink(x, y + 1, z, IDimLink.TYPE_DUNGEON);
|
||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
|
||||
|
||||
//If the current dimension isn't Limbo, build a Rift Gateway out of Stone Bricks
|
||||
if (dimension.id() != properties.LimboDimensionID)
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||
import StevenDimDoors.mod_pocketDim.core.IDimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
@@ -36,7 +36,7 @@ public class PocketBuilder
|
||||
|
||||
private PocketBuilder() { }
|
||||
|
||||
public static boolean generateNewDungeonPocket(IDimLink link, DDProperties properties)
|
||||
public static boolean generateNewDungeonPocket(DimLink link, DDProperties properties)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ public class PocketBuilder
|
||||
schematic.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(IDimLink link, DDProperties properties)
|
||||
public static boolean generateNewPocket(DimLink link, DDProperties properties)
|
||||
{
|
||||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties);
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class PocketBuilder
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public static boolean generateNewPocket(IDimLink link, int size, int wallThickness, DDProperties properties)
|
||||
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties)
|
||||
{
|
||||
if (link == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user