Optimized Weighted Random Dungeon Selection

Optimized the selection of random dungeons with weights applied. We now
have a class called WeightedContainer for taping into Minecraft's
weighted selection code without having to extend the WeightedRandomItem
class. Using that, we no longer need to keep a list with duplicate
dungeons to achieve weighted selection, so I removed that variable.
This commit is contained in:
SenseiKiwi
2013-06-17 22:26:39 -04:00
parent b9f95a284a
commit 438b251d8f
3 changed files with 168 additions and 157 deletions

View File

@@ -125,19 +125,15 @@ public class dimHelper extends DimensionManager
else return -10;
}
public int getDimDepth(int DimID)
{
if(this.dimList.containsKey(DimID))
if (dimList.containsKey(DimID))
{
return (int)this.dimList.get(DimID).depth;
return dimList.get(DimID).depth;
}
else return 1;
}
private Entity teleportEntity(World oldWorld, Entity entity, LinkData link) //this beautiful teleport method is based off of xCompWiz's teleport function.
{
Entity cart=entity.ridingEntity;
@@ -976,28 +972,21 @@ public class dimHelper extends DimensionManager
link = this.createLink(this.getWorld(link.locDimID).provider.dimensionId,dimensionID,link.locXCoord,link.locYCoord,link.locZCoord, link.destXCoord,link.destYCoord,link.destZCoord,link.linkOrientation); //creates and registers the two rifts that link the parent and pocket dim.
this.createLink(dimensionID,this.getWorld(link.locDimID).provider.dimensionId, link.destXCoord,link.destYCoord,link.destZCoord, link.locXCoord,link.locYCoord,link.locZCoord, this.flipDoorMetadata(link.linkOrientation));
if(isRandomRift)
if (isRandomRift)
{
DungeonHelper.instance().generateDungeonlink(link);
DungeonHelper.instance().generateDungeonLink(link);
}
return link;
}
/**
* function that saves all dim data in a hashMap. Calling too often can cause Concurrent modification exceptions, so be careful.
* @return
*/
//TODO change from saving serialized objects to just saving data for compatabilies sake.
//TODO If saving is multithreaded as the concurrent modification exception implies, you should be synchronizing access. ~SenseiKiwi
public void save()
{
if(this.isSaving) return;