Fixed Rotation in Schematic Loader and Partially Overhauled Commands #32

Merged
SenseiKiwi merged 9 commits from master into master 2013-06-26 04:51:57 +00:00
2 changed files with 102 additions and 106 deletions
Showing only changes of commit 471114415b - Show all commits

View File

@@ -814,7 +814,7 @@ public class SchematicLoader
entities = nbtdata.getTagList("Entities"); entities = nbtdata.getTagList("Entities");
tileentities = nbtdata.getTagList("TileEntities"); tileentities = nbtdata.getTagList("TileEntities");
**/ **/
input.close(); input.close();
//combine the split block IDs into a single short[] //combine the split block IDs into a single short[]
@@ -907,41 +907,37 @@ public class SchematicLoader
} }
} }
//determines necessary rotation, reflection, and translation to build the .schematic by finding the difference between the //Compute the Y-axis translation that places our structure correctly
//.schematic incomingLink location which is relative to the .schematic only, and comparing it with the world incoming link coordinates yCooe = incY - incomingLink.getY();
//must also factor in the orientation of the incoming door.
if(orientation==0) //TODO currently broken, only orientation 3 works atm
{
xCooe=-incomingLink.getX()+incX;
yCooe=-incomingLink.getY()+incY;
zCooe=-incomingLink.getZ()+incZ;
} //Loop to actually place the blocks
if(orientation==1)//TODO currently broken, only orientation 3 works atm for ( x = 0; x < width; x++)
{ {
xCooe=-incomingLink.getX()+incX; for ( z = 0; z < length; z++)
yCooe=-incomingLink.getY()+incY;
zCooe=-incomingLink.getZ()+incZ;
}
if(orientation==2)//TODO currently broken, only orientation 3 works atm
{
xCooe=-incomingLink.getX()+incX;
yCooe=-incomingLink.getY()+incY;
zCooe=-incomingLink.getZ()+incZ;
}
if(orientation==3)//TODO this only works because it is the default orientation of the pocket dim
{
xCooe=-incomingLink.getX()+incX;
yCooe=-incomingLink.getY()+incY;
zCooe=-incomingLink.getZ()+incZ;
}
//loop to actually place the blocks
for ( x = 0; x < width; ++x)
{
for ( y = 0; y < height; ++y)
{ {
for ( z = 0; z < length; ++z) //Compute the X-axis and Z-axis translations that will shift
//and rotate our structure properly.
switch (orientation)
{
case 0:
xCooe = -incomingLink.getX() + incX;
zCooe = -incomingLink.getZ() + incZ;
break;
case 1:
xCooe = -incomingLink.getX() + incX;
zCooe = -incomingLink.getZ() + incZ;
break;
case 2:
xCooe = -incomingLink.getX() + incX;
zCooe = -incomingLink.getZ() + incZ;
break;
case 3:
xCooe = -incomingLink.getX() + incX;
zCooe = -incomingLink.getZ() + incZ;
break;
}
for ( y = 0; y < height; y++)
{ {
int index = y * width * length + z * width + x; int index = y * width * length + z * width + x;
@@ -990,23 +986,23 @@ public class SchematicLoader
{ {
tile.readFromNBT(tag); tile.readFromNBT(tag);
} }
**/ **/
//fill chests //fill chests
if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityChest) if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityChest)
{ {
TileEntityChest chest = (TileEntityChest) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe); TileEntityChest chest = (TileEntityChest) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe);
ChestGenHooks info = DDLoot.DungeonChestInfo; ChestGenHooks info = DDLoot.DungeonChestInfo;
WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), (TileEntityChest)world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe), info.getCount(rand)); WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), (TileEntityChest)world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe), info.getCount(rand));
} }
//fill dispensers //fill dispensers
if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityDispenser) if(world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe) instanceof TileEntityDispenser)
{ {
TileEntityDispenser dispenser = (TileEntityDispenser) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe); TileEntityDispenser dispenser = (TileEntityDispenser) world.getBlockTileEntity(x+xCooe, y+yCooe, z+zCooe);
dispenser.addItem(new ItemStack(Item.arrow, 64)); dispenser.addItem(new ItemStack(Item.arrow, 64));
} }
} }
} }
} }
@@ -1018,35 +1014,35 @@ public class SchematicLoader
{ {
int depth = dimHelper.instance.getDimDepth(originDimID); int depth = dimHelper.instance.getDimDepth(originDimID);
int xNoise = 0; int xNoise = 0;
int zNoise =0; int zNoise =0;
switch(world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe)) switch(world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe))
{ {
case 0: case 0:
xNoise = (int)rand.nextInt(depth+1*200)+depth*50; xNoise = (int)rand.nextInt(depth+1*200)+depth*50;
zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth;
break; break;
case 1: case 1:
xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth;
zNoise = (int) rand.nextInt(depth+1*200)+depth*50; zNoise = (int) rand.nextInt(depth+1*200)+depth*50;
break; break;
case 2: case 2:
xNoise = - (rand.nextInt(depth+1*200)+depth*50); xNoise = - (rand.nextInt(depth+1*200)+depth*50);
zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; zNoise = (int)rand.nextInt(depth+1*20)-(10)*depth;
break; break;
case 3: case 3:
xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth; xNoise = (int)rand.nextInt(depth+1*20)-(10)*depth;
zNoise = -(rand.nextInt(depth+1*200)+depth*50); zNoise = -(rand.nextInt(depth+1*200)+depth*50);
break; break;
} }
LinkData sideLink = new LinkData(destDimID,0,point.getX()+xCooe, point.getY()+yCooe, point.getZ()+zCooe,xNoise+point.getX()+xCooe, point.getY()+yCooe+1, zNoise+point.getZ()+zCooe,true,world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe)); LinkData sideLink = new LinkData(destDimID,0,point.getX()+xCooe, point.getY()+yCooe, point.getZ()+zCooe,xNoise+point.getX()+xCooe, point.getY()+yCooe+1, zNoise+point.getZ()+zCooe,true,world.getBlockMetadata(point.getX()+xCooe, point.getY()+yCooe-1, point.getZ()+zCooe));
dimHelper.instance.createPocket(sideLink, true, true); dimHelper.instance.createPocket(sideLink, true, true);
} }
//generate linkData for wooden dim doors leading to the overworld //generate linkData for wooden dim doors leading to the overworld
@@ -1064,7 +1060,7 @@ public class SchematicLoader
else if((rand.nextBoolean()&&randomLink!=null)) else if((rand.nextBoolean()&&randomLink!=null))
{ {
sideLink.destDimID=randomLink.locDimID; sideLink.destDimID=randomLink.locDimID;
// System.out.println("randomLink"); // System.out.println("randomLink");
} }
sideLink.destYCoord=yCoordHelper.getFirstUncovered(sideLink.destDimID, point.getX()+xCooe,10,point.getZ()+zCooe); sideLink.destYCoord=yCoordHelper.getFirstUncovered(sideLink.destDimID, point.getX()+xCooe,10,point.getZ()+zCooe);
@@ -1131,8 +1127,8 @@ public class SchematicLoader
Chunk chunk; Chunk chunk;
cX = x >> 4; cX = x >> 4;
cZ = z >> 4; cZ = z >> 4;
cY=y >>4; cY=y >>4;
int chunkX=(x % 16)< 0 ? ((x) % 16)+16 : ((x) % 16); int chunkX=(x % 16)< 0 ? ((x) % 16)+16 : ((x) % 16);
int chunkZ=((z) % 16)< 0 ? ((z) % 16)+16 : ((z) % 16); int chunkZ=((z) % 16)< 0 ? ((z) % 16)+16 : ((z) % 16);

View File

@@ -391,7 +391,7 @@ public class mod_pocketDim
@ServerStarting @ServerStarting
public void serverStarting(FMLServerStartingEvent event) public void serverStarting(FMLServerStartingEvent event)
{ {
CommandRegenPocket.instance().register(event); CommandResetDungeons.instance().register(event);
CommandCreateDungeonRift.instance().register(event); CommandCreateDungeonRift.instance().register(event);
CommandDeleteAllLinks.instance().register(event); CommandDeleteAllLinks.instance().register(event);
CommandDeleteDimensionData.instance().register(event); CommandDeleteDimensionData.instance().register(event);