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:
Aikar 2016-04-03 16:28:17 -04:00
parent e2263633d4
commit eb76e508f5
2 changed files with 10 additions and 3 deletions

View file

@ -11,7 +11,12 @@
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 (i > 0) {

View file

@ -1,8 +1,10 @@
--- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
+++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
@@ -44,6 +44,11 @@
@@ -43,7 +43,13 @@
@Override
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)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.DIRT.defaultBlockState()).isCancelled()) {
@ -12,7 +14,7 @@
world.setBlockAndUpdate(pos, Blocks.DIRT.defaultBlockState());
} else {
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);
if (world.getBlockState(blockposition1).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(iblockdata1, world, blockposition1)) {