Added regen dungeon command & removed hasMark

This commit is contained in:
StevenRS11 2013-06-24 01:40:56 -04:00
parent 8bbd1384c5
commit 06a8abbf74
7 changed files with 104 additions and 4 deletions

View file

@ -26,7 +26,6 @@ public class DimData implements Serializable
public boolean hasDoor=false;
public boolean isDimRandomRift=false;
public DungeonGenerator dungeonGenerator = null;
public boolean hasMarks=false;
//public boolean isPrivatePocket = false;
public HashMap<Integer, HashMap<Integer, HashMap<Integer, LinkData>>> linksInThisDim=new HashMap();
HashMap<Integer, LinkData> dimX;

View file

@ -1140,7 +1140,6 @@ public class SchematicLoader
Entity mob = new MobObelisk(world);
mob.setLocationAndAngles(point.getX(),point.getY(), point.getZ(), 1, 1);
world.spawnEntityInWorld(mob);
dimHelper.dimList.get(link.destDimID).hasMarks=true;
}

View file

@ -0,0 +1,43 @@
package StevenDimDoors.mod_pocketDim.commands;
import java.io.File;
import net.minecraft.entity.player.EntityPlayer;
import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.DimData;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
public class CommandRegenPocket extends DDCommandBase
{
private static CommandRegenPocket instance = null;
private CommandRegenPocket()
{
super("dd-regenDungeons");
}
public static CommandRegenPocket instance()
{
if (instance == null)
instance = new CommandRegenPocket();
return instance;
}
@Override
protected void processCommand(EntityPlayer sender, String[] command)
{
DungeonHelper dungeonHelper = DungeonHelper.instance();
DDProperties properties = DDProperties.instance();
for(DimData data : dimHelper.dimList.values())
{
if(data.isDimRandomRift)
{
dimHelper.instance.regenPocket(data);
}
}
}
}

View file

@ -0,0 +1,32 @@
package StevenDimDoors.mod_pocketDim.helpers;
import java.io.File;
public class DeleteFolder
{
public static boolean deleteFolder(File file)
{
try
{
File[] files = file.listFiles();
if(files==null)
{
file.delete();
return true;
}
for(File inFile : files)
{
DeleteFolder.deleteFolder(inFile);
}
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
}

View file

@ -810,6 +810,32 @@ public class dimHelper extends DimensionManager
}
}
}
}
public void regenPocket(DimData dimData)
{
if(this.getWorld(dimData.dimID)!=null ||!dimData.isPocket)
{
return;
}
File save = new File( this.getCurrentSaveRootDirectory()+"/DimensionalDoors/pocketDimID" + dimData.dimID);
DeleteFolder.deleteFolder(save);
dimData.hasBeenFilled=false;
dimData.hasDoor=false;
for(LinkData link : dimData.printAllLinkData())
{
link.hasGennedDoor=false;
LinkData linkOut =this.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID);
if(linkOut!=null)
{
linkOut.hasGennedDoor=false;
}
}
}
/**
* method called when the client disconects/server stops to unregister dims.

View file

@ -29,6 +29,7 @@ import StevenDimDoors.mod_pocketDim.commands.CommandDeleteRifts;
import StevenDimDoors.mod_pocketDim.commands.CommandEndDungeonCreation;
import StevenDimDoors.mod_pocketDim.commands.CommandPrintDimensionData;
import StevenDimDoors.mod_pocketDim.commands.CommandPruneDimensions;
import StevenDimDoors.mod_pocketDim.commands.CommandRegenPocket;
import StevenDimDoors.mod_pocketDim.commands.CommandStartDungeonCreation;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
@ -390,6 +391,7 @@ public class mod_pocketDim
@ServerStarting
public void serverStarting(FMLServerStartingEvent event)
{
CommandRegenPocket.instance().register(event);
CommandCreateDungeonRift.instance().register(event);
CommandDeleteAllLinks.instance().register(event);
CommandDeleteDimensionData.instance().register(event);

View file

@ -70,8 +70,7 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
if (dimData == null ||
dimData.dungeonGenerator == null ||
dimData.dungeonGenerator.isOpen||
dimData.hasMarks)
dimData.dungeonGenerator.isOpen)
{
return;
}