mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Configurable random tick rates for blocks
A general purpose patch that includes config options for the tick rate of a variety of blocks that are random ticked. Co-authored-by: MrPowerGamerBR <git@mrpowergamerbr.com>
This commit is contained in:
parent
e2263633d4
commit
eb76e508f5
2 changed files with 10 additions and 3 deletions
|
@ -11,7 +11,12 @@
|
||||||
|
|
||||||
public class FarmBlock extends Block {
|
public class FarmBlock extends Block {
|
||||||
|
|
||||||
@@ -92,28 +96,51 @@
|
@@ -89,31 +93,56 @@
|
||||||
|
@Override
|
||||||
|
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||||
|
int i = (Integer) state.getValue(FarmBlock.MOISTURE);
|
||||||
|
+ if (i > 0 && world.paperConfig().tickRates.wetFarmland != 1 && (world.paperConfig().tickRates.wetFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.wetFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks
|
||||||
|
+ if (i == 0 && world.paperConfig().tickRates.dryFarmland != 1 && (world.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks
|
||||||
|
|
||||||
if (!FarmBlock.isNearWater(world, pos) && !world.isRainingAt(pos.above())) {
|
if (!FarmBlock.isNearWater(world, pos) && !world.isRainingAt(pos.above())) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
--- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
--- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
||||||
+++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
+++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
||||||
@@ -44,6 +44,11 @@
|
@@ -43,7 +43,13 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||||
|
+ if (this instanceof GrassBlock && world.paperConfig().tickRates.grassSpread != 1 && (world.paperConfig().tickRates.grassSpread < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.grassSpread != 0)) { return; } // Paper - Configurable random tick rates for blocks
|
||||||
if (!SpreadingSnowyDirtBlock.canBeGrass(state, world, pos)) {
|
if (!SpreadingSnowyDirtBlock.canBeGrass(state, world, pos)) {
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.DIRT.defaultBlockState()).isCancelled()) {
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.DIRT.defaultBlockState()).isCancelled()) {
|
||||||
|
@ -12,7 +14,7 @@
|
||||||
world.setBlockAndUpdate(pos, Blocks.DIRT.defaultBlockState());
|
world.setBlockAndUpdate(pos, Blocks.DIRT.defaultBlockState());
|
||||||
} else {
|
} else {
|
||||||
if (world.getMaxLocalRawBrightness(pos.above()) >= 9) {
|
if (world.getMaxLocalRawBrightness(pos.above()) >= 9) {
|
||||||
@@ -53,7 +58,7 @@
|
@@ -53,7 +59,7 @@
|
||||||
BlockPos blockposition1 = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
BlockPos blockposition1 = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
||||||
|
|
||||||
if (world.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(iblockdata1, world, blockposition1)) {
|
if (world.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(iblockdata1, world, blockposition1)) {
|
||||||
|
|
Loading…
Reference in a new issue