Flipped a Table

Replaced several core classes from DD with new classes to enforce
integrity checks. Rewriting everything that depended on those classes is
a massive undertaking but it should simplify our code and prevent the
many bugs we've seen lately. The rewrite isn't done yet, just committing
my progress so far.
This commit is contained in:
SenseiKiwi
2013-08-29 02:14:24 -04:00
parent 050bdd1090
commit 934dcfde3d
61 changed files with 3450 additions and 4233 deletions

View File

@@ -1,14 +1,13 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.io.File;
import java.util.Collection;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
import StevenDimDoors.mod_pocketDim.core.IDimLink;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandCreateDungeonRift extends DDCommandBase
{
@@ -56,16 +55,17 @@ public class CommandCreateDungeonRift extends DDCommandBase
}
else
{
DungeonGenerator result;
IDimLink link;
DungeonData result;
int x = MathHelper.floor_double(sender.posX);
int y = MathHelper.floor_double(sender.posY);
int z = MathHelper.floor_double (sender.posZ);
NewLinkData link = new NewLinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
if (command[0].equals("random"))
{
dimHelper.instance.createLink(link);
link = dimHelper.instance.createPocket(link, true, true);
link = new NewLinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
PocketManager.createLink(link);
link = PocketManager.createPocket(link, true, true);
sender.sendChatToPlayer("Created a rift to a random dungeon (Dimension ID = " + link.destDimID + ").");
}
else
@@ -79,9 +79,10 @@ public class CommandCreateDungeonRift extends DDCommandBase
if (result != null)
{
//Create a rift to our selected dungeon and notify the player
link = dimHelper.instance.createPocket(link, true, true);
dimHelper.instance.getDimData(link.destDimID).dungeonGenerator = result;
sender.sendChatToPlayer("Created a rift to \"" + getSchematicName(result) + "\" dungeon (Dimension ID = " + link.destDimID + ").");
link = new NewLinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
link = PocketManager.instance.createPocket(link, true, true);
PocketManager.instance.getDimData(link.destDimID).dungeonGenerator = result;
sender.sendChatToPlayer("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination.getDimensionID() + ").");
}
else
{
@@ -93,20 +94,20 @@ public class CommandCreateDungeonRift extends DDCommandBase
return DDCommandResult.SUCCESS;
}
private DungeonGenerator findDungeonByPartialName(String query, Collection<DungeonGenerator> dungeons)
private DungeonData findDungeonByPartialName(String query, Collection<DungeonData> dungeons)
{
//Search for the shortest dungeon name that contains the lowercase query string.
String dungeonName;
String normalQuery = query.toLowerCase();
DungeonGenerator bestMatch = null;
DungeonData bestMatch = null;
int matchLength = Integer.MAX_VALUE;
for (DungeonGenerator dungeon : dungeons)
for (DungeonData dungeon : dungeons)
{
//We need to extract the file's name. Comparing against schematicPath could
//yield false matches if the query string is contained within the path.
dungeonName = getSchematicName(dungeon).toLowerCase();
dungeonName = dungeon.schematicName().toLowerCase();
if (dungeonName.length() < matchLength && dungeonName.contains(normalQuery))
{
matchLength = dungeonName.length();
@@ -115,14 +116,4 @@ public class CommandCreateDungeonRift extends DDCommandBase
}
return bestMatch;
}
private static String getSchematicName(DungeonGenerator dungeon)
{
//TODO: Move this to DungeonHelper and use it for all schematic name parsing.
//In the future, we really should include the schematic's name as part of DungeonGenerator
//to avoid redoing this work constantly.
File schematic = new File(dungeon.schematicPath);
String fileName = schematic.getName();
return fileName.substring(0, fileName.length() - DungeonHelper.SCHEMATIC_FILE_EXTENSION.length());
}
}