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:
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||
|
||||
public class CommandCreatePocket extends DDCommandBase
|
||||
@@ -39,10 +38,10 @@ public class CommandCreatePocket extends DDCommandBase
|
||||
int x = (int) sender.posX;
|
||||
int y = (int) sender.posY;
|
||||
int z = (int) sender.posZ;
|
||||
NewLinkData link = DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
|
||||
DungeonHelper.instance().createCustomDungeonDoor(sender.worldObj, x, y, z);
|
||||
|
||||
//Notify the player
|
||||
sender.sendChatToPlayer("Created a door to a pocket dimension (Dimension ID = " + link.destDimID + "). Please build your dungeon there.");
|
||||
sender.sendChatToPlayer("Created a door to a pocket dimension. Please build your dungeon there.");
|
||||
}
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteAllLinks extends DDCommandBase
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public class CommandDeleteAllLinks extends DDCommandBase
|
||||
else if(command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
if (!PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
@@ -54,24 +54,24 @@ public class CommandDeleteAllLinks extends DDCommandBase
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
if(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.instance.getDimData(targetDim);
|
||||
ArrayList<NewLinkData> linksInDim = dim.getLinksInDim();
|
||||
NewDimData dim = PocketManager.instance.getDimData(targetDim);
|
||||
ArrayList<ILinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
for (NewLinkData link : linksInDim)
|
||||
for (ILinkData link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
World targetWorld = PocketManager.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
targetWorld = PocketManager.getWorld(targetDim);
|
||||
dim.removeLinkAtCoords(link);
|
||||
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
linksRemoved++;
|
||||
|
||||
@@ -4,9 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteDimensionData extends DDCommandBase
|
||||
{
|
||||
@@ -39,7 +39,7 @@ public class CommandDeleteDimensionData extends DDCommandBase
|
||||
else if (command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
if(!PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
@@ -54,23 +54,23 @@ public class CommandDeleteDimensionData extends DDCommandBase
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
if(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
try
|
||||
{
|
||||
for(DimData dimData :dimHelper.dimList.values())
|
||||
for(NewDimData newDimData :PocketManager.dimList.values())
|
||||
{
|
||||
Collection<NewLinkData> links= new ArrayList<NewLinkData>();
|
||||
links.addAll( dimData.getLinksInDim());
|
||||
Collection<ILinkData> links= new ArrayList<ILinkData>();
|
||||
links.addAll( newDimData.getLinksInDim());
|
||||
|
||||
for(NewLinkData link : links)
|
||||
for(ILinkData link : links)
|
||||
{
|
||||
if(link.destDimID==targetDim)
|
||||
{
|
||||
dimHelper.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
|
||||
PocketManager.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
|
||||
linksRemoved++;
|
||||
}
|
||||
if(dimData.dimID==targetDim)
|
||||
if(newDimData.dimID==targetDim)
|
||||
{
|
||||
linksRemoved++;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class CommandDeleteDimensionData extends DDCommandBase
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
dimHelper.dimList.remove(targetDim);
|
||||
PocketManager.dimList.remove(targetDim);
|
||||
sender.sendChatToPlayer("Removed dimension " + targetDim + " from DimDoors and deleted " + linksRemoved + " links");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandDeleteRifts extends DDCommandBase
|
||||
{
|
||||
@@ -40,7 +40,7 @@ public class CommandDeleteRifts extends DDCommandBase
|
||||
else if(command.length==1)
|
||||
{
|
||||
targetDim = parseInt(sender, command[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
if(!PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
@@ -55,24 +55,24 @@ public class CommandDeleteRifts extends DDCommandBase
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
if(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.instance.getDimData(targetDim);
|
||||
ArrayList<NewLinkData> linksInDim = dim.getLinksInDim();
|
||||
NewDimData dim = PocketManager.instance.getDimData(targetDim);
|
||||
ArrayList<ILinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
for(NewLinkData link : linksInDim)
|
||||
for(ILinkData link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
World targetWorld = PocketManager.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
targetWorld = PocketManager.getWorld(targetDim);
|
||||
|
||||
if (targetWorld.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord) == mod_pocketDim.blockRift.blockID)
|
||||
{
|
||||
|
||||
@@ -3,9 +3,9 @@ package StevenDimDoors.mod_pocketDim.commands;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandPrintDimensionData extends DDCommandBase
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class CommandPrintDimensionData extends DDCommandBase
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
int targetDim;
|
||||
DimData dimData;
|
||||
NewDimData newDimData;
|
||||
|
||||
if (command.length == 0)
|
||||
{
|
||||
@@ -50,17 +50,17 @@ public class CommandPrintDimensionData extends DDCommandBase
|
||||
return DDCommandResult.TOO_MANY_ARGUMENTS;
|
||||
}
|
||||
|
||||
dimData = dimHelper.instance.getDimData(targetDim);
|
||||
if (dimData == null)
|
||||
newDimData = PocketManager.instance.getDimData(targetDim);
|
||||
if (newDimData == null)
|
||||
{
|
||||
return DDCommandResult.UNREGISTERED_DIMENSION;
|
||||
}
|
||||
|
||||
ArrayList<NewLinkData> links = dimData.getLinksInDim();
|
||||
ArrayList<ILinkData> links = newDimData.getLinksInDim();
|
||||
|
||||
sender.sendChatToPlayer("Dimension ID = " + dimData.dimID);
|
||||
sender.sendChatToPlayer("Dimension Depth = " + dimData.depth);
|
||||
for (NewLinkData link : links)
|
||||
sender.sendChatToPlayer("Dimension ID = " + newDimData.dimID);
|
||||
sender.sendChatToPlayer("Dimension Depth = " + newDimData.depth);
|
||||
for (ILinkData link : links)
|
||||
{
|
||||
sender.sendChatToPlayer(link.printLinkData());
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewLinkData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandPruneDimensions extends DDCommandBase
|
||||
{
|
||||
@@ -42,31 +42,31 @@ public class CommandPruneDimensions extends DDCommandBase
|
||||
int removedCount = 0;
|
||||
boolean deleteFolders = (command.length == 1);
|
||||
Set<Integer> linkedDimensions = new HashSet<Integer>();
|
||||
Collection<DimData> allDims = new ArrayList<DimData>();
|
||||
allDims.addAll(dimHelper.dimList.values());
|
||||
Collection<NewDimData> allDims = new ArrayList<NewDimData>();
|
||||
allDims.addAll(PocketManager.dimList.values());
|
||||
|
||||
for (DimData data : allDims)
|
||||
for (NewDimData data : allDims)
|
||||
{
|
||||
for (NewLinkData link : data.getLinksInDim())
|
||||
for (ILinkData link : data.getLinksInDim())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
}
|
||||
for (NewLinkData link : dimHelper.instance.interDimLinkList.values())
|
||||
for (ILinkData link : dimHelper.PocketManager.interDimLinkList.values())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
for (DimData data : allDims)
|
||||
for (NewDimData data : allDims)
|
||||
{
|
||||
if (!linkedDimensions.contains(data.dimID))
|
||||
{
|
||||
if (dimHelper.instance.pruneDimension(data, deleteFolders))
|
||||
if (PocketManager.instance.pruneDimension(data, deleteFolders))
|
||||
{
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
dimHelper.instance.save();
|
||||
PocketManager.instance.save();
|
||||
sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims.");
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public class CommandResetDungeons extends DDCommandBase
|
||||
{
|
||||
@@ -32,12 +32,12 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
int dungeonCount = 0;
|
||||
int resetCount = 0;
|
||||
|
||||
for (DimData data : dimHelper.dimList.values())
|
||||
for (NewDimData data : PocketManager.dimList.values())
|
||||
{
|
||||
if (data.isDimRandomRift)
|
||||
{
|
||||
dungeonCount++;
|
||||
if (dimHelper.instance.resetPocket(data))
|
||||
if (PocketManager.instance.resetPocket(data))
|
||||
{
|
||||
resetCount++;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -39,7 +39,7 @@ public class CommandTeleportPlayer extends DDCommandBase
|
||||
@Override
|
||||
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
|
||||
{
|
||||
List dimensionIDs = Arrays.asList(dimHelper.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
||||
List dimensionIDs = Arrays.asList(PocketManager.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
|
||||
EntityPlayer targetPlayer = sender;
|
||||
int dimDestinationID = sender.worldObj.provider.dimensionId;
|
||||
|
||||
@@ -66,12 +66,12 @@ public class CommandTeleportPlayer extends DDCommandBase
|
||||
{
|
||||
return DDCommandResult.INVALID_DIMENSION_ID;
|
||||
}
|
||||
if(dimHelper.getWorld(dimDestinationID)==null)
|
||||
if(PocketManager.getWorld(dimDestinationID)==null)
|
||||
{
|
||||
dimHelper.initDimension(dimDestinationID);
|
||||
PocketManager.initDimension(dimDestinationID);
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(dimHelper.getWorld(dimDestinationID)));
|
||||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(PocketManager.getWorld(dimDestinationID)));
|
||||
targetPlayer.setPositionAndUpdate(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]));
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user