Udated and moved legacy support code (DimData, LinkData, OldSaveImporter) to their own package.

Gave them better names, renamed NewDimData to DimData since it's no longer new.
This commit is contained in:
Michael Zanga 2016-08-08 10:53:01 -04:00
parent 1e37e50712
commit cd904e9d96
46 changed files with 552 additions and 793 deletions

View file

@ -6,7 +6,7 @@ import com.zixiken.dimdoors.network.DimDoorsNetwork;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.NetHandlerPlayServer;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import net.minecraftforge.common.network.ForgeMessage; import net.minecraftforge.common.network.ForgeMessage;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -22,7 +22,7 @@ public class ConnectionHandler {
if (FMLCommonHandler.instance().getSide() == Side.SERVER) { if (FMLCommonHandler.instance().getSide() == Side.SERVER) {
NetHandlerPlayServer server = ((NetHandlerPlayServer)event.handler); NetHandlerPlayServer server = ((NetHandlerPlayServer)event.handler);
FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER); FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER);
for (NewDimData data : PocketManager.getDimensions()) { for (DimData data : PocketManager.getDimensions()) {
try { try {
int id = data.id(); int id = data.id();
if (data.isPocketDimension() || id == DDProperties.instance().LimboDimensionID) if (data.isPocketDimension() || id == DDProperties.instance().LimboDimensionID)

View file

@ -10,15 +10,13 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Random; import java.util.Random;
public class DeathTracker public class DeathTracker {
{
private ArrayList<String> usernameList; private ArrayList<String> usernameList;
private HashSet<String> usernameSet; private HashSet<String> usernameSet;
private String filePath; private String filePath;
private boolean modified; private boolean modified;
public DeathTracker(String filePath) public DeathTracker(String filePath) {
{
this.usernameList = new ArrayList<String>(); this.usernameList = new ArrayList<String>();
this.usernameSet = new HashSet<String>(); this.usernameSet = new HashSet<String>();
this.filePath = filePath; this.filePath = filePath;
@ -27,72 +25,47 @@ public class DeathTracker
readFromFile(); readFromFile();
} }
private void readFromFile() private void readFromFile() {
{ try {
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath))); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)));
for (String line = reader.readLine(); line != null; line = reader.readLine()) for (String line = reader.readLine(); line != null; line = reader.readLine()) {
{
line = line.trim(); line = line.trim();
if (!line.isEmpty()) if (!line.isEmpty()) usernameSet.add(line);
{
usernameSet.add(line);
}
} }
reader.close(); reader.close();
} }
catch (FileNotFoundException e) { } catch (FileNotFoundException e) {}
catch (IOException e) catch (IOException e) {
{
System.err.println("An unexpected exception occurred while trying to read DeathTracker data:"); System.err.println("An unexpected exception occurred while trying to read DeathTracker data:");
System.err.println(e.toString()); System.err.println(e.toString());
} }
usernameList.addAll(usernameSet); usernameList.addAll(usernameSet);
} }
public void writeToFile() public void writeToFile() {
{ try {
try
{
PrintWriter writer = new PrintWriter(filePath); PrintWriter writer = new PrintWriter(filePath);
for (String username : usernameList) for (String username : usernameList) writer.println(username);
{
writer.println(username);
}
writer.close(); writer.close();
modified = false; modified = false;
} } catch (FileNotFoundException e) {
catch (FileNotFoundException e)
{
System.err.println("An unexpected exception occurred while trying to read DeathTracker data:"); System.err.println("An unexpected exception occurred while trying to read DeathTracker data:");
System.err.println(e.toString()); System.err.println(e.toString());
} }
} }
public boolean isModified() public boolean isModified() {return modified;}
{
return modified;
}
public boolean isEmpty() public boolean isEmpty() {return usernameList.isEmpty();}
{
return usernameList.isEmpty();
}
public String getRandomUsername(Random random) public String getRandomUsername(Random random) {
{
if (usernameList.isEmpty()) if (usernameList.isEmpty())
{ throw new IllegalStateException("Cannot retrieve a random username from an empty list.");
throw new IllegalStateException("Cannot retrieve a random username from an empty list.");
}
return usernameList.get(random.nextInt(usernameList.size())); return usernameList.get(random.nextInt(usernameList.size()));
} }
public boolean addUsername(String username) public boolean addUsername(String username) {
{ if (usernameSet.add(username)) {
if (usernameSet.add(username))
{
usernameList.add(username); usernameList.add(username);
modified = true; modified = true;
return true; return true;

View file

@ -1,258 +0,0 @@
package com.zixiken.dimdoors;
/**Class that contains all the information about a specific dim that is pertienent to Dim Doors. Holds all the rifts present in the dim sorted by x,y,z and
* wether or not the dim is a pocket or not, along with its depth.
* @Return
*/
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import com.zixiken.dimdoors.config.DDProperties;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@Deprecated
public class DimData implements Serializable
{
public int dimID;
public int depth;
public int dimOrientation;
public World world;
public LinkData exitDimLink;
public boolean isPocket;
public boolean hasBeenFilled=false;
public boolean hasDoor=false;
public boolean isDimRandomRift=false;
public Object dungeonGenerator = null;
//public boolean isPrivatePocket = false;
public HashMap<Integer, HashMap<Integer, HashMap<Integer, LinkData>>> linksInThisDim = new HashMap();
HashMap<Integer, LinkData> dimX;
HashMap<Integer, HashMap<Integer, LinkData>> dimY ;
static final long serialVersionUID = 454342L;
public DimData(int dimID, boolean isPocket, int depth, LinkData exitLinkData)
{
this.dimID=dimID;
this.depth=depth;
this.isPocket=isPocket;
this.exitDimLink= exitLinkData;
}
public DimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ)
{
this(dimID, isPocket, depth, new LinkData(exitLinkDimID, exitX, exitY, exitZ));
}
public LinkData findNearestRift(World world, int range, int x, int y, int z)
{
LinkData nearest=null;
float distance=range+1;
int i=-range;
int j=-range;
int k=-range;
DDProperties properties = DDProperties.instance();
while (i<range)
{
while (j<range)
{
while (k<range)
{
if (world.getBlock(x+i, y+j, z+k) == DimDoors.blockRift && MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)<distance)
{
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)!=0)
{
nearest=this.findLinkAtCoords(x+i, y+j, z+k);
distance=MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k);
}
}
k++;
}
k=-range;
j++;
}
j=-range;
i++;
}
return nearest;
}
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z)
{
LinkData nearest=null;
ArrayList rifts = new ArrayList();
int i=-range;
int j=-range;
int k=-range;
DDProperties properties = DDProperties.instance();
while (i<range)
{
while (j<range)
{
while (k<range)
{
if(world.getBlock(x+i, y+j, z+k)== DimDoors.blockRift)
{
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k)!=0)
{
nearest=this.findLinkAtCoords(x+i, y+j, z+k);
if(nearest!=null)
{
rifts.add(nearest);
}
}
}
k++;
}
k=-range;
j++;
}
j=-range;
i++;
}
return rifts;
}
public LinkData addLinkToDim(LinkData link)
{
if(this.linksInThisDim.containsKey(link.locZCoord))
{
this.dimY=this.linksInThisDim.get(link.locZCoord);
if(this.dimY.containsKey(link.locYCoord))
{
this.dimX=this.dimY.get(link.locYCoord);
}
else
{
this.dimX=new HashMap<Integer, LinkData>();
}
}
else
{
this.dimX=new HashMap<Integer, LinkData>();
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
}
this.dimX.put(link.locXCoord, link);
this.dimY.put(link.locYCoord, dimX);
this.linksInThisDim.put(link.locZCoord, dimY);
//System.out.println("added link to dim "+this.dimID);
return link;
}
public LinkData addLinkToDim( int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, int linkOrientation)
{
LinkData linkData= new LinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord, locationZCoord, destinationXCoord, destinationYCoord,destinationZCoord,this.isPocket,linkOrientation);
return this.addLinkToDim(linkData);
}
public boolean isLimbo()
{
return (this.dimID == DDProperties.instance().LimboDimensionID);
}
public void removeLinkAtCoords(LinkData link)
{
this.removeLinkAtCoords(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord);
}
public void removeLinkAtCoords(int locationID, int locationXCoord, int locationYCoord, int locationZCoord)
{
if (this.linksInThisDim.containsKey(locationZCoord))
{
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord))
{
this.dimX=this.dimY.get(locationYCoord);
}
else
{
this.dimX=new HashMap<Integer, LinkData>();
}
}
else
{
this.dimX=new HashMap<Integer, LinkData>();
this.dimY=new HashMap<Integer, HashMap<Integer, LinkData>>();
}
this.dimX.remove(locationXCoord);
this.dimY.put(locationYCoord, dimX);
this.linksInThisDim.put(locationZCoord, dimY);
}
public LinkData findLinkAtCoords(int locationXCoord, int locationYCoord, int locationZCoord)
{
try
{
if(this.linksInThisDim.containsKey(locationZCoord))
{
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord))
{
this.dimX=this.dimY.get(locationYCoord);
if(this.dimX.containsKey(locationXCoord))
{
return this.dimX.get(locationXCoord);
}
}
}
}
catch(Exception E)
{
return null;
}
return null;
}
public ArrayList<LinkData> getLinksInDim()
{
//TODO: We might want to modify this function, but I'm afraid of breaking something right now.
//To begin with, the name is wrong. This doesn't print anything! >_o ~SenseiKiwi
ArrayList<LinkData> links = new ArrayList<LinkData>();
if (this.linksInThisDim == null)
{
return links;
}
for (HashMap<Integer, HashMap<Integer, LinkData>> first : this.linksInThisDim.values())
{
for (HashMap<Integer, LinkData> second : first.values())
{
for (LinkData linkData : second.values())
{
links.add(linkData);
}
}
}
return links;
}
}

View file

@ -1,85 +0,0 @@
package com.zixiken.dimdoors;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import com.zixiken.dimdoors.dungeon.pack.DungeonPack;
import com.zixiken.dimdoors.dungeon.pack.DungeonType;
import com.zixiken.dimdoors.helpers.DungeonHelper;
@Deprecated
public class DungeonGenerator implements Serializable
{
//This static field is hax so that I don't have to add an instance field to DungeonGenerator to support DungeonType.
//Otherwise it would have to be serializable and all sorts of problems would arise.
private static final HashMap<DungeonGenerator, DungeonType> dungeonTypes = new HashMap<DungeonGenerator, DungeonType>();
public int weight;
public String schematicPath;
public ArrayList<HashMap> sideRifts = new ArrayList<HashMap>();
public LinkData exitLink;
public boolean isOpen;
public int sideDoorsSoFar=0;
public int exitDoorsSoFar=0;
public int deadEndsSoFar=0;
public DungeonGenerator(int weight, String schematicPath, boolean isOpen, DungeonType dungeonType)
{
this.weight = weight;
this.schematicPath = schematicPath;
this.isOpen = isOpen;
dungeonTypes.put(this, dungeonType); //Hax...
}
public DungeonType getDungeonType()
{
DungeonType type = dungeonTypes.get(this);
if (type == null)
{
//Infer the dungeon's type from its file name
//There is minimal risk of us applying this to untagged dungeons and this'll be phased out
//when we get the new save format.
try
{
File file = new File(schematicPath);
String typeName = file.getName().split("_")[0];
String packName = file.getParentFile().getName();
DungeonPack pack = DungeonHelper.instance().getDungeonPack(packName);
if (pack == null)
{
pack = DungeonHelper.instance().getDungeonPack("ruins");
}
type = pack.getType(typeName);
}
catch (Exception e) { }
if (type == null)
{
type = DungeonType.UNKNOWN_TYPE;
}
dungeonTypes.put(this, type);
}
return type;
}
@Override
public int hashCode()
{
return (schematicPath != null) ? schematicPath.hashCode() : 0;
}
@Override
public boolean equals(Object other)
{
return equals((DungeonGenerator) other);
}
public boolean equals(DungeonGenerator other)
{
return ((this.schematicPath != null && this.schematicPath.equals(other.schematicPath)) ||
(this.schematicPath == other.schematicPath));
}
}

View file

