f4653d0522
Improved DungeonSchematic to the point that it can replace SchematicLoader as our method of loading dungeons. Some of the code was copied over rather than refactored to save time. It's been subdivided so make it much more readable. Also, we can reimplement portions of it as WorldOperations later on further remove redudancy. Testing shows that there is one problem left to fix: door blocks are not being set up correctly at the moment. Rifts are being set up properly and attaching doors to rifts will show that dungeons continue to generate fine. Added classes to support DungeonSchematic and its additional filtering logic on import and export. SpecialBlockFinder handles listing the entrance, other doors in the dungeon, and end portal frames. FillContainersOperation is a WorldOperation that fills chests and dispensers. BlockRotator is a temporary class to hold transformMetadata() and transformPoint() until we rewrite that code later. Stripped out most of the code from SchematicLoader to ensure it's no longer used. The only remaining function sets up dungeon pockets. We can phase it out in a later version so as not to delay our release. Removed references to SchematicLoader in mod_pocketDim since it no longer needs to be instantiated.
107 lines
2.9 KiB
Java
107 lines
2.9 KiB
Java
package StevenDimDoors.mod_pocketDim.dungeon;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
|
import StevenDimDoors.mod_pocketDim.schematic.Schematic;
|
|
import StevenDimDoors.mod_pocketDim.schematic.SchematicFilter;
|
|
|
|
public class SpecialBlockFinder extends SchematicFilter {
|
|
|
|
private short warpDoorID;
|
|
private short dimensionalDoorID;
|
|
private short monolithSpawnMarkerID;
|
|
private short exitMarkerID;
|
|
private int entranceOrientation;
|
|
private Schematic schematic;
|
|
private Point3D entranceDoorLocation;
|
|
private ArrayList<Point3D> exitDoorLocations;
|
|
private ArrayList<Point3D> dimensionalDoorLocations;
|
|
private ArrayList<Point3D> monolithSpawnLocations;
|
|
|
|
public SpecialBlockFinder(short warpDoorID, short dimensionalDoorID, short monolithSpawnMarkerID, short exitMarkerID)
|
|
{
|
|
super("SpecialBlockFinder");
|
|
this.warpDoorID = warpDoorID;
|
|
this.dimensionalDoorID = dimensionalDoorID;
|
|
this.monolithSpawnMarkerID = monolithSpawnMarkerID;
|
|
this.exitMarkerID = exitMarkerID;
|
|
this.entranceDoorLocation = null;
|
|
this.entranceOrientation = 0;
|
|
this.exitDoorLocations = new ArrayList<Point3D>();
|
|
this.dimensionalDoorLocations = new ArrayList<Point3D>();
|
|
this.monolithSpawnLocations = new ArrayList<Point3D>();
|
|
this.schematic = null;
|
|
}
|
|
|
|
public int getEntranceOrientation() {
|
|
return entranceOrientation;
|
|
}
|
|
|
|
public Point3D getEntranceDoorLocation() {
|
|
return entranceDoorLocation;
|
|
}
|
|
|
|
public ArrayList<Point3D> getExitDoorLocations() {
|
|
return exitDoorLocations;
|
|
}
|
|
|
|
public ArrayList<Point3D> getDimensionalDoorLocations() {
|
|
return dimensionalDoorLocations;
|
|
}
|
|
|
|
public ArrayList<Point3D> getMonolithSpawnLocations() {
|
|
return monolithSpawnLocations;
|
|
}
|
|
|
|
@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;
|
|
|
|
if (blocks[index] == monolithSpawnMarkerID)
|
|
{
|
|
monolithSpawnLocations.add(schematic.calculatePoint(index));
|
|
}
|
|
else if (blocks[index] == dimensionalDoorID)
|
|
{
|
|
indexBelow = schematic.calculateIndexBelow(index);
|
|
if (indexBelow >= 0 && blocks[indexBelow] == dimensionalDoorID)
|
|
{
|
|
dimensionalDoorLocations.add(schematic.calculatePoint(index));
|
|
}
|
|
}
|
|
else if (blocks[index] == warpDoorID)
|
|
{
|
|
indexBelow = schematic.calculateIndexBelow(index);
|
|
if (indexBelow >= 0 && blocks[indexBelow] == warpDoorID)
|
|
{
|
|
indexDoubleBelow = schematic.calculateIndexBelow(indexBelow);
|
|
if (indexDoubleBelow >= 0 && blocks[indexDoubleBelow] == exitMarkerID)
|
|
{
|
|
exitDoorLocations.add(schematic.calculatePoint(index));
|
|
}
|
|
else if (entranceDoorLocation == null)
|
|
{
|
|
entranceDoorLocation = schematic.calculatePoint(index);
|
|
entranceOrientation = (metadata[indexBelow] & 3);
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
protected boolean terminates()
|
|
{
|
|
return false;
|
|
}
|
|
}
|