added support for different dungeon gateways
This commit is contained in:
@@ -39,6 +39,8 @@ public class DungeonSchematic extends Schematic {
|
|||||||
private static final short STANDARD_ETERNAL_FABRIC_ID = 220;
|
private static final short STANDARD_ETERNAL_FABRIC_ID = 220;
|
||||||
private static final short STANDARD_WARP_DOOR_ID = 1975;
|
private static final short STANDARD_WARP_DOOR_ID = 1975;
|
||||||
private static final short STANDARD_DIMENSIONAL_DOOR_ID = 1970;
|
private static final short STANDARD_DIMENSIONAL_DOOR_ID = 1970;
|
||||||
|
private static final short STANDARD_TRANSIENT_DOOR_ID = 1979;
|
||||||
|
|
||||||
private static final short MONOLITH_SPAWN_MARKER_ID = (short) Block.endPortalFrame.blockID;
|
private static final short MONOLITH_SPAWN_MARKER_ID = (short) Block.endPortalFrame.blockID;
|
||||||
private static final short EXIT_DOOR_MARKER_ID = (short) Block.sandStone.blockID;
|
private static final short EXIT_DOOR_MARKER_ID = (short) Block.sandStone.blockID;
|
||||||
private static final int NETHER_DIMENSION_ID = -1;
|
private static final int NETHER_DIMENSION_ID = -1;
|
||||||
@@ -53,7 +55,8 @@ public class DungeonSchematic extends Schematic {
|
|||||||
STANDARD_FABRIC_OF_REALITY_ID,
|
STANDARD_FABRIC_OF_REALITY_ID,
|
||||||
STANDARD_ETERNAL_FABRIC_ID,
|
STANDARD_ETERNAL_FABRIC_ID,
|
||||||
STANDARD_WARP_DOOR_ID,
|
STANDARD_WARP_DOOR_ID,
|
||||||
STANDARD_DIMENSIONAL_DOOR_ID
|
STANDARD_DIMENSIONAL_DOOR_ID,
|
||||||
|
STANDARD_TRANSIENT_DOOR_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
private DungeonSchematic(Schematic source)
|
private DungeonSchematic(Schematic source)
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
//Now do other stuff
|
//Now do other stuff
|
||||||
MinecraftForge.EVENT_BUS.register(new EventHookContainer(properties));
|
MinecraftForge.EVENT_BUS.register(new EventHookContainer(properties));
|
||||||
|
|
||||||
riftGen = new GatewayGenerator(properties);
|
riftGen = new GatewayGenerator(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,10 +280,12 @@ public class mod_pocketDim
|
|||||||
|
|
||||||
CraftingManager.registerRecipies();
|
CraftingManager.registerRecipies();
|
||||||
DungeonHelper.initialize();
|
DungeonHelper.initialize();
|
||||||
|
this.riftGen.initGateways();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Register loot chests
|
// Register loot chests
|
||||||
DDLoot.registerInfo(properties);
|
DDLoot.registerInfo(properties);
|
||||||
|
|
||||||
proxy.loadTextures();
|
proxy.loadTextures();
|
||||||
proxy.registerRenderers();
|
proxy.registerRenderers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.world;
|
package StevenDimDoors.mod_pocketDim.world;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
@@ -14,6 +15,8 @@ import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
|||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
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.GatewayTwoPillars;
|
||||||
import cpw.mods.fml.common.IWorldGenerator;
|
import cpw.mods.fml.common.IWorldGenerator;
|
||||||
|
|
||||||
public class GatewayGenerator implements IWorldGenerator
|
public class GatewayGenerator implements IWorldGenerator
|
||||||
@@ -32,11 +35,20 @@ public class GatewayGenerator implements IWorldGenerator
|
|||||||
private static final int NETHER_DIMENSION_ID = -1;
|
private static final int NETHER_DIMENSION_ID = -1;
|
||||||
private static final int END_DIMENSION_ID = 1;
|
private static final int END_DIMENSION_ID = 1;
|
||||||
|
|
||||||
|
private static ArrayList<BaseGateway> gateways;
|
||||||
|
|
||||||
private final DDProperties properties;
|
private final DDProperties properties;
|
||||||
|
|
||||||
public GatewayGenerator(DDProperties properties)
|
public GatewayGenerator(DDProperties properties)
|
||||||
{
|
{
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initGateways()
|
||||||
|
{
|
||||||
|
gateways=new ArrayList<BaseGateway>();
|
||||||
|
gateways.add(new GatewayTwoPillars(this.properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -134,6 +146,8 @@ 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);
|
||||||
|
/**
|
||||||
//Create a partial link to a dungeon.
|
//Create a partial link to a dungeon.
|
||||||
dimension = PocketManager.getDimensionData(world);
|
dimension = PocketManager.getDimensionData(world);
|
||||||
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, 0);
|
link = dimension.createLink(x, y + 1, z, LinkTypes.DUNGEON, 0);
|
||||||
@@ -150,6 +164,7 @@ public class GatewayGenerator implements IWorldGenerator
|
|||||||
|
|
||||||
//Place the shiny transient door into a dungeon
|
//Place the shiny transient door into a dungeon
|
||||||
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 0, mod_pocketDim.transientDoor);
|
ItemDimensionalDoor.placeDoorBlock(world, x, y, z, 0, mod_pocketDim.transientDoor);
|
||||||
|
**/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package StevenDimDoors.mod_pocketDim.world.gateways;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
|
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||||
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
|
||||||
|
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
|
||||||
|
public abstract class BaseGateway
|
||||||
|
{
|
||||||
|
protected DungeonPack startingPack;
|
||||||
|
protected boolean isBiomeSpecific;
|
||||||
|
protected ArrayList<String> allowedBiomeNames;
|
||||||
|
protected boolean surfaceGateway;
|
||||||
|
protected int generationWeight;
|
||||||
|
protected String schematicPath;
|
||||||
|
protected GatewayBlockFilter filter;
|
||||||
|
|
||||||
|
|
||||||
|
public BaseGateway(DDProperties properties)
|
||||||
|
{
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the gateway centered on the given coords
|
||||||
|
* @param world
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
*/
|
||||||
|
public boolean generate(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
Point3D doorLocation= new Point3D(0,0,0);
|
||||||
|
int orientation = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(this.schematicPath!=null)
|
||||||
|
{
|
||||||
|
Schematic schematic = Schematic.readFromResource(schematicPath);
|
||||||
|
schematic.applyFilter(filter);
|
||||||
|
doorLocation = filter.getEntranceDoorLocation();
|
||||||
|
orientation = filter.getEntranceOrientation();
|
||||||
|
schematic.copyToWorld(world, x-doorLocation.getX(), y-doorLocation.getY(), z-doorLocation.getZ());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.generateRandomBits(world, x,y,z);
|
||||||
|
|
||||||
|
DimLink link = PocketManager.getDimensionData(world).createLink(x, y + 1, z, LinkTypes.DUNGEON, orientation);
|
||||||
|
PocketBuilder.generateSelectedDungeonPocket(link, mod_pocketDim.properties, this.getStartingDungeon(world.rand));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract void generateRandomBits(World world, int x, int y, int z);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns a dungeon from the assigned pack to start with
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DungeonData getStartingDungeon(Random random)
|
||||||
|
{
|
||||||
|
return startingPack.getRandomDungeon(random);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* determines if a given location is valid for the gateway to be generated, based on height, biome, and world.
|
||||||
|
* @param world
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @param biome
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isLocationValid(World world, int x, int y, int z, BiomeGenBase biome)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldGenUnderground()
|
||||||
|
{
|
||||||
|
return !surfaceGateway;
|
||||||
|
}
|
||||||
|
public boolean isBiomeValid(BiomeGenBase biome)
|
||||||
|
{
|
||||||
|
return this.isBiomeSpecific||this.allowedBiomeNames.contains(biome.biomeName.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package StevenDimDoors.mod_pocketDim.world.gateways;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
|
||||||
|
|
||||||
|
public class GatewayBlockFilter extends SchematicFilter {
|
||||||
|
|
||||||
|
private short dimensionalDoorID;
|
||||||
|
private int entranceOrientation;
|
||||||
|
private Schematic schematic;
|
||||||
|
private Point3D entranceDoorLocation;
|
||||||
|
private int transientDoorID;
|
||||||
|
|
||||||
|
|
||||||
|
public GatewayBlockFilter(short dimensionalDoorID,short transientDoorID)
|
||||||
|
{
|
||||||
|
super("GatewayEnteranceFinder");
|
||||||
|
this.dimensionalDoorID = dimensionalDoorID;
|
||||||
|
this.entranceDoorLocation = null;
|
||||||
|
this.entranceOrientation = 0;
|
||||||
|
this.schematic = null;
|
||||||
|
this.transientDoorID=transientDoorID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEntranceOrientation() {
|
||||||
|
return entranceOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point3D getEntranceDoorLocation() {
|
||||||
|
return entranceDoorLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean initialize(Schematic schematic, short[] blocks, byte[] metadata)
|
||||||
|
{
|
||||||
|
this.schematic = schematic;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean applyToBlock(int index, short[] blocks, byte[] metadata)
|
||||||
|
{
|
||||||
|
int indexBelow;
|
||||||
|
int indexDoubleBelow;
|
||||||
|
System.out.println(blocks[index]);
|
||||||
|
if (blocks[index] == dimensionalDoorID)
|
||||||
|
{
|
||||||
|
indexBelow = schematic.calculateIndexBelow(index);
|
||||||
|
if (indexBelow >= 0 && blocks[indexBelow] == dimensionalDoorID)
|
||||||
|
{
|
||||||
|
entranceDoorLocation = schematic.calculatePoint(index);
|
||||||
|
entranceOrientation = (metadata[indexBelow] & 3);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (blocks[index] == transientDoorID)
|
||||||
|
{
|
||||||
|
indexBelow = schematic.calculateIndexBelow(index);
|
||||||
|
if (indexBelow >= 0 && blocks[indexBelow] == transientDoorID)
|
||||||
|
{
|
||||||
|
entranceDoorLocation = schematic.calculatePoint(index);
|
||||||
|
entranceOrientation = (metadata[indexBelow] & 3);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean terminates()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package StevenDimDoors.mod_pocketDim.world.gateways;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
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.world.World;
|
||||||
|
|
||||||
|
public class GatewayTwoPillars extends BaseGateway
|
||||||
|
{
|
||||||
|
|
||||||
|
private GatewayBlockFilter filter;
|
||||||
|
|
||||||
|
public GatewayTwoPillars(DDProperties properties)
|
||||||
|
{
|
||||||
|
super(properties);
|
||||||
|
super.startingPack=DungeonHelper.instance().getDungeonPack("RUINS");
|
||||||
|
super.isBiomeSpecific=false;
|
||||||
|
super.allowedBiomeNames=null;
|
||||||
|
surfaceGateway=true;
|
||||||
|
generationWeight = 0;
|
||||||
|
schematicPath="/schematics/gateways/twoPillars.schematic";
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
void generateRandomBits(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
src/main/resources/schematics/gateways/twoPillars.schematic
Normal file
BIN
src/main/resources/schematics/gateways/twoPillars.schematic
Normal file
Binary file not shown.
Reference in New Issue
Block a user