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:
parent
1e37e50712
commit
cd904e9d96
46 changed files with 552 additions and 793 deletions
|
@ -6,7 +6,7 @@ import com.zixiken.dimdoors.network.DimDoorsNetwork;
|
|||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
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.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -22,7 +22,7 @@ public class ConnectionHandler {
|
|||
if (FMLCommonHandler.instance().getSide() == Side.SERVER) {
|
||||
NetHandlerPlayServer server = ((NetHandlerPlayServer)event.handler);
|
||||
FMLEmbeddedChannel channel = NetworkRegistry.INSTANCE.getChannel("FORGE", Side.SERVER);
|
||||
for (NewDimData data : PocketManager.getDimensions()) {
|
||||
for (DimData data : PocketManager.getDimensions()) {
|
||||
try {
|
||||
int id = data.id();
|
||||
if (data.isPocketDimension() || id == DDProperties.instance().LimboDimensionID)
|
||||
|
|
|
@ -10,15 +10,13 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class DeathTracker
|
||||
{
|
||||
public class DeathTracker {
|
||||
private ArrayList<String> usernameList;
|
||||
private HashSet<String> usernameSet;
|
||||
private String filePath;
|
||||
private boolean modified;
|
||||
|
||||
public DeathTracker(String filePath)
|
||||
{
|
||||
public DeathTracker(String filePath) {
|
||||
this.usernameList = new ArrayList<String>();
|
||||
this.usernameSet = new HashSet<String>();
|
||||
this.filePath = filePath;
|
||||
|
@ -27,72 +25,47 @@ public class DeathTracker
|
|||
readFromFile();
|
||||
}
|
||||
|
||||
private void readFromFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
private void readFromFile() {
|
||||
try {
|
||||
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();
|
||||
if (!line.isEmpty())
|
||||
{
|
||||
usernameSet.add(line);
|
||||
}
|
||||
if (!line.isEmpty()) usernameSet.add(line);
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
catch (FileNotFoundException e) { }
|
||||
catch (IOException e)
|
||||
{
|
||||
catch (FileNotFoundException e) {}
|
||||
catch (IOException e) {
|
||||
System.err.println("An unexpected exception occurred while trying to read DeathTracker data:");
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
usernameList.addAll(usernameSet);
|
||||
usernameList.addAll(usernameSet);
|
||||
}
|
||||
|
||||
public void writeToFile()
|
||||
{
|
||||
try
|
||||
{
|
||||
public void writeToFile() {
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter(filePath);
|
||||
for (String username : usernameList)
|
||||
{
|
||||
writer.println(username);
|
||||
}
|
||||
for (String username : usernameList) writer.println(username);
|
||||
writer.close();
|
||||
modified = false;
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
} catch (FileNotFoundException e) {
|
||||
System.err.println("An unexpected exception occurred while trying to read DeathTracker data:");
|
||||
System.err.println(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModified()
|
||||
{
|
||||
return modified;
|
||||
}
|
||||
public boolean isModified() {return modified;}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return usernameList.isEmpty();
|
||||
}
|
||||
public boolean isEmpty() {return usernameList.isEmpty();}
|
||||
|
||||
public String getRandomUsername(Random random)
|
||||
{
|
||||
public String getRandomUsername(Random random) {
|
||||
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()));
|
||||
}
|
||||
|
||||
public boolean addUsername(String username)
|
||||
{
|
||||
if (usernameSet.add(username))
|
||||
{
|
||||
public boolean addUsername(String username) {
|
||||
if (usernameSet.add(username)) {
|
||||
usernameList.add(username);
|
||||
modified = true;
|
||||
return true;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.zixiken.dimdoors;
|
|||
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.config.DDWorldProperties;
|
||||
import com.zixiken.dimdoors.core.*;
|
||||
import com.zixiken.dimdoors.items.BaseItemDoor;
|
||||
import com.zixiken.dimdoors.items.ItemWarpDoor;
|
||||
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.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import com.zixiken.dimdoors.core.DDTeleporter;
|
||||
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 com.zixiken.dimdoors.core.DimData;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -85,7 +82,7 @@ public class EventHookContainer
|
|||
{
|
||||
if(stack.getItem() instanceof ItemWarpDoor)
|
||||
{
|
||||
NewDimData data = PocketManager.getDimensionData(world);
|
||||
DimData data = PocketManager.getDimensionData(world);
|
||||
|
||||
if(data.type() == DimensionType.PERSONAL)
|
||||
{
|
||||
|
@ -229,7 +226,7 @@ public class EventHookContainer
|
|||
Chunk chunk = event.getChunk();
|
||||
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))
|
||||
{
|
||||
regenerator.scheduleSlowRegeneration(link);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.zixiken.dimdoors.blocks;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.tileentities.TileEntityDimDoorGold;
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class BlockGoldDimDoor extends BaseDimDoor {
|
|||
@Override
|
||||
public void placeLink(World world, BlockPos pos) {
|
||||
if (!world.isRemote && world.getBlockState(pos.down()).getBlock() == this) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (link == null)
|
||||
dimension.createLink(pos, LinkType.POCKET, world.getBlockState(pos.down()).getValue(BlockDoor.FACING));
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.*;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.client.ClosingRiftFX;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.tileentities.TileEntityRift;
|
||||
|
@ -25,7 +26,6 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import com.zixiken.dimdoors.client.GoggleRiftFX;
|
||||
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();
|
||||
|
||||
// Find reachable blocks that are vulnerable to rift damage and include air
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.zixiken.dimdoors.blocks;
|
||||
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
|
@ -10,7 +11,6 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
||||
public class DimensionalDoor extends BaseDimDoor {
|
||||
public static final String ID = "dimDoor";
|
||||
|
@ -26,7 +26,7 @@ public class DimensionalDoor extends BaseDimDoor {
|
|||
public void placeLink(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos.down());
|
||||
if (!world.isRemote && state.getBlock() == this) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (link == null)
|
||||
dimension.createLink(pos, LinkType.POCKET, state.getValue(BlockDoor.FACING));
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
|
||||
public class PersonalDimDoor extends BaseDimDoor {
|
||||
public static final String ID = "dimDoorPersonal";
|
||||
|
@ -26,7 +26,7 @@ public class PersonalDimDoor extends BaseDimDoor {
|
|||
public void placeLink(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos.down());
|
||||
if (!world.isRemote && state.getBlock() == this) {
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (link == null) {
|
||||
if (world.provider instanceof PersonalPocketProvider)
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit
|
|||
@Override
|
||||
public void placeLink(World world, BlockPos pos) {
|
||||
if (!world.isRemote) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (link == null && dimension.isPocketDimension())
|
||||
dimension.createLink(pos, LinkType.UNSAFE_EXIT, EnumFacing.EAST);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zixiken.dimdoors.blocks;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -9,13 +9,9 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.DDTeleporter;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
|
||||
public class TransientDoor extends BaseDimDoor {
|
||||
public static final String ID = "transientDoor";
|
||||
|
@ -53,7 +49,7 @@ public class TransientDoor extends BaseDimDoor {
|
|||
public void placeLink(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos.down());
|
||||
if (!world.isRemote && state.getBlock() == this) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (link == null && dimension.isPocketDimension()) {
|
||||
dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING));
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.zixiken.dimdoors.blocks;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
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 net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -28,7 +28,7 @@ public class UnstableDoor extends BaseDimDoor {
|
|||
public void placeLink(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos.down());
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
|
||||
public class WarpDoor extends BaseDimDoor {
|
||||
public static final String ID = "dimDoorWarp";
|
||||
|
@ -25,7 +25,7 @@ public class WarpDoor extends BaseDimDoor {
|
|||
public void placeLink(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos.down());
|
||||
if (!world.isRemote && state.getBlock() == this) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (link == null && dimension.isPocketDimension()) {
|
||||
dimension.createLink(pos, LinkType.SAFE_EXIT, state.getValue(BlockDoor.FACING));
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.zixiken.dimdoors.commands;
|
|||
import java.util.Collection;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
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.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
||||
public class CommandCreateDungeonRift extends DDCommandBase {
|
||||
private static CommandCreateDungeonRift instance = null;
|
||||
|
@ -31,7 +31,7 @@ public class CommandCreateDungeonRift extends DDCommandBase {
|
|||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
NewDimData dimension;
|
||||
DimData dimension;
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
if (command.length == 0) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
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.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
||||
public class CommandCreateRandomRift extends DDCommandBase {
|
||||
private static CommandCreateRandomRift instance = null;
|
||||
|
@ -34,7 +34,7 @@ public class CommandCreateRandomRift extends DDCommandBase {
|
|||
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command) {
|
||||
NewDimData dimension;
|
||||
DimData dimension;
|
||||
DungeonHelper dungeonHelper = DungeonHelper.instance();
|
||||
|
||||
if (command.length > 1)
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.zixiken.dimdoors.DimDoors;
|
|||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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.util.Point4D;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class CommandDeleteRifts extends DDCommandBase
|
|||
int y;
|
||||
int z;
|
||||
Point4D location;
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
ArrayList<DimLink> links = dimension.getAllLinks();
|
||||
for (DimLink link : links)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.zixiken.dimdoors.core.DimLink;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import com.zixiken.dimdoors.core.DimensionType;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
|
||||
public class CommandResetDungeons extends DDCommandBase {
|
||||
|
@ -34,13 +34,13 @@ public class CommandResetDungeons extends DDCommandBase {
|
|||
int resetCount = 0;
|
||||
int dungeonCount = 0;
|
||||
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,
|
||||
// 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);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class CommandResetDungeons extends DDCommandBase {
|
|||
// 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,
|
||||
// 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) {
|
||||
dungeonCount++;
|
||||
id = dimension.id();
|
||||
|
@ -63,7 +63,7 @@ public class CommandResetDungeons extends DDCommandBase {
|
|||
}
|
||||
|
||||
// Modify the loaded dungeons to prevent bugs
|
||||
for (NewDimData dungeon : loadedDungeons) {
|
||||
for (DimData dungeon : loadedDungeons) {
|
||||
// Find top-most loaded dungeons and update their parents.
|
||||
// They will automatically update their children.
|
||||
// Dungeons with non-dungeon parents don't need to be fixed.
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
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.util.Point4D;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class CommandTeleportPlayer extends DDCommandBase {
|
|||
World world;
|
||||
int dimensionID;
|
||||
Point4D destination;
|
||||
NewDimData dimension;
|
||||
DimData dimension;
|
||||
boolean checkOrientation;
|
||||
EntityPlayer targetPlayer;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.world.LimboProvider;
|
||||
import com.zixiken.dimdoors.Point3D;
|
||||
import com.zixiken.dimdoors.blocks.BaseDimDoor;
|
||||
import com.zixiken.dimdoors.blocks.IDimDoor;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
|
@ -446,8 +445,8 @@ public class DDTeleporter {
|
|||
// That means that it was a pocket and it was deleted.
|
||||
// Depending on the link type, we must overwrite it or cancel
|
||||
// the teleport operation. We don't need to assign 'link' with
|
||||
// a different value. NewDimData will overwrite it in-place.
|
||||
NewDimData start = PocketManager.getDimensionData(link.source().getDimension());
|
||||
// a different value. DimData will overwrite it in-place.
|
||||
DimData start = PocketManager.getDimensionData(link.source().getDimension());
|
||||
if (link.linkType() == LinkType.DUNGEON)
|
||||
{
|
||||
// Ovewrite the link into a dungeon link with no destination
|
||||
|
@ -515,7 +514,7 @@ public class DDTeleporter {
|
|||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
NewDimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString());
|
||||
DimData dim = PocketManager.getPersonalDimensionForPlayer(player.getGameProfile().getId().toString());
|
||||
if(dim == null)
|
||||
{
|
||||
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
|
||||
// because we want to have unbiased selection among all links.
|
||||
ArrayList<Point4D> matches = new ArrayList<Point4D>();
|
||||
for (NewDimData dimension : PocketManager.getRootDimensions())
|
||||
for (DimData dimension : PocketManager.getRootDimensions())
|
||||
{
|
||||
for (DimLink link : dimension.getAllLinks())
|
||||
{
|
||||
|
@ -574,7 +573,7 @@ public class DDTeleporter {
|
|||
// To avoid loops, don't generate a destination if the player is
|
||||
// already in a non-pocket dimension.
|
||||
|
||||
NewDimData current = PocketManager.getDimensionData(link.point.getDimension());
|
||||
DimData current = PocketManager.getDimensionData(link.point.getDimension());
|
||||
|
||||
if (current.isPocketDimension())
|
||||
{
|
||||
|
@ -632,7 +631,7 @@ public class DDTeleporter {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -643,9 +642,9 @@ public class DDTeleporter {
|
|||
// There is a chance of choosing the Nether first before other root dimensions
|
||||
// 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);
|
||||
|
||||
if (random.nextInt(MAX_ROOT_SHIFT_CHANCE) < shiftChance)
|
||||
|
@ -660,7 +659,7 @@ public class DDTeleporter {
|
|||
}
|
||||
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))
|
||||
{
|
||||
return generateSafeExit(selection, link, properties);
|
||||
|
@ -672,7 +671,7 @@ public class DDTeleporter {
|
|||
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
|
||||
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()));
|
||||
}
|
||||
|
||||
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
|
||||
// some precautions to protect the player. The X and Z coordinates
|
||||
|
@ -759,7 +758,7 @@ public class DDTeleporter {
|
|||
|
||||
// Create a reverse link for returning
|
||||
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);
|
||||
|
||||
sourceDim.setLinkDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.TreeMap;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.watcher.ClientLinkData;
|
||||
import com.zixiken.dimdoors.Point3D;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonData;
|
||||
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.PackedLinkTail;
|
||||
|
||||
public abstract class NewDimData implements IPackable<PackedDimData> {
|
||||
public abstract class DimData implements IPackable<PackedDimData> {
|
||||
private static class InnerDimLink extends DimLink {
|
||||
public InnerDimLink(Point4D source, DimLink parent, EnumFacing orientation, DDLock lock) {
|
||||
super(source, orientation, lock, parent);
|
||||
|
@ -37,7 +36,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
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()));
|
||||
}
|
||||
|
||||
|
@ -130,9 +129,9 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
protected int depth;
|
||||
protected int packDepth;
|
||||
protected DimensionType type;
|
||||
protected NewDimData parent;
|
||||
protected NewDimData root;
|
||||
protected List<NewDimData> children;
|
||||
protected DimData parent;
|
||||
protected DimData root;
|
||||
protected List<DimData> children;
|
||||
protected Point4D origin;
|
||||
protected EnumFacing orientation;
|
||||
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
|
||||
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)) {
|
||||
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.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.children = new ArrayList<NewDimData>();
|
||||
this.children = new ArrayList<DimData>();
|
||||
this.parent = parent;
|
||||
this.packDepth = 0;
|
||||
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
|
||||
if (root == null) {
|
||||
throw new IllegalArgumentException("root cannot be null.");
|
||||
|
@ -185,7 +184,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
this.id = id;
|
||||
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.linkList = new ArrayList<InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||
this.children = new ArrayList<NewDimData>();
|
||||
this.children = new ArrayList<DimData>();
|
||||
this.parent = null;
|
||||
this.packDepth = 0;
|
||||
this.type = type;
|
||||
|
@ -430,11 +429,11 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
return origin;
|
||||
}
|
||||
|
||||
public NewDimData parent() {
|
||||
public DimData parent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public NewDimData root() {
|
||||
public DimData root() {
|
||||
return root;
|
||||
}
|
||||
|
||||
|
@ -454,7 +453,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
return linkList.size();
|
||||
}
|
||||
|
||||
public Iterable<NewDimData> children() {
|
||||
public Iterable<DimData> 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
|
||||
Stack<NewDimData> ordering = new Stack<NewDimData>();
|
||||
Stack<DimData> ordering = new Stack<DimData>();
|
||||
ordering.addAll(this.children);
|
||||
|
||||
while (!ordering.isEmpty()) {
|
||||
NewDimData current = ordering.pop();
|
||||
DimData current = ordering.pop();
|
||||
current.resetDepth();
|
||||
ordering.addAll(current.children);
|
||||
}
|
||||
|
@ -517,7 +516,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
this.modified = true;
|
||||
}
|
||||
|
||||
public static int calculatePackDepth(NewDimData parent, DungeonData current) {
|
||||
public static int calculatePackDepth(DimData parent, DungeonData current) {
|
||||
DungeonData predecessor = parent.dungeon();
|
||||
if (current == null) {
|
||||
throw new IllegalArgumentException("current cannot be null.");
|
||||
|
@ -613,7 +612,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
parent.children.remove(this);
|
||||
}
|
||||
// Remove this dimension as the parent of its children
|
||||
for (NewDimData child : children) {
|
||||
for (DimData child : children) {
|
||||
child.parent = null;
|
||||
}
|
||||
// Clear all fields
|
||||
|
@ -646,7 +645,7 @@ public abstract class NewDimData implements IPackable<PackedDimData> {
|
|||
dungeon.dungeonType().Owner.getName());
|
||||
}
|
||||
//Make a list of children
|
||||
for(NewDimData data : this.children) {
|
||||
for(DimData data : this.children) {
|
||||
ChildIDs.add(data.id);
|
||||
}
|
||||
for(DimLink link:this.links()) {
|
|
@ -2,5 +2,5 @@ package com.zixiken.dimdoors.core;
|
|||
|
||||
public interface IDimRegistrationCallback
|
||||
{
|
||||
public NewDimData registerDimension(int dimensionID, int rootID, DimensionType type);
|
||||
public DimData registerDimension(int dimensionID, int rootID, DimensionType type);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.zixiken.dimdoors.config.DDProperties;
|
|||
import com.zixiken.dimdoors.helpers.Compactor;
|
||||
import com.zixiken.dimdoors.helpers.DeleteFolder;
|
||||
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.util.Point4D;
|
||||
import com.zixiken.dimdoors.watcher.ClientDimData;
|
||||
|
@ -34,13 +34,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
*/
|
||||
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
|
||||
// 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
|
||||
// instances of NewDimData going through PocketManager. In turn, that
|
||||
// instances of DimData going through PocketManager. In turn, that
|
||||
// enforces
|
||||
// that any link destinations must be real dimensions controlled by
|
||||
// PocketManager.
|
||||
|
@ -50,7 +50,7 @@ public class PocketManager
|
|||
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
|
||||
super(id, root, type);
|
||||
|
@ -64,7 +64,7 @@ public class PocketManager
|
|||
public void onCreated(ClientLinkData link)
|
||||
{
|
||||
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)
|
||||
dimension.createLink(source, LinkType.CLIENT, 0, link.lock);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class PocketManager
|
|||
public void onDeleted(ClientLinkData link)
|
||||
{
|
||||
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)
|
||||
dimension.deleteLink(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class PocketManager
|
|||
public void update(ClientLinkData link)
|
||||
{
|
||||
Point4D source = link.point;
|
||||
NewDimData dimension = getDimensionData(source.getDimension());
|
||||
DimData dimension = getDimensionData(source.getDimension());
|
||||
if (dimension != null) {
|
||||
DimLink dLink = dimension.getLink(source);
|
||||
dLink.lock = link.lock;
|
||||
|
@ -122,7 +122,7 @@ public class PocketManager
|
|||
// exposing a private constructor ONLY to a very specific trusted class.
|
||||
|
||||
@Override
|
||||
public NewDimData registerDimension(int dimensionID, int rootID, DimensionType type)
|
||||
public DimData registerDimension(int dimensionID, int rootID, DimensionType type)
|
||||
{
|
||||
return registerClientDimension(dimensionID, rootID, type);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class PocketManager
|
|||
public static volatile boolean isConnected = false;
|
||||
private static final UpdateWatcherProxy<ClientLinkData> linkWatcher = new UpdateWatcherProxy<ClientLinkData>();
|
||||
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
|
||||
// DD data.
|
||||
|
@ -149,7 +149,7 @@ public class PocketManager
|
|||
private static ArrayList<Integer> dimensionIDBlackList = null;
|
||||
|
||||
// Stores all the personal pocket mappings
|
||||
private static HashMap<String, NewDimData> personalPocketsMapping = null;
|
||||
private static HashMap<String, DimData> personalPocketsMapping = null;
|
||||
|
||||
public static boolean isLoaded()
|
||||
{
|
||||
|
@ -175,9 +175,9 @@ public class PocketManager
|
|||
isLoading = true;
|
||||
|
||||
dimensionData = new HashMap<Integer, InnerDimData>();
|
||||
rootDimensions = new ArrayList<NewDimData>();
|
||||
rootDimensions = new ArrayList<DimData>();
|
||||
dimensionIDBlackList = new ArrayList<Integer>();
|
||||
personalPocketsMapping = new HashMap<String, NewDimData>();
|
||||
personalPocketsMapping = new HashMap<String, DimData>();
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
{
|
||||
|
@ -241,13 +241,13 @@ public class PocketManager
|
|||
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
|
||||
// actually a pocket.
|
||||
// We cast to InnerDimData so that if anyone tries to be a smartass and
|
||||
// create their
|
||||
// own version of NewDimData, this will throw an exception.
|
||||
// own version of DimData, this will throw an exception.
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
|
@ -299,7 +299,7 @@ public class PocketManager
|
|||
|
||||
private static void registerPockets(DDProperties properties)
|
||||
{
|
||||
for (NewDimData dimension : dimensionData.values())
|
||||
for (DimData dimension : dimensionData.values())
|
||||
{
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
|
@ -328,7 +328,7 @@ public class PocketManager
|
|||
|
||||
private static void unregisterPockets()
|
||||
{
|
||||
for (NewDimData dimension : dimensionData.values())
|
||||
for (DimData dimension : dimensionData.values())
|
||||
{
|
||||
if (dimension.isPocketDimension())
|
||||
{
|
||||
|
@ -374,7 +374,7 @@ public class PocketManager
|
|||
try
|
||||
{
|
||||
System.out.println("Importing old DD save data...");
|
||||
OldSaveImporter.importOldSave(oldSaveData);
|
||||
LegacySaveImporter.importOldSave(oldSaveData);
|
||||
|
||||
oldSaveData.renameTo(new File(oldSaveData.getAbsolutePath() + "_IMPORTED"));
|
||||
|
||||
|
@ -449,7 +449,7 @@ public class PocketManager
|
|||
return world;
|
||||
}
|
||||
|
||||
public static NewDimData registerDimension(World world)
|
||||
public static DimData registerDimension(World world)
|
||||
{
|
||||
return registerDimension(world.provider.getDimensionId(), null, DimensionType.ROOT);
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ public class PocketManager
|
|||
* @param playername
|
||||
* @return
|
||||
*/
|
||||
public static NewDimData registerPocket(NewDimData parent, DimensionType type, String playername)
|
||||
public static DimData registerPocket(DimData parent, DimensionType type, String playername)
|
||||
{
|
||||
if (parent == null)
|
||||
{
|
||||
|
@ -480,7 +480,7 @@ public class PocketManager
|
|||
throw new IllegalArgumentException("A personal pocket must be attached to a playername");
|
||||
}
|
||||
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
|
||||
NewDimData data = registerDimension(dimensionID, (InnerDimData) parent, type);
|
||||
DimData data = registerDimension(dimensionID, (InnerDimData) parent, type);
|
||||
personalPocketsMapping.put(playername, data);
|
||||
return data;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ public class PocketManager
|
|||
if (parent.type == DimensionType.PERSONAL)
|
||||
{
|
||||
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
|
||||
NewDimData data = registerDimension(dimensionID, (InnerDimData) parent, DimensionType.PERSONAL);
|
||||
DimData data = registerDimension(dimensionID, (InnerDimData) parent, DimensionType.PERSONAL);
|
||||
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);
|
||||
}
|
||||
|
@ -514,7 +514,7 @@ public class PocketManager
|
|||
* @param type
|
||||
* @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))
|
||||
{
|
||||
|
@ -536,7 +536,7 @@ public class PocketManager
|
|||
}
|
||||
|
||||
@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
|
||||
|
@ -581,22 +581,22 @@ public class PocketManager
|
|||
return dimension;
|
||||
}
|
||||
|
||||
public static NewDimData getDimensionData(int dimensionID)
|
||||
public static DimData getDimensionData(int 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());
|
||||
}
|
||||
|
||||
public static NewDimData createDimensionData(World world)
|
||||
public static DimData createDimensionData(World world)
|
||||
{
|
||||
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
|
||||
// anyone from
|
||||
|
@ -605,14 +605,14 @@ public class PocketManager
|
|||
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
|
||||
// dimension,
|
||||
// assume it's a non-pocket dimension that hasn't been initialized with
|
||||
// us before
|
||||
// and create a NewDimData instance for it.
|
||||
NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
|
||||
// and create a DimData instance for it.
|
||||
DimData dimension = PocketManager.dimensionData.get(dimensionID);
|
||||
|
||||
// if we do not have a record of it, then it must be a root
|
||||
if (dimension == null)
|
||||
|
@ -622,15 +622,15 @@ public class PocketManager
|
|||
return dimension;
|
||||
}
|
||||
|
||||
public static Iterable<? extends NewDimData> getDimensions()
|
||||
public static Iterable<? extends DimData> getDimensions()
|
||||
{
|
||||
return dimensionData.values();
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
@ -671,7 +671,7 @@ public class PocketManager
|
|||
if (!isLoaded())
|
||||
return null;
|
||||
|
||||
NewDimData dimension = dimensionData.get(dimensionID);
|
||||
DimData dimension = dimensionData.get(dimensionID);
|
||||
if (dimension != null)
|
||||
{
|
||||
return dimension.getLink(x, y, z);
|
||||
|
@ -760,7 +760,7 @@ public class PocketManager
|
|||
return linkWatcher;
|
||||
}
|
||||
|
||||
public static NewDimData getPersonalDimensionForPlayer(String name)
|
||||
public static DimData getPersonalDimensionForPlayer(String name)
|
||||
{
|
||||
if (personalPocketsMapping.containsKey(name))
|
||||
{
|
||||
|
@ -769,12 +769,12 @@ public class PocketManager
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void setPersonalPocketsMapping(HashMap<String, NewDimData> ppMap)
|
||||
public static void setPersonalPocketsMapping(HashMap<String, DimData> ppMap)
|
||||
{
|
||||
personalPocketsMapping = ppMap;
|
||||
}
|
||||
|
||||
public static HashMap<String, NewDimData> getPersonalPocketMapping()
|
||||
public static HashMap<String, DimData> getPersonalPocketMapping()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return personalPocketsMapping;
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Random;
|
|||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.blocks.IDimDoor;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
|
@ -28,7 +29,6 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.schematic.BlockRotator;
|
||||
import com.zixiken.dimdoors.schematic.ChunkBlockSetter;
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
BlockPos minCorner = new BlockPos(0, 0, 0);
|
||||
|
@ -236,16 +236,16 @@ public class DungeonSchematic extends Schematic {
|
|||
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()));
|
||||
DimLink reverseLink = dimension.createLink(pocketCenter, LinkType.REVERSE, orientation);
|
||||
Point4D destination = entryLink.source();
|
||||
NewDimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||
DimData prevDim = PocketManager.getDimensionData(destination.getDimension());
|
||||
prevDim.setLinkDestination(reverseLink, destination.toBlockPos());
|
||||
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
|
||||
BlockPos location = point;
|
||||
BlockRotator.transformPoint(location, entrance, rotation, pocketCenter);
|
||||
|
@ -262,7 +262,7 @@ public class DungeonSchematic extends Schematic {
|
|||
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
|
||||
BlockPos location = point;
|
||||
|
|
|
@ -6,9 +6,9 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonData;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
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())
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ public class DungeonPack
|
|||
// 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.
|
||||
// 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)
|
||||
{
|
||||
subtreeHistory = DungeonHelper.listDungeonsInTree(ancestor, this, MAX_SUBTREE_LIST_SIZE);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.util.List;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.world.PocketBuilder;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -17,8 +18,6 @@ import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||
import com.zixiken.dimdoors.experimental.BoundingBox;
|
||||
import com.zixiken.dimdoors.IChunkLoader;
|
||||
import com.zixiken.dimdoors.Point3D;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
|
||||
public class ChunkLoaderHelper implements LoadingCallback {
|
||||
|
@ -52,7 +51,7 @@ public class ChunkLoaderHelper implements LoadingCallback {
|
|||
return ticket;
|
||||
}
|
||||
|
||||
public static void forcePocketChunks(NewDimData pocket, Ticket ticket) {
|
||||
public static void forcePocketChunks(DimData pocket, Ticket ticket) {
|
||||
BoundingBox bounds = PocketBuilder.calculateDefaultBounds(pocket);
|
||||
BlockPos minCorner = bounds.minCorner();
|
||||
BlockPos maxCorner = bounds.maxCorner();
|
||||
|
@ -71,7 +70,7 @@ public class ChunkLoaderHelper implements LoadingCallback {
|
|||
}
|
||||
|
||||
public static void loadForcedChunkWorlds(FMLServerStartingEvent event) {
|
||||
for (NewDimData data : PocketManager.getDimensions()) {
|
||||
for (DimData data : PocketManager.getDimensions()) {
|
||||
if(data.isPocketDimension()) {
|
||||
String chunkDir = DimensionManager.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + data.id();
|
||||
|
||||
|
|
|
@ -4,11 +4,9 @@ import java.io.*;
|
|||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.DimensionType;
|
||||
import com.zixiken.dimdoors.core.IDimRegistrationCallback;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
|
||||
import com.zixiken.dimdoors.core.*;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import com.zixiken.dimdoors.watcher.ClientLinkData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
@ -18,18 +16,18 @@ public class Compactor
|
|||
{
|
||||
|
||||
@SuppressWarnings("unused") // ?
|
||||
private static class DimComparator implements Comparator<NewDimData> {
|
||||
private static class DimComparator implements Comparator<DimData> {
|
||||
@Override
|
||||
public int compare(NewDimData a, NewDimData b)
|
||||
public int compare(DimData a, DimData b)
|
||||
{
|
||||
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.
|
||||
output.writeInt(values.size());
|
||||
for (NewDimData dimension : values) {
|
||||
for (DimData dimension : values) {
|
||||
output.writeInt(dimension.id());
|
||||
output.writeInt(dimension.root().id());
|
||||
output.writeInt(dimension.type().index);
|
||||
|
@ -46,7 +44,7 @@ public class Compactor
|
|||
/*
|
||||
// To compress the dimension IDs, we'll sort them by ID
|
||||
// and write the _difference_ between their ID numbers.
|
||||
NewDimData[] dimensions = new NewDimData[values.size()];
|
||||
DimData[] dimensions = new DimData[values.size()];
|
||||
dimensions = values.toArray(dimensions);
|
||||
Arrays.sort(dimensions, new DimComparator());
|
||||
*/
|
||||
|
@ -68,7 +66,7 @@ public class Compactor
|
|||
callback.registerDimension(rootID, rootID, type);
|
||||
}
|
||||
// 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();
|
||||
for (int h = 0; h < linkCount; h++) {
|
||||
ClientLinkData link = ClientLinkData.read(input);
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
|
@ -31,7 +32,6 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.WeightedRandom;
|
||||
import net.minecraft.world.World;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonSchematic;
|
||||
import com.zixiken.dimdoors.dungeon.pack.DungeonType;
|
||||
import com.zixiken.dimdoors.util.FileFilters;
|
||||
|
@ -200,7 +200,7 @@ public class DungeonHelper {
|
|||
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
|
||||
// in the link data itself. That would solve the dungeon pre-generation issue.
|
||||
// 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) {
|
||||
//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);
|
||||
|
||||
//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);
|
||||
DungeonData selection;
|
||||
DungeonPackConfig config;
|
||||
|
@ -506,11 +506,11 @@ public class DungeonHelper {
|
|||
* @param maxSize - the maximum number of dungeons that can be listed
|
||||
* @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.");
|
||||
|
||||
int count = 0;
|
||||
NewDimData current = start;
|
||||
DimData current = start;
|
||||
DungeonData dungeon = current.dungeon();
|
||||
ArrayList<DungeonData> history = new ArrayList<DungeonData>();
|
||||
|
||||
|
@ -530,12 +530,12 @@ public class DungeonHelper {
|
|||
* @param maxSize - the maximum number of dungeons that can be listed
|
||||
* @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;
|
||||
NewDimData current;
|
||||
DimData current;
|
||||
DungeonData dungeon;
|
||||
ArrayList<DungeonData> dungeons = new ArrayList<DungeonData>();
|
||||
Queue<NewDimData> pendingDimensions = new LinkedList<NewDimData>();
|
||||
Queue<DimData> pendingDimensions = new LinkedList<DimData>();
|
||||
pendingDimensions.add(root);
|
||||
|
||||
// Perform a breadth-first search through the dungeon graph
|
||||
|
@ -547,7 +547,7 @@ public class DungeonHelper {
|
|||
if (dungeon != null && dungeon.dungeonType().Owner == pack) {
|
||||
dungeons.add(dungeon);
|
||||
// Add all child dungeons for checking later
|
||||
for (NewDimData child : current.children()) {
|
||||
for (DimData child : current.children()) {
|
||||
pendingDimensions.add(child);
|
||||
}
|
||||
}
|
||||
|
@ -562,10 +562,10 @@ public class DungeonHelper {
|
|||
* @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
|
||||
*/
|
||||
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.
|
||||
NewDimData parent = dimension;
|
||||
NewDimData current = null;
|
||||
DimData parent = dimension;
|
||||
DimData current = null;
|
||||
|
||||
// We solve this inductively. We begin with null as the first valid ancestor,
|
||||
// like a kind of virtual child dimension. Then "current" references the
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.util.BlockPos;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
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.SideOnly;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class ItemRiftRemover extends Item {
|
|||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (hit != null) {
|
||||
BlockPos pos = hit.getBlockPos();
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (world.getBlockState(pos).getBlock() == DimDoors.blockRift && link != null &&
|
||||
player.canPlayerEdit(pos, hit.sideHit, stack)) {
|
||||
|
@ -66,7 +66,7 @@ public class ItemRiftRemover extends Item {
|
|||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (hit == null) return false;
|
||||
pos = hit.getBlockPos();
|
||||
NewDimData dimension = PocketManager.createDimensionData(world);
|
||||
DimData dimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
if (world.getBlockState(pos).getBlock() != DimDoors.blockRift || link == null ||
|
||||
!player.canPlayerEdit(pos, hit.sideHit, stack)) return false;
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.List;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.blocks.BaseDimDoor;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -63,8 +63,8 @@ public class ItemRiftSignature extends Item {
|
|||
if (source != null) {
|
||||
// The link was used before and already has an endpoint stored.
|
||||
// Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
DimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
|
||||
DimLink link = sourceDimension.createLink(source.getPoint().toBlockPos(), LinkType.NORMAL,
|
||||
source.getOrientation());
|
||||
|
@ -128,7 +128,7 @@ public class ItemRiftSignature extends Item {
|
|||
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();
|
||||
|
||||
tag.setInteger("linkX", pos.getX());
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.zixiken.dimdoors.items;
|
|||
import java.util.List;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -10,12 +11,10 @@ import net.minecraft.init.Items;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -42,8 +41,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature {
|
|||
Point4DOrientation source = getSource(stack);
|
||||
if (source != null) {
|
||||
// Yes, it's initialized.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.createDimensionData(world);
|
||||
DimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
DimData destinationDimension = PocketManager.createDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getPoint().toBlockPos(), LinkType.NORMAL,
|
||||
source.getOrientation());
|
||||
DimLink reverse = destinationDimension.getLink(pos);
|
||||
|
@ -105,8 +104,8 @@ public class ItemStabilizedRiftSignature extends ItemRiftSignature {
|
|||
|
||||
// The SRS must have been initialized
|
||||
if (source != null) {
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.createDimensionData(world);
|
||||
DimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
DimData destinationDimension = PocketManager.createDimensionData(world);
|
||||
DimLink reverse = destinationDimension.getLink(pos);
|
||||
DimLink link;
|
||||
|
||||
|
|
182
src/main/java/com/zixiken/dimdoors/legacy/LegacyDimData.java
Normal file
182
src/main/java/com/zixiken/dimdoors/legacy/LegacyDimData.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.zixiken.dimdoors.network.handlers;
|
||||
|
||||
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.network.packets.ClientJoinPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -16,7 +16,7 @@ public class ClientJoinHandler implements IMessageHandler<ClientJoinPacket, IMes
|
|||
@Override
|
||||
public IMessage onMessage(ClientJoinPacket message, MessageContext ctx) {
|
||||
EntityPlayer player = DimDoors.proxy.getMessagePlayer(ctx);
|
||||
NewDimData dimensionData = PocketManager.getDimensionData(player.worldObj);
|
||||
DimData dimensionData = PocketManager.getDimensionData(player.worldObj);
|
||||
|
||||
if (dimensionData.isPocketDimension())
|
||||
player.worldObj.provider.registerWorld(player.worldObj);
|
||||
|
|
|
@ -9,17 +9,13 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.zixiken.dimdoors.Point3D;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.core.*;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonData;
|
||||
import com.zixiken.dimdoors.helpers.DungeonHelper;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.util.DDLogger;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import com.zixiken.dimdoors.core.DimensionType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.util.FileFilters;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import com.google.common.io.Files;
|
||||
|
@ -95,7 +91,7 @@ public class DDSaveHandler
|
|||
unpackDimData(packedDims);
|
||||
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())
|
||||
{
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
|
@ -209,7 +205,7 @@ public class DDSaveHandler
|
|||
{
|
||||
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);
|
||||
|
||||
|
||||
|
@ -229,7 +225,7 @@ public class DDSaveHandler
|
|||
{
|
||||
for(PackedLinkData packedLink : linksToUnpack)
|
||||
{
|
||||
NewDimData data = PocketManager.createDimensionDataDangerously(packedLink.source.getDimension());
|
||||
DimData data = PocketManager.createDimensionDataDangerously(packedLink.source.getDimension());
|
||||
if(data.getLink(packedLink.parent)!=null)
|
||||
{
|
||||
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
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -13,7 +14,6 @@ import net.minecraft.world.GameRules;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.helpers.yCoordHelper;
|
||||
import com.zixiken.dimdoors.util.ChunkLocation;
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class CustomLimboPopulator implements IRegularTickReceiver {
|
|||
|
||||
private void placeMonolithsInPocket(int dimensionID, int chunkX, int chunkZ)
|
||||
{
|
||||
NewDimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||
DimData dimension = PocketManager.getDimensionData(dimensionID);
|
||||
World pocket = DimensionManager.getWorld(dimensionID);
|
||||
|
||||
if (pocket == null ||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zixiken.dimdoors.tileentities;
|
||||
|
||||
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.helpers.ChunkLoaderHelper;
|
||||
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
|
||||
// link associated with it.
|
||||
if (!worldObj.isRemote) {
|
||||
NewDimData dimension = PocketManager.createDimensionData(worldObj);
|
||||
DimData dimension = PocketManager.createDimensionData(worldObj);
|
||||
|
||||
// Check whether a ticket has already been assigned to this door
|
||||
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.
|
||||
// 1. The door must be inside the pocket's XZ boundaries,
|
||||
// to prevent loading of chunks with a distant door
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Random;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -15,7 +16,6 @@ import net.minecraft.network.NetworkManager;
|
|||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.util.Point4D;
|
||||
import com.zixiken.dimdoors.watcher.ClientLinkData;
|
||||
import net.minecraft.util.BlockPos;
|
||||
|
@ -124,7 +124,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable
|
|||
}
|
||||
|
||||
private void closeRift() {
|
||||
NewDimData dimension = PocketManager.createDimensionData(worldObj);
|
||||
DimData dimension = PocketManager.createDimensionData(worldObj);
|
||||
if (growth < CLOSING_PERIOD / 2) {
|
||||
for (DimLink riftLink : dimension.findRiftsInRange(worldObj, 6, pos)) {
|
||||
Point4D location = riftLink.source();
|
||||
|
@ -192,7 +192,7 @@ public class TileEntityRift extends DDTileEntityBase implements ITickable
|
|||
return;
|
||||
}
|
||||
|
||||
NewDimData dimension = PocketManager.createDimensionData(worldObj);
|
||||
DimData dimension = PocketManager.createDimensionData(worldObj);
|
||||
DimLink link = dimension.getLink(pos);
|
||||
|
||||
if (link.childCount() >= MAX_CHILD_LINKS || countAncestorLinks(link) >= MAX_ANCESTOR_LINKS) {
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.zixiken.dimdoors.watcher;
|
|||
|
||||
import java.io.*;
|
||||
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimensionType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class ClientDimData
|
||||
|
@ -20,7 +20,7 @@ public class ClientDimData
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public ClientDimData(NewDimData dimension)
|
||||
public ClientDimData(DimData dimension)
|
||||
{
|
||||
ID = dimension.id();
|
||||
this.rootID = dimension.root().id();
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.zixiken.dimdoors.world;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.*;
|
||||
import com.zixiken.dimdoors.helpers.BlockPosHelper;
|
||||
import net.minecraft.block.Block;
|
||||
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.minecraftforge.common.DimensionManager;
|
||||
import com.zixiken.dimdoors.experimental.BoundingBox;
|
||||
import com.zixiken.dimdoors.Point3D;
|
||||
import com.zixiken.dimdoors.blocks.IDimDoor;
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.DimensionType;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonData;
|
||||
import com.zixiken.dimdoors.dungeon.DungeonSchematic;
|
||||
import com.zixiken.dimdoors.dungeon.pack.DungeonPackConfig;
|
||||
|
@ -47,7 +43,7 @@ public class 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
|
||||
DungeonPackConfig packConfig = dungeon.dungeonType().Owner != null ? dungeon.dungeonType().Owner.getConfig() : null;
|
||||
Point4D source = link.source();
|
||||
|
@ -92,8 +88,8 @@ public class PocketBuilder
|
|||
}
|
||||
|
||||
// Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
|
||||
DimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
DimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
|
||||
|
||||
//Load a world
|
||||
World world = PocketManager.loadDimension(dimension.id());
|
||||
|
@ -119,7 +115,7 @@ public class PocketBuilder
|
|||
}
|
||||
|
||||
//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);
|
||||
|
||||
if (pair == null) {
|
||||
|
@ -131,7 +127,7 @@ public class PocketBuilder
|
|||
DungeonSchematic schematic = pair.getSecond();
|
||||
|
||||
//Register a new dimension
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
|
||||
DimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
|
||||
|
||||
//Load a world
|
||||
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) {
|
||||
int depth = NewDimData.calculatePackDepth(dimension.parent(), dungeon);
|
||||
private static BlockPos calculateNoisyDestination(Point4D source, DimData dimension, DungeonData dungeon, EnumFacing facing) {
|
||||
int depth = DimData.calculatePackDepth(dimension.parent(), dungeon);
|
||||
int forwardNoise = MathHelper.getRandomIntegerInRange(random, 10 * depth, 130 * depth);
|
||||
int sidewaysNoise = MathHelper.getRandomIntegerInRange(random, -10 * depth, 10 * depth);
|
||||
|
||||
|
@ -160,7 +156,7 @@ public class PocketBuilder
|
|||
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;
|
||||
DungeonSchematic schematic = null;
|
||||
|
||||
|
@ -302,8 +298,8 @@ public class PocketBuilder
|
|||
try
|
||||
{
|
||||
//Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.PERSONAL, player.getGameProfile().getId().toString());
|
||||
DimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
DimData dimension = PocketManager.registerPocket(parent, DimensionType.PERSONAL, player.getGameProfile().getId().toString());
|
||||
|
||||
|
||||
//Load a world
|
||||
|
@ -347,8 +343,8 @@ public class PocketBuilder
|
|||
try
|
||||
{
|
||||
//Register a new dimension
|
||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
NewDimData dimension = PocketManager.registerPocket(parent, type);
|
||||
DimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||
DimData dimension = PocketManager.registerPocket(parent, type);
|
||||
|
||||
|
||||
//Load a world
|
||||
|
@ -516,7 +512,7 @@ public class PocketBuilder
|
|||
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
|
||||
// The Y bounds will be set to encompass the height of a chunk.
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.zixiken.dimdoors.world;
|
|||
|
||||
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.ticking.CustomLimboPopulator;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
|
@ -49,7 +49,7 @@ public class PocketGenerator extends ChunkProviderGenerate {
|
|||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
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()) {
|
||||
return this.worldObj.getBiomeGenForCoords(pos).getSpawnableList(type);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zixiken.dimdoors.world;
|
||||
|
||||
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.core.PocketManager;
|
||||
import com.zixiken.dimdoors.ticking.CustomLimboPopulator;
|
||||
|
@ -85,7 +85,7 @@ public class PocketProvider extends WorldProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
NewDimData data = PocketManager.getDimensionData(this.dimensionId);
|
||||
DimData data = PocketManager.getDimensionData(this.dimensionId);
|
||||
if(data == null || data.type() == DimensionType.POCKET) {
|
||||
super.generateLightBrightnessTable();
|
||||
return;
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraft.world.gen.structure.StructureComponent;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
|
||||
public class ComponentNetherGateway extends StructureComponent
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ public class ComponentNetherGateway extends StructureComponent
|
|||
int x = this.getXWithOffset(3, 3);
|
||||
int z = this.getZWithOffset(3, 3);
|
||||
DimLink link;
|
||||
NewDimData dimension;
|
||||
DimData dimension;
|
||||
|
||||
// This function might run multiple times for a single component
|
||||
// due to the way Minecraft handles structure generation!
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.config.DDProperties;
|
||||
import com.zixiken.dimdoors.core.DimData;
|
||||
import com.zixiken.dimdoors.core.DimLink;
|
||||
import com.zixiken.dimdoors.core.LinkType;
|
||||
import com.zixiken.dimdoors.core.NewDimData;
|
||||
import com.zixiken.dimdoors.core.PocketManager;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.world.PocketProvider;
|
||||
|
@ -80,7 +80,7 @@ public class GatewayGenerator implements IWorldGenerator
|
|||
int attempts;
|
||||
boolean valid;
|
||||
DimLink link;
|
||||
NewDimData dimension;
|
||||
DimData dimension;
|
||||
|
||||
// Check if we're allowed to generate rift clusters in this dimension.
|
||||
// If so, randomly decide whether to one.
|
||||
|
|
Loading…
Reference in a new issue