package StevenDimDoors.mod_pocketDim; /**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 java.util.Iterator; import net.minecraft.util.MathHelper; import net.minecraft.world.World; 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 HashMap>> linksInThisDim=new HashMap(); HashMap dimX; HashMap> 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=dimID; this.depth=depth; this.isPocket=isPocket; this.exitDimLink= 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; while (i(); } } else { this.dimX=new HashMap(); this.dimY=new HashMap>(); } 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); linkData.linkOrientation=linkOrientation; return this.addLinkToDim(linkData); } public boolean isLimbo() { if(this.dimID==mod_pocketDim.limboDimID) { return true; } else { return false; } } 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(); } } else { this.dimX=new HashMap(); this.dimY=new HashMap>(); } 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 printAllLinkData() { ArrayList links = new ArrayList(); Iterator itr= this.linksInThisDim.keySet().iterator(); while (itr.hasNext()) { HashMap first = this.linksInThisDim.get((Integer)itr.next()); Iterator itrfirst= first.keySet().iterator(); while (itrfirst.hasNext()) { HashMap second = (HashMap) first.get((Integer)itrfirst.next()); Iterator itrsecond= second.keySet().iterator(); while (itrsecond.hasNext()) { //TODO make a for(each : in) loops, and make it so that it returns the links instead of printing them LinkData link = (LinkData) second.get((Integer)itrsecond.next()); links.add(link); } } } return links; } }