Refixing Tool paradigm and adding some more stuff to the Encampment
This commit is contained in:
parent
cce90ce8fd
commit
6aec0a87ea
12 changed files with 387 additions and 54 deletions
|
@ -13,6 +13,9 @@ public class BuildingSchematic
|
|||
public String name;
|
||||
public int doorX;
|
||||
public int doorZ;
|
||||
public int doorY;
|
||||
public int buildingTier;
|
||||
public int buildingType;
|
||||
public List<BlockSet> blockList;
|
||||
|
||||
public BuildingSchematic()
|
||||
|
@ -26,6 +29,9 @@ public class BuildingSchematic
|
|||
blockList = new ArrayList();
|
||||
this.doorX = 0;
|
||||
this.doorZ = 0;
|
||||
this.doorY = 0;
|
||||
this.buildingTier = 0;
|
||||
this.buildingType = DemonBuilding.BUILDING_HOUSE;
|
||||
}
|
||||
|
||||
public void addBlockWithMeta(Block block, int meta, int xOffset, int yOffset, int zOffset)
|
||||
|
@ -62,7 +68,7 @@ public class BuildingSchematic
|
|||
{
|
||||
int gridX = (int)((coords.xCoord+2*Math.signum(coords.xCoord))/5);
|
||||
int gridZ = (int)((coords.zCoord+2*Math.signum(coords.zCoord))/5);
|
||||
|
||||
|
||||
holder.setGridSpace(gridX, gridZ, new GridSpace(GridSpace.HOUSE,0));
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +81,49 @@ public class BuildingSchematic
|
|||
int gridX = (int)((doorX+2*Math.signum(doorX))/5);
|
||||
int gridZ = (int)((doorZ+2*Math.signum(doorZ))/5);
|
||||
|
||||
return new Int3(gridX, 0, gridZ);
|
||||
return new Int3(gridX, doorY, gridZ);
|
||||
}
|
||||
|
||||
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
|
||||
{
|
||||
GridSpaceHolder grid = this.createGSH();
|
||||
for(int i=this.getMinY(); i<=this.getMaxY(); i++)
|
||||
{
|
||||
grid.destroyAllInGridSpaces(world, xCoord, yCoord + i, zCoord, dir);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinY()
|
||||
{
|
||||
int min = 0;
|
||||
for(BlockSet set : blockList)
|
||||
{
|
||||
for(Int3 pos : set.getPositions())
|
||||
{
|
||||
if(pos.yCoord < min)
|
||||
{
|
||||
min = pos.yCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
public int getMaxY()
|
||||
{
|
||||
int max = 0;
|
||||
for(BlockSet set : blockList)
|
||||
{
|
||||
for(Int3 pos : set.getPositions())
|
||||
{
|
||||
if(pos.yCoord > max)
|
||||
{
|
||||
max = pos.yCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
|
@ -6,17 +6,20 @@ import WayofTime.alchemicalWizardry.common.Int3;
|
|||
|
||||
public class DemonBuilding
|
||||
{
|
||||
public static final int BUILDING_HOUSE = 0;
|
||||
public static final int BUILDING_PORTAL = 1;
|
||||
|
||||
public BuildingSchematic schematic;
|
||||
public GridSpaceHolder area;
|
||||
public int buildingTier;
|
||||
public int type;
|
||||
public int buildingType;
|
||||
public Int3 doorGridSpace;
|
||||
|
||||
public DemonBuilding(BuildingSchematic schematic)
|
||||
{
|
||||
this.schematic = schematic;
|
||||
this.type = 0;
|
||||
this.buildingTier = 0;
|
||||
this.buildingType = schematic.buildingType;
|
||||
this.buildingTier = schematic.buildingTier;
|
||||
this.area = this.createGSHForSchematic(schematic);
|
||||
this.doorGridSpace = schematic.getGridSpotOfDoor();
|
||||
}
|
||||
|
@ -43,6 +46,13 @@ public class DemonBuilding
|
|||
|
||||
public GridSpaceHolder createGSHForSchematic(BuildingSchematic scheme)
|
||||
{
|
||||
switch(this.buildingType)
|
||||
{
|
||||
case DemonBuilding.BUILDING_HOUSE:
|
||||
return scheme.createGSH();
|
||||
case DemonBuilding.BUILDING_PORTAL:
|
||||
|
||||
}
|
||||
return scheme.createGSH();
|
||||
}
|
||||
|
||||
|
@ -70,7 +80,7 @@ public class DemonBuilding
|
|||
break;
|
||||
}
|
||||
|
||||
return new Int3(x, 0, z);
|
||||
return new Int3(x, doorGridSpace.yCoord, z);
|
||||
}
|
||||
|
||||
public Int3 getGridOffsetFromRoad(ForgeDirection sideOfRoad, int yLevel)
|
||||
|
@ -97,4 +107,9 @@ public class DemonBuilding
|
|||
|
||||
return new Int3(x, yLevel, z);
|
||||
}
|
||||
|
||||
public void destroyAllInField(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
|
||||
{
|
||||
schematic.destroyAllInField(world, xCoord, yCoord, zCoord, dir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package WayofTime.alchemicalWizardry.common.demonVillage;
|
||||
|
||||
import WayofTime.alchemicalWizardry.ModBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class GridSpaceHolder
|
||||
|
@ -192,6 +195,7 @@ public class GridSpaceHolder
|
|||
|
||||
public void setAllGridSpaces(int xInit, int zInit, int yLevel, ForgeDirection dir, int type, GridSpaceHolder master)
|
||||
{
|
||||
System.out.println("Grid space selected: (" + xInit + "," + zInit + ")");
|
||||
if(master != null)
|
||||
{
|
||||
for(int i=-negXRadius; i<=posXRadius; i++)
|
||||
|
@ -227,9 +231,62 @@ public class GridSpaceHolder
|
|||
break;
|
||||
}
|
||||
|
||||
System.out.println("Grid space (" + (xInit + xOff) + "," + (zInit + zOff) + ")");
|
||||
|
||||
master.setGridSpace(xInit + xOff, zInit + zOff, new GridSpace(type, yLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyAllInGridSpaces(World world, int xCoord, int yCoord, int zCoord, ForgeDirection dir)
|
||||
{
|
||||
for(int i=-negXRadius; i<=posXRadius; i++)
|
||||
{
|
||||
for(int j=-negZRadius; j<=posZRadius; j++)
|
||||
{
|
||||
GridSpace thisSpace = this.getGridSpace(i, j);
|
||||
if(thisSpace.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int xOff = 0;
|
||||
int zOff = 0;
|
||||
|
||||
switch(dir)
|
||||
{
|
||||
case SOUTH:
|
||||
xOff = -i;
|
||||
zOff = -j;
|
||||
break;
|
||||
case WEST:
|
||||
xOff = j;
|
||||
zOff = -i;
|
||||
break;
|
||||
case EAST:
|
||||
xOff = -j;
|
||||
zOff = i;
|
||||
break;
|
||||
default:
|
||||
xOff = i;
|
||||
zOff = j;
|
||||
break;
|
||||
}
|
||||
|
||||
for(int l = -2; l<=2; l++)
|
||||
{
|
||||
for(int m = -2; m<=2; m++)
|
||||
{
|
||||
Block block = world.getBlock(xCoord + xOff*5 + l, yCoord, zCoord + zOff*5 + m);
|
||||
if(block == ModBlocks.blockDemonPortal)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
world.setBlockToAir(xCoord + xOff*5 + l, yCoord, zCoord + zOff*5 + m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue