Gateways nearly done, added sandstone gateways
This commit is contained in:
parent
21267309a1
commit
0fcf02e75f
6 changed files with 127 additions and 40 deletions
|
@ -16,6 +16,7 @@ import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
import StevenDimDoors.mod_pocketDim.items.ItemDimensionalDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.world.gateways.BaseGateway;
|
import StevenDimDoors.mod_pocketDim.world.gateways.BaseGateway;
|
||||||
|
import StevenDimDoors.mod_pocketDim.world.gateways.GatewaySandstonePillars;
|
||||||
import StevenDimDoors.mod_pocketDim.world.gateways.GatewayTwoPillars;
|
import StevenDimDoors.mod_pocketDim.world.gateways.GatewayTwoPillars;
|
||||||
import cpw.mods.fml.common.IWorldGenerator;
|
import cpw.mods.fml.common.IWorldGenerator;
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ public class GatewayGenerator implements IWorldGenerator
|
||||||
private static final int END_DIMENSION_ID = 1;
|
private static final int END_DIMENSION_ID = 1;
|
||||||
|
|
||||||
private static ArrayList<BaseGateway> gateways;
|
private static ArrayList<BaseGateway> gateways;
|
||||||
|
private static BaseGateway defaultGateway;
|
||||||
|
|
||||||
private final DDProperties properties;
|
private final DDProperties properties;
|
||||||
|
|
||||||
|
@ -48,7 +50,11 @@ public class GatewayGenerator implements IWorldGenerator
|
||||||
public void initGateways()
|
public void initGateways()
|
||||||
{
|
{
|
||||||
gateways=new ArrayList<BaseGateway>();
|
gateways=new ArrayList<BaseGateway>();
|
||||||
gateways.add(new GatewayTwoPillars(this.properties));
|
this.defaultGateway=new GatewayTwoPillars(this.properties);
|
||||||
|
|
||||||
|
//add gateways here
|
||||||
|
gateways.add(new GatewaySandstonePillars(this.properties));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,25 +152,23 @@ public class GatewayGenerator implements IWorldGenerator
|
||||||
//Build the gateway if we found a valid location
|
//Build the gateway if we found a valid location
|
||||||
if (valid)
|
if (valid)
|
||||||
{
|
{
|
||||||
this.gateways.get(random.nextInt(gateways.size())).generate(world, x, y, z);
|
//TODO I feel like this is slow and should be optimized. We are linear time with total # of generation restrictions
|
||||||
/**
|
//Create an array and copy valid gateways into it
|
||||||
//Create a partial link to a dungeon.
|
ArrayList<BaseGateway> validGateways = new ArrayList<BaseGateway>();
|
||||||
dimension = PocketManager.getDimensionData(world);
|
for(BaseGateway gateway:gateways)
|
||||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, 0);
|
|
||||||
|
|
||||||
//If the current dimension isn't Limbo, build a Rift Gateway out of Stone Bricks
|
|
||||||
if (dimension.id() != properties.LimboDimensionID)
|
|
||||||
{
|
{
|
||||||
createStoneGateway(world, x, y, z, random);
|
if(gateway.isLocationValid(world, x, y, z, world.getBiomeGenForCoords(x, z)))
|
||||||
|
{
|
||||||
|
validGateways.add(gateway);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
//Add default gateway if we where unable to find a suitable gateway
|
||||||
|
if(validGateways.isEmpty())
|
||||||
{
|
{
|
||||||
createLimboGateway(world, x, y, z, properties.LimboBlockID);
|
validGateways.add(this.defaultGateway);
|
||||||
}
|
}
|
||||||
|
//randomly select a gateway from the pool of viable gateways
|
||||||
//Place the shiny transient door into a dungeon
|
validGateways.get(random.nextInt(validGateways.size())).generate(world, x, y, z);
|
||||||
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 0, mod_pocketDim.transientDoor);
|
|
||||||
**/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,34 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
|
||||||
public abstract class BaseGateway
|
public abstract class BaseGateway
|
||||||
{
|
{
|
||||||
|
//This pack is what the dungeon initially generates into from this gateway.
|
||||||
protected DungeonPack startingPack;
|
protected DungeonPack startingPack;
|
||||||
|
|
||||||
|
/**Flag that determines if this gateway is tied to a specific biome.
|
||||||
|
*For compatabilities sake, we are just using string comparison to check.
|
||||||
|
**/
|
||||||
protected boolean isBiomeSpecific;
|
protected boolean isBiomeSpecific;
|
||||||
protected ArrayList<String> allowedBiomeNames;
|
|
||||||
|
/**
|
||||||
|
* List of biome names that we check against. Is by default a whitelist, but the isBiomeValid method
|
||||||
|
* can be overriden for specific gateways. For example, any biome containing 'forest' would be valid if we added 'forest',
|
||||||
|
* even from other mods.
|
||||||
|
*/
|
||||||
|
protected ArrayList<String> biomeNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List containing all the .schematics attached to this gateway. Selection is random by default,
|
||||||
|
* but can be overriden for specific gateways in getSchematicToBuild
|
||||||
|
*/
|
||||||
|
protected ArrayList<String> schematicPaths= new ArrayList<String>();
|
||||||
|
|
||||||
|
//TODO not yet implemented
|
||||||
protected boolean surfaceGateway;
|
protected boolean surfaceGateway;
|
||||||
|
|
||||||
|
//TODO not yet implemented
|
||||||
protected int generationWeight;
|
protected int generationWeight;
|
||||||
protected String schematicPath;
|
|
||||||
|
//Used to find the doorway for the .schematic
|
||||||
protected GatewayBlockFilter filter;
|
protected GatewayBlockFilter filter;
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,27 +68,19 @@ public abstract class BaseGateway
|
||||||
*/
|
*/
|
||||||
public boolean generate(World world, int x, int y, int z)
|
public boolean generate(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
|
||||||
int orientation = 0;
|
int orientation = 0;
|
||||||
try
|
|
||||||
|
if(this.hasSchematic())
|
||||||
{
|
{
|
||||||
if(this.schematicPath!=null)
|
Schematic schematic = this.getSchematicToBuild(world, x, y, z);
|
||||||
{
|
|
||||||
Schematic schematic = Schematic.readFromResource(schematicPath);
|
schematic.applyFilter(filter);
|
||||||
schematic.applyFilter(filter);
|
Point3D doorLocation = filter.getEntranceDoorLocation();
|
||||||
|
orientation = filter.getEntranceOrientation();
|
||||||
|
|
||||||
Point3D doorLocation = filter.getEntranceDoorLocation();
|
schematic.copyToWorld(world, x-doorLocation.getX(), y+1-doorLocation.getY(), z-doorLocation.getZ());
|
||||||
orientation = filter.getEntranceOrientation();
|
|
||||||
|
|
||||||
schematic.copyToWorld(world, x-doorLocation.getX(), y+1-doorLocation.getY(), z-doorLocation.getZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
System.err.println("Could not load schematic "+this.schematicPath+" for gateway");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.generateRandomBits(world, x,y,z);
|
this.generateRandomBits(world, x,y,z);
|
||||||
|
|
||||||
DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
|
DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
|
||||||
|
@ -75,6 +89,29 @@ public abstract class BaseGateway
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a .schematic to generate for this gateway
|
||||||
|
* @param world
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Schematic getSchematicToBuild(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
//TODO- refine selection criteria here, this is the default case
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Schematic.readFromResource(schematicPaths.get(world.rand.nextInt(schematicPaths.size())));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println("Could not load schematic for gateway");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this function to generate randomized bits of the structure.
|
* Use this function to generate randomized bits of the structure.
|
||||||
* @param world
|
* @param world
|
||||||
|
@ -104,7 +141,8 @@ public abstract class BaseGateway
|
||||||
*/
|
*/
|
||||||
public boolean isLocationValid(World world, int x, int y, int z, BiomeGenBase biome)
|
public boolean isLocationValid(World world, int x, int y, int z, BiomeGenBase biome)
|
||||||
{
|
{
|
||||||
return false;
|
//TODO- refine condition here as warranted
|
||||||
|
return this.isBiomeValid(biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldGenUnderground()
|
public boolean shouldGenUnderground()
|
||||||
|
@ -114,7 +152,11 @@ public abstract class BaseGateway
|
||||||
|
|
||||||
public boolean isBiomeValid(BiomeGenBase biome)
|
public boolean isBiomeValid(BiomeGenBase biome)
|
||||||
{
|
{
|
||||||
return this.isBiomeSpecific||this.allowedBiomeNames.contains(biome.biomeName.toLowerCase());
|
return !this.isBiomeSpecific||this.biomeNames.contains(biome.biomeName.toLowerCase());
|
||||||
|
}
|
||||||
|
public boolean hasSchematic()
|
||||||
|
{
|
||||||
|
return this.schematicPaths!=null&&this.schematicPaths.size()>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ public class GatewayBlockFilter extends SchematicFilter {
|
||||||
{
|
{
|
||||||
int indexBelow;
|
int indexBelow;
|
||||||
int indexDoubleBelow;
|
int indexDoubleBelow;
|
||||||
System.out.println(blocks[index]);
|
|
||||||
if (blocks[index] == dimensionalDoorID)
|
if (blocks[index] == dimensionalDoorID)
|
||||||
{
|
{
|
||||||
indexBelow = schematic.calculateIndexBelow(index);
|
indexBelow = schematic.calculateIndexBelow(index);
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package StevenDimDoors.mod_pocketDim.world.gateways;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||||
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
|
|
||||||
|
public class GatewaySandstonePillars extends BaseGateway
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final int GATEWAY_RADIUS = 4;
|
||||||
|
|
||||||
|
public GatewaySandstonePillars(DDProperties properties)
|
||||||
|
{
|
||||||
|
super(properties);
|
||||||
|
super.startingPack=DungeonHelper.instance().getDungeonPack("RUINS");
|
||||||
|
super.isBiomeSpecific=true;
|
||||||
|
super.biomeNames.add("desert");
|
||||||
|
surfaceGateway=true;
|
||||||
|
generationWeight = 0;
|
||||||
|
schematicPaths.add("/schematics/gateways/sandstonePillars.schematic");
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean generate(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
//simple to transform the generation location here.
|
||||||
|
//Do you think this is the best way to do this?
|
||||||
|
return super.generate(world, x, y+2, z);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void generateRandomBits(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,10 +19,10 @@ public class GatewayTwoPillars extends BaseGateway
|
||||||
super(properties);
|
super(properties);
|
||||||
super.startingPack=DungeonHelper.instance().getDungeonPack("RUINS");
|
super.startingPack=DungeonHelper.instance().getDungeonPack("RUINS");
|
||||||
super.isBiomeSpecific=false;
|
super.isBiomeSpecific=false;
|
||||||
super.allowedBiomeNames=null;
|
super.biomeNames=null;
|
||||||
surfaceGateway=true;
|
surfaceGateway=true;
|
||||||
generationWeight = 0;
|
generationWeight = 0;
|
||||||
schematicPath="/schematics/gateways/twoPillars.schematic";
|
schematicPaths.add("/schematics/gateways/twoPillars.schematic");
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue