final update for 1.4.7- optimized random rift code, reverted name change

Signed-off-by: StevenRS11 <stevenrs11@aol.com>
This commit is contained in:
StevenRS11 2013-04-01 16:43:11 -04:00
parent f9c1e41677
commit 49b5925ae5
3 changed files with 44 additions and 31 deletions

View file

@ -228,35 +228,30 @@ public class DimData implements Serializable
public ArrayList<LinkData> printAllLinkData() public ArrayList<LinkData> printAllLinkData()
{ {
ArrayList links = new ArrayList(); ArrayList links = new ArrayList();
Iterator itr= this.linksInThisDim.keySet().iterator(); if(this.linksInThisDim==null)
{
while (itr.hasNext()) return links;
}
for(HashMap<Integer, HashMap<Integer, LinkData>> first : this.linksInThisDim.values())
{ {
HashMap first = this.linksInThisDim.get((Integer)itr.next());
Iterator itrfirst= first.keySet().iterator();
while (itrfirst.hasNext()) for(HashMap<Integer, LinkData> second : first.values())
{ {
HashMap second = (HashMap) first.get((Integer)itrfirst.next());
Iterator itrsecond= second.keySet().iterator();
while (itrsecond.hasNext()) for(LinkData linkData :second.values())
{ {
links.add(linkData);
//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; return links;
} }
} }

View file

@ -1182,14 +1182,31 @@ public class dimHelper extends DimensionManager
while (!foundRandomDest&&size>0&&i<100) while (!foundRandomDest&&size>0&&i<100)
{ {
i++; i++;
DimData dimData;
DimData dimData = dimHelper.dimList.get(rand.nextInt(size)); ArrayList linksInDim=new ArrayList();
for(size--;size>=0;)
ArrayList linksInDim = dimData.printAllLinkData(); {
dimData = dimHelper.dimList.get(rand.nextInt(dimList.size()));
if(dimData==null)
{
break;
}
linksInDim = dimData.printAllLinkData();
if(!linksInDim.isEmpty())
{
break;
}
}
if(linksInDim.isEmpty())
{
break;
}
LinkData link1 = (LinkData) linksInDim.get(rand.nextInt(linksInDim.size())); LinkData link1 = (LinkData) linksInDim.get(rand.nextInt(linksInDim.size()));
if(link1!=null) if(link1!=null)
@ -1209,6 +1226,7 @@ public class dimHelper extends DimensionManager
/** /**
* gets a link based on coords and a world object * gets a link based on coords and a world object
* @param x * @param x

View file

@ -39,7 +39,7 @@ import StevenDimDoors.mod_pocketDim.commands.CommandDeleteDimData;
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts; import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts;
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDims; import StevenDimDoors.mod_pocketDim.commands.CommandPruneDims;
@Mod(modid = "Dimensional_Doors", name = "Dimensional Doors", version = mod_pocketDim.version) @Mod(modid = "DimensionalDoors", name = "Dimensional Doors", version = mod_pocketDim.version)
@NetworkMod(clientSideRequired = true, serverSideRequired = false, @NetworkMod(clientSideRequired = true, serverSideRequired = false,
clientPacketHandlerSpec = clientPacketHandlerSpec =