Readded commands
Also implemented dungeon regeneration
This commit is contained in:
@@ -4,7 +4,10 @@ import java.util.Collection;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
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;
|
||||
@@ -29,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)
|
||||
@@ -60,13 +64,16 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
int x = MathHelper.floor_double(sender.posX);
|
||||
int y = MathHelper.floor_double(sender.posY);
|
||||
int z = MathHelper.floor_double (sender.posZ);
|
||||
|
||||
int orientation = MathHelper.floor_double((double) ((sender.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (command[0].equals("random"))
|
||||
{
|
||||
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 + ").");
|
||||
|
||||
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,10 +86,11 @@ public class CommandCreateDungeonRift extends DDCommandBase
|
||||
if (result != null)
|
||||
{
|
||||
//Create a rift to our selected dungeon and notify the player
|
||||
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() + ").");
|
||||
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
|
||||
{
|
||||
|
||||
@@ -4,8 +4,9 @@ import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
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 (!PocketManager.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(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
NewDimData dim = PocketManager.instance.getDimData(targetDim);
|
||||
ArrayList<ILinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
NewDimData dim = PocketManager.getDimensionData(targetDim);
|
||||
ArrayList<DimLink> linksInDim = dim.getAllLinks();
|
||||
|
||||
for (ILinkData link : linksInDim)
|
||||
for (DimLink link : linksInDim)
|
||||
{
|
||||
World targetWorld = PocketManager.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)
|
||||
{
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = PocketManager.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
|
||||
}
|
||||
|
||||
@@ -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.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
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(!PocketManager.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(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
try
|
||||
{
|
||||
for(NewDimData newDimData :PocketManager.dimList.values())
|
||||
{
|
||||
Collection<ILinkData> links= new ArrayList<ILinkData>();
|
||||
links.addAll( newDimData.getLinksInDim());
|
||||
|
||||
for(ILinkData link : links)
|
||||
{
|
||||
if(link.destDimID==targetDim)
|
||||
{
|
||||
PocketManager.instance.getDimData(link.locDimID).removeLinkAtCoords(link);
|
||||
linksRemoved++;
|
||||
}
|
||||
if(newDimData.dimID==targetDim)
|
||||
{
|
||||
linksRemoved++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
PocketManager.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
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import java.util.ArrayList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
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(!PocketManager.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(PocketManager.dimList.containsKey(targetDim))
|
||||
{
|
||||
NewDimData dim = PocketManager.instance.getDimData(targetDim);
|
||||
ArrayList<ILinkData> linksInDim = dim.getLinksInDim();
|
||||
|
||||
NewDimData dim = PocketManager.getDimensionData(targetDim);
|
||||
ArrayList<DimLink> linksInDim = dim.getAllLinks();
|
||||
|
||||
for(ILinkData link : linksInDim)
|
||||
for (DimLink link : linksInDim)
|
||||
{
|
||||
World targetWorld = PocketManager.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)
|
||||
{
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
PocketManager.initDimension(targetDim);
|
||||
}
|
||||
targetWorld = PocketManager.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
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
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;
|
||||
NewDimData newDimData;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
newDimData = PocketManager.instance.getDimData(targetDim);
|
||||
if (newDimData == null)
|
||||
{
|
||||
return DDCommandResult.UNREGISTERED_DIMENSION;
|
||||
}
|
||||
|
||||
ArrayList<ILinkData> links = newDimData.getLinksInDim();
|
||||
|
||||
sender.sendChatToPlayer("Dimension ID = " + newDimData.dimID);
|
||||
sender.sendChatToPlayer("Dimension Depth = " + newDimData.depth);
|
||||
for (ILinkData link : links)
|
||||
{
|
||||
sender.sendChatToPlayer(link.printLinkData());
|
||||
}
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -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.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.ILinkData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
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<NewDimData> allDims = new ArrayList<NewDimData>();
|
||||
allDims.addAll(PocketManager.dimList.values());
|
||||
|
||||
for (NewDimData data : allDims)
|
||||
{
|
||||
for (ILinkData link : data.getLinksInDim())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
}
|
||||
for (ILinkData link : dimHelper.PocketManager.interDimLinkList.values())
|
||||
{
|
||||
linkedDimensions.add(link.destDimID);
|
||||
}
|
||||
for (NewDimData data : allDims)
|
||||
{
|
||||
if (!linkedDimensions.contains(data.dimID))
|
||||
{
|
||||
if (PocketManager.instance.pruneDimension(data, deleteFolders))
|
||||
{
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
PocketManager.instance.save();
|
||||
sender.sendChatToPlayer("Removed " + removedCount + " unreachable pocket dims.");
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
|
||||
private CommandResetDungeons()
|
||||
{
|
||||
super("dd-resetdungeons", "");
|
||||
super("dd-rebuilddungeons", "");
|
||||
}
|
||||
|
||||
public static CommandResetDungeons instance()
|
||||
@@ -32,12 +32,12 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
int dungeonCount = 0;
|
||||
int resetCount = 0;
|
||||
|
||||
for (NewDimData data : PocketManager.dimList.values())
|
||||
for (NewDimData data : PocketManager.getDimensions())
|
||||
{
|
||||
if (data.isDimRandomRift)
|
||||
if (data.isDungeon())
|
||||
{
|
||||
dungeonCount++;
|
||||
if (PocketManager.instance.resetPocket(data))
|
||||
if (PocketManager.resetDungeon(data))
|
||||
{
|
||||
resetCount++;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class CommandResetDungeons extends DDCommandBase
|
||||
}
|
||||
|
||||
//Notify the user of the results
|
||||
sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were reset.");
|
||||
sender.sendChatToPlayer("Reset complete. " + resetCount + " out of " + dungeonCount + " dungeons were rebuilt.");
|
||||
return DDCommandResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,16 @@ import java.util.List;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.BlankTeleporter;
|
||||
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(PocketManager.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(PocketManager.getWorld(dimDestinationID)==null)
|
||||
{
|
||||
PocketManager.initDimension(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]));
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user