mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Added CustomBlock#getDrag
This commit is contained in:
parent
51af720bd4
commit
1440aa8403
@ -413,7 +413,16 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
|
|||||||
|
|
||||||
float drag;
|
float drag;
|
||||||
if (onGround) {
|
if (onGround) {
|
||||||
drag = 0.5f; // ground drag
|
final BlockPosition blockPosition = position.toBlockPosition();
|
||||||
|
final CustomBlock customBlock =
|
||||||
|
instance.getCustomBlock(blockPosition);
|
||||||
|
if (customBlock != null) {
|
||||||
|
// Custom drag
|
||||||
|
drag = customBlock.getDrag(instance, blockPosition);
|
||||||
|
} else {
|
||||||
|
// Default ground drag
|
||||||
|
drag = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
// Stop player velocity
|
// Stop player velocity
|
||||||
if (PlayerUtils.isNettyClient(this)) {
|
if (PlayerUtils.isNettyClient(this)) {
|
||||||
|
@ -109,7 +109,7 @@ public abstract class CustomBlock {
|
|||||||
* Can be set to < 0 to be cancelled, in this case vanilla time will be used
|
* Can be set to < 0 to be cancelled, in this case vanilla time will be used
|
||||||
*
|
*
|
||||||
* @param player the player who is trying to break the block
|
* @param player the player who is trying to break the block
|
||||||
* @param position
|
* @param position the block position
|
||||||
* @return the time in ms to break it
|
* @return the time in ms to break it
|
||||||
*/
|
*/
|
||||||
public abstract int getBreakDelay(Player player, BlockPosition position);
|
public abstract int getBreakDelay(Player player, BlockPosition position);
|
||||||
@ -195,6 +195,17 @@ public abstract class CustomBlock {
|
|||||||
update(instance, position, blockData);
|
update(instance, position, blockData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the drag of this block
|
||||||
|
* <p>
|
||||||
|
* It has to be between 0 and 1
|
||||||
|
*
|
||||||
|
* @return the drag of this block
|
||||||
|
*/
|
||||||
|
public float getDrag(Instance instance, BlockPosition blockPosition) {
|
||||||
|
return 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows custom block to write block entity data to a given NBT compound.
|
* Allows custom block to write block entity data to a given NBT compound.
|
||||||
* Used to send block entity data to the client over the network.
|
* Used to send block entity data to the client over the network.
|
||||||
|
Loading…
Reference in New Issue
Block a user