public class CubeDetector
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
CubeDetector.BlockPosAction |
static interface |
CubeDetector.IDetectionListener
Listener for detections.
|
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 int |
compareVec3i(net.minecraft.util.Vec3i vec1,
net.minecraft.util.Vec3i vec2) |
protected boolean |
coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
CubeDetector.BlockPosAction locationAction)
Run the
CubeDetector.BlockPosAction for all the possible locations within this structure. |
protected boolean |
coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
int[] accumulatedCoordinates,
CubeDetector.BlockPosAction locationAction)
Run the
CubeDetector.BlockPosAction for all the possible locations within this structure. |
net.minecraft.util.Vec3i |
detect(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
net.minecraft.util.BlockPos excludeLocation,
boolean changeState)
Detect a structure at the given start location.
|
net.minecraft.util.Vec3i |
detect(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
net.minecraft.util.BlockPos excludeLocation,
CubeDetector.IValidationAction action,
boolean changeState)
Detect a structure at the given start location.
|
java.util.Collection<AllowedBlock> |
getAllowedBlocks() |
net.minecraft.util.Vec3i |
getExactSize() |
java.util.List<? extends CubeDetector.IDetectionListener> |
getListeners() |
net.minecraft.util.Vec3i |
getMinimumSize() |
protected boolean |
isAir(net.minecraft.world.World world,
net.minecraft.util.BlockPos location) |
protected boolean |
isEdge(net.minecraft.world.World world,
int[][] dimensionEgdes,
net.minecraft.util.BlockPos location) |
protected boolean |
isValidLocation(net.minecraft.world.World world,
net.minecraft.util.BlockPos location,
net.minecraft.util.BlockPos excludeLocation) |
protected boolean |
isValidLocation(net.minecraft.world.World world,
net.minecraft.util.BlockPos location,
CubeDetector.IValidationAction action,
net.minecraft.util.BlockPos excludeLocation) |
protected net.minecraft.util.BlockPos |
navigateToBorder(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
int dimension,
boolean max,
net.minecraft.util.BlockPos excludeLocation)
Find the border of valid/non-valid locations in one given dimension (both directions).
|
protected net.minecraft.util.BlockPos |
navigateToBorder(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
int dimension,
int direction,
net.minecraft.util.BlockPos excludeLocation)
Find the border of valid/non-valid locations in one given dimension for just one direction.
|
protected net.minecraft.util.BlockPos |
navigateToCorner(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
int[] dimensions,
boolean max,
net.minecraft.util.BlockPos excludeLocation)
Navigate to a corner from a given startlocation for the given dimensions.
|
protected void |
notifyListeners(net.minecraft.world.World world,
net.minecraft.util.BlockPos location,
net.minecraft.util.Vec3i size,
boolean valid,
net.minecraft.util.BlockPos originCorner) |
protected void |
postValidate(net.minecraft.world.World world,
net.minecraft.util.Vec3i size,
int[][] dimensionEgdes,
boolean valid,
net.minecraft.util.BlockPos originCorner,
net.minecraft.util.BlockPos excludeLocation) |
CubeDetector |
setExactSize(net.minecraft.util.Vec3i 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(net.minecraft.util.Vec3i minimumSize)
The size is the inner size -1 on each dimension, so 2x2x2 is one blockState in the middle open,
with edge blocks on the side forming a 3x3x3.
|
protected boolean |
validateAllowedBlockConditions(net.minecraft.world.World world,
net.minecraft.util.BlockPos location)
Validate if the blockState at the given location conforms with the
AllowedBlock
conditions. |
protected boolean |
validateDimensionEdges(net.minecraft.world.World world,
int[][] dimensionEgdes,
boolean valid,
CubeDetector.IValidationAction action,
net.minecraft.util.BlockPos excludeLocation)
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,
net.minecraft.util.BlockPos location,
CubeDetector.IValidationAction action,
net.minecraft.util.BlockPos excludeLocation)
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 net.minecraft.util.Vec3i getMinimumSize()
public CubeDetector setMinimumSize(net.minecraft.util.Vec3i minimumSize)
minimumSize - the minimumSize to setpublic net.minecraft.util.Vec3i getExactSize()
public CubeDetector setExactSize(net.minecraft.util.Vec3i exactSize)
exactSize - the exactSize to setpublic java.util.List<? extends CubeDetector.IDetectionListener> getListeners()
protected void notifyListeners(net.minecraft.world.World world,
net.minecraft.util.BlockPos location,
net.minecraft.util.Vec3i size,
boolean valid,
net.minecraft.util.BlockPos originCorner)
protected boolean isValidLocation(net.minecraft.world.World world,
net.minecraft.util.BlockPos location,
CubeDetector.IValidationAction action,
net.minecraft.util.BlockPos excludeLocation)
protected boolean isValidLocation(net.minecraft.world.World world,
net.minecraft.util.BlockPos location,
net.minecraft.util.BlockPos excludeLocation)
protected boolean isAir(net.minecraft.world.World world,
net.minecraft.util.BlockPos location)
protected net.minecraft.util.BlockPos navigateToBorder(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
int dimension,
int direction,
net.minecraft.util.BlockPos excludeLocation)
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.excludeLocation - The location of the block that is being removed, used for invalidating, null for validating.protected net.minecraft.util.BlockPos navigateToBorder(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
int dimension,
boolean max,
net.minecraft.util.BlockPos excludeLocation)
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 positiveexcludeLocation - The location of the block that is being removed, used for invalidating, null for validating.
otherwise negative.protected net.minecraft.util.BlockPos navigateToCorner(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
int[] dimensions,
boolean max,
net.minecraft.util.BlockPos excludeLocation)
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.excludeLocation - The location of the block that is being removed, used for invalidating, null for validating.protected boolean isEdge(net.minecraft.world.World world,
int[][] dimensionEgdes,
net.minecraft.util.BlockPos location)
protected boolean validateLocationInStructure(net.minecraft.world.World world,
int[][] dimensionEgdes,
net.minecraft.util.BlockPos location,
CubeDetector.IValidationAction action,
net.minecraft.util.BlockPos excludeLocation)
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.excludeLocation - The location of the block that is being removed, used for invalidating, null for validating.protected boolean coordinateRecursion(net.minecraft.world.World world,
int[][] dimensionEgdes,
CubeDetector.BlockPosAction locationAction)
CubeDetector.BlockPosAction 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.BlockPosAction locationAction)
CubeDetector.BlockPosAction 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,
net.minecraft.util.BlockPos location)
AllowedBlock
conditions.world - The world.location - The location.protected boolean validateDimensionEdges(net.minecraft.world.World world,
int[][] dimensionEgdes,
boolean valid,
CubeDetector.IValidationAction action,
net.minecraft.util.BlockPos excludeLocation)
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.excludeLocation - The location of the block that is being removed, used for invalidating, null for validating.protected void postValidate(net.minecraft.world.World world,
net.minecraft.util.Vec3i size,
int[][] dimensionEgdes,
boolean valid,
net.minecraft.util.BlockPos originCorner,
net.minecraft.util.BlockPos excludeLocation)
public net.minecraft.util.Vec3i detect(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
net.minecraft.util.BlockPos excludeLocation,
boolean changeState)
world - The world to look in.startLocation - The starting location.excludeLocation - The location of the block that is being removed, used for invalidating, null for validating.changeState - If the post-validate actions should be called, and thus potentially change the world blockState
states.public net.minecraft.util.Vec3i detect(net.minecraft.world.World world,
net.minecraft.util.BlockPos startLocation,
net.minecraft.util.BlockPos excludeLocation,
CubeDetector.IValidationAction action,
boolean changeState)
world - The world to look in.startLocation - The starting location.excludeLocation - The location of the block that is being removed, used for invalidating, null for validating.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 blockState
states.protected int compareVec3i(net.minecraft.util.Vec3i vec1,
net.minecraft.util.Vec3i vec2)