diff --git a/StevenDimDoors/mod_pocketDim/DimData.java b/StevenDimDoors/mod_pocketDim/DimData.java index 42873cbb..867b793c 100644 --- a/StevenDimDoors/mod_pocketDim/DimData.java +++ b/StevenDimDoors/mod_pocketDim/DimData.java @@ -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 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; } + } \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/TileEntityRift.java b/StevenDimDoors/mod_pocketDim/TileEntityRift.java index 30891e59..b3f0f303 100644 --- a/StevenDimDoors/mod_pocketDim/TileEntityRift.java +++ b/StevenDimDoors/mod_pocketDim/TileEntityRift.java @@ -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) { diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java new file mode 100644 index 00000000..57559a61 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/commands/CommandDeleteRifts.java @@ -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 or blank for current dim"); + + + } + + + + + if(shouldGo) + { + if(dimHelper.dimList.containsKey(targetDim)) + { + DimData dim = dimHelper.dimList.get(targetDim); + + ArrayList 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 + + } +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandPruneDims.java b/StevenDimDoors/mod_pocketDim/commands/CommandPruneDims.java new file mode 100644 index 00000000..d64d20c3 --- /dev/null +++ b/StevenDimDoors/mod_pocketDim/commands/CommandPruneDims.java @@ -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 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."); + + + + + + + + + } +} \ No newline at end of file diff --git a/StevenDimDoors/mod_pocketDim/dimDoor.java b/StevenDimDoors/mod_pocketDim/dimDoor.java index 1313c2a9..f6bede55 100644 --- a/StevenDimDoors/mod_pocketDim/dimDoor.java +++ b/StevenDimDoors/mod_pocketDim/dimDoor.java @@ -371,11 +371,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); @@ -383,14 +378,7 @@ public class dimDoor extends BlockContainer tile.orientation=metaData%8 ; - - - - - - - - + diff --git a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java index 3490796d..e2c2fb1f 100644 --- a/StevenDimDoors/mod_pocketDim/mod_pocketDim.java +++ b/StevenDimDoors/mod_pocketDim/mod_pocketDim.java @@ -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; @@ -280,6 +279,9 @@ public class mod_pocketDim @Init public void Init(FMLInitializationEvent event) { + + + transientDoor = (new TransientDoor(transientDoorID, Material.iron)).setHardness(1.0F).setRequiresSelfNotify().setBlockName("transientDoor"); @@ -610,6 +612,9 @@ public class mod_pocketDim @ServerStarting public void serverStarting(FMLServerStartingEvent event) { + event.registerServerCommand(removeRiftsCommand); + event.registerServerCommand(pruneDimsCommand); + dimHelper.instance.load(); diff --git a/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java b/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java index dd5905e9..e70458ec 100644 --- a/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java +++ b/StevenDimDoors/mod_pocketDimClient/RenderDimDoor.java @@ -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); } }