added server commands, prune_pocket_dims and delete_rifts <dimID>

Signed-off-by: StevenRS11 <steven.r.stafford.ii.14@dartmouth.edu>
This commit is contained in:
StevenRS11 2013-03-23 01:25:50 -04:00
parent f800a9a353
commit 55dc5edb9b
7 changed files with 190 additions and 24 deletions

View file

@ -4,6 +4,7 @@ package StevenDimDoors.mod_pocketDim;
* @Return
*/
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -224,8 +225,9 @@ public class DimData implements Serializable
public void printAllLinkData()
public ArrayList<LinkData> printAllLinkData()
{
ArrayList links = new ArrayList();
Iterator itr= this.linksInThisDim.keySet().iterator();
while (itr.hasNext())
@ -247,12 +249,14 @@ public class DimData implements Serializable
LinkData link = (LinkData) second.get((Integer)itrsecond.next());
link.printLinkData();
links.add(link);
}
}
}
return links;
}
}

View file

@ -67,7 +67,7 @@ public class TileEntityRift extends TileEntity
List list = worldObj.getEntitiesWithinAABB(EntityEnderman.class, AxisAlignedBB.getBoundingBox( this.xCoord-9, this.yCoord-3, this.zCoord-9, this.xCoord+9, this.yCoord+3, this.zCoord+9));
if(list.size()<5)
if(list.size()<1)
{

View file

@ -0,0 +1,101 @@
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 net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.world.World;
public class CommandDeleteRifts extends CommandBase
{
public String getCommandName()//the name of our command
{
return "delete_rifts";
}
@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_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)
{
dimHelper.instance.linksForRendering.remove(link);
World targetWorld = dimHelper.getWorld(targetDim);
if(targetWorld==null)
{
dimHelper.initDimension(targetDim);
}
else if(targetWorld.provider==null)
{
dimHelper.initDimension(targetDim);
}
targetWorld.setBlockWithNotify(link.locXCoord, link.locYCoord, link.locZCoord, 0);
linksRemoved++;
}
dim.linksInThisDim.clear();
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+linksRemoved+" rifts.");
}
}
// 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
}
}

View file

@ -0,0 +1,69 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.LinkData;
import StevenDimDoors.mod_pocketDim.dimHelper;
public class CommandPruneDims extends CommandBase
{
public String getCommandName()//the name of our command
{
return "prune_pocket_dims";
}
@Override
public void processCommand(ICommandSender var1, String[] var2)
{
int numRemoved=0;
ArrayList dimsWithLinks=new ArrayList();
Collection<DimData> allDims = new ArrayList();
allDims.addAll(dimHelper.dimList.values());
for(DimData data: allDims)
{
for(LinkData link:data.printAllLinkData())
{
if(!dimsWithLinks.contains(link.destDimID))
{
dimsWithLinks.add(link.destDimID);
}
}
}
for(LinkData link : dimHelper.instance.interDimLinkList.values())
{
if(!dimsWithLinks.contains(link.destDimID))
{
dimsWithLinks.add(link.destDimID);
}
}
for(DimData data : allDims)
{
if(!dimsWithLinks.contains(data.dimID))
{
dimHelper.dimList.remove(data.dimID);
numRemoved++;
}
}
dimHelper.instance.save();
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Removed "+numRemoved+" unreachable pocket dims.");
}
}

View file

@ -372,11 +372,6 @@ public class dimDoor extends BlockContainer
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
TileEntityDimDoor tile = (TileEntityDimDoor) par1World.getBlockTileEntity(par2, par3, par4);
tile.openOrClosed=this.isDoorOpen( par1World, par2, par3, par4);
int metaData = this.getFullMetadata(par1World, par2, par3, par4);
@ -387,13 +382,6 @@ public class dimDoor extends BlockContainer
}
public boolean isOpaqueCube()
{

View file

@ -2,25 +2,19 @@ package StevenDimDoors.mod_pocketDim;
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.tileentity.RenderEndPortal;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.command.ICommand;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityEndPortal;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import StevenDimDoors.mod_pocketDimClient.ClientPacketHandler;
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
import StevenDimDoors.mod_pocketDimClient.RenderDimDoor;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
@ -40,6 +34,8 @@ 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.CommandDeleteRifts;
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDims;
@Mod(modid = "DimensionalDoors", name = "Dimensional Doors", version = mod_pocketDim.version)
@ -62,6 +58,9 @@ public class mod_pocketDim
public static mod_pocketDim instance = new mod_pocketDim();
public static SchematicLoader loader = new SchematicLoader();
public static final ICommand removeRiftsCommand = new CommandDeleteRifts();
public static final ICommand pruneDimsCommand = new CommandPruneDims();
public static int providerID;
public static int dimDoorID;
@ -281,6 +280,9 @@ public class mod_pocketDim
public void Init(FMLInitializationEvent event)
{
transientDoor = (new TransientDoor(transientDoorID, Material.iron)).setHardness(1.0F).setRequiresSelfNotify().setBlockName("transientDoor");
linkDimDoor = (new linkDimDoor(linkDimDoorID, Material.iron)).setHardness(1.0F).setRequiresSelfNotify().setBlockName("dimDoor");
@ -610,6 +612,9 @@ public class mod_pocketDim
@ServerStarting
public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(removeRiftsCommand);
event.registerServerCommand(pruneDimsCommand);
dimHelper.instance.load();

View file

@ -270,7 +270,6 @@ public class RenderDimDoor extends TileEntitySpecialRenderer
{
if(mod_pocketDim.enableDoorOpenGL)
{
System.out.println("rendering");
this.renderDimDoorTileEntity((TileEntityDimDoor)par1TileEntity, par2, par4, par6, par8);
}
}