THE UPDATE

Merging months of dev work into master. The update is playable, but
untested.
This commit is contained in:
StevenRS11
2013-11-05 18:15:23 -05:00
parent be89913263
commit a04a266c17
154 changed files with 8826 additions and 8272 deletions

View File

@@ -1,14 +1,16 @@
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.LinkData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
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
{
@@ -30,6 +32,7 @@ public class CommandCreateDungeonRift extends DDCommandBase
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
NewDimData dimension;
DungeonHelper dungeonHelper = DungeonHelper.instance();
if (sender.worldObj.isRemote)
@@ -56,17 +59,21 @@ public class CommandCreateDungeonRift extends DDCommandBase
}
else
{
DungeonGenerator result;
DimLink link;
DungeonData result;
int x = MathHelper.floor_double(sender.posX);
int y = MathHelper.floor_double(sender.posY);
int z = MathHelper.floor_double (sender.posZ);
LinkData link = new LinkData(sender.worldObj.provider.dimensionId, 0, x, y + 1, z, x, y + 1, z, true, 3);
int orientation = MathHelper.floor_double((double) ((sender.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
if (command[0].equals("random"))
{
dimHelper.instance.createLink(link);
link = dimHelper.instance.createPocket(link, true, true);
sender.sendChatToPlayer("Created a rift to a random dungeon (Dimension ID = " + link.destDimID + ").");
dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
sender.sendChatToPlayer("Created a rift to a random dungeon.");
}
else
{
@@ -79,9 +86,12 @@ 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 + ").");
//TODO currently crashes, need to create the dimension first
dimension = PocketManager.getDimensionData(sender.worldObj);
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON);
PocketManager.getDimensionData(link.destination().getDimension()).initializeDungeon(x, y + 1, z, orientation,link, result);
sender.worldObj.setBlock(x, y + 1, z,mod_pocketDim.blockRift.blockID,0,3);
sender.sendChatToPlayer("Created a rift to \"" + result.schematicName() + "\" dungeon (Dimension ID = " + link.destination().getDimension() + ").");
}
else
{
@@ -93,20 +103,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 +125,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());
}
}

View File

@@ -1,7 +1,6 @@
package StevenDimDoors.mod_pocketDim.commands;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
public class CommandCreatePocket extends DDCommandBase
@@ -35,14 +34,14 @@ public class CommandCreatePocket extends DDCommandBase
}
//Place a door leading to a pocket dimension where the player is standing.
//The pocket dimension will be serve as a room for the player to build a dungeon.
//The pocket dimension will serve as a room for the player to build a dungeon.
int x = (int) sender.posX;
int y = (int) sender.posY;
int z = (int) sender.posZ;
LinkData 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;
}

View File

@@ -4,9 +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.LinkData;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public class CommandDeleteAllLinks extends DDCommandBase
{
@@ -32,53 +33,34 @@ public class CommandDeleteAllLinks extends DDCommandBase
int targetDim;
boolean shouldGo= true;
if(command.length==0)
{
targetDim= sender.worldObj.provider.dimensionId;
}
else if(command.length==1)
if(command.length==1)
{
targetDim = parseInt(sender, command[0]);
if(!dimHelper.dimList.containsKey(targetDim))
{
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
shouldGo=false;
}
}
else
{
targetDim=0;
shouldGo=false;
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID> or blank for current dim");
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
}
if(shouldGo)
{
if(dimHelper.dimList.containsKey(targetDim))
{
DimData dim = dimHelper.instance.getDimData(targetDim);
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
NewDimData dim = PocketManager.getDimensionData(targetDim);
ArrayList<DimLink> linksInDim = dim.getAllLinks();
for (LinkData link : linksInDim)
for (DimLink link : linksInDim)
{
World targetWorld = dimHelper.getWorld(targetDim);
World targetWorld = PocketManager.loadDimension(targetDim);
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
dim.deleteLink(link);
//TODO Probably should check what the block is, but thats annoying so Ill do it later.
if(targetWorld==null)
{
dimHelper.initDimension(targetDim);
}
else if(targetWorld.provider==null)
{
dimHelper.initDimension(targetDim);
}
targetWorld = dimHelper.getWorld(targetDim);
dim.removeLinkAtCoords(link);
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
linksRemoved++;
}
//dim.linksInThisDim.clear();
sender.sendChatToPlayer("Removed " + linksRemoved + " links.");
}
}
return DDCommandResult.SUCCESS; //TEMPORARY HACK
}

View File

