finished dungeon export basic implementation
This commit is contained in:
parent
40551fe013
commit
fa15c13d37
7 changed files with 196 additions and 63 deletions
|
@ -757,7 +757,7 @@ public class SchematicLoader
|
|||
int blockMetaData=loader.blockData[index];
|
||||
NBTTagList tileEntity = loader.tileentities;
|
||||
HashMap tileEntityMap= new HashMap();
|
||||
int size = tileEntity.tagCount();
|
||||
//int size = tileEntity.tagCount();
|
||||
|
||||
|
||||
if(blockToReplace==Block.doorIron.blockID)
|
||||
|
|
|
@ -68,12 +68,28 @@ public class CommandAddDungeonRift extends CommandBase
|
|||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer(dungeonName);
|
||||
|
||||
}
|
||||
|
||||
for(DungeonGenerator dungeonGen : mod_pocketDim.customDungeons)
|
||||
{
|
||||
String dungeonName =dungeonGen.schematicPath;
|
||||
if(dungeonName.contains("DimDoors_Custom_schematics"))
|
||||
{
|
||||
dungeonName= dungeonName.substring(dungeonName.indexOf("DimDoors_Custom_schematics")+26);
|
||||
}
|
||||
|
||||
dungeonName =dungeonName.replace("/", "").replace(".", "").replace("schematics", "").replace("schematic", "");
|
||||
|
||||
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer(dungeonName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if(var2.length!=0)
|
||||
{
|
||||
for(DungeonGenerator dungeonGen : mod_pocketDim.registeredDungeons)
|
||||
|
||||
for(DungeonGenerator dungeonGen : mod_pocketDim.registeredDungeons)
|
||||
{
|
||||
String dungeonName =dungeonGen.schematicPath.toLowerCase();
|
||||
|
||||
|
@ -93,7 +109,37 @@ public class CommandAddDungeonRift extends CommandBase
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
for(DungeonGenerator dungeonGen : mod_pocketDim.customDungeons)
|
||||
{
|
||||
String dungeonName =dungeonGen.schematicPath.toLowerCase();
|
||||
|
||||
|
||||
|
||||
if(dungeonName.contains(var2[0].toLowerCase()))
|
||||
{
|
||||
|
||||
link = dimHelper.instance.createPocket(link,true, true);
|
||||
|
||||
dimHelper.dimList.get(link.destDimID).dungeonGenerator=dungeonGen;
|
||||
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("Genned dungeon " +dungeonName);
|
||||
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(var2!=null&&!var2[0].equals("random"))
|
||||
{
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("could not find dungeon, 'list' for list of dungeons");
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package StevenDimDoors.mod_pocketDim.commands;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DungeonGenerator;
|
||||
import StevenDimDoors.mod_pocketDim.customDungeonImporter;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public class CommandEndDungeonCreation extends CommandBase
|
||||
{
|
||||
|
@ -19,18 +22,41 @@ public class CommandEndDungeonCreation extends CommandBase
|
|||
public void processCommand(ICommandSender var1, String[] var2)
|
||||
|
||||
{
|
||||
int x = (int) this.getCommandSenderAsPlayer(var1).posX;
|
||||
int y = (int) this.getCommandSenderAsPlayer(var1).posY;
|
||||
int z = (int) this.getCommandSenderAsPlayer(var1).posZ;
|
||||
|
||||
EntityPlayer player =this.getCommandSenderAsPlayer(var1);
|
||||
|
||||
if(!customDungeonImporter.customDungeonStatus.containsKey(player.worldObj.provider.dimensionId))
|
||||
{
|
||||
if(var2.length==0)
|
||||
{
|
||||
player.sendChatToPlayer("Must have started dungeon creation, use argument OVERRIDE to export anyway");
|
||||
return;
|
||||
|
||||
}
|
||||
else if(!var2[1].contains("OVERRIDE"))
|
||||
{
|
||||
player.sendChatToPlayer("Must have started dungeon creation, use argument OVERRIDE to export anyway");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
|
||||
if(var2.length==0)
|
||||
{
|
||||
System.out.println("Must name file");
|
||||
player.sendChatToPlayer("Must name file");
|
||||
}
|
||||
else
|
||||
{
|
||||
customDungeonImporter.exportDungeon(this.getCommandSenderAsPlayer(var1).worldObj, x, y, z, mod_pocketDim.schematicContainer+"/"+var2[0]);
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("created dungeon schematic in " +mod_pocketDim.schematicContainer+"/"+var2[0]);
|
||||
DungeonGenerator newDungeon = customDungeonImporter.exportDungeon(player.worldObj, x, y, z, mod_pocketDim.schematicContainer+"/"+var2[0]+".schematic");
|
||||
player.sendChatToPlayer("created dungeon schematic in " +mod_pocketDim.schematicContainer+"/"+var2[0]+".schematic");
|
||||
mod_pocketDim.customDungeons.add(newDungeon);
|
||||
|
||||
dimHelper.instance.teleportToPocket(player.worldObj, customDungeonImporter.customDungeonStatus.get(player.worldObj.provider.dimensionId), player);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
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.customDungeonImporter;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CommandPrintDungeonData extends CommandBase
|
||||
{
|
||||
public String getCommandName()//the name of our command
|
||||
{
|
||||
return "print_dungeon_data";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2)
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
|||
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.customDungeonImporter;
|
||||
import StevenDimDoors.mod_pocketDim.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.command.CommandBase;
|
||||
|
@ -37,6 +38,7 @@ public class CommandStartDungeonCreation extends CommandBase
|
|||
link = dimHelper.instance.createPocket(link,true, false);
|
||||
|
||||
dimHelper.instance.teleportToPocket(player.worldObj, link, player);
|
||||
customDungeonImporter.customDungeonStatus.put(player.worldObj.provider.dimensionId, dimHelper.instance.getLinkDataFromCoords(link.destXCoord, link.destYCoord, link.destZCoord, link.destDimID));
|
||||
|
||||
this.getCommandSenderAsPlayer(var1).sendChatToPlayer("DimID = "+ link.destDimID);
|
||||
|
||||
|
|
|
@ -29,14 +29,16 @@ import StevenDimDoors.mod_pocketDim.helpers.yCoordHelper;
|
|||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ByteArrayTag;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.CompoundTag;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.NBTOutputStream;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.jnbt.ShortTag;
|
||||
|
||||
public class customDungeonImporter
|
||||
{
|
||||
NBTTagCompound nbtdata= new NBTTagCompound();
|
||||
|
||||
public static HashMap<Integer, LinkData> customDungeonStatus = new HashMap<Integer, LinkData>();
|
||||
|
||||
|
||||
public static void exportDungeon(World world, int xI, int yI, int zI, String file)
|
||||
public static DungeonGenerator exportDungeon(World world, int xI, int yI, int zI, String file)
|
||||
{
|
||||
int xMin;
|
||||
int yMin;
|
||||
|
@ -49,8 +51,8 @@ public class customDungeonImporter
|
|||
xMin=xMax=xI;
|
||||
yMin=yMax=yI;
|
||||
zMin=zMax=zI;
|
||||
/**
|
||||
for(int count=0;xI<50;xI++)
|
||||
|
||||
for(int count=0;count<50;count++)
|
||||
{
|
||||
|
||||
if(world.getBlockId(xMin, yI, zI)!=mod_pocketDim.blockDimWallPermID)
|
||||
|
@ -67,21 +69,21 @@ public class customDungeonImporter
|
|||
}
|
||||
if(world.getBlockId(xMax, yI, zI)!=mod_pocketDim.blockDimWallPermID)
|
||||
{
|
||||
xMin++;
|
||||
xMax++;
|
||||
}
|
||||
if(world.getBlockId(xI, yMax, zI)!=mod_pocketDim.blockDimWallPermID)
|
||||
{
|
||||
yMin++;
|
||||
yMax++;
|
||||
}
|
||||
if(world.getBlockId(xI, yI, zMax)!=mod_pocketDim.blockDimWallPermID)
|
||||
{
|
||||
zMin++;
|
||||
zMax++;
|
||||
}
|
||||
}
|
||||
**/
|
||||
short width = 100;//(short) (xMax-xMin);
|
||||
short height= 100;//(short) (yMax-yMin);
|
||||
short length= 100;//(short) (zMax=zMin);
|
||||
|
||||
short width =(short) (xMax-xMin);
|
||||
short height= (short) (yMax-yMin);
|
||||
short length= (short) (zMax-zMin);
|
||||
|
||||
|
||||
|
||||
|
@ -89,12 +91,13 @@ public class customDungeonImporter
|
|||
byte[] addBlocks = null;
|
||||
byte[] blockData = new byte[width * height * length];
|
||||
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int z = 0; z < length; ++z) {
|
||||
int index = y * width * length + z * width + x;
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
int meta= world.getBlockMetadata(x, y, z);
|
||||
int blockID = world.getBlockId(x+xMin, y+yMin, z+zMin);
|
||||
int meta= world.getBlockMetadata(x+xMin, y+yMin, z+zMin);
|
||||
// Save 4096 IDs in an AddBlocks section
|
||||
if (blockID > 255) {
|
||||
if (addBlocks == null) { // Lazily create section
|
||||
|
@ -124,6 +127,10 @@ public class customDungeonImporter
|
|||
HashMap schematic = new HashMap();
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
if (addBlocks != null) {
|
||||
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||
}
|
||||
|
@ -140,6 +147,7 @@ public class customDungeonImporter
|
|||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new DungeonGenerator(0,file,true);
|
||||
}
|
||||
|
||||
}
|
|
@ -209,6 +209,9 @@ public class mod_pocketDim
|
|||
|
||||
public static ArrayList<DungeonGenerator> exits = new ArrayList<DungeonGenerator>();
|
||||
|
||||
public static ArrayList<DungeonGenerator> customDungeons = new ArrayList<DungeonGenerator>();
|
||||
|
||||
|
||||
public static ArrayList metadataFlipList = new ArrayList();
|
||||
public static ArrayList metadataNextList = new ArrayList();
|
||||
|
||||
|
@ -314,50 +317,63 @@ public class mod_pocketDim
|
|||
{
|
||||
String[] name = schematicFile.getName().split("_");
|
||||
|
||||
|
||||
boolean open= name[2].equals("open");
|
||||
|
||||
int weight = Integer.parseInt(name[3].replace(".schematic", ""));
|
||||
|
||||
String path = schematicFile.getAbsolutePath();
|
||||
|
||||
if(name[0].equals("hub"))
|
||||
if(name.length<4)
|
||||
{
|
||||
this.hubs.add(new DungeonGenerator(weight,path,open));
|
||||
System.out.println("Importing custom dungeon gen mechanics failed, adding to secondary list");
|
||||
this.customDungeons.add(new DungeonGenerator(0,schematicFile.getAbsolutePath(),true));
|
||||
System.out.println("Imported "+schematicFile.getName());
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean open= name[2].equals("open");
|
||||
|
||||
int weight = Integer.parseInt(name[3].replace(".schematic", ""));
|
||||
|
||||
String path = schematicFile.getAbsolutePath();
|
||||
|
||||
if(name[0].equals("hub"))
|
||||
{
|
||||
this.hubs.add(new DungeonGenerator(weight,path,open));
|
||||
}
|
||||
else if(name[0].equals("simpleHall"))
|
||||
{
|
||||
this.simpleHalls.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("complexHall"))
|
||||
{
|
||||
this.complexHalls.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("trap"))
|
||||
{
|
||||
this.pistonTraps.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("deadEnd"))
|
||||
{
|
||||
this.deadEnds.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("exit"))
|
||||
{
|
||||
this.exits.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("mazes"))
|
||||
{
|
||||
this.mazes.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
|
||||
|
||||
System.out.println("Imported "+schematicFile.getName());
|
||||
}
|
||||
else if(name[0].equals("simpleHall"))
|
||||
{
|
||||
this.simpleHalls.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("complexHall"))
|
||||
{
|
||||
this.complexHalls.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("trap"))
|
||||
{
|
||||
this.pistonTraps.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("deadEnd"))
|
||||
{
|
||||
this.deadEnds.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("exit"))
|
||||
{
|
||||
this.exits.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
else if(name[0].equals("mazes"))
|
||||
{
|
||||
this.mazes.add(new DungeonGenerator(weight,path,open));
|
||||
|
||||
}
|
||||
|
||||
|
||||
System.out.println("Imported "+schematicFile.getName());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue