added another command- delete_all_links
Signed-off-by: StevenRS11 <steven.r.stafford.ii.14@dartmouth.edu>
This commit is contained in:
112
StevenDimDoors/mod_pocketDim/commands/CommandDeleteAllLinks.java
Normal file
112
StevenDimDoors/mod_pocketDim/commands/CommandDeleteAllLinks.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CommandDeleteAllLinks extends CommandBase
|
||||
{
|
||||
public String getCommandName()//the name of our command
|
||||
{
|
||||
return "delete_all_links";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2)
|
||||
|
||||
{
|
||||
int linksRemoved=0;
|
||||
int targetDim;
|
||||
boolean shouldGo= true;
|
||||
|
||||
if(var2.length==0)
|
||||
{
|
||||
targetDim= this.getCommandSenderAsPlayer(var1).worldObj.provider.dimensionId;
|
||||
}
|
||||
else if(var2.length==1)
|
||||
{
|
||||
targetDim= this.parseInt(var1, var2[0]);
|
||||
if(!dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error- dim "+targetDim+" not registered");
|
||||
shouldGo=false;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetDim=0;
|
||||
shouldGo=false;
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Error-Invalid argument, delete_all_links <targetDimID> or blank for current dim");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(shouldGo)
|
||||
{
|
||||
if(dimHelper.dimList.containsKey(targetDim))
|
||||
{
|
||||
DimData dim = dimHelper.dimList.get(targetDim);
|
||||
|
||||
ArrayList<LinkData> linksInDim = dim.printAllLinkData();
|
||||
|
||||
for(LinkData link : linksInDim)
|
||||
{
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
}
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
}
|
||||
|
||||
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
|
||||
{
|
||||
dimHelper.instance.linksForRendering.remove(link);
|
||||
dim.removeLinkAtCoords(link);
|
||||
|
||||
|
||||
|
||||
targetWorld.setBlockWithNotify(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
|
||||
|
||||
linksRemoved++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//dim.linksInThisDim.clear();
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+linksRemoved+" links.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// this.getCommandSenderAsPlayer(var1).sendChatToPlayer(String.valueOf(var2));
|
||||
// this.getCommandSenderAsPlayer(var1).sendChatToPlayer(String.valueOf(var2.length));
|
||||
// this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+linksRemoved+" rifts.");
|
||||
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.world.World;
|
||||
@@ -65,8 +66,8 @@ public class CommandDeleteRifts extends CommandBase
|
||||
|
||||
for(LinkData link : linksInDim)
|
||||
{
|
||||
dimHelper.instance.linksForRendering.remove(link);
|
||||
World targetWorld = dimHelper.getWorld(targetDim);
|
||||
|
||||
if(targetWorld==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
@@ -74,16 +75,26 @@ public class CommandDeleteRifts extends CommandBase
|
||||
else if(targetWorld.provider==null)
|
||||
{
|
||||
dimHelper.initDimension(targetDim);
|
||||
|
||||
}
|
||||
targetWorld = dimHelper.getWorld(targetDim);
|
||||
|
||||
targetWorld.setBlockWithNotify(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
if(targetWorld.getBlockId(link.locXCoord, link.locYCoord, link.locZCoord)==mod_pocketDim.blockRiftID)
|
||||
{
|
||||
dimHelper.instance.linksForRendering.remove(link);
|
||||
dim.removeLinkAtCoords(link);
|
||||
|
||||
|
||||
linksRemoved++;
|
||||
|
||||
targetWorld.setBlockWithNotify(link.locXCoord, link.locYCoord, link.locZCoord, 0);
|
||||
|
||||
|
||||
linksRemoved++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dim.linksInThisDim.clear();
|
||||
//dim.linksInThisDim.clear();
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+linksRemoved+" rifts.");
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteAllLinks;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts;
|
||||
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDims;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class mod_pocketDim
|
||||
|
||||
public static final ICommand removeRiftsCommand = new CommandDeleteRifts();
|
||||
public static final ICommand pruneDimsCommand = new CommandPruneDims();
|
||||
public static final ICommand removeAllLinksCommand = new CommandDeleteAllLinks();
|
||||
|
||||
|
||||
public static int providerID;
|
||||
@@ -614,6 +616,7 @@ public class mod_pocketDim
|
||||
{
|
||||
event.registerServerCommand(removeRiftsCommand);
|
||||
event.registerServerCommand(pruneDimsCommand);
|
||||
event.registerServerCommand(removeAllLinksCommand);
|
||||
|
||||
dimHelper.instance.load();
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class pocketProvider extends WorldProvider
|
||||
public String getDimensionName()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return "PocketDim";
|
||||
return "PocketDim "+this.dimensionId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user