From eb76e508f5884bab6b6fb38c124a7c845e67a4f5 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 3 Apr 2016 16:28:17 -0400 Subject: [PATCH] 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 --- .../net/minecraft/world/level/block/FarmBlock.java.patch | 7 ++++++- .../world/level/block/SpreadingSnowyDirtBlock.java.patch | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch index b802c6ae1f..5f2869ec20 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch @@ -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) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch index 8e0f4e799f..5777f59736 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch @@ -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)) {