Block Ticking API

This commit is contained in:
Owen1212055 2021-12-26 13:23:46 -05:00
parent 1158ad3a6a
commit 63ca8a9302
2 changed files with 31 additions and 0 deletions

View file

@ -78,6 +78,12 @@ 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;
}
@ -709,5 +715,23 @@ public class CraftBlock implements Block {
public boolean isValidTool(ItemStack itemStack) {
return getDrops(itemStack).size() != 0;
}
@Override
public void tick() {
final ServerLevel level = this.world.getMinecraftWorld();
this.getNMS().tick(level, this.position, level.random);
}
@Override
public void fluidTick() {
this.getNMSFluid().tick(this.world.getMinecraftWorld(), this.position, this.getNMS());
}
@Override
public void randomTick() {
final ServerLevel level = this.world.getMinecraftWorld();
this.getNMS().randomTick(level, this.position, level.random);
}
// Paper end
}

View file

@ -761,4 +761,11 @@ public class CraftBlockData implements BlockData {
return speed;
}
// Paper end - destroy speed API
// Paper start - Block tick API
@Override
public boolean isRandomlyTicked() {
return this.state.isRandomlyTicking();
}
// Paper end - Block tick API
}