geforkt von Mirrors/Paper
Add API for ticking fluids (#10435)
* Add API for ticking fluids * update javadocs
Dieser Commit ist enthalten in:
Ursprung
07e8f74355
Commit
bdfe4c21f6
@ -17,14 +17,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+ * Causes the block to be ticked, this is different from {@link Block#randomTick()},
|
+ * Causes the block to be ticked, this is different from {@link Block#randomTick()},
|
||||||
+ * in that it is usually scheduled to occur, for example
|
+ * in that it is usually scheduled to occur, for example
|
||||||
+ * redstone components being activated, sand falling, etc.
|
+ * redstone components being activated, sand falling, etc.
|
||||||
|
+ * <p>
|
||||||
|
+ * This method may directly fire events relating to block ticking.
|
||||||
|
+ *
|
||||||
|
+ * @see #fluidTick()
|
||||||
+ */
|
+ */
|
||||||
+ void tick();
|
+ void tick();
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
|
+ * Causes the fluid to be ticked, this is different from {@link Block#randomTick()},
|
||||||
|
+ * in that it is usually scheduled to occur, for example
|
||||||
|
+ * causing waterlogged blocks to spread.
|
||||||
|
+ * <p>
|
||||||
|
+ * This method may directly fire events relating to fluid ticking.
|
||||||
|
+ *
|
||||||
|
+ * @see #tick()
|
||||||
|
+ */
|
||||||
|
+ void fluidTick();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
+ * Causes the block to be ticked randomly.
|
+ * Causes the block to be ticked randomly.
|
||||||
+ * This has a chance to execute naturally if {@link BlockData#isRandomlyTicked()} is true.
|
+ * This has a chance to execute naturally if {@link BlockData#isRandomlyTicked()} is true.
|
||||||
+ * <p>
|
+ * <p>
|
||||||
+ * For certain blocks, this behavior may be the same as {@link Block#tick()}.
|
+ * For certain blocks, this behavior may be the same as {@link Block#tick()}.
|
||||||
|
+ * <p>
|
||||||
|
+ * This method may directly fire events relating to block random ticking.
|
||||||
|
+ *
|
||||||
|
+ * @see #tick()
|
||||||
|
+ * @see #fluidTick()
|
||||||
+ */
|
+ */
|
||||||
+ void randomTick();
|
+ void randomTick();
|
||||||
// Paper end
|
// Paper end
|
||||||
|
@ -8,6 +8,19 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/ma
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftBlock implements Block {
|
||||||
|
return this.world.getBlockState(this.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ public net.minecraft.world.level.material.FluidState getNMSFluid() {
|
||||||
|
+ return this.world.getFluidState(this.position);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
public BlockPos getPosition() {
|
||||||
|
return this.position;
|
||||||
|
}
|
||||||
@@ -0,0 +0,0 @@ public class CraftBlock implements Block {
|
@@ -0,0 +0,0 @@ public class CraftBlock implements Block {
|
||||||
public boolean isValidTool(ItemStack itemStack) {
|
public boolean isValidTool(ItemStack itemStack) {
|
||||||
return getDrops(itemStack).size() != 0;
|
return getDrops(itemStack).size() != 0;
|
||||||
@ -15,18 +28,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void tick() {
|
+ public void tick() {
|
||||||
+ net.minecraft.world.level.block.state.BlockState blockData = this.getNMS();
|
+ final ServerLevel level = this.world.getMinecraftWorld();
|
||||||
+ net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld();
|
+ this.getNMS().tick(level, this.position, level.random);
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ blockData.getBlock().tick(blockData, level, this.position, level.random);
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void fluidTick() {
|
||||||
|
+ this.getNMSFluid().tick(this.world.getMinecraftWorld(), this.position);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void randomTick() {
|
+ public void randomTick() {
|
||||||
+ net.minecraft.world.level.block.state.BlockState blockData = this.getNMS();
|
+ final ServerLevel level = this.world.getMinecraftWorld();
|
||||||
+ net.minecraft.server.level.ServerLevel level = this.world.getMinecraftWorld();
|
+ this.getNMS().randomTick(level, this.position, level.random);
|
||||||
+
|
|
||||||
+ blockData.getBlock().randomTick(blockData, level, this.position, level.random);
|
|
||||||
+ }
|
+ }
|
||||||
// Paper end
|
// Paper end
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren