2013-07-30 19:58:14 +02:00
|
|
|
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));
|
2013-07-30 23:57:05 +02:00
|
|
|
return true;
|
2013-07-30 19:58:14 +02:00
|
|
|
}
|
2013-07-30 23:57:05 +02:00
|
|
|
if (blocks[index] == dimensionalDoorID)
|
2013-07-30 19:58:14 +02:00
|
|
|
{
|
|
|
|
indexBelow = schematic.calculateIndexBelow(index);
|
|
|
|
if (indexBelow >= 0 && blocks[indexBelow] == dimensionalDoorID)
|
|
|
|
{
|
|
|
|
dimensionalDoorLocations.add(schematic.calculatePoint(index));
|
2013-07-30 23:57:05 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
2013-07-30 19:58:14 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-30 23:57:05 +02:00
|
|
|
if (blocks[index] == warpDoorID)
|
2013-07-30 19:58:14 +02:00
|
|
|
{
|
|
|
|
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));
|
2013-07-30 23:57:05 +02:00
|
|
|
return true;
|
2013-07-30 19:58:14 +02:00
|
|
|
}
|
|
|
|
else if (entranceDoorLocation == null)
|
|
|
|
{
|
|
|
|
entranceDoorLocation = schematic.calculatePoint(index);
|
|
|
|
entranceOrientation = (metadata[indexBelow] & 3);
|
2013-07-30 23:57:05 +02:00
|
|
|
return true;
|
2013-07-30 19:58:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-30 23:57:05 +02:00
|
|
|
return false;
|
2013-07-30 19:58:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean terminates()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|