@ -2,6 +2,7 @@ package com.zixiken.dimdoors;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.config.DDWorldProperties; import com.zixiken.dimdoors.config.DDWorldProperties;
import com.zixiken.dimdoors.core.*;
import com.zixiken.dimdoors.items.BaseItemDoor; import com.zixiken.dimdoors.items.BaseItemDoor;
import com.zixiken.dimdoors.items.ItemWarpDoor; import com.zixiken.dimdoors.items.ItemWarpDoor;
import com.zixiken.dimdoors.ticking.RiftRegenerator; import com.zixiken.dimdoors.ticking.RiftRegenerator;
@ -26,11 +27,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.terraingen.InitMapGenEvent; import net.minecraftforge.event.terraingen.InitMapGenEvent;
import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import com.zixiken.dimdoors.core.DDTeleporter; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.DimensionType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.core.PocketManager;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -85,7 +82,7 @@ public class EventHookContainer
{ {
if(stack.getItem() instanceof ItemWarpDoor) if(stack.getItem() instanceof ItemWarpDoor)
{ {
NewDimData data = PocketManager.getDimensionData(world); DimData data = PocketManager.getDimensionData(world);
if(data.type() == DimensionType.PERSONAL) if(data.type() == DimensionType.PERSONAL)
{ {
@ -229,7 +226,7 @@ public class EventHookContainer
Chunk chunk = event.getChunk(); Chunk chunk = event.getChunk();
if (!chunk.worldObj.isRemote && PocketManager.isLoaded()) if (!chunk.worldObj.isRemote && PocketManager.isLoaded())
{ {
NewDimData dimension = PocketManager.createDimensionData(chunk.worldObj); DimData dimension = PocketManager.createDimensionData(chunk.worldObj);
for (DimLink link : dimension.getChunkLinks(chunk.xPosition, chunk.zPosition)) for (DimLink link : dimension.getChunkLinks(chunk.xPosition, chunk.zPosition))
{ {
regenerator.scheduleSlowRegeneration(link); regenerator.scheduleSlowRegeneration(link);

View file

@ -1,68 +0,0 @@
package com.zixiken.dimdoors;
import java.io.Serializable;
@Deprecated
public class LinkData implements Serializable
{
public int locXCoord;
public int locYCoord;
public int locZCoord;
public int destXCoord;
public int destYCoord;
public int destZCoord;
public int numberofChildren;
public boolean isLocPocket;
public int linkOrientation;
public int destDimID;
public int locDimID;
public boolean exists=false;
public boolean hasGennedDoor=false;
static final long serialVersionUID = 45544342L;
public LinkData()
{
this.exists=false;
}
public LinkData(int exitLinkDimID, int exitX, int exitY, int exitZ)
{
this.destDimID=exitLinkDimID;
this.destXCoord=exitX;
this.destYCoord=exitY;
this.destZCoord=exitZ;
}
public LinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord, int destinationXCoord, int destinationYCoord, int destinationZCoord, boolean isPocket,int orientation)
{
this.exists = true;
this.locXCoord=locationXCoord;
this.locYCoord=locationYCoord;
this.locZCoord=locationZCoord;
this.destXCoord=destinationXCoord;
this.destYCoord=destinationYCoord;
this.destZCoord=destinationZCoord;
this.destDimID=destinationDimID;
this.locDimID=locationDimID;
this.isLocPocket=isPocket;
this.linkOrientation=orientation;
}
public String printLinkData()
{
//TODO: Rewrite this to make it prettier. @_@ I'm afraid of changing it to ToString() on the off
//chance it'll cause explosions and sadness. Damn serialization! ~SenseiKiwi
String linkInfo;
linkInfo = String.valueOf(this.locDimID) + "locDimID "+String.valueOf(this.locXCoord)+":locXCoord "+String.valueOf(this.locYCoord)+":locYCoord "+String.valueOf(this.locZCoord)+":locZCoord ";
linkInfo.concat("\n"+ String.valueOf(this.destDimID)+"DestDimID "+String.valueOf(this.destXCoord)+":destXCoord "+String.valueOf(this.destYCoord)+":destYCoord "+String.valueOf(this.destZCoord)+":destZCoord ");
return linkInfo;
}
}

View file

@ -1,9 +1,9 @@
package com.zixiken.dimdoors.blocks; package com.zixiken.dimdoors.blocks;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.tileentities.TileEntityDimDoorGold; import com.zixiken.dimdoors.tileentities.TileEntityDimDoorGold;
@ -26,7 +26,7 @@ public class BlockGoldDimDoor extends BaseDimDoor {
@Override @Override
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
if (!world.isRemote && world.getBlockState(pos.down()).getBlock() == this) { if (!world.isRemote && world.getBlockState(pos.down()).getBlock() == this) {
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link == null) if (link == null)
dimension.createLink(pos, LinkType.POCKET, world.getBlockState(pos.down()).getValue(BlockDoor.FACING)); dimension.createLink(pos, LinkType.POCKET, world.getBlockState(pos.down()).getValue(BlockDoor.FACING));

View file

@ -5,6 +5,7 @@ import java.util.*;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.client.ClosingRiftFX; import com.zixiken.dimdoors.client.ClosingRiftFX;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.tileentities.TileEntityRift; import com.zixiken.dimdoors.tileentities.TileEntityRift;
@ -25,7 +26,6 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.IFluidBlock;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import com.zixiken.dimdoors.client.GoggleRiftFX; import com.zixiken.dimdoors.client.GoggleRiftFX;
import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.FMLClientHandler;
@ -197,7 +197,7 @@ public class BlockRift extends Block implements ITileEntityProvider {
} }
} }
public boolean spreadRift(NewDimData dimension, DimLink parent, World world, Random random) { public boolean spreadRift(DimData dimension, DimLink parent, World world, Random random) {
Point4D source = parent.source(); Point4D source = parent.source();
// Find reachable blocks that are vulnerable to rift damage and include air // Find reachable blocks that are vulnerable to rift damage and include air

View file

@ -1,5 +1,6 @@
package com.zixiken.dimdoors.blocks; package com.zixiken.dimdoors.blocks;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
@ -10,7 +11,6 @@ import net.minecraft.item.Item;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
public class DimensionalDoor extends BaseDimDoor { public class DimensionalDoor extends BaseDimDoor {
public static final String ID = "dimDoor"; public static final String ID = "dimDoor";
@ -26,7 +26,7 @@ public class DimensionalDoor extends BaseDimDoor {
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos.down()); IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) { if (!world.isRemote && state.getBlock() == this) {
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link == null) if (link == null)
dimension.createLink(pos, LinkType.POCKET, state.getValue(BlockDoor.FACING)); dimension.createLink(pos, LinkType.POCKET, state.getValue(BlockDoor.FACING));

View file

@ -11,7 +11,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
public class PersonalDimDoor extends BaseDimDoor { public class PersonalDimDoor extends BaseDimDoor {
public static final String ID = "dimDoorPersonal"; public static final String ID = "dimDoorPersonal";
@ -26,7 +26,7 @@ public class PersonalDimDoor extends BaseDimDoor {
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos.down()); IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) { if (!world.isRemote && state.getBlock() == this) {
NewDimData dimension = PocketManager.getDimensionData(world); DimData dimension = PocketManager.getDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link == null) { if (link == null) {
if (world.provider instanceof PersonalPocketProvider) if (world.provider instanceof PersonalPocketProvider)

View file

@ -88,7 +88,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
@Override @Override
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
if (!world.isRemote) { if (!world.isRemote) {
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link == null && dimension.isPocketDimension()) if (link == null && dimension.isPocketDimension())
dimension.createLink(pos, LinkType.UNSAFE_EXIT, EnumFacing.EAST); dimension.createLink(pos, LinkType.UNSAFE_EXIT, EnumFacing.EAST);

View file

@ -1,7 +1,7 @@
package com.zixiken.dimdoors.blocks; package com.zixiken.dimdoors.blocks;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.*;
import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -9,13 +9,9 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.DDTeleporter; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.core.PocketManager;
public class TransientDoor extends BaseDimDoor { public class TransientDoor extends BaseDimDoor {
public static final String ID = "transientDoor"; public static final String ID = "transientDoor";
@ -53,7 +49,7 @@ public class TransientDoor extends BaseDimDoor {
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos.down()); IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) { if (!world.isRemote && state.getBlock() == this) {
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link == null && dimension.isPocketDimension()) { if (link == null && dimension.isPocketDimension()) {
dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING)); dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING));

View file

@ -2,7 +2,7 @@ package com.zixiken.dimdoors.blocks;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockDoor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -28,7 +28,7 @@ public class UnstableDoor extends BaseDimDoor {
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos.down()); IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) { if (!world.isRemote && state.getBlock() == this) {
NewDimData dimension = PocketManager.getDimensionData(world); DimData dimension = PocketManager.getDimensionData(world);
dimension.createLink(pos, LinkType.RANDOM, state.getValue(BlockDoor.FACING)); dimension.createLink(pos, LinkType.RANDOM, state.getValue(BlockDoor.FACING));
} }
} }

View file

@ -10,7 +10,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
public class WarpDoor extends BaseDimDoor { public class WarpDoor extends BaseDimDoor {
public static final String ID = "dimDoorWarp"; public static final String ID = "dimDoorWarp";
@ -25,7 +25,7 @@ public class WarpDoor extends BaseDimDoor {
public void placeLink(World world, BlockPos pos) { public void placeLink(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos.down()); IBlockState state = world.getBlockState(pos.down());
if (!world.isRemote && state.getBlock() == this) { if (!world.isRemote && state.getBlock() == this) {
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link == null && dimension.isPocketDimension()) { if (link == null && dimension.isPocketDimension()) {
dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING)); dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING));

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.commands;
import java.util.Collection; import java.util.Collection;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
@ -13,7 +14,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import com.zixiken.dimdoors.core.NewDimData;
public class CommandCreateDungeonRift extends DDCommandBase { public class CommandCreateDungeonRift extends DDCommandBase {
private static CommandCreateDungeonRift instance = null; private static CommandCreateDungeonRift instance = null;
@ -31,7 +31,7 @@ public class CommandCreateDungeonRift extends DDCommandBase {
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) { protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
NewDimData dimension; DimData dimension;
DungeonHelper dungeonHelper = DungeonHelper.instance(); DungeonHelper dungeonHelper = DungeonHelper.instance();
if (command.length == 0) { if (command.length == 0) {

View file

@ -5,6 +5,7 @@ import java.util.Collection;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
@ -15,7 +16,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import com.zixiken.dimdoors.core.NewDimData;
public class CommandCreateRandomRift extends DDCommandBase { public class CommandCreateRandomRift extends DDCommandBase {
private static CommandCreateRandomRift instance = null; private static CommandCreateRandomRift instance = null;
@ -34,7 +34,7 @@ public class CommandCreateRandomRift extends DDCommandBase {
@Override @Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) { protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
NewDimData dimension; DimData dimension;
DungeonHelper dungeonHelper = DungeonHelper.instance(); DungeonHelper dungeonHelper = DungeonHelper.instance();
if (command.length > 1) if (command.length > 1)

View file

@ -6,7 +6,7 @@ import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
@ -63,7 +63,7 @@ public class CommandDeleteRifts extends DDCommandBase
int y; int y;
int z; int z;
Point4D location; Point4D location;
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
ArrayList<DimLink> links = dimension.getAllLinks(); ArrayList<DimLink> links = dimension.getAllLinks();
for (DimLink link : links) for (DimLink link : links)
{ {

View file

@ -7,7 +7,7 @@ import com.zixiken.dimdoors.core.DimLink;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import com.zixiken.dimdoors.core.DimensionType; import com.zixiken.dimdoors.core.DimensionType;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
public class CommandResetDungeons extends DDCommandBase { public class CommandResetDungeons extends DDCommandBase {
@ -34,13 +34,13 @@ public class CommandResetDungeons extends DDCommandBase {
int resetCount = 0; int resetCount = 0;
int dungeonCount = 0; int dungeonCount = 0;
HashSet<Integer> deletedDimensions = new HashSet<Integer>(); HashSet<Integer> deletedDimensions = new HashSet<Integer>();
ArrayList<NewDimData> loadedDungeons = new ArrayList<NewDimData>(); ArrayList<DimData> loadedDungeons = new ArrayList<DimData>();
// Copy the list of dimensions to iterate over the copy. Otherwise, // Copy the list of dimensions to iterate over the copy. Otherwise,
// we would trigger an exception by modifying the original list. // we would trigger an exception by modifying the original list.
ArrayList<NewDimData> dimensions = new ArrayList<NewDimData>(); ArrayList<DimData> dimensions = new ArrayList<DimData>();
for (NewDimData dimension : PocketManager.getDimensions()) { for (DimData dimension : PocketManager.getDimensions()) {
dimensions.add(dimension); dimensions.add(dimension);
} }
@ -48,7 +48,7 @@ public class CommandResetDungeons extends DDCommandBase {
// Iterate over the list of dimensions. Check which ones are dungeons. // Iterate over the list of dimensions. Check which ones are dungeons.
// If a dungeon is found, try to delete it. If it can't be deleted, // If a dungeon is found, try to delete it. If it can't be deleted,
// then it must be loaded and needs to be updated to prevent bugs. // then it must be loaded and needs to be updated to prevent bugs.
for (NewDimData dimension : dimensions) { for (DimData dimension : dimensions) {
if (dimension.type() == DimensionType.DUNGEON) { if (dimension.type() == DimensionType.DUNGEON) {
dungeonCount++; dungeonCount++;
id = dimension.id(); id = dimension.id();
@ -63,7 +63,7 @@ public class CommandResetDungeons extends DDCommandBase {
} }
// Modify the loaded dungeons to prevent bugs // Modify the loaded dungeons to prevent bugs
for (NewDimData dungeon : loadedDungeons) { for (DimData dungeon : loadedDungeons) {
// Find top-most loaded dungeons and update their parents. // Find top-most loaded dungeons and update their parents.
// They will automatically update their children. // They will automatically update their children.
// Dungeons with non-dungeon parents don't need to be fixed. // Dungeons with non-dungeon parents don't need to be fixed.

View file

@ -5,7 +5,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.DDTeleporter; import com.zixiken.dimdoors.core.DDTeleporter;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
@ -32,7 +32,7 @@ public class CommandTeleportPlayer extends DDCommandBase {
World world; World world;
int dimensionID; int dimensionID;
Point4D destination; Point4D destination;
NewDimData dimension; DimData dimension;
boolean checkOrientation; boolean checkOrientation;
EntityPlayer targetPlayer; EntityPlayer targetPlayer;

View file

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.world.LimboProvider; import com.zixiken.dimdoors.world.LimboProvider;
import com.zixiken.dimdoors.Point3D;
import com.zixiken.dimdoors.blocks.BaseDimDoor; import com.zixiken.dimdoors.blocks.BaseDimDoor;
import com.zixiken.dimdoors.blocks.IDimDoor; import com.zixiken.dimdoors.blocks.IDimDoor;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
@ -446,8 +445,8 @@ public class DDTeleporter {
// That means that it was a pocket and it was deleted. // That means that it was a pocket and it was deleted.
// Depending on the link type, we must overwrite it or cancel // Depending on the link type, we must overwrite it or cancel
// the teleport operation. We don't need to assign 'link' with // the teleport operation. We don't need to assign 'link' with
// a different value. NewDimData will overwrite it in-place. // a different value. DimData will overwrite it in-place.
NewDimData start = PocketManager.getDimensionData(link.source().getDimension()); DimData start = PocketManager.getDimensionData(link.source().getDimension());
if (link.linkType() == LinkType.DUNGEON) if (link.linkType() == LinkType.DUNGEON)
{ {
// Ovewrite the link into a dungeon link with no destination // Ovewrite the link into a dungeon link with no destination
@ -515,7 +514,7 @@ public class DDTeleporter {
} }
EntityPlayer player = (EntityPlayer)entity; EntityPlayer player = (EntityPlayer)entity;
NewDimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString()); DimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString());
if(dim == null) if(dim == null)
{ {
return PocketBuilder.generateNewPersonalPocket(link, properties, player, door); return PocketBuilder.generateNewPersonalPocket(link, properties, player, door);
@ -544,7 +543,7 @@ public class DDTeleporter {
// Don't just pick a random root and a random link within that root // Don't just pick a random root and a random link within that root
// because we want to have unbiased selection among all links. // because we want to have unbiased selection among all links.
ArrayList<Point4D> matches = new ArrayList<Point4D>(); ArrayList<Point4D> matches = new ArrayList<Point4D>();
for (NewDimData dimension : PocketManager.getRootDimensions()) for (DimData dimension : PocketManager.getRootDimensions())
{ {
for (DimLink link : dimension.getAllLinks()) for (DimLink link : dimension.getAllLinks())
{ {
@ -574,7 +573,7 @@ public class DDTeleporter {
// To avoid loops, don't generate a destination if the player is // To avoid loops, don't generate a destination if the player is
// already in a non-pocket dimension. // already in a non-pocket dimension.
NewDimData current = PocketManager.getDimensionData(link.point.getDimension()); DimData current = PocketManager.getDimensionData(link.point.getDimension());
if (current.isPocketDimension()) if (current.isPocketDimension())
{ {
@ -632,7 +631,7 @@ public class DDTeleporter {
private static boolean generateSafeExit(DimLink link, DDProperties properties) private static boolean generateSafeExit(DimLink link, DDProperties properties)
{ {
NewDimData current = PocketManager.getDimensionData(link.point.getDimension()); DimData current = PocketManager.getDimensionData(link.point.getDimension());
return generateSafeExit(current.root(), link, properties); return generateSafeExit(current.root(), link, properties);
} }
@ -643,9 +642,9 @@ public class DDTeleporter {
// There is a chance of choosing the Nether first before other root dimensions // There is a chance of choosing the Nether first before other root dimensions
// to compensate for servers with many Mystcraft ages or other worlds. // to compensate for servers with many Mystcraft ages or other worlds.
NewDimData current = PocketManager.getDimensionData(link.point.getDimension()); DimData current = PocketManager.getDimensionData(link.point.getDimension());
ArrayList<NewDimData> roots = PocketManager.getRootDimensions(); ArrayList<DimData> roots = PocketManager.getRootDimensions();
int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1); int shiftChance = START_ROOT_SHIFT_CHANCE + ROOT_SHIFT_CHANCE_PER_LEVEL * (current.packDepth() - 1);
if (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance) if (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance)
@ -660,7 +659,7 @@ public class DDTeleporter {
} }
for (int attempts = 0; attempts < 10; attempts++) for (int attempts = 0; attempts < 10; attempts++)
{ {
NewDimData selection = roots.get( random.nextInt(roots.size()) ); DimData selection = roots.get( random.nextInt(roots.size()) );
if (selection != current.root() && isValidForDungeonExit(selection, properties)) if (selection != current.root() && isValidForDungeonExit(selection, properties))
{ {
return generateSafeExit(selection, link, properties); return generateSafeExit(selection, link, properties);
@ -672,7 +671,7 @@ public class DDTeleporter {
return generateSafeExit(current.root(), link, properties); return generateSafeExit(current.root(), link, properties);
} }
private static boolean isValidForDungeonExit(NewDimData destination, DDProperties properties) private static boolean isValidForDungeonExit(DimData destination, DDProperties properties)
{ {
// Prevent exits to The End and Limbo // Prevent exits to The End and Limbo
if (destination.id() == END_DIMENSION_ID || destination.id() == properties.LimboDimensionID) if (destination.id() == END_DIMENSION_ID || destination.id() == properties.LimboDimensionID)
@ -685,7 +684,7 @@ public class DDTeleporter {
return (world != null && !SPIRIT_WORLD_NAME.equals(world.provider.getDimensionName())); return (world != null && !SPIRIT_WORLD_NAME.equals(world.provider.getDimensionName()));
} }
private static boolean generateSafeExit(NewDimData destinationDim, DimLink link, DDProperties properties) private static boolean generateSafeExit(DimData destinationDim, DimLink link, DDProperties properties)
{ {
// A safe exit attempts to place a Warp Door in a dimension with // A safe exit attempts to place a Warp Door in a dimension with
// some precautions to protect the player. The X and Z coordinates // some precautions to protect the player. The X and Z coordinates
@ -759,7 +758,7 @@ public class DDTeleporter {
// Create a reverse link for returning // Create a reverse link for returning
int orientation = getDestinationOrientation(source, properties); int orientation = getDestinationOrientation(source, properties);
NewDimData sourceDim = PocketManager.getDimensionData(link.source().getDimension()); DimData sourceDim = PocketManager.getDimensionData(link.source().getDimension());
DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkType.REVERSE,orientation); DimLink reverse = destinationDim.createLink(x, y + 2, z, LinkType.REVERSE,orientation);
sourceDim.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ()); sourceDim.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());

View file

@ -10,7 +10,6 @@ import java.util.TreeMap;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.watcher.ClientLinkData; import com.zixiken.dimdoors.watcher.ClientLinkData;
import com.zixiken.dimdoors.Point3D;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.dungeon.DungeonData; import com.zixiken.dimdoors.dungeon.DungeonData;
import com.zixiken.dimdoors.dungeon.pack.DungeonPack; import com.zixiken.dimdoors.dungeon.pack.DungeonPack;
@ -27,7 +26,7 @@ import com.zixiken.dimdoors.saving.PackedDungeonData;
import com.zixiken.dimdoors.saving.PackedLinkData; import com.zixiken.dimdoors.saving.PackedLinkData;
import com.zixiken.dimdoors.saving.PackedLinkTail; import com.zixiken.dimdoors.saving.PackedLinkTail;
public abstract class NewDimData implements IPackable<PackedDimData> { public abstract class DimData implements IPackable<PackedDimData> {
private static class InnerDimLink extends DimLink { private static class InnerDimLink extends DimLink {
public InnerDimLink(Point4D source, DimLink parent, EnumFacing orientation, DDLock lock) { public InnerDimLink(Point4D source, DimLink parent, EnumFacing orientation, DDLock lock) {
super(source, orientation, lock, parent); super(source, orientation, lock, parent);
@ -37,7 +36,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
super(source, orientation, lock, linkType); super(source, orientation, lock, linkType);
} }
public void setDestination(BlockPos pos, NewDimData dimension) { public void setDestination(BlockPos pos, DimData dimension) {
tail.setDestination(new Point4D(pos, dimension.id())); tail.setDestination(new Point4D(pos, dimension.id()));
} }
@ -130,9 +129,9 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
protected int depth; protected int depth;
protected int packDepth; protected int packDepth;
protected DimensionType type; protected DimensionType type;
protected NewDimData parent; protected DimData parent;
protected NewDimData root; protected DimData root;
protected List<NewDimData> children; protected List<DimData> children;
protected Point4D origin; protected Point4D origin;
protected EnumFacing orientation; protected EnumFacing orientation;
protected DungeonData dungeon; protected DungeonData dungeon;
@ -143,7 +142,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
// Don't write this field to a file - it should be recreated on startup // Don't write this field to a file - it should be recreated on startup
private Map<ChunkCoordIntPair, List<InnerDimLink>> chunkMapping; private Map<ChunkCoordIntPair, List<InnerDimLink>> chunkMapping;
protected NewDimData(int id, NewDimData parent, DimensionType type, IUpdateWatcher<ClientLinkData> linkWatcher) { protected DimData(int id, DimData parent, DimensionType type, IUpdateWatcher<ClientLinkData> linkWatcher) {
if (type != DimensionType.ROOT && (parent == null)) { if (type != DimensionType.ROOT && (parent == null)) {
throw new NullPointerException("Dimensions can be pocket dimensions if and only if they have a parent dimension."); throw new NullPointerException("Dimensions can be pocket dimensions if and only if they have a parent dimension.");
} }
@ -151,7 +150,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
this.id = id; this.id = id;
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //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.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
this.children = new ArrayList<NewDimData>(); this.children = new ArrayList<DimData>();
this.parent = parent; this.parent = parent;
this.packDepth = 0; this.packDepth = 0;
this.type = type; this.type = type;
@ -176,7 +175,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
} }
} }
protected NewDimData(int id, NewDimData root, DimensionType type) { protected DimData(int id, DimData root, DimensionType type) {
// This constructor is meant for client-side code only // This constructor is meant for client-side code only
if (root == null) { if (root == null) {
throw new IllegalArgumentException("root cannot be null."); throw new IllegalArgumentException("root cannot be null.");
@ -185,7 +184,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
this.id = id; this.id = id;
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //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.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
this.children = new ArrayList<NewDimData>(); this.children = new ArrayList<DimData>();
this.parent = null; this.parent = null;
this.packDepth = 0; this.packDepth = 0;
this.type = type; this.type = type;
@ -430,11 +429,11 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
return origin; return origin;
} }
public NewDimData parent() { public DimData parent() {
return parent; return parent;
} }
public NewDimData root() { public DimData root() {
return root; return root;
} }
@ -454,7 +453,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
return linkList.size(); return linkList.size();
} }
public Iterable<NewDimData> children() { public Iterable<DimData> children() {
return children; return children;
} }
@ -497,11 +496,11 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
} }
// Update the depths for child dimensions using a depth-first traversal // Update the depths for child dimensions using a depth-first traversal
Stack<NewDimData> ordering = new Stack<NewDimData>(); Stack<DimData> ordering = new Stack<DimData>();
ordering.addAll(this.children); ordering.addAll(this.children);
while (!ordering.isEmpty()) { while (!ordering.isEmpty()) {
NewDimData current = ordering.pop(); DimData current = ordering.pop();
current.resetDepth(); current.resetDepth();
ordering.addAll(current.children); ordering.addAll(current.children);
} }
@ -517,7 +516,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
this.modified = true; this.modified = true;
} }
public static int calculatePackDepth(NewDimData parent, DungeonData current) { public static int calculatePackDepth(DimData parent, DungeonData current) {
DungeonData predecessor = parent.dungeon(); DungeonData predecessor = parent.dungeon();
if (current == null) { if (current == null) {
throw new IllegalArgumentException("current cannot be null."); throw new IllegalArgumentException("current cannot be null.");
@ -613,7 +612,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
parent.children.remove(this); parent.children.remove(this);
} }
// Remove this dimension as the parent of its children // Remove this dimension as the parent of its children
for (NewDimData child : children) { for (DimData child : children) {
child.parent = null; child.parent = null;
} }
// Clear all fields // Clear all fields
@ -646,7 +645,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
dungeon.dungeonType().Owner.getName()); dungeon.dungeonType().Owner.getName());
} }
//Make a list of children //Make a list of children
for(NewDimData data : this.children) { for(DimData data : this.children) {
ChildIDs.add(data.id); ChildIDs.add(data.id);
} }
for(DimLink link:this.links()) { for(DimLink link:this.links()) {

View file

@ -2,5 +2,5 @@ package com.zixiken.dimdoors.core;
public interface IDimRegistrationCallback public interface IDimRegistrationCallback
{ {
public NewDimData registerDimension(int dimensionID, int rootID, DimensionType type); public DimData registerDimension(int dimensionID, int rootID, DimensionType type);
} }

View file

@ -16,7 +16,7 @@ import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.helpers.Compactor; import com.zixiken.dimdoors.helpers.Compactor;
import com.zixiken.dimdoors.helpers.DeleteFolder; import com.zixiken.dimdoors.helpers.DeleteFolder;
import com.zixiken.dimdoors.saving.DDSaveHandler; import com.zixiken.dimdoors.saving.DDSaveHandler;
import com.zixiken.dimdoors.saving.OldSaveImporter; import com.zixiken.dimdoors.legacy.LegacySaveImporter;
import com.zixiken.dimdoors.saving.PackedDimData; import com.zixiken.dimdoors.saving.PackedDimData;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import com.zixiken.dimdoors.watcher.ClientDimData; import com.zixiken.dimdoors.watcher.ClientDimData;
@ -34,13 +34,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
*/ */
public class PocketManager public class PocketManager
{ {
private static class InnerDimData extends NewDimData private static class InnerDimData extends DimData
{ {
// This class allows us to instantiate NewDimData indirectly without // This class allows us to instantiate DimData indirectly without
// exposing // exposing
// a public constructor from NewDimData. It's meant to stop us from // a public constructor from DimData. It's meant to stop us from
// constructing // constructing
// instances of NewDimData going through PocketManager. In turn, that // instances of DimData going through PocketManager. In turn, that
// enforces // enforces
// that any link destinations must be real dimensions controlled by // that any link destinations must be real dimensions controlled by
// PocketManager. // PocketManager.
@ -50,7 +50,7 @@ public class PocketManager
super(id, parent, type, linkWatcher); super(id, parent, type, linkWatcher);
} }
public InnerDimData(int id, NewDimData root, DimensionType type) public InnerDimData(int id, DimData root, DimensionType type)
{ {
// This constructor is meant for client-side code only // This constructor is meant for client-side code only
super(id, root, type); super(id, root, type);
@ -64,7 +64,7 @@ public class PocketManager
public void onCreated(ClientLinkData link) public void onCreated(ClientLinkData link)
{ {
Point4D source = link.point; Point4D source = link.point;
NewDimData dimension = getDimensionData(source.getDimension()); DimData dimension = getDimensionData(source.getDimension());
if (dimension != null && dimension.getLink(source.getX(), source.getY(), source.getZ()) == null) if (dimension != null && dimension.getLink(source.getX(), source.getY(), source.getZ()) == null)
dimension.createLink(source, LinkType.CLIENT, 0, link.lock); dimension.createLink(source, LinkType.CLIENT, 0, link.lock);
} }
@ -73,7 +73,7 @@ public class PocketManager
public void onDeleted(ClientLinkData link) public void onDeleted(ClientLinkData link)
{ {
Point4D source = link.point; Point4D source = link.point;
NewDimData dimension = getDimensionData(source.getDimension()); DimData dimension = getDimensionData(source.getDimension());
if (dimension != null && dimension.getLink(source.getX(),source.getY(),source.getZ()) != null) if (dimension != null && dimension.getLink(source.getX(),source.getY(),source.getZ()) != null)
dimension.deleteLink(source.getX(), source.getY(), source.getZ()); dimension.deleteLink(source.getX(), source.getY(), source.getZ());
} }
@ -82,7 +82,7 @@ public class PocketManager
public void update(ClientLinkData link) public void update(ClientLinkData link)
{ {
Point4D source = link.point; Point4D source = link.point;
NewDimData dimension = getDimensionData(source.getDimension()); DimData dimension = getDimensionData(source.getDimension());
if (dimension != null) { if (dimension != null) {
DimLink dLink = dimension.getLink(source); DimLink dLink = dimension.getLink(source);
dLink.lock = link.lock; dLink.lock = link.lock;
@ -122,7 +122,7 @@ public class PocketManager
// exposing a private constructor ONLY to a very specific trusted class. // exposing a private constructor ONLY to a very specific trusted class.
@Override @Override
public NewDimData registerDimension(int dimensionID, int rootID, DimensionType type) public DimData registerDimension(int dimensionID, int rootID, DimensionType type)
{ {
return registerClientDimension(dimensionID, rootID, type); return registerClientDimension(dimensionID, rootID, type);
} }
@ -139,7 +139,7 @@ public class PocketManager
public static volatile boolean isConnected = false; public static volatile boolean isConnected = false;
private static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>(); private static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>(); private static final UpdateWatcherProxy<ClientDimData> dimWatcher = new UpdateWatcherProxy<ClientDimData>();
private static ArrayList<NewDimData> rootDimensions = null; private static ArrayList<DimData> rootDimensions = null;
// HashMap that maps all the dimension IDs registered with DimDoors to their // HashMap that maps all the dimension IDs registered with DimDoors to their
// DD data. // DD data.
@ -149,7 +149,7 @@ public class PocketManager
private static ArrayList<Integer> dimensionIDBlackList = null; private static ArrayList<Integer> dimensionIDBlackList = null;
// Stores all the personal pocket mappings // Stores all the personal pocket mappings
private static HashMap<String, NewDimData> personalPocketsMapping = null; private static HashMap<String, DimData> personalPocketsMapping = null;
public static boolean isLoaded() public static boolean isLoaded()
{ {
@ -175,9 +175,9 @@ public class PocketManager
isLoading = true; isLoading = true;
dimensionData = new HashMap<Integer, InnerDimData>(); dimensionData = new HashMap<Integer, InnerDimData>();
rootDimensions = new ArrayList<NewDimData>(); rootDimensions = new ArrayList<DimData>();
dimensionIDBlackList = new ArrayList<Integer>(); dimensionIDBlackList = new ArrayList<Integer>();
personalPocketsMapping = new HashMap<String, NewDimData>(); personalPocketsMapping = new HashMap<String, DimData>();
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) if (FMLCommonHandler.instance().getEffectiveSide().isClient())
{ {
@ -241,13 +241,13 @@ public class PocketManager
return true; return true;
} }
public static boolean deletePocket(NewDimData target, boolean deleteFolder) public static boolean deletePocket(DimData target, boolean deleteFolder)
{ {
// We can't delete the dimension if it's currently loaded or if it's not // We can't delete the dimension if it's currently loaded or if it's not
// actually a pocket. // actually a pocket.
// We cast to InnerDimData so that if anyone tries to be a smartass and // We cast to InnerDimData so that if anyone tries to be a smartass and
// create their // create their
// own version of NewDimData, this will throw an exception. // own version of DimData, this will throw an exception.
InnerDimData dimension = (InnerDimData) target; InnerDimData dimension = (InnerDimData) target;
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null) if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
{ {
@ -299,7 +299,7 @@ public class PocketManager
private static void registerPockets(DDProperties properties) private static void registerPockets(DDProperties properties)
{ {
for (NewDimData dimension : dimensionData.values()) for (DimData dimension : dimensionData.values())
{ {
if (dimension.isPocketDimension()) if (dimension.isPocketDimension())
{ {
@ -328,7 +328,7 @@ public class PocketManager
private static void unregisterPockets() private static void unregisterPockets()
{ {
for (NewDimData dimension : dimensionData.values()) for (DimData dimension : dimensionData.values())
{ {
if (dimension.isPocketDimension()) if (dimension.isPocketDimension())
{ {
@ -374,7 +374,7 @@ public class PocketManager
try try
{ {
System.out.println("Importing old DD save data..."); System.out.println("Importing old DD save data...");
OldSaveImporter.importOldSave(oldSaveData); LegacySaveImporter.importOldSave(oldSaveData);
oldSaveData.renameTo(new File(oldSaveData.getAbsolutePath() + "_IMPORTED")); oldSaveData.renameTo(new File(oldSaveData.getAbsolutePath() + "_IMPORTED"));
@ -449,7 +449,7 @@ public class PocketManager
return world; return world;
} }
public static NewDimData registerDimension(World world) public static DimData registerDimension(World world)
{ {
return registerDimension(world.provider.getDimensionId(), null, DimensionType.ROOT); return registerDimension(world.provider.getDimensionId(), null, DimensionType.ROOT);
} }
@ -462,7 +462,7 @@ public class PocketManager
* @param playername * @param playername
* @return * @return
*/ */
public static NewDimData registerPocket(NewDimData parent, DimensionType type, String playername) public static DimData registerPocket(DimData parent, DimensionType type, String playername)
{ {
if (parent == null) if (parent == null)
{ {
@ -480,7 +480,7 @@ public class PocketManager
throw new IllegalArgumentException("A personal pocket must be attached to a playername"); throw new IllegalArgumentException("A personal pocket must be attached to a playername");
} }
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID); DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
NewDimData data = registerDimension(dimensionID, (InnerDimData) parent, type); DimData data = registerDimension(dimensionID, (InnerDimData) parent, type);
personalPocketsMapping.put(playername, data); personalPocketsMapping.put(playername, data);
return data; return data;
} }
@ -490,7 +490,7 @@ public class PocketManager
if (parent.type == DimensionType.PERSONAL) if (parent.type == DimensionType.PERSONAL)
{ {
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID); DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
NewDimData data = registerDimension(dimensionID, (InnerDimData) parent, DimensionType.PERSONAL); DimData data = registerDimension(dimensionID, (InnerDimData) parent, DimensionType.PERSONAL);
return data; return data;
} }
@ -501,7 +501,7 @@ public class PocketManager
} }
public static NewDimData registerPocket(NewDimData parent, DimensionType type) public static DimData registerPocket(DimData parent, DimensionType type)
{ {
return registerPocket(parent, type, null); return registerPocket(parent, type, null);
} }
@ -514,7 +514,7 @@ public class PocketManager
* @param type * @param type
* @return * @return
*/ */
private static NewDimData registerDimension(int dimensionID, InnerDimData parent, DimensionType type) private static DimData registerDimension(int dimensionID, InnerDimData parent, DimensionType type)
{ {
if (dimensionData.containsKey(dimensionID)) if (dimensionData.containsKey(dimensionID))
{ {
@ -536,7 +536,7 @@ public class PocketManager
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private static NewDimData registerClientDimension(int dimensionID, int rootID, DimensionType type) private static DimData registerClientDimension(int dimensionID, int rootID, DimensionType type)
{ {
// No need to raise events heres since this code should only run on the // No need to raise events heres since this code should only run on the
@ -581,22 +581,22 @@ public class PocketManager
return dimension; return dimension;
} }
public static NewDimData getDimensionData(int dimensionID) public static DimData getDimensionData(int dimensionID)
{ {
return PocketManager.dimensionData.get(dimensionID); return PocketManager.dimensionData.get(dimensionID);
} }
public static NewDimData getDimensionData(World dimension) public static DimData getDimensionData(World dimension)
{ {
return PocketManager.dimensionData.get(dimension.provider.getDimensionId()); return PocketManager.dimensionData.get(dimension.provider.getDimensionId());
} }
public static NewDimData createDimensionData(World world) public static DimData createDimensionData(World world)
{ {
return createDimensionData(world.provider.getDimensionId()); return createDimensionData(world.provider.getDimensionId());
} }
public static NewDimData createDimensionDataDangerously(int dimensionID) public static DimData createDimensionDataDangerously(int dimensionID)
{ {
// Same as createDimensionData(int), but public. Meant to discourage // Same as createDimensionData(int), but public. Meant to discourage
// anyone from // anyone from
@ -605,14 +605,14 @@ public class PocketManager
return createDimensionData(dimensionID); return createDimensionData(dimensionID);
} }
protected static NewDimData createDimensionData(int dimensionID) protected static DimData createDimensionData(int dimensionID)
{ {
// Retrieve the data for a dimension. If we don't have a record for that // Retrieve the data for a dimension. If we don't have a record for that
// dimension, // dimension,
// assume it's a non-pocket dimension that hasn't been initialized with // assume it's a non-pocket dimension that hasn't been initialized with
// us before // us before
// and create a NewDimData instance for it. // and create a DimData instance for it.
NewDimData dimension = PocketManager.dimensionData.get(dimensionID); DimData dimension = PocketManager.dimensionData.get(dimensionID);
// if we do not have a record of it, then it must be a root // if we do not have a record of it, then it must be a root
if (dimension == null) if (dimension == null)
@ -622,15 +622,15 @@ public class PocketManager
return dimension; return dimension;
} }
public static Iterable<? extends NewDimData> getDimensions() public static Iterable<? extends DimData> getDimensions()
{ {
return dimensionData.values(); return dimensionData.values();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static ArrayList<NewDimData> getRootDimensions() public static ArrayList<DimData> getRootDimensions()
{ {
return (ArrayList<NewDimData>) rootDimensions.clone(); return (ArrayList<DimData>) rootDimensions.clone();
} }
public static void tryUnload() { public static void tryUnload() {
@ -671,7 +671,7 @@ public class PocketManager
if (!isLoaded()) if (!isLoaded())
return null; return null;
NewDimData dimension = dimensionData.get(dimensionID); DimData dimension = dimensionData.get(dimensionID);
if (dimension != null) if (dimension != null)
{ {
return dimension.getLink(x, y, z); return dimension.getLink(x, y, z);
@ -760,7 +760,7 @@ public class PocketManager
return linkWatcher; return linkWatcher;
} }
public static NewDimData getPersonalDimensionForPlayer(String name) public static DimData getPersonalDimensionForPlayer(String name)
{ {
if (personalPocketsMapping.containsKey(name)) if (personalPocketsMapping.containsKey(name))
{ {
@ -769,12 +769,12 @@ public class PocketManager
return null; return null;
} }
public static void setPersonalPocketsMapping(HashMap<String, NewDimData> ppMap) public static void setPersonalPocketsMapping(HashMap<String, DimData> ppMap)
{ {
personalPocketsMapping = ppMap; personalPocketsMapping = ppMap;
} }
public static HashMap<String, NewDimData> getPersonalPocketMapping() public static HashMap<String, DimData> getPersonalPocketMapping()
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return personalPocketsMapping; return personalPocketsMapping;

View file

@ -10,6 +10,7 @@ import java.util.Random;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.blocks.IDimDoor; import com.zixiken.dimdoors.blocks.IDimDoor;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
@ -28,7 +29,6 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.schematic.BlockRotator; import com.zixiken.dimdoors.schematic.BlockRotator;
import com.zixiken.dimdoors.schematic.ChunkBlockSetter; import com.zixiken.dimdoors.schematic.ChunkBlockSetter;
import com.zixiken.dimdoors.schematic.CompoundFilter; import com.zixiken.dimdoors.schematic.CompoundFilter;
@ -186,7 +186,7 @@ public class DungeonSchematic extends Schematic {
setUpDungeon(PocketManager.createDimensionData(world), world, pocketCenter, turnAngle, entryLink, random, properties, blockSetter); setUpDungeon(PocketManager.createDimensionData(world), world, pocketCenter, turnAngle, entryLink, random, properties, blockSetter);
} }
private void setUpDungeon(NewDimData dimension, World world, BlockPos pocketCenter, EnumFacing turnAngle, DimLink entryLink, Random random, DDProperties properties, IBlockSetter blockSetter) private void setUpDungeon(DimData dimension, World world, BlockPos pocketCenter, EnumFacing turnAngle, DimLink entryLink, Random random, DDProperties properties, IBlockSetter blockSetter)
{ {
//Transform dungeon corners //Transform dungeon corners
BlockPos minCorner = new BlockPos(0, 0, 0); BlockPos minCorner = new BlockPos(0, 0, 0);
@ -236,16 +236,16 @@ public class DungeonSchematic extends Schematic {
minCorner = temp; minCorner = temp;
} }
private static void createEntranceReverseLink(World world, NewDimData dimension, BlockPos pocketCenter, DimLink entryLink) { private static void createEntranceReverseLink(World world, DimData dimension, BlockPos pocketCenter, DimLink entryLink) {
EnumFacing orientation = EnumFacingHelper.getFacingFromBlockState(world.getBlockState(pocketCenter.down())); EnumFacing orientation = EnumFacingHelper.getFacingFromBlockState(world.getBlockState(pocketCenter.down()));
DimLink reverseLink = dimension.createLink(pocketCenter, LinkType.REVERSE, orientation); DimLink reverseLink = dimension.createLink(pocketCenter, LinkType.REVERSE, orientation);
Point4D destination = entryLink.source(); Point4D destination = entryLink.source();
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension()); DimData prevDim = PocketManager.getDimensionData(destination.getDimension());
prevDim.setLinkDestination(reverseLink, destination.toBlockPos()); prevDim.setLinkDestination(reverseLink, destination.toBlockPos());
initDoorTileEntity(world, pocketCenter); initDoorTileEntity(world, pocketCenter);
} }
private static void createExitDoorLink(World world, NewDimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter, IBlockSetter blockSetter) { private static void createExitDoorLink(World world, DimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter, IBlockSetter blockSetter) {
//Transform the door's location to the pocket coordinate system //Transform the door's location to the pocket coordinate system
BlockPos location = point; BlockPos location = point;
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter); BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
@ -262,7 +262,7 @@ public class DungeonSchematic extends Schematic {
initDoorTileEntity(world, location); initDoorTileEntity(world, location);
} }
private static void createDimensionalDoorLink(World world, NewDimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter) private static void createDimensionalDoorLink(World world, DimData dimension, BlockPos point, BlockPos entrance, EnumFacing rotation, BlockPos pocketCenter)
{ {
//Transform the door's location to the pocket coordinate system //Transform the door's location to the pocket coordinate system
BlockPos location = point; BlockPos location = point;

View file

@ -6,9 +6,9 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.dungeon.DungeonData; import com.zixiken.dimdoors.dungeon.DungeonData;
import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandom;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.helpers.DungeonHelper; import com.zixiken.dimdoors.helpers.DungeonHelper;
import com.zixiken.dimdoors.util.WeightedContainer; import com.zixiken.dimdoors.util.WeightedContainer;
@ -123,7 +123,7 @@ public class DungeonPack
} }
} }
public DungeonData getNextDungeon(NewDimData parent, Random random) public DungeonData getNextDungeon(DimData parent, Random random)
{ {
if (allDungeons.isEmpty()) if (allDungeons.isEmpty())
{ {
@ -144,7 +144,7 @@ public class DungeonPack
// Search over (DuplicateSearchLevels - 1); zero means don't search at all, // Search over (DuplicateSearchLevels - 1); zero means don't search at all,
// one means search only up to the level of the immediate parent, and so on. // one means search only up to the level of the immediate parent, and so on.
// Since we start with the parent, we need to drop the max levels by one. // Since we start with the parent, we need to drop the max levels by one.
NewDimData ancestor = DungeonHelper.getAncestor(parent, this, config.getDuplicateSearchLevels() - 1); DimData ancestor = DungeonHelper.getAncestor(parent, this, config.getDuplicateSearchLevels() - 1);
if (ancestor != null) if (ancestor != null)
{ {
subtreeHistory = DungeonHelper.listDungeonsInTree(ancestor, this, MAX_SUBTREE_LIST_SIZE); subtreeHistory = DungeonHelper.listDungeonsInTree(ancestor, this, MAX_SUBTREE_LIST_SIZE);

View file

@ -4,6 +4,7 @@ import java.io.File;
import java.util.List; import java.util.List;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.world.PocketBuilder; import com.zixiken.dimdoors.world.PocketBuilder;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -17,8 +18,6 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.common.ForgeChunkManager.Type;
import com.zixiken.dimdoors.experimental.BoundingBox; import com.zixiken.dimdoors.experimental.BoundingBox;
import com.zixiken.dimdoors.IChunkLoader; import com.zixiken.dimdoors.IChunkLoader;
import com.zixiken.dimdoors.Point3D;
import com.zixiken.dimdoors.core.NewDimData;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
public class ChunkLoaderHelper implements LoadingCallback { public class ChunkLoaderHelper implements LoadingCallback {
@ -52,7 +51,7 @@ public class ChunkLoaderHelper implements LoadingCallback {
return ticket; return ticket;
} }
public static void forcePocketChunks(NewDimData pocket, Ticket ticket) { public static void forcePocketChunks(DimData pocket, Ticket ticket) {
BoundingBox bounds = PocketBuilder.calculateDefaultBounds(pocket); BoundingBox bounds = PocketBuilder.calculateDefaultBounds(pocket);
BlockPos minCorner = bounds.minCorner(); BlockPos minCorner = bounds.minCorner();
BlockPos maxCorner = bounds.maxCorner(); BlockPos maxCorner = bounds.maxCorner();
@ -71,7 +70,7 @@ public class ChunkLoaderHelper implements LoadingCallback {
} }
public static void loadForcedChunkWorlds(FMLServerStartingEvent event) { public static void loadForcedChunkWorlds(FMLServerStartingEvent event) {
for (NewDimData data : PocketManager.getDimensions()) { for (DimData data : PocketManager.getDimensions()) {
if(data.isPocketDimension()) { if(data.isPocketDimension()) {
String chunkDir = DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + data.id(); String chunkDir = DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + data.id();

View file

@ -4,11 +4,9 @@ import java.io.*;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.DimensionType; import com.zixiken.dimdoors.core.*;
import com.zixiken.dimdoors.core.IDimRegistrationCallback; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import com.zixiken.dimdoors.watcher.ClientLinkData; import com.zixiken.dimdoors.watcher.ClientLinkData;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -18,18 +16,18 @@ public class Compactor
{ {
@SuppressWarnings("unused") // ? @SuppressWarnings("unused") // ?
private static class DimComparator implements Comparator<NewDimData> { private static class DimComparator implements Comparator<DimData> {
@Override @Override
public int compare(NewDimData a, NewDimData b) public int compare(DimData a, DimData b)
{ {
return a.id() - b.id(); return a.id() - b.id();
} }
} }
public static void write(Collection<? extends NewDimData> values, ByteBuf output) throws IOException { public static void write(Collection<? extends DimData> values, ByteBuf output) throws IOException {
// SenseiKiwi: Just encode the data straight up for now. I'll implement fancier compression later. // SenseiKiwi: Just encode the data straight up for now. I'll implement fancier compression later.
output.writeInt(values.size()); output.writeInt(values.size());
for (NewDimData dimension : values) { for (DimData dimension : values) {
output.writeInt(dimension.id()); output.writeInt(dimension.id());
output.writeInt(dimension.root().id()); output.writeInt(dimension.root().id());
output.writeInt(dimension.type().index); output.writeInt(dimension.type().index);
@ -46,7 +44,7 @@ public class Compactor
/* /*
// To compress the dimension IDs, we'll sort them by ID // To compress the dimension IDs, we'll sort them by ID
// and write the _difference_ between their ID numbers. // and write the _difference_ between their ID numbers.
NewDimData[] dimensions = new NewDimData[values.size()]; DimData[] dimensions = new DimData[values.size()];
dimensions = values.toArray(dimensions); dimensions = values.toArray(dimensions);
Arrays.sort(dimensions, new DimComparator()); Arrays.sort(dimensions, new DimComparator());
*/ */
@ -68,7 +66,7 @@ public class Compactor
callback.registerDimension(rootID, rootID, type); callback.registerDimension(rootID, rootID, type);
} }
// Don't check if (id != rootID) - we want to retrieve the reference anyway // Don't check if (id != rootID) - we want to retrieve the reference anyway
NewDimData dimension = callback.registerDimension(id, rootID, type); DimData dimension = callback.registerDimension(id, rootID, type);
int linkCount = input.readInt(); int linkCount = input.readInt();
for (int h = 0; h < linkCount; h++) { for (int h = 0; h < linkCount; h++) {
ClientLinkData link = ClientLinkData.read(input); ClientLinkData link = ClientLinkData.read(input);

View file

@ -19,6 +19,7 @@ import java.util.regex.Pattern;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
@ -31,7 +32,6 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.dungeon.DungeonSchematic; import com.zixiken.dimdoors.dungeon.DungeonSchematic;
import com.zixiken.dimdoors.dungeon.pack.DungeonType; import com.zixiken.dimdoors.dungeon.pack.DungeonType;
import com.zixiken.dimdoors.util.FileFilters; import com.zixiken.dimdoors.util.FileFilters;
@ -200,7 +200,7 @@ public class DungeonHelper {
return dungeonPackMapping.get(name.toUpperCase()); return dungeonPackMapping.get(name.toUpperCase());
} }
private DungeonPack getDimDungeonPack(NewDimData dimension) { private DungeonPack getDimDungeonPack(DimData dimension) {
// TODO: Drop support for dim-based packs and switch to embedding the pack // TODO: Drop support for dim-based packs and switch to embedding the pack
// in the link data itself. That would solve the dungeon pre-generation issue. // in the link data itself. That would solve the dungeon pre-generation issue.
// Gateways should dictate which packs are being used, not the dimensions. // Gateways should dictate which packs are being used, not the dimensions.
@ -227,7 +227,7 @@ public class DungeonHelper {
public DimLink createCustomDungeonDoor(World world, BlockPos pos) { public DimLink createCustomDungeonDoor(World world, BlockPos pos) {
//Create a link above the specified position. Link to a new pocket dimension. //Create a link above the specified position. Link to a new pocket dimension.
NewDimData dimension = PocketManager.getDimensionData(world); DimData dimension = PocketManager.getDimensionData(world);
DimLink link = dimension.createLink(pos.up(), LinkType.POCKET, EnumFacing.NORTH); DimLink link = dimension.createLink(pos.up(), LinkType.POCKET, EnumFacing.NORTH);
//Place a Warp Door linked to that pocket //Place a Warp Door linked to that pocket
@ -412,7 +412,7 @@ public class DungeonHelper {
} }
} }
public DungeonData selectNextDungeon(NewDimData parent, Random random) { public DungeonData selectNextDungeon(DimData parent, Random random) {
DungeonPack pack = getDimDungeonPack(parent); DungeonPack pack = getDimDungeonPack(parent);
DungeonData selection; DungeonData selection;
DungeonPackConfig config; DungeonPackConfig config;
@ -506,11 +506,11 @@ public class DungeonHelper {
* @param maxSize - the maximum number of dungeons that can be listed * @param maxSize - the maximum number of dungeons that can be listed
* @return a list of dungeons used in a given chain * @return a list of dungeons used in a given chain
*/ */
public static ArrayList<DungeonData> getDungeonChainHistory(NewDimData start, DungeonPack pack, int maxSize) { public static ArrayList<DungeonData> getDungeonChainHistory(DimData start, DungeonPack pack, int maxSize) {
if (start == null) throw new IllegalArgumentException("dimension cannot be null."); if (start == null) throw new IllegalArgumentException("dimension cannot be null.");
int count = 0; int count = 0;
NewDimData current = start; DimData current = start;
DungeonData dungeon = current.dungeon(); DungeonData dungeon = current.dungeon();
ArrayList<DungeonData> history = new ArrayList<DungeonData>(); ArrayList<DungeonData> history = new ArrayList<DungeonData>();
@ -530,12 +530,12 @@ public class DungeonHelper {
* @param maxSize - the maximum number of dungeons that can be listed * @param maxSize - the maximum number of dungeons that can be listed
* @return a list of the dungeons used in a given dungeon tree * @return a list of the dungeons used in a given dungeon tree
*/ */
public static ArrayList<DungeonData> listDungeonsInTree(NewDimData root, DungeonPack pack, int maxSize) { public static ArrayList<DungeonData> listDungeonsInTree(DimData root, DungeonPack pack, int maxSize) {
int count = 0; int count = 0;
NewDimData current; DimData current;
DungeonData dungeon; DungeonData dungeon;
ArrayList<DungeonData> dungeons = new ArrayList<DungeonData>(); ArrayList<DungeonData> dungeons = new ArrayList<DungeonData>();
Queue<NewDimData> pendingDimensions = new LinkedList<NewDimData>(); Queue<DimData> pendingDimensions = new LinkedList<DimData>();
pendingDimensions.add(root); pendingDimensions.add(root);
// Perform a breadth-first search through the dungeon graph // Perform a breadth-first search through the dungeon graph
@ -547,7 +547,7 @@ public class DungeonHelper {
if (dungeon != null && dungeon.dungeonType().Owner == pack) { if (dungeon != null && dungeon.dungeonType().Owner == pack) {
dungeons.add(dungeon); dungeons.add(dungeon);
// Add all child dungeons for checking later // Add all child dungeons for checking later
for (NewDimData child : current.children()) { for (DimData child : current.children()) {
pendingDimensions.add(child); pendingDimensions.add(child);
} }
} }
@ -562,10 +562,10 @@ public class DungeonHelper {
* @param maxLevels - the maximum number of ancestors to check * @param maxLevels - the maximum number of ancestors to check
* @return the highest ancestor that belongs to the specified pack within the specified levels, or <code>null</code> if none exists * @return the highest ancestor that belongs to the specified pack within the specified levels, or <code>null</code> if none exists
*/ */
public static NewDimData getAncestor(NewDimData dimension, DungeonPack pack, int maxLevels) { public static DimData getAncestor(DimData dimension, DungeonPack pack, int maxLevels) {
// Find the ancestor of a dimension located a specified number of levels up. // Find the ancestor of a dimension located a specified number of levels up.
NewDimData parent = dimension; DimData parent = dimension;
NewDimData current = null; DimData current = null;
// We solve this inductively. We begin with null as the first valid ancestor, // We solve this inductively. We begin with null as the first valid ancestor,
// like a kind of virtual child dimension. Then "current" references the // like a kind of virtual child dimension. Then "current" references the

View file

@ -14,7 +14,7 @@ import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -41,7 +41,7 @@ public class ItemRiftRemover extends Item {
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true); MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
if (hit != null) { if (hit != null) {
BlockPos pos = hit.getBlockPos(); BlockPos pos = hit.getBlockPos();
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (world.getBlockState(pos).getBlock() == DimDoors.blockRift && link != null && if (world.getBlockState(pos).getBlock() == DimDoors.blockRift && link != null &&
player.canPlayerEdit(pos, hit.sideHit, stack)) { player.canPlayerEdit(pos, hit.sideHit, stack)) {
@ -66,7 +66,7 @@ public class ItemRiftRemover extends Item {
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true); MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
if (hit == null) return false; if (hit == null) return false;
pos = hit.getBlockPos(); pos = hit.getBlockPos();
NewDimData dimension = PocketManager.createDimensionData(world); DimData dimension = PocketManager.createDimensionData(world);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (world.getBlockState(pos).getBlock() != DimDoors.blockRift || link == null || if (world.getBlockState(pos).getBlock() != DimDoors.blockRift || link == null ||
!player.canPlayerEdit(pos, hit.sideHit, stack)) return false; !player.canPlayerEdit(pos, hit.sideHit, stack)) return false;

View file

@ -4,9 +4,9 @@ import java.util.List;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.blocks.BaseDimDoor; import com.zixiken.dimdoors.blocks.BaseDimDoor;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -63,8 +63,8 @@ public class ItemRiftSignature extends Item {
if (source != null) { if (source != null) {
// The link was used before and already has an endpoint stored. // The link was used before and already has an endpoint stored.
// Create links connecting the two endpoints. // Create links connecting the two endpoints.
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension()); DimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
NewDimData destinationDimension = PocketManager.getDimensionData(world); DimData destinationDimension = PocketManager.getDimensionData(world);
DimLink link = sourceDimension.createLink(source.getPoint().toBlockPos(), LinkType.NORMAL, DimLink link = sourceDimension.createLink(source.getPoint().toBlockPos(), LinkType.NORMAL,
source.getOrientation()); source.getOrientation());
@ -128,7 +128,7 @@ public class ItemRiftSignature extends Item {
return pos.up(2); return pos.up(2);
} }
public static void setSource(ItemStack itemStack, BlockPos pos, EnumFacing orientation, NewDimData dimension) { public static void setSource(ItemStack itemStack, BlockPos pos, EnumFacing orientation, DimData dimension) {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("linkX", pos.getX()); tag.setInteger("linkX", pos.getX());

View file

@ -3,6 +3,7 @@ package com.zixiken.dimdoors.items;
import java.util.List; import java.util.List;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,12 +11,10 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -42,8 +41,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature {
Point4DOrientation source = getSource(stack); Point4DOrientation source = getSource(stack);
if (source != null) { if (source != null) {
// Yes, it's initialized. // Yes, it's initialized.
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension()); DimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
NewDimData destinationDimension = PocketManager.createDimensionData(world); DimData destinationDimension = PocketManager.createDimensionData(world);
DimLink link = sourceDimension.createLink(source.getPoint().toBlockPos(), LinkType.NORMAL, DimLink link = sourceDimension.createLink(source.getPoint().toBlockPos(), LinkType.NORMAL,
source.getOrientation()); source.getOrientation());
DimLink reverse = destinationDimension.getLink(pos); DimLink reverse = destinationDimension.getLink(pos);
@ -105,8 +104,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature {
// The SRS must have been initialized // The SRS must have been initialized
if (source != null) { if (source != null) {
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension()); DimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
NewDimData destinationDimension = PocketManager.createDimensionData(world); DimData destinationDimension = PocketManager.createDimensionData(world);
DimLink reverse = destinationDimension.getLink(pos); DimLink reverse = destinationDimension.getLink(pos);
DimLink link; DimLink link;

View file

@ -0,0 +1,182 @@
package com.zixiken.dimdoors.legacy;
/**Class that contains all the information about a specific dim that is pertienent to Dim Doors. Holds all the rifts present in the dim sorted by x,y,z and
* wether or not the dim is a pocket or not, along with its depth.
* @Return
*/
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.config.DDProperties;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
@Deprecated
public class LegacyDimData implements Serializable {
public int dimID;
public int depth;
public int dimOrientation;
public World world;
public LegacyLinkData exitDimLink;
public boolean isPocket;
public boolean hasBeenFilled = false;
public boolean hasDoor = false;
public boolean isDimRandomRift = false;
public Object dungeonGenerator = null;
//public boolean isPrivatePocket = false;
public HashMap<Integer, HashMap<Integer, HashMap<Integer, LegacyLinkData>>> linksInThisDim =
new HashMap<Integer, HashMap<Integer, HashMap<Integer, LegacyLinkData>>>();
HashMap<Integer, LegacyLinkData> dimX;
HashMap<Integer, HashMap<Integer, LegacyLinkData>> dimY ;
static final long serialVersionUID = 454342L;
public LegacyDimData(int dimID, boolean isPocket, int depth, LegacyLinkData exitLinkData) {
this.dimID = dimID;
this.depth = depth;
this.isPocket = isPocket;
this.exitDimLink = exitLinkData;
}
public LegacyDimData(int dimID, boolean isPocket, int depth, int exitLinkDimID, int exitX, int exitY, int exitZ) {
this(dimID, isPocket, depth, new LegacyLinkData(exitLinkDimID, exitX, exitY, exitZ));
}
public LegacyLinkData findNearestRift(World world, int range, int x, int y, int z) {
LegacyLinkData nearest = null;
float distance = range+1;
int i = -range;
int j = -range;
int k = -range;
while (i < range) {
while (j < range) {
while (k < range) {
if (world.getBlockState(new BlockPos(x+i, y+j, z+k)).getBlock() == DimDoors.blockRift &&
MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k) < distance) {
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k) != 0) {
nearest = this.findLinkAtCoords(x+i, y+j, z+k);
distance = MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k);
}
}
k++;
}
k = -range;
j++;
}
j = -range;
i++;
}
return nearest;
}
public ArrayList findRiftsInRange(World world, int range, int x, int y, int z) {
LegacyLinkData nearest;
ArrayList<LegacyLinkData> rifts = new ArrayList<LegacyLinkData>();
int i = -range;
int j = -range;
int k = -range;
while (i < range) {
while (j < range) {
while (k < range) {
if(world.getBlockState(new BlockPos(x+i, y+j, z+k)).getBlock() == DimDoors.blockRift) {
if(MathHelper.abs(i)+MathHelper.abs(j)+MathHelper.abs(k) != 0) {
nearest = this.findLinkAtCoords(x+i, y+j, z+k);
if(nearest != null) rifts.add(nearest);
}
}
k++;
}
k = -range;
j++;
}
j = -range;
i++;
}
return rifts;
}
public LegacyLinkData addLinkToDim(LegacyLinkData link) {
if(this.linksInThisDim.containsKey(link.locZCoord)) {
this.dimY=this.linksInThisDim.get(link.locZCoord);
if(this.dimY.containsKey(link.locYCoord)) this.dimX=this.dimY.get(link.locYCoord);
else this.dimX=new HashMap<Integer, LegacyLinkData>();
} else {
this.dimX=new HashMap<Integer, LegacyLinkData>();
this.dimY=new HashMap<Integer, HashMap<Integer, LegacyLinkData>>();
}
this.dimX.put(link.locXCoord, link);
this.dimY.put(link.locYCoord, dimX);
this.linksInThisDim.put(link.locZCoord, dimY);
//System.out.println("added link to dim "+this.dimID);
return link;
}
public LegacyLinkData addLinkToDim(int destinationDimID, int locationXCoord, int locationYCoord, int locationZCoord,
int destinationXCoord, int destinationYCoord, int destinationZCoord, int linkOrientation) {
LegacyLinkData linkData = new LegacyLinkData(this.dimID, destinationDimID, locationXCoord, locationYCoord,
locationZCoord, destinationXCoord, destinationYCoord,
destinationZCoord, this.isPocket, linkOrientation);
return this.addLinkToDim(linkData);
}
public boolean isLimbo() {return (this.dimID == DDProperties.instance().LimboDimensionID);}
public void removeLinkAtCoords(LegacyLinkData link) {
this.removeLinkAtCoords(link.locDimID, link.locXCoord, link.locYCoord, link.locZCoord);
}
public void removeLinkAtCoords(int locationID, int locationXCoord, int locationYCoord, int locationZCoord) {
if (this.linksInThisDim.containsKey(locationZCoord)) {
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord)) this.dimX=this.dimY.get(locationYCoord);
else this.dimX=new HashMap<Integer, LegacyLinkData>();
} else {
this.dimX=new HashMap<Integer, LegacyLinkData>();
this.dimY=new HashMap<Integer, HashMap<Integer, LegacyLinkData>>();
}
this.dimX.remove(locationXCoord);
this.dimY.put(locationYCoord, dimX);
this.linksInThisDim.put(locationZCoord, dimY);
}
public LegacyLinkData findLinkAtCoords(int locationXCoord, int locationYCoord, int locationZCoord) {
try {
if(this.linksInThisDim.containsKey(locationZCoord)) {
this.dimY=this.linksInThisDim.get(locationZCoord);
if(this.dimY.containsKey(locationYCoord)) {
this.dimX=this.dimY.get(locationYCoord);
if(this.dimX.containsKey(locationXCoord)) return this.dimX.get(locationXCoord);
}
}
} catch(Exception E) {return null;}
return null;
}
public ArrayList<LegacyLinkData> getLinksInDim() {
//TODO: We might want to modify this function, but I'm afraid of breaking something right now.
//To begin with, the name is wrong. This doesn't print anything! >_o ~SenseiKiwi
ArrayList<LegacyLinkData> links = new ArrayList<LegacyLinkData>();
if (this.linksInThisDim == null) return links;
for (HashMap<Integer, HashMap<Integer, LegacyLinkData>> first : this.linksInThisDim.values())
for (HashMap<Integer, LegacyLinkData> second : first.values())
for (LegacyLinkData linkData : second.values()) links.add(linkData);
return links;
}
}

View file

@ -0,0 +1,62 @@
package com.zixiken.dimdoors.legacy;
import java.io.Serializable;
@Deprecated
public class LegacyLinkData implements Serializable {
public int locXCoord;
public int locYCoord;
public int locZCoord;
public int destXCoord;
public int destYCoord;
public int destZCoord;
public int numberofChildren;
public boolean isLocPocket;
public int linkOrientation;
public int destDimID;
public int locDimID;
public boolean exists=false;
public boolean hasGennedDoor = false;
static final long serialVersionUID = 45544342L;
public LegacyLinkData() {this.exists = false;}
public LegacyLinkData(int exitLinkDimID, int exitX, int exitY, int exitZ) {
this.destDimID = exitLinkDimID;
this.destXCoord = exitX;
this.destYCoord = exitY;
this.destZCoord = exitZ;
}
public LegacyLinkData(int locationDimID, int destinationDimID, int locationXCoord, int locationYCoord,
int locationZCoord, int destinationXCoord, int destinationYCoord,
int destinationZCoord, boolean isPocket, int orientation) {
this.exists = true;
this.locXCoord = locationXCoord;
this.locYCoord = locationYCoord;
this.locZCoord = locationZCoord;
this.destXCoord = destinationXCoord;
this.destYCoord = destinationYCoord;
this.destZCoord = destinationZCoord;
this.destDimID = destinationDimID;
this.locDimID = locationDimID;
this.isLocPocket = isPocket;
this.linkOrientation = orientation;
}
public String printLinkData() {
//TODO: Rewrite this to make it prettier. @_@ I'm afraid of changing it to ToString() on the off
//chance it'll cause explosions and sadness. Damn serialization! ~SenseiKiwi
String linkInfo;
linkInfo = String.valueOf(this.locDimID) + "locDimID "+String.valueOf(this.locXCoord)+":locXCoord "+String.valueOf(this.locYCoord)+":locYCoord "+String.valueOf(this.locZCoord)+":locZCoord ";
linkInfo.concat("\n"+ String.valueOf(this.destDimID)+"DestDimID "+String.valueOf(this.destXCoord)+":destXCoord "+String.valueOf(this.destYCoord)+":destYCoord "+String.valueOf(this.destZCoord)+":destZCoord ");
return linkInfo;
}
}

View file

@ -0,0 +1,94 @@
package com.zixiken.dimdoors.legacy;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.zixiken.dimdoors.ObjectSaveInputStream;
import com.zixiken.dimdoors.core.DimensionType;
import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.saving.DDSaveHandler;
import com.zixiken.dimdoors.saving.PackedDimData;
import com.zixiken.dimdoors.saving.PackedLinkData;
import com.zixiken.dimdoors.saving.PackedLinkTail;
import com.zixiken.dimdoors.util.Point4D;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
public class LegacySaveImporter {
public static void importOldSave(File file) throws IOException, ClassNotFoundException {
FileInputStream saveFile = new FileInputStream(file);
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
HashMap comboSave =((HashMap) save.readObject());
save.close();
List<PackedLinkData> allPackedLinks = new ArrayList<PackedLinkData>();
HashMap<Integer,PackedDimData> newPackedDimData = new HashMap<Integer,PackedDimData>();
HashMap<Integer, LegacyDimData> dimMap;
try {
dimMap = (HashMap<Integer, LegacyDimData>) comboSave.get("dimList");
} catch(Exception e) {
System.out.println("Could not import old save data");
return;
}
//build the child list
HashMap<Integer, ArrayList<Integer>> parentChildMapping = new HashMap<Integer, ArrayList<Integer>>();
for(LegacyDimData data : dimMap.values()) {
if(data.isPocket) {
LegacyLinkData link = data.exitDimLink;
if(parentChildMapping.containsKey(link.destDimID))
parentChildMapping.get(link.destDimID).add(data.dimID);
else {
parentChildMapping.put(link.destDimID, new ArrayList<Integer>());
parentChildMapping.get(link.destDimID).add(data.dimID);
}
parentChildMapping.remove(data.dimID);
}
}
for(LegacyDimData data : dimMap.values()) {
List<PackedLinkData> newPackedLinkData = new ArrayList<PackedLinkData>();
List<Integer> childDims;
if(parentChildMapping.containsKey(data.dimID)) childDims = parentChildMapping.get(data.dimID);
else childDims = new ArrayList<Integer>();
for(LegacyLinkData link : data.getLinksInDim()) {
Point4D source = new Point4D(new BlockPos(link.locXCoord, link.locYCoord, link.locZCoord),
link.locDimID);
Point4D destintion = new Point4D(new BlockPos(link.destXCoord, link.destYCoord, link.destZCoord),
link.destDimID);
PackedLinkTail tail = new PackedLinkTail(destintion, LinkType.NORMAL);
List<BlockPos> children = new ArrayList<BlockPos>();
PackedLinkData newPackedLink = new PackedLinkData(source, new BlockPos(-1,-1,-1), tail,
EnumFacing.getHorizontal(link.linkOrientation), children, null);
newPackedLinkData.add(newPackedLink);
allPackedLinks.add(newPackedLink);
}
PackedDimData dim;
DimensionType type;
if(data.isPocket) {
if(data.dungeonGenerator != null) type = DimensionType.DUNGEON;
else type = DimensionType.POCKET;
} else type = DimensionType.ROOT;
if(data.isPocket) dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID,
data.exitDimLink.locDimID, EnumFacing.SOUTH, type, data.hasBeenFilled, null,
new BlockPos(0,64,0), childDims, newPackedLinkData, null);
else dim = new PackedDimData(data.dimID, data.depth, data.depth, data.dimID, data.dimID,
EnumFacing.EAST.SOUTH, type, data.hasBeenFilled, null, new BlockPos(0,64,0),
childDims, newPackedLinkData, null);
newPackedDimData.put(dim.ID,dim);
}
DDSaveHandler.unpackDimData(newPackedDimData);
DDSaveHandler.unpackLinkData(allPackedLinks);
}
}

View file

@ -1,7 +1,7 @@
package com.zixiken.dimdoors.network.handlers; package com.zixiken.dimdoors.network.handlers;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.network.packets.ClientJoinPacket; import com.zixiken.dimdoors.network.packets.ClientJoinPacket;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -16,7 +16,7 @@ public class ClientJoinHandler implements IMessageHandler<ClientJoinPacket, IMes
@Override @Override
public IMessage onMessage(ClientJoinPacket message, MessageContext ctx) { public IMessage onMessage(ClientJoinPacket message, MessageContext ctx) {
EntityPlayer player = DimDoors.proxy.getMessagePlayer(ctx); EntityPlayer player = DimDoors.proxy.getMessagePlayer(ctx);
NewDimData dimensionData = PocketManager.getDimensionData(player.worldObj); DimData dimensionData = PocketManager.getDimensionData(player.worldObj);
if (dimensionData.isPocketDimension()) if (dimensionData.isPocketDimension())
player.worldObj.provider.registerWorld(player.worldObj); player.worldObj.provider.registerWorld(player.worldObj);

View file

@ -9,17 +9,13 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import com.zixiken.dimdoors.Point3D; import com.zixiken.dimdoors.core.*;
import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.dungeon.DungeonData; import com.zixiken.dimdoors.dungeon.DungeonData;
import com.zixiken.dimdoors.helpers.DungeonHelper; import com.zixiken.dimdoors.helpers.DungeonHelper;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.util.DDLogger; import com.zixiken.dimdoors.util.DDLogger;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.core.DimensionType; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.util.FileFilters; import com.zixiken.dimdoors.util.FileFilters;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import com.google.common.io.Files; import com.google.common.io.Files;
@ -95,7 +91,7 @@ public class DDSaveHandler
unpackDimData(packedDims); unpackDimData(packedDims);
unpackLinkData(linksToUnpack); unpackLinkData(linksToUnpack);
HashMap<String, NewDimData> personalPocketsMap = new HashMap<String, NewDimData>(); HashMap<String, DimData> personalPocketsMap = new HashMap<String, DimData>();
for(Entry<String, Integer> pair : ppMap.entrySet()) for(Entry<String, Integer> pair : ppMap.entrySet())
{ {
personalPocketsMap.put(pair.getKey(), PocketManager.getDimensionData(pair.getValue())); personalPocketsMap.put(pair.getKey(), PocketManager.getDimensionData(pair.getValue()));
@ -106,7 +102,7 @@ public class DDSaveHandler
} }
/** /**
* Takes a list of packedDimData and rebuilds the DimData for it * Takes a list of packedDimData and rebuilds the LegacyDimData for it
* @param packedDims * @param packedDims
* @return * @return
*/ */
@ -209,7 +205,7 @@ public class DDSaveHandler
{ {
if(packedLink.parent.equals(fakePoint)) if(packedLink.parent.equals(fakePoint))
{ {
NewDimData data = PocketManager.getDimensionData(packedLink.source.getDimension()); DimData data = PocketManager.getDimensionData(packedLink.source.getDimension());
LinkType linkType = LinkType.getLinkTypeFromIndex(packedLink.tail.linkType); LinkType linkType = LinkType.getLinkTypeFromIndex(packedLink.tail.linkType);
@ -229,7 +225,7 @@ public class DDSaveHandler
{ {
for(PackedLinkData packedLink : linksToUnpack) for(PackedLinkData packedLink : linksToUnpack)
{ {
NewDimData data = PocketManager.createDimensionDataDangerously(packedLink.source.getDimension()); DimData data = PocketManager.createDimensionDataDangerously(packedLink.source.getDimension());
if(data.getLink(packedLink.parent)!=null) if(data.getLink(packedLink.parent)!=null)
{ {
data.createChildLink(packedLink.source, data.getLink(packedLink.parent), packedLink.lock); data.createChildLink(packedLink.source, data.getLink(packedLink.parent), packedLink.lock);
@ -331,13 +327,13 @@ public class DDSaveHandler
} }
} }
private static boolean writePersonalPocketMap(HashMap<String, NewDimData> hashMap, String savePath) private static boolean writePersonalPocketMap(HashMap<String, DimData> hashMap, String savePath)
{ {
try try
{ {
HashMap<String, Integer> ppMap = new HashMap<String, Integer>(); HashMap<String, Integer> ppMap = new HashMap<String, Integer>();
for(Entry<String, NewDimData> pair : hashMap.entrySet()) for(Entry<String, DimData> pair : hashMap.entrySet())
{ {
ppMap.put(pair.getKey(), pair.getValue().id()); ppMap.put(pair.getKey(), pair.getValue().id());
} }

View file

@ -1,120 +0,0 @@
package com.zixiken.dimdoors.saving;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.zixiken.dimdoors.DimData;
import com.zixiken.dimdoors.LinkData;
import com.zixiken.dimdoors.ObjectSaveInputStream;
import com.zixiken.dimdoors.Point3D;
import com.zixiken.dimdoors.core.DimensionType;
import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.util.Point4D;
public class OldSaveImporter
{
public static void importOldSave(File file) throws IOException, ClassNotFoundException
{
FileInputStream saveFile = new FileInputStream(file);
ObjectSaveInputStream save = new ObjectSaveInputStream(saveFile);
HashMap comboSave =((HashMap) save.readObject());
save.close();
List<PackedLinkData> allPackedLinks = new ArrayList<PackedLinkData>();
HashMap<Integer,PackedDimData> newPackedDimData = new HashMap<Integer,PackedDimData>();
HashMap<Integer, DimData> dimMap;
try
{
dimMap = (HashMap<Integer, DimData>) comboSave.get("dimList");
}
catch(Exception e)
{
System.out.println("Could not import old save data");
return;
}
//build the child list
HashMap<Integer, ArrayList<Integer>> parentChildMapping = new HashMap<Integer, ArrayList<Integer>>();
for(DimData data : dimMap.values())
{
if(data.isPocket)
{
LinkData link = data.exitDimLink;
if(parentChildMapping.containsKey(link.destDimID))
{
parentChildMapping.get(link.destDimID).add(data.dimID);
}
else
{
parentChildMapping.put(link.destDimID, new ArrayList<Integer>());
parentChildMapping.get(link.destDimID).add(data.dimID);
}
parentChildMapping.remove(data.dimID);
}
}
for(DimData data : dimMap.values())
{
List<PackedLinkData> newPackedLinkData = new ArrayList<PackedLinkData>();
List<Integer> childDims;
if(parentChildMapping.containsKey(data.dimID))
{
childDims =parentChildMapping.get(data.dimID);
}
else
{
childDims = new ArrayList<Integer>();
}
for(LinkData link : data.getLinksInDim())
{
Point4D source = new Point4D(link.locXCoord,link.locYCoord,link.locZCoord,link.locDimID);
Point4D destintion = new Point4D(link.destXCoord,link.destYCoord,link.destZCoord,link.destDimID);
PackedLinkTail tail = new PackedLinkTail(destintion, LinkType.NORMAL);
List<BlockPos> children = new ArrayList<BlockPos>();
PackedLinkData newPackedLink = new PackedLinkData(source, new BlockPos(-1,-1,-1), tail, link.linkOrientation,children, null);
newPackedLinkData.add(newPackedLink);
allPackedLinks.add(newPackedLink);
}
PackedDimData dim;
DimensionType type;
if(data.isPocket)
{
if(data.dungeonGenerator!=null)
{
type = DimensionType.DUNGEON;
}
else
{
type = DimensionType.POCKET;
}
}
else
{
type = DimensionType.ROOT;
}
if(data.isPocket)
{
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, type, data.hasBeenFilled, null, new BlockPos(0,64,0), childDims, newPackedLinkData, null);
}
else
{
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.dimID, data.dimID, 0, type, data.hasBeenFilled, null, new BlockPos(0,64,0), childDims, newPackedLinkData, null);
}
newPackedDimData.put(dim.ID,dim);
}
DDSaveHandler.unpackDimData(newPackedDimData);
DDSaveHandler.unpackLinkData(allPackedLinks);
}
}

View file

@ -4,6 +4,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -13,7 +14,6 @@ import net.minecraft.world.GameRules;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.helpers.yCoordHelper; import com.zixiken.dimdoors.helpers.yCoordHelper;
import com.zixiken.dimdoors.util.ChunkLocation; import com.zixiken.dimdoors.util.ChunkLocation;
@ -89,7 +89,7 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ) private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ)
{ {
NewDimData dimension = PocketManager.getDimensionData(dimensionID); DimData dimension = PocketManager.getDimensionData(dimensionID);
World pocket = DimensionManager.getWorld(dimensionID); World pocket = DimensionManager.getWorld(dimensionID);
if (pocket == null || if (pocket == null ||

View file

@ -1,7 +1,7 @@
package com.zixiken.dimdoors.tileentities; package com.zixiken.dimdoors.tileentities;
import com.zixiken.dimdoors.IChunkLoader; import com.zixiken.dimdoors.IChunkLoader;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.helpers.ChunkLoaderHelper; import com.zixiken.dimdoors.helpers.ChunkLoaderHelper;
import com.zixiken.dimdoors.world.PocketBuilder; import com.zixiken.dimdoors.world.PocketBuilder;
@ -27,7 +27,7 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo
// block or the lower one because only one of them should have a // block or the lower one because only one of them should have a
// link associated with it. // link associated with it.
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
NewDimData dimension = PocketManager.createDimensionData(worldObj); DimData dimension = PocketManager.createDimensionData(worldObj);
// Check whether a ticket has already been assigned to this door // Check whether a ticket has already been assigned to this door
if (chunkTicket == null) { if (chunkTicket == null) {
@ -53,7 +53,7 @@ public class TileEntityDimDoorGold extends TileEntityDimDoor implements IChunkLo
} }
} }
private boolean isValidChunkLoaderSetup(NewDimData dimension) { private boolean isValidChunkLoaderSetup(DimData dimension) {
// Check the various conditions that make this a valid door setup. // Check the various conditions that make this a valid door setup.
// 1. The door must be inside the pocket's XZ boundaries, // 1. The door must be inside the pocket's XZ boundaries,
// to prevent loading of chunks with a distant door // to prevent loading of chunks with a distant door

View file

@ -5,6 +5,7 @@ import java.util.Random;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -15,7 +16,6 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.util.Point4D; import com.zixiken.dimdoors.util.Point4D;
import com.zixiken.dimdoors.watcher.ClientLinkData; import com.zixiken.dimdoors.watcher.ClientLinkData;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
@ -124,7 +124,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable
} }
private void closeRift() { private void closeRift() {
NewDimData dimension = PocketManager.createDimensionData(worldObj); DimData dimension = PocketManager.createDimensionData(worldObj);
if (growth < CLOSING_PERIOD / 2) { if (growth < CLOSING_PERIOD / 2) {
for (DimLink riftLink : dimension.findRiftsInRange(worldObj, 6, pos)) { for (DimLink riftLink : dimension.findRiftsInRange(worldObj, 6, pos)) {
Point4D location = riftLink.source(); Point4D location = riftLink.source();
@ -192,7 +192,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable
return; return;
} }
NewDimData dimension = PocketManager.createDimensionData(worldObj); DimData dimension = PocketManager.createDimensionData(worldObj);
DimLink link = dimension.getLink(pos); DimLink link = dimension.getLink(pos);
if (link.childCount() >= MAX_CHILD_LINKS || countAncestorLinks(link) >= MAX_ANCESTOR_LINKS) { if (link.childCount() >= MAX_CHILD_LINKS || countAncestorLinks(link) >= MAX_ANCESTOR_LINKS) {

View file

@ -2,8 +2,8 @@ package com.zixiken.dimdoors.watcher;
import java.io.*; import java.io.*;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimensionType; import com.zixiken.dimdoors.core.DimensionType;
import com.zixiken.dimdoors.core.NewDimData;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
public class ClientDimData public class ClientDimData
@ -20,7 +20,7 @@ public class ClientDimData
this.type = type; this.type = type;
} }
public ClientDimData(NewDimData dimension) public ClientDimData(DimData dimension)
{ {
ID = dimension.id(); ID = dimension.id();
this.rootID = dimension.root().id(); this.rootID = dimension.root().id();

View file

@ -3,7 +3,7 @@ package com.zixiken.dimdoors.world;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.*;
import com.zixiken.dimdoors.helpers.BlockPosHelper; import com.zixiken.dimdoors.helpers.BlockPosHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -16,13 +16,9 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import com.zixiken.dimdoors.experimental.BoundingBox; import com.zixiken.dimdoors.experimental.BoundingBox;
import com.zixiken.dimdoors.Point3D;
import com.zixiken.dimdoors.blocks.IDimDoor; import com.zixiken.dimdoors.blocks.IDimDoor;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DimensionType; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.dungeon.DungeonData; import com.zixiken.dimdoors.dungeon.DungeonData;
import com.zixiken.dimdoors.dungeon.DungeonSchematic; import com.zixiken.dimdoors.dungeon.DungeonSchematic;
import com.zixiken.dimdoors.dungeon.pack.DungeonPackConfig; import com.zixiken.dimdoors.dungeon.pack.DungeonPackConfig;
@ -47,7 +43,7 @@ public class PocketBuilder
private PocketBuilder() { } private PocketBuilder() { }
private static boolean buildDungeonPocket(DungeonData dungeon, NewDimData dimension, DimLink link, DungeonSchematic schematic, World world, DDProperties properties) { private static boolean buildDungeonPocket(DungeonData dungeon, DimData dimension, DimLink link, DungeonSchematic schematic, World world, DDProperties properties) {
//Calculate the destination point //Calculate the destination point
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null; DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
Point4D source = link.source(); Point4D source = link.source();
@ -92,8 +88,8 @@ public class PocketBuilder
} }
// Register a new dimension // Register a new dimension
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension()); DimData parent = PocketManager.getDimensionData(link.source().getDimension());
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON); DimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
//Load a world //Load a world
World world = PocketManager.loadDimension(dimension.id()); World world = PocketManager.loadDimension(dimension.id());
@ -119,7 +115,7 @@ public class PocketBuilder
} }
//Choose a dungeon to generate //Choose a dungeon to generate
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension()); DimData parent = PocketManager.getDimensionData(link.source().getDimension());
Pair<DungeonData, DungeonSchematic> pair = selectNextDungeon(parent, random, properties); Pair<DungeonData, DungeonSchematic> pair = selectNextDungeon(parent, random, properties);
if (pair == null) { if (pair == null) {
@ -131,7 +127,7 @@ public class PocketBuilder
DungeonSchematic schematic = pair.getSecond(); DungeonSchematic schematic = pair.getSecond();
//Register a new dimension //Register a new dimension
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON); DimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
//Load a world //Load a world
World world = PocketManager.loadDimension(dimension.id()); World world = PocketManager.loadDimension(dimension.id());
@ -145,8 +141,8 @@ public class PocketBuilder
} }
private static BlockPos calculateNoisyDestination(Point4D source, NewDimData dimension, DungeonData dungeon, EnumFacing facing) { private static BlockPos calculateNoisyDestination(Point4D source, DimData dimension, DungeonData dungeon, EnumFacing facing) {
int depth = NewDimData.calculatePackDepth(dimension.parent(), dungeon); int depth = DimData.calculatePackDepth(dimension.parent(), dungeon);
int forwardNoise = MathHelper.getRandomIntegerInRange(random, 10 * depth, 130 * depth); int forwardNoise = MathHelper.getRandomIntegerInRange(random, 10 * depth, 130 * depth);
int sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth); int sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth);
@ -160,7 +156,7 @@ public class PocketBuilder
return linkDestination; return linkDestination;
} }
private static Pair<DungeonData, DungeonSchematic> selectNextDungeon(NewDimData parent, Random random, DDProperties properties) { private static Pair<DungeonData, DungeonSchematic> selectNextDungeon(DimData parent, Random random, DDProperties properties) {
DungeonData dungeon = null; DungeonData dungeon = null;
DungeonSchematic schematic = null; DungeonSchematic schematic = null;
@ -302,8 +298,8 @@ public class PocketBuilder
try try
{ {
//Register a new dimension //Register a new dimension
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension()); DimData parent = PocketManager.getDimensionData(link.source().getDimension());
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.PERSONAL, player.getGameProfile().getId().toString()); DimData dimension = PocketManager.registerPocket(parent, DimensionType.PERSONAL, player.getGameProfile().getId().toString());
//Load a world //Load a world
@ -347,8 +343,8 @@ public class PocketBuilder
try try
{ {
//Register a new dimension //Register a new dimension
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension()); DimData parent = PocketManager.getDimensionData(link.source().getDimension());
NewDimData dimension = PocketManager.registerPocket(parent, type); DimData dimension = PocketManager.registerPocket(parent, type);
//Load a world //Load a world
@ -516,7 +512,7 @@ public class PocketBuilder
chunk.setChunkModified(); chunk.setChunkModified();
} }
public static BoundingBox calculateDefaultBounds(NewDimData pocket) public static BoundingBox calculateDefaultBounds(DimData pocket)
{ {
// Calculate the XZ bounds of this pocket assuming that it has the default size // Calculate the XZ bounds of this pocket assuming that it has the default size
// The Y bounds will be set to encompass the height of a chunk. // The Y bounds will be set to encompass the height of a chunk.

View file

@ -2,7 +2,7 @@ package com.zixiken.dimdoors.world;
import java.util.List; import java.util.List;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.ticking.CustomLimboPopulator; import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.EnumCreatureType;
@ -49,7 +49,7 @@ public class PocketGenerator extends ChunkProviderGenerate {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
public List getPossibleCreatures(EnumCreatureType type, BlockPos pos) { public List getPossibleCreatures(EnumCreatureType type, BlockPos pos) {
NewDimData dimension = PocketManager.createDimensionData(this.worldObj); DimData dimension = PocketManager.createDimensionData(this.worldObj);
if (dimension != null && dimension.dungeon() != null && !dimension.dungeon().isOpen()) { if (dimension != null && dimension.dungeon() != null && !dimension.dungeon().isOpen()) {
return this.worldObj.getBiomeGenForCoords(pos).getSpawnableList(type); return this.worldObj.getBiomeGenForCoords(pos).getSpawnableList(type);
} }

View file

@ -1,7 +1,7 @@
package com.zixiken.dimdoors.world; package com.zixiken.dimdoors.world;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.ticking.CustomLimboPopulator; import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
@ -85,7 +85,7 @@ public class PocketProvider extends WorldProvider {
return; return;
} }
NewDimData data = PocketManager.getDimensionData(this.dimensionId); DimData data = PocketManager.getDimensionData(this.dimensionId);
if(data == null || data.type() == DimensionType.POCKET) { if(data == null || data.type() == DimensionType.POCKET) {
super.generateLightBrightnessTable(); super.generateLightBrightnessTable();
return; return;

View file

@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureComponent;
import com.zixiken.dimdoors.core.NewDimData; import com.zixiken.dimdoors.core.DimData;
public class ComponentNetherGateway extends StructureComponent public class ComponentNetherGateway extends StructureComponent
{ {
@ -147,7 +147,7 @@ public class ComponentNetherGateway extends StructureComponent
int x = this.getXWithOffset(3, 3); int x = this.getXWithOffset(3, 3);
int z = this.getZWithOffset(3, 3); int z = this.getZWithOffset(3, 3);
DimLink link; DimLink link;
NewDimData dimension; DimData dimension;
// This function might run multiple times for a single component // This function might run multiple times for a single component
// due to the way Minecraft handles structure generation! // due to the way Minecraft handles structure generation!

View file

@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import com.zixiken.dimdoors.config.DDProperties; import com.zixiken.dimdoors.config.DDProperties;
import com.zixiken.dimdoors.core.DimData;
import com.zixiken.dimdoors.core.DimLink; import com.zixiken.dimdoors.core.DimLink;
import com.zixiken.dimdoors.core.LinkType; import com.zixiken.dimdoors.core.LinkType;
import com.zixiken.dimdoors.core.NewDimData;
import com.zixiken.dimdoors.core.PocketManager; import com.zixiken.dimdoors.core.PocketManager;
import com.zixiken.dimdoors.DimDoors; import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.world.PocketProvider; import com.zixiken.dimdoors.world.PocketProvider;
@ -80,7 +80,7 @@ public class GatewayGenerator implements IWorldGenerator
int attempts; int attempts;
boolean valid; boolean valid;
DimLink link; DimLink link;
NewDimData dimension; DimData dimension;
// Check if we're allowed to generate rift clusters in this dimension. // Check if we're allowed to generate rift clusters in this dimension.
// If so, randomly decide whether to one. // If so, randomly decide whether to one.