Fixed gateway filters
This commit is contained in:
parent
b947154b2d
commit
f061b072fd
2 changed files with 70 additions and 20 deletions
|
@ -1,7 +1,10 @@
|
||||||
package StevenDimDoors.mod_pocketDim.world.gateways;
|
package StevenDimDoors.mod_pocketDim.world.gateways;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
@ -10,8 +13,13 @@ import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||||
|
import StevenDimDoors.mod_pocketDim.dungeon.ModBlockFilter;
|
||||||
|
import StevenDimDoors.mod_pocketDim.dungeon.SpecialBlockFinder;
|
||||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.BlockRotator;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.CompoundFilter;
|
||||||
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
||||||
|
import StevenDimDoors.mod_pocketDim.schematic.ReplacementFilter;
|
||||||
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
|
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
|
||||||
import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
|
import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
|
||||||
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
import StevenDimDoors.mod_pocketDim.world.PocketBuilder;
|
||||||
|
@ -21,6 +29,23 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||||
|
|
||||||
public abstract class BaseGateway
|
public abstract class BaseGateway
|
||||||
{
|
{
|
||||||
|
//TODO all these constants probably need to go somewhere, they are being
|
||||||
|
//duplicated atm
|
||||||
|
private static final short MAX_VANILLA_BLOCK_ID = 173;
|
||||||
|
private static final short STANDARD_FABRIC_OF_REALITY_ID = 1973;
|
||||||
|
private static final short STANDARD_ETERNAL_FABRIC_ID = 220;
|
||||||
|
private static final short STANDARD_WARP_DOOR_ID = 1975;
|
||||||
|
private static final short STANDARD_DIMENSIONAL_DOOR_ID = 1970;
|
||||||
|
private static final short STANDARD_TRANSIENT_DOOR_ID = 1979;
|
||||||
|
|
||||||
|
private static final short[] MOD_BLOCK_FILTER_EXCEPTIONS = new short[] {
|
||||||
|
STANDARD_FABRIC_OF_REALITY_ID,
|
||||||
|
STANDARD_ETERNAL_FABRIC_ID,
|
||||||
|
STANDARD_WARP_DOOR_ID,
|
||||||
|
STANDARD_DIMENSIONAL_DOOR_ID,
|
||||||
|
STANDARD_TRANSIENT_DOOR_ID
|
||||||
|
};
|
||||||
|
|
||||||
//This pack is what the dungeon initially generates into from this gateway.
|
//This pack is what the dungeon initially generates into from this gateway.
|
||||||
protected DungeonPack startingPack;
|
protected DungeonPack startingPack;
|
||||||
|
|
||||||
|
@ -48,14 +73,11 @@ public abstract class BaseGateway
|
||||||
//TODO not yet implemented
|
//TODO not yet implemented
|
||||||
protected int generationWeight;
|
protected int generationWeight;
|
||||||
|
|
||||||
//Used to find the doorway for the .schematic
|
private DDProperties properties;
|
||||||
protected GatewayBlockFilter filter;
|
|
||||||
|
|
||||||
|
|
||||||
public BaseGateway(DDProperties properties)
|
public BaseGateway(DDProperties properties)
|
||||||
{
|
{
|
||||||
filter = new GatewayBlockFilter((short) properties.DimensionalDoorID, (short) properties.TransientDoorID,
|
this.properties=properties;
|
||||||
(short) properties.WarpDoorID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,16 +93,33 @@ public abstract class BaseGateway
|
||||||
|
|
||||||
if (this.hasSchematic())
|
if (this.hasSchematic())
|
||||||
{
|
{
|
||||||
|
//Get the correct filters
|
||||||
|
GatewayBlockFilter filter = new GatewayBlockFilter();
|
||||||
Schematic schematic = this.getSchematicToBuild(world, x, y, z);
|
Schematic schematic = this.getSchematicToBuild(world, x, y, z);
|
||||||
|
CompoundFilter standardizer = new CompoundFilter();
|
||||||
|
standardizer.addFilter(new ModBlockFilter(MAX_VANILLA_BLOCK_ID, MOD_BLOCK_FILTER_EXCEPTIONS,
|
||||||
|
(short) properties.FabricBlockID, (byte) 0));
|
||||||
|
|
||||||
|
Map<Short, Short> mapping = getAssignedToStandardIDMapping(properties);
|
||||||
|
for (Entry<Short, Short> entry : mapping.entrySet())
|
||||||
|
{
|
||||||
|
if (entry.getKey() != entry.getValue())
|
||||||
|
{
|
||||||
|
standardizer.addFilter(new ReplacementFilter(entry.getValue(), entry.getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//apply the filters
|
||||||
|
schematic.applyFilter(standardizer);
|
||||||
schematic.applyFilter(filter);
|
schematic.applyFilter(filter);
|
||||||
|
|
||||||
Point3D doorLocation = filter.getEntranceDoorLocation();
|
Point3D doorLocation = filter.getEntranceDoorLocation();
|
||||||
orientation = filter.getEntranceOrientation();
|
orientation = filter.getEntranceOrientation();
|
||||||
|
|
||||||
// I suspect that the location used below is wrong. Gateways should be placed vertically based on
|
// I suspect that the location used below is wrong. Gateways should be placed vertically based on
|
||||||
// the Y position of the surface where they belong. I'm pretty sure including doorLocation.getY()
|
// the Y position of the surface where they belong. I'm pretty sure including doorLocation.getY()
|
||||||
// messes up the calculation. ~SenseiKiwi
|
// messes up the calculation. ~SenseiKiwi
|
||||||
|
|
||||||
//schematic.copyToWorld(world, x - doorLocation.getX(), y, z - doorLocation.getZ());
|
//schematic.copyToWorld(world, x - doorLocation.getX(), y, z - doorLocation.getZ());
|
||||||
schematic.copyToWorld(world, x - doorLocation.getX(), y + 1 - doorLocation.getY(), z - doorLocation.getZ());
|
schematic.copyToWorld(world, x - doorLocation.getX(), y + 1 - doorLocation.getY(), z - doorLocation.getZ());
|
||||||
}
|
}
|
||||||
|
@ -163,4 +202,17 @@ public abstract class BaseGateway
|
||||||
{
|
{
|
||||||
return this.schematicPaths != null && !this.schematicPaths.isEmpty();
|
return this.schematicPaths != null && !this.schematicPaths.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO- we probably should put this is a seperate class, or have it in DDProperties.
|
||||||
|
private Map<Short, Short> getAssignedToStandardIDMapping(DDProperties properties)
|
||||||
|
{
|
||||||
|
//If we ever need this broadly or support other mods, this should be moved to a separate class
|
||||||
|
TreeMap<Short, Short> mapping = new TreeMap<Short, Short>();
|
||||||
|
mapping.put((short) properties.FabricBlockID, STANDARD_FABRIC_OF_REALITY_ID);
|
||||||
|
mapping.put((short) properties.PermaFabricBlockID, STANDARD_ETERNAL_FABRIC_ID);
|
||||||
|
mapping.put((short) properties.WarpDoorID, STANDARD_WARP_DOOR_ID);
|
||||||
|
mapping.put((short) properties.DimensionalDoorID, STANDARD_DIMENSIONAL_DOOR_ID);
|
||||||
|
mapping.put((short) properties.TransientDoorID, STANDARD_TRANSIENT_DOOR_ID);
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,20 @@ import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
|
||||||
|
|
||||||
public class GatewayBlockFilter extends SchematicFilter {
|
public class GatewayBlockFilter extends SchematicFilter {
|
||||||
|
|
||||||
private short dimensionalDoorID;
|
private static final short STANDARD_WARP_DOOR_ID = 1975;
|
||||||
private int transientDoorID;
|
private static final short STANDARD_DIMENSIONAL_DOOR_ID = 1970;
|
||||||
private int warpDoorID;
|
private static final short STANDARD_TRANSIENT_DOOR_ID = 1979;
|
||||||
|
|
||||||
private int entranceOrientation;
|
private int entranceOrientation;
|
||||||
private Schematic schematic;
|
private Schematic schematic;
|
||||||
private Point3D entranceDoorLocation;
|
private Point3D entranceDoorLocation;
|
||||||
|
|
||||||
public GatewayBlockFilter(short dimensionalDoorID, short transientDoorID, short warpDoorID)
|
public GatewayBlockFilter()
|
||||||
{
|
{
|
||||||
super("GatewayEntranceFinder");
|
super("GatewayEntranceFinder");
|
||||||
this.entranceDoorLocation = null;
|
this.entranceDoorLocation = null;
|
||||||
this.entranceOrientation = 0;
|
this.entranceOrientation = 0;
|
||||||
this.schematic = null;
|
this.schematic = null;
|
||||||
this.dimensionalDoorID = dimensionalDoorID;
|
|
||||||
this.transientDoorID = transientDoorID;
|
|
||||||
this.warpDoorID = warpDoorID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEntranceOrientation() {
|
public int getEntranceOrientation() {
|
||||||
|
@ -46,30 +44,30 @@ public class GatewayBlockFilter extends SchematicFilter {
|
||||||
{
|
{
|
||||||
int indexBelow;
|
int indexBelow;
|
||||||
int indexDoubleBelow;
|
int indexDoubleBelow;
|
||||||
if (blocks[index] == dimensionalDoorID)
|
if (blocks[index] == STANDARD_DIMENSIONAL_DOOR_ID)
|
||||||
{
|
{
|
||||||
indexBelow = schematic.calculateIndexBelow(index);
|
indexBelow = schematic.calculateIndexBelow(index);
|
||||||
if (indexBelow >= 0 && blocks[indexBelow] == dimensionalDoorID)
|
if (indexBelow >= 0 && blocks[indexBelow] == STANDARD_DIMENSIONAL_DOOR_ID)
|
||||||
{
|
{
|
||||||
entranceDoorLocation = schematic.calculatePoint(index);
|
entranceDoorLocation = schematic.calculatePoint(index);
|
||||||
entranceOrientation = (metadata[indexBelow] & 3);
|
entranceOrientation = (metadata[indexBelow] & 3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (blocks[index] == transientDoorID)
|
if (blocks[index] == STANDARD_TRANSIENT_DOOR_ID)
|
||||||
{
|
{
|
||||||
indexBelow = schematic.calculateIndexBelow(index);
|
indexBelow = schematic.calculateIndexBelow(index);
|
||||||
if (indexBelow >= 0 && blocks[indexBelow] == transientDoorID)
|
if (indexBelow >= 0 && blocks[indexBelow] == STANDARD_TRANSIENT_DOOR_ID)
|
||||||
{
|
{
|
||||||
entranceDoorLocation = schematic.calculatePoint(index);
|
entranceDoorLocation = schematic.calculatePoint(index);
|
||||||
entranceOrientation = (metadata[indexBelow] & 3);
|
entranceOrientation = (metadata[indexBelow] & 3);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (blocks[index] == warpDoorID)
|
if (blocks[index] == STANDARD_WARP_DOOR_ID)
|
||||||
{
|
{
|
||||||
indexBelow = schematic.calculateIndexBelow(index);
|
indexBelow = schematic.calculateIndexBelow(index);
|
||||||
if (indexBelow >= 0 && blocks[indexBelow] == warpDoorID)
|
if (indexBelow >= 0 && blocks[indexBelow] == STANDARD_WARP_DOOR_ID)
|
||||||
{
|
{
|
||||||
entranceDoorLocation = schematic.calculatePoint(index);
|
entranceDoorLocation = schematic.calculatePoint(index);
|
||||||
entranceOrientation = (metadata[indexBelow] & 3);
|
entranceOrientation = (metadata[indexBelow] & 3);
|
||||||
|
|
Loading…
Reference in a new issue