public class CubeDetector
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CubeDetector.IDetectionListener
Listener for detections.
|
protected static interface |
CubeDetector.ILocationAction |
static interface |
CubeDetector.IValidationAction |
| Constructor and Description |
|---|
CubeDetector(AllowedBlock[] allowedBlocks,
java.util.List<? extends CubeDetector.IDetectionListener> listeners)
Make a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAllowedBlocks(AllowedBlock[] allowedBlocks) |
protected boolean |
coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
CubeDetector.ILocationAction locationAction)
Run the
CubeDetector.ILocationAction for all the possible locations within this structure. |
protected boolean |
coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
int[] accumulatedCoordinates,
CubeDetector.ILocationAction locationAction)
Run the
CubeDetector.ILocationAction for all the possible locations within this structure. |
Size |
detect(net.minecraft.world.World world,
ILocation startLocation,
boolean valid,
boolean changeState)
Detect a structure at the given start location.
|
Size |
detect(net.minecraft.world.World world,
ILocation startLocation,
boolean valid,
CubeDetector.IValidationAction action,
boolean changeState)
Detect a structure at the given start location.
|
java.util.Collection<AllowedBlock> |
getAllowedBlocks() |
Size |
getExactSize() |
java.util.List<? extends CubeDetector.IDetectionListener> |
getListeners() |
Size |
getMinimumSize() |
protected boolean |
isAir(net.minecraft.world.World world,
ILocation location) |
protected boolean |
isEdge(net.minecraft.world.World world,
int[][] dimensionEgdes,
ILocation location) |
protected boolean |
isValidLocation(net.minecraft.world.World world,
ILocation location) |
protected boolean |
isValidLocation(net.minecraft.world.World world,
ILocation location,
CubeDetector.IValidationAction action) |
protected ILocation |
navigateToBorder(net.minecraft.world.World world,
ILocation startLocation,
int dimension,
boolean max)
Find the border of valid/non-valid locations in one given dimension (both directions).
|
protected ILocation |
navigateToBorder(net.minecraft.world.World world,
ILocation startLocation,
int dimension,
int direction)
Find the border of valid/non-valid locations in one given dimension for just one direction.
|
protected ILocation |
navigateToCorner(net.minecraft.world.World world,
ILocation startLocation,
int[] dimensions,
boolean max)
Navigate to a corner from a given startlocation for the given dimensions.
|
protected void |
notifyListeners(net.minecraft.world.World world,
ILocation location,
Size size,
boolean valid,
ILocation originCorner) |
protected void |
postValidate(net.minecraft.world.World world,
Size size,
int[][] dimensionEgdes,
boolean valid,
ILocation originCorner) |
CubeDetector |
setExactSize(Size exactSize)
The size is the inner size -1 on each dimension, so 2x2x2 is one block in the middle open,
with edge blocks on the side forming a 3x3x3.
|
CubeDetector |
setMinimumSize(Size minimumSize)
The size is the inner size -1 on each dimension, so 2x2x2 is one block in the middle open,
with edge blocks on the side forming a 3x3x3.
|
protected boolean |
validateAllowedBlockConditions(net.minecraft.world.World world,
ILocation location)
Validate if the block at the given location conforms with the
AllowedBlock
conditions. |
protected boolean |
validateDimensionEdges(net.minecraft.world.World world,
int[][] dimensionEgdes,
boolean valid,
CubeDetector.IValidationAction action)
This will validate if the given structure has full borders and is hollow at the middle.
|
protected boolean |
validateLocationInStructure(net.minecraft.world.World world,
int[][] dimensionEgdes,
ILocation location,
CubeDetector.IValidationAction action)
Check if a given location is valid, taking into account the edges of the structure, so that
we know which locations should be borders, and which ones should be air.
|
public CubeDetector(AllowedBlock[] allowedBlocks, java.util.List<? extends CubeDetector.IDetectionListener> listeners)
allowedBlocks - The blocks that are allowed in this cube.listeners - Listeners for detections.public java.util.Collection<AllowedBlock> getAllowedBlocks()
public void addAllowedBlocks(AllowedBlock[] allowedBlocks)
allowedBlocks - The allowed blockspublic Size getMinimumSize()
public CubeDetector setMinimumSize(Size minimumSize)
minimumSize - the minimumSize to setpublic Size getExactSize()
public CubeDetector setExactSize(Size exactSize)
exactSize - the exactSize to setpublic java.util.List<? extends CubeDetector.IDetectionListener> getListeners()
protected void notifyListeners(net.minecraft.world.World world,
ILocation location,
Size size,
boolean valid,
ILocation originCorner)
protected boolean isValidLocation(net.minecraft.world.World world,
ILocation location,
CubeDetector.IValidationAction action)
protected boolean isValidLocation(net.minecraft.world.World world,
ILocation location)
protected boolean isAir(net.minecraft.world.World world,
ILocation location)
protected ILocation navigateToBorder(net.minecraft.world.World world, ILocation startLocation, int dimension, int direction)
world - The world to look in.startLocation - The location to start looking from.dimension - The dimension to navigate in.direction - the distance to go by.protected ILocation navigateToBorder(net.minecraft.world.World world, ILocation startLocation, int dimension, boolean max)
world - The world to look in.startLocation - The location to start looking from.dimension - The dimension to navigate in.max - If the direction to look in for the given dimension should be positive
otherwise negative.protected ILocation navigateToCorner(net.minecraft.world.World world, ILocation startLocation, int[] dimensions, boolean max)
world - The world to look in.startLocation - The location to start looking from.dimensions - The dimension to navigate in.max - If the maximum distance from the startLocation should be looked for.protected boolean isEdge(net.minecraft.world.World world,
int[][] dimensionEgdes,
ILocation location)
protected boolean validateLocationInStructure(net.minecraft.world.World world,
int[][] dimensionEgdes,
ILocation location,
CubeDetector.IValidationAction action)
world - The world.dimensionEgdes - The edges per dimension. [dimension][start=0 | stop=1]location - The location to check.action - The action to execute when a location has been validated.protected boolean coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
CubeDetector.ILocationAction locationAction)
CubeDetector.ILocationAction for all the possible locations within this structure.world - The world.dimensionEgdes - The edges per dimension. [dimension][start=0 | stop=1]locationAction - The runnable that will be called for each location in the structure.protected boolean coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
int[] accumulatedCoordinates,
CubeDetector.ILocationAction locationAction)
CubeDetector.ILocationAction for all the possible locations within this structure.
When the accumulatedCoordinates size equals the desired amount of dimensions,
this recursion will enter a leaf and check the conditions for that location.world - The world.dimensionEgdes - The edges per dimension. [dimension][start=0 | stop=1]accumulatedCoordinates - The accumulated coordinates up until now.locationAction - The runnable that will be called for each location in the structure.protected boolean validateAllowedBlockConditions(net.minecraft.world.World world,
ILocation location)
AllowedBlock
conditions.world - The world.location - The location.protected boolean validateDimensionEdges(net.minecraft.world.World world,
int[][] dimensionEgdes,
boolean valid,
CubeDetector.IValidationAction action)
world - The world.dimensionEgdes - The edges per dimension. [dimension][start=0 | stop=1]valid - True if the structure should be validated, false if it should be invalidated.action - The action to execute when a location has been validated.protected void postValidate(net.minecraft.world.World world,
Size size,
int[][] dimensionEgdes,
boolean valid,
ILocation originCorner)
public Size detect(net.minecraft.world.World world, ILocation startLocation, boolean valid, boolean changeState)
world - The world to look in.startLocation - The starting location.valid - True if the structure should be validated, false if it should be invalidated.changeState - If the post-validate actions should be called, and thus potentially change the world block
states.public Size detect(net.minecraft.world.World world, ILocation startLocation, boolean valid, CubeDetector.IValidationAction action, boolean changeState)
world - The world to look in.startLocation - The starting location.valid - True if the structure should be validated, false if it should be invalidated.action - The action to execute when a location has been validated.changeState - If the post-validate actions should be called, and thus potentially change the world block
states.