Gateway generation now emulates old functionality

This commit is contained in:
StevenRS11 2014-01-14 13:40:27 -05:00
parent 9f00345065
commit 0e4e36c454
4 changed files with 47 additions and 11 deletions

View file

@ -33,7 +33,8 @@ public abstract class BaseGateway
public BaseGateway(DDProperties properties) public BaseGateway(DDProperties properties)
{ {
//not using DD properties because sometimes its IDS can be wrong, but require it so we dont init too early //not using DD properties because sometimes its IDS can be wrong, but require it so we dont init too early
filter = new GatewayBlockFilter((short) mod_pocketDim.dimensionalDoor.blockID,(short) mod_pocketDim.transientDoor.blockID); filter = new GatewayBlockFilter((short) mod_pocketDim.dimensionalDoor.blockID,
(short) mod_pocketDim.transientDoor.blockID,(short)mod_pocketDim.warpDoor.blockID);
} }
/** /**
@ -65,13 +66,7 @@ public abstract class BaseGateway
doorLocation = filter.getEntranceDoorLocation(); doorLocation = filter.getEntranceDoorLocation();
orientation = filter.getEntranceOrientation(); orientation = filter.getEntranceOrientation();
schematic.copyToWorld(world, x-schematic.getWidth()+doorLocation.getX(), y-schematic.getHeight()+doorLocation.getY(), z-schematic.getLength()+doorLocation.getZ()); schematic.copyToWorld(world, x-doorLocation.getX(), y+1-doorLocation.getY(), z-doorLocation.getZ());
//TODO debug code to easily locate the rifts
for(int c = 0; c<240; c++)
{
world.setBlock(x, y+c, z,Block.glowStone.blockID);
}
} }
} }
catch (Exception e) catch (Exception e)
@ -123,6 +118,7 @@ public abstract class BaseGateway
{ {
return !surfaceGateway; return !surfaceGateway;
} }
public boolean isBiomeValid(BiomeGenBase biome) public boolean isBiomeValid(BiomeGenBase biome)
{ {
return this.isBiomeSpecific||this.allowedBiomeNames.contains(biome.biomeName.toLowerCase()); return this.isBiomeSpecific||this.allowedBiomeNames.contains(biome.biomeName.toLowerCase());

View file

@ -9,13 +9,15 @@ import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
public class GatewayBlockFilter extends SchematicFilter { public class GatewayBlockFilter extends SchematicFilter {
private short dimensionalDoorID; private short dimensionalDoorID;
private int transientDoorID;
private int warpDoorID;
private int entranceOrientation; private int entranceOrientation;
private Schematic schematic; private Schematic schematic;
private Point3D entranceDoorLocation; private Point3D entranceDoorLocation;
private int transientDoorID;
public GatewayBlockFilter(short dimensionalDoorID,short transientDoorID)
public GatewayBlockFilter(short dimensionalDoorID,short transientDoorID,short warpDoorID)
{ {
super("GatewayEnteranceFinder"); super("GatewayEnteranceFinder");
this.dimensionalDoorID = dimensionalDoorID; this.dimensionalDoorID = dimensionalDoorID;
@ -23,6 +25,7 @@ public class GatewayBlockFilter extends SchematicFilter {
this.entranceOrientation = 0; this.entranceOrientation = 0;
this.schematic = null; this.schematic = null;
this.transientDoorID=transientDoorID; this.transientDoorID=transientDoorID;
this.warpDoorID=warpDoorID;
} }
public int getEntranceOrientation() { public int getEntranceOrientation() {
@ -66,6 +69,16 @@ public class GatewayBlockFilter extends SchematicFilter {
return true; return true;
} }
} }
if (blocks[index] == warpDoorID)
{
indexBelow = schematic.calculateIndexBelow(index);
if (indexBelow >= 0 && blocks[indexBelow] == warpDoorID)
{
entranceDoorLocation = schematic.calculatePoint(index);
entranceOrientation = (metadata[indexBelow] & 3);
return true;
}
}
return false; return false;
} }

View file

@ -6,12 +6,13 @@ import StevenDimDoors.mod_pocketDim.DDProperties;
import StevenDimDoors.mod_pocketDim.mod_pocketDim; import StevenDimDoors.mod_pocketDim.mod_pocketDim;
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack; import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper; import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
import net.minecraft.block.Block;
import net.minecraft.world.World; import net.minecraft.world.World;
public class GatewayTwoPillars extends BaseGateway public class GatewayTwoPillars extends BaseGateway
{ {
private GatewayBlockFilter filter; private static final int GATEWAY_RADIUS = 4;
public GatewayTwoPillars(DDProperties properties) public GatewayTwoPillars(DDProperties properties)
{ {
@ -27,7 +28,33 @@ public class GatewayTwoPillars extends BaseGateway
@Override @Override
void generateRandomBits(World world, int x, int y, int z) void generateRandomBits(World world, int x, int y, int z)
{ {
final int blockID = Block.stoneBrick.blockID;
//Replace some of the ground around the gateway with bricks
for (int xc = -GATEWAY_RADIUS; xc <= GATEWAY_RADIUS; xc++)
{
for (int zc= -GATEWAY_RADIUS; zc <= GATEWAY_RADIUS; zc++)
{
//Check that the block is supported by an opaque block.
//This prevents us from building over a cliff, on the peak of a mountain,
//or the surface of the ocean or a frozen lake.
if (world.isBlockOpaqueCube(x + xc, y - 2, z + zc))
{
//Randomly choose whether to place bricks or not. The math is designed so that the
//chances of placing a block decrease as we get farther from the gateway's center.
if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(2) + 3)
{
//Place Stone Bricks
world.setBlock(x + xc, y - 1, z + zc, blockID, 0, 3);
}
else if (Math.abs(xc) + Math.abs(zc) < world.rand.nextInt(3) + 3)
{
//Place Cracked Stone Bricks
world.setBlock(x + xc, y - 1, z + zc, blockID, 2, 3);
}
}
}
}
} }
} }