Comments for BlockPlacementRule

This commit is contained in:
themode 2020-09-08 15:57:06 +02:00
parent 2f5af27211
commit 1525d81852
2 changed files with 32 additions and 7 deletions

View File

@ -16,7 +16,7 @@ public class BlockManager {
private BlockPlacementRule[] placementRules = new BlockPlacementRule[Short.MAX_VALUE];
/**
* Register a custom block
* Register a {@link CustomBlock}
*
* @param customBlock the custom block to register
* @throws IllegalArgumentException if {@param customBlock} block id is negative
@ -30,7 +30,7 @@ public class BlockManager {
}
/**
* Register a block placement rule
* Register a {@link BlockPlacementRule}
*
* @param blockPlacementRule the block placement rule to register
* @throws IllegalArgumentException if {@param blockPlacementRule} block id is negative
@ -42,7 +42,7 @@ public class BlockManager {
}
/**
* Get the block placement rule of the specific block
* Get the {@link BlockPlacementRule} of the specific block
*
* @param block the block to check
* @return the block placement rule associated with the block, null if not any
@ -52,7 +52,7 @@ public class BlockManager {
}
/**
* Get the block placement rule of the specific block
* Get the {@link BlockPlacementRule} of the specific block
*
* @param blockStateId the block id to check
* @return the block placement rule associated with the id, null if not any
@ -63,7 +63,7 @@ public class BlockManager {
}
/**
* Get the CustomBlock with the specific identifier {@link CustomBlock#getIdentifier()}
* Get the {@link CustomBlock} with the specific identifier {@link CustomBlock#getIdentifier()}
*
* @param identifier the custom block identifier
* @return the {@link CustomBlock} associated with the identifier, null if not any
@ -73,7 +73,7 @@ public class BlockManager {
}
/**
* Get the CustomBlock with the specific custom block id {@link CustomBlock#getCustomBlockId()}
* Get the {@link CustomBlock} with the specific custom block id {@link CustomBlock#getCustomBlockId()}
*
* @param id the custom block id
* @return the {@link CustomBlock} associated with the id, null if not any

View File

@ -18,10 +18,35 @@ public abstract class BlockPlacementRule {
this(block.getBlockId());
}
/**
* Get if the block can be placed in {@code blockPosition}
* Can for example, be used for blocks which have to be placed on a solid block
*
* @param instance the instance of the block
* @param blockPosition the position where the block is trying to get place
* @return true if the block placement position is valid
*/
public abstract boolean canPlace(Instance instance, BlockPosition blockPosition);
public abstract short blockRefresh(Instance instance, BlockPosition blockPosition, short currentID);
/**
* Called when the block state id can be updated (for instance if a neighbour block changed)
*
* @param instance the instance of the block
* @param blockPosition the block position
* @param currentStateID the current block state id of the block
* @return the updated block state id
*/
public abstract short blockRefresh(Instance instance, BlockPosition blockPosition, short currentStateID);
/**
* Called when the block is placed
*
* @param instance the instance of the block
* @param block the block placed
* @param blockFace the block face
* @param pl the player who placed the block
* @return the block state id of the placed block
*/
public abstract short blockPlace(Instance instance, Block block, BlockFace blockFace, Player pl);
public short getBlockId() {