@@ -1,95 +0,0 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandDeleteDimensionData extends DDCommandBase
{
private static CommandDeleteDimensionData instance = null;
private CommandDeleteDimensionData()
{
super("dd-deletedimension", "???");
}
public static CommandDeleteDimensionData instance()
{
if (instance == null)
instance = new CommandDeleteDimensionData();
return instance;
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
int linksRemoved=0;
int targetDim;
boolean shouldGo= true;
if (command.length==0)
{
targetDim= sender.worldObj.provider.dimensionId;
}
else if (command.length==1)
{
targetDim = parseInt(sender, command[0]);
if(!dimHelper.dimList.containsKey(targetDim))
{
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
shouldGo=false;
}
}
else
{
targetDim=0;
shouldGo=false;
sender.sendChatToPlayer("Error-Invalid argument, delete_dim_data <targetDimID> or blank for current dim");
}
if(shouldGo)
{
if(dimHelper.dimList.containsKey(targetDim))
{
try
{
for(DimData dimData :dimHelper.dimList.values())
{
Collection<LinkData> links= new ArrayList<LinkData>();
links.addAll( dimData.getLinksInDim());
for(LinkData link : links)
{
if(link.destDimID==targetDim)
{
dimHelper.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
linksRemoved++;
}
if(dimData.dimID==targetDim)
{
linksRemoved++;
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
dimHelper.dimList.remove(targetDim);
sender.sendChatToPlayer("Removed dimension " + targetDim + " from DimDoors and deleted " + linksRemoved + " links");
}
else
{
sender.sendChatToPlayer("Error- dimension "+targetDim+" not registered with dimDoors");
}
}
return DDCommandResult.SUCCESS; //TEMPORARY HACK
}
}

View File

@@ -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.LinkData;
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public class CommandDeleteRifts extends DDCommandBase
{
@@ -33,56 +33,36 @@ public class CommandDeleteRifts extends DDCommandBase
int targetDim;
boolean shouldGo= true;
if(command.length==0)
{
targetDim= sender.worldObj.provider.dimensionId;
}
else if(command.length==1)
if(command.length==1)
{
targetDim = parseInt(sender, command[0]);
if(!dimHelper.dimList.containsKey(targetDim))
{
sender.sendChatToPlayer("Error- dim "+targetDim+" not registered");
shouldGo=false;
}
}
else
{
targetDim=0;
shouldGo=false;
sender.sendChatToPlayer("Error-Invalid argument, delete_links <targetDimID> or blank for current dim");
sender.sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID>");
}
if(shouldGo)
{
if(dimHelper.dimList.containsKey(targetDim))
{
DimData dim = dimHelper.instance.getDimData(targetDim);
ArrayList<LinkData> linksInDim = dim.getLinksInDim();
NewDimData dim = PocketManager.getDimensionData(targetDim);
ArrayList<DimLink> linksInDim = dim.getAllLinks();
for(LinkData link : linksInDim)
for (DimLink link : linksInDim)
{
World targetWorld = dimHelper.getWorld(targetDim);
if(targetWorld==null)
World targetWorld = PocketManager.loadDimension(targetDim);
if(sender.worldObj.getBlockId(link.source().getX(), link.source().getY(), link.source().getZ())==mod_pocketDim.blockRift.blockID)
{
dimHelper.initDimension(targetDim);
}
else if(targetWorld.provider==null)
{
dimHelper.initDimension(targetDim);
}
targetWorld = dimHelper.getWorld(targetDim);
if (targetWorld.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord) == mod_pocketDim.blockRift.blockID)
{
dim.removeLinkAtCoords(link);
targetWorld.setBlock(link.locXCoord, link.locYCoord, link.locZCoord, 0);
targetWorld.setBlock(link.source().getX(), link.source().getY(), link.source().getZ(), 0);
linksRemoved++;
dim.deleteLink(link);
}
}
sender.sendChatToPlayer("Removed "+linksRemoved+" rifts.");
}
sender.sendChatToPlayer("Removed " + linksRemoved + " rifts.");
}
return DDCommandResult.SUCCESS; //TEMPORARY HACK
}

View File

@@ -1,69 +0,0 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandPrintDimensionData extends DDCommandBase
{
private static CommandPrintDimensionData instance = null;
private CommandPrintDimensionData()
{
super("dd-dimensiondata", "[dimension number]");
}
public static CommandPrintDimensionData instance()
{
if (instance == null)
instance = new CommandPrintDimensionData();
return instance;
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
int targetDim;
DimData dimData;
if (command.length == 0)
{
targetDim = sender.worldObj.provider.dimensionId;
}
else if (command.length == 1)
{
try
{
targetDim = Integer.parseInt(command[0]);
}
catch (Exception ex)
{
return DDCommandResult.INVALID_DIMENSION_ID;
}
}
else
{
return DDCommandResult.TOO_MANY_ARGUMENTS;
}
dimData = dimHelper.instance.getDimData(targetDim);
if (dimData == null)
{
return DDCommandResult.UNREGISTERED_DIMENSION;
}
ArrayList<LinkData> links = dimData.getLinksInDim();
sender.sendChatToPlayer("Dimension ID = " + dimData.dimID);
sender.sendChatToPlayer("Dimension Depth = " + dimData.depth);
for (LinkData link : links)
{
sender.sendChatToPlayer(link.printLinkData());
}
return DDCommandResult.SUCCESS;
}
}

View File

@@ -1,73 +0,0 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandPruneDimensions extends DDCommandBase
{
private static CommandPruneDimensions instance = null;
private CommandPruneDimensions()
{
super("dd-prune", "['delete']");
}
public static CommandPruneDimensions instance()
{
if (instance == null)
instance = new CommandPruneDimensions();
return instance;
}
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
if (command.length > 1)
{
return DDCommandResult.TOO_MANY_ARGUMENTS;
}
if (command.length == 1 && !command[0].equalsIgnoreCase("delete"))
{
return DDCommandResult.INVALID_ARGUMENTS;
}
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());
for (DimData data : allDims)
{
for (LinkData link : data.getLinksInDim())
{
linkedDimensions.add(link.destDimID);
}
}
for (LinkData link : dimHelper.instance.interDimLinkList.values())
{
linkedDimensions.add(link.destDimID);
}
for (DimData data : allDims)
{
if (!linkedDimensions.contains(data.dimID))
{
if (dimHelper.instance.pruneDimension(data, deleteFolders))
{
removedCount++;
}
}
}
dimHelper.instance.save();
sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims.");
return DDCommandResult.SUCCESS;
}
}

View File

@@ -1,8 +1,13 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import net.minecraftforge.common.DimensionManager;
import StevenDimDoors.mod_pocketDim.core.DimLink;
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
import StevenDimDoors.mod_pocketDim.core.NewDimData;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
public class CommandResetDungeons extends DDCommandBase
{
@@ -24,6 +29,10 @@ public class CommandResetDungeons extends DDCommandBase
@Override
protected DDCommandResult processCommand(EntityPlayer sender, String[] command)
{
if(sender.worldObj.isRemote)
{
return DDCommandResult.SUCCESS;
}
if (command.length > 0)
{
return DDCommandResult.TOO_FEW_ARGUMENTS;
@@ -31,19 +40,49 @@ public class CommandResetDungeons extends DDCommandBase
int dungeonCount = 0;
int resetCount = 0;
for (DimData data : dimHelper.dimList.values())
ArrayList<Integer> dimsToDelete = new ArrayList<Integer>();
ArrayList<Integer> dimsToFix = new ArrayList<Integer>();
for (NewDimData data : PocketManager.getDimensions())
{
if (data.isDimRandomRift)
if(DimensionManager.getWorld(data.id())==null&&data.isDungeon())
{
resetCount++;
dungeonCount++;
if (dimHelper.instance.resetPocket(data))
dimsToDelete.add(data.id());
}
else if(data.isDungeon())
{
dimsToFix.add(data.id());
dungeonCount++;
for(DimLink link : data.links())
{
resetCount++;
if(link.linkType()==LinkTypes.REVERSE)
{
data.createLink(link.source(), LinkTypes.DUNGEON_EXIT, link.orientation());
}
if(link.linkType()==LinkTypes.DUNGEON)
{
data.createLink(link.source(), LinkTypes.DUNGEON, link.orientation());
}
}
}
}
for(Integer dimID:dimsToDelete)
{
PocketManager.deletePocket(PocketManager.getDimensionData(dimID), true);
}
/**
* temporary workaround
*/
for(Integer dimID: dimsToFix)
{
PocketManager.getDimensionData(dimID).setParentToRoot();
}
//TODO- for some reason the parent field of loaded dimenions get reset to null if I call .setParentToRoot() before I delete the pockets.
//TODO implement blackList
//Notify the user of the results
sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset.");
return DDCommandResult.SUCCESS;

View File

@@ -6,13 +6,16 @@ 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.DDTeleporter;
import StevenDimDoors.mod_pocketDim.core.PocketManager;
import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
import StevenDimDoors.mod_pocketDim.util.Point4D;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
public class CommandTeleportPlayer extends DDCommandBase
@@ -39,7 +42,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(DimensionManager.getStaticDimensionIDs()); //Gets list of all registered dimensions, regardless if loaded or not
EntityPlayer targetPlayer = sender;
int dimDestinationID = sender.worldObj.provider.dimensionId;
@@ -66,13 +69,10 @@ public class CommandTeleportPlayer extends DDCommandBase
{
return DDCommandResult.INVALID_DIMENSION_ID;
}
if(dimHelper.getWorld(dimDestinationID)==null)
{
dimHelper.initDimension(dimDestinationID);
}
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension((EntityPlayerMP) targetPlayer, dimDestinationID, new BlankTeleporter(dimHelper.getWorld(dimDestinationID)));
targetPlayer.setPositionAndUpdate(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]));
PocketManager.loadDimension(dimDestinationID);
Point4D destination = new Point4D(Integer.parseInt(command[2]),Integer.parseInt(command[3]),Integer.parseInt(command[4]),dimDestinationID);
DDTeleporter.teleportEntity(targetPlayer, destination, false);
}
else
{