Paper/patches/server/0736-Fix-Spigot-growth-modifiers.patch
Nassim Jahnke c0936a71bd
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9440)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
01aa02eb PR-858: Add LivingEntity#playHurtAnimation()
9421320f PR-884: Refinements to new ban API for improved compatibility and correctness
37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API
4eeb174b All smithing inventories are now the new smithing inventory
f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop
e7a807fa PR-879: Add Player#sendHealthUpdate()
692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml
2d033390 SPIGOT-7403: Add direct API for waxed signs
16a08373 PR-876: Add missing Raider API and 'no action ticks'

CraftBukkit Changes:
b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation()
95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities
0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness
0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit
648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API
31fe848d6 All smithing inventories are now the new smithing inventory
9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table
9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop
3be9ac171 PR-1220: Add Player#sendHealthUpdate()
c1279f775 PR-1209: Clean up various patches
c432e4397 Fix Raider#setCelebrating() implementation
504d96665 SPIGOT-7403: Add direct API for waxed signs
c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks'
85b89c3dd Increase outdated build delay

Spigot Changes:
9ebce8af Rebuild patches
64b565e6 Rebuild patches
2023-07-04 10:22:56 +02:00

141 lines
8.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Fri, 3 Dec 2021 17:09:24 -0800
Subject: [PATCH] Fix Spigot growth modifiers
Fixes kelp modifier changing growth for other crops
Also add growth modifiers for glow berries, mangrove propagules,
torchflower crops and pitcher plant crops
Also fix above-mentioned modifiers from having the reverse effect
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
diff --git a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
index 55f2fa02a36f0500b47f9ce377926719557106e5..18b5bce1138d50be32e5da013221be69dc47e21f 100644
--- a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
@@ -47,9 +47,17 @@ public class CaveVinesBlock extends GrowingPlantHeadBlock implements Bonemealabl
@Override
protected BlockState getGrowIntoState(BlockState state, RandomSource random) {
- return super.getGrowIntoState(state, random).setValue(BERRIES, Boolean.valueOf(random.nextFloat() < 0.11F));
+ // Paper start
+ return this.getGrowIntoState(state, random, null);
}
+ @Override
+ protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) {
+ final boolean value = random.nextFloat() < (level != null ? (0.11F * (level.spigotConfig.glowBerryModifier / 100.0F)) : 0.11F);
+ return (BlockState) super.getGrowIntoState(state, random).setValue(CaveVinesBlock.BERRIES, value);
+ }
+ // Paper end
+
@Override
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {
return new ItemStack(Items.GLOW_BERRIES);
diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java
index 08d442713bf0cc4f01f693c9a2fbd1a17a6fa348..decb8caa67bc5f4525e4d92fedf465a17171fceb 100644
--- a/src/main/java/net/minecraft/world/level/block/CropBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CropBlock.java
@@ -84,6 +84,10 @@ public class CropBlock extends BushBlock implements BonemealableBlock {
modifier = world.spigotConfig.carrotModifier;
} else if (this == Blocks.POTATOES) {
modifier = world.spigotConfig.potatoModifier;
+ // Paper start
+ } else if (this == Blocks.TORCHFLOWER_CROP) {
+ modifier = world.spigotConfig.torchFlowerModifier;
+ // Paper end
} else {
modifier = world.spigotConfig.wheatModifier;
}
diff --git a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
index 53b91cf8092b46dbf45afea9ccf439d565d1914a..3a1aa4e2405090ccebefb7f5944f36462929e221 100644
--- a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
@@ -56,12 +56,18 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements
BlockPos blockposition1 = pos.relative(this.growthDirection);
if (this.canGrowInto(world.getBlockState(blockposition1))) {
- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, this.getGrowIntoState(state, world.random)); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, blockposition1, this.getGrowIntoState(state, world.random, world)); // CraftBukkit // Paper
}
}
}
+ // Paper start
+ protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) {
+ return this.getGrowIntoState(state, random);
+ }
+ // Paper end
+
protected BlockState getGrowIntoState(BlockState state, RandomSource random) {
return (BlockState) state.cycle(GrowingPlantHeadBlock.AGE);
}
diff --git a/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java b/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java
index 5d78348fc18b22ccb7ad109890f867e20efec047..44c78f0d56c3459c063c104e401a521e3df7d8e5 100644
--- a/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/MangrovePropaguleBlock.java
@@ -89,7 +89,7 @@ public class MangrovePropaguleBlock extends SaplingBlock implements SimpleWaterl
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (!isHanging(state)) {
- if (random.nextInt(7) == 0) {
+ if (random.nextFloat() < (world.spigotConfig.saplingModifier / (100.0F * 7))) { // Paper
this.advanceTree(world, pos, state, random);
}
diff --git a/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java b/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
index 593eae04ecf6dee86c9c3664ddcdc3f86d042e66..849c0ae6ca30691134f51e5d4d5da372e0e728bd 100644
--- a/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
@@ -116,7 +116,7 @@ public class PitcherCropBlock extends DoublePlantBlock implements BonemealableBl
@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
float f = CropBlock.getGrowthSpeed(this, world, pos);
- boolean bl = random.nextInt((int)(25.0F / f) + 1) == 0;
+ boolean bl = random.nextFloat() < (world.spigotConfig.pitcherPlantModifier / (100.0F * (Math.floor(25.0F / f) + 1))); // Paper
if (bl) {
this.grow(world, state, pos, 1);
}
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index b7d6197cb5f46bb020fff049ae2dd8fc3ee8ff2f..38da4cc3fe3be86e43432de942a1290fa8215474 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -96,6 +96,7 @@ public class SpigotWorldConfig
public int beetrootModifier;
public int carrotModifier;
public int potatoModifier;
+ public int torchFlowerModifier; // Paper
public int wheatModifier;
public int wartModifier;
public int vineModifier;
@@ -106,6 +107,8 @@ public class SpigotWorldConfig
public int twistingVinesModifier;
public int weepingVinesModifier;
public int caveVinesModifier;
+ public int glowBerryModifier; // Paper
+ public int pitcherPlantModifier; // Paper
private int getAndValidateGrowth(String crop)
{
int modifier = this.getInt( "growth." + crop.toLowerCase(java.util.Locale.ENGLISH) + "-modifier", 100 );
@@ -129,6 +132,7 @@ public class SpigotWorldConfig
this.beetrootModifier = this.getAndValidateGrowth( "Beetroot" );
this.carrotModifier = this.getAndValidateGrowth( "Carrot" );
this.potatoModifier = this.getAndValidateGrowth( "Potato" );
+ this.torchFlowerModifier = this.getAndValidateGrowth("TorchFlower"); // Paper
this.wheatModifier = this.getAndValidateGrowth( "Wheat" );
this.wartModifier = this.getAndValidateGrowth( "NetherWart" );
this.vineModifier = this.getAndValidateGrowth( "Vine" );
@@ -139,6 +143,8 @@ public class SpigotWorldConfig
this.twistingVinesModifier = this.getAndValidateGrowth( "TwistingVines" );
this.weepingVinesModifier = this.getAndValidateGrowth( "WeepingVines" );
this.caveVinesModifier = this.getAndValidateGrowth( "CaveVines" );
+ this.glowBerryModifier = this.getAndValidateGrowth("GlowBerry"); // Paper
+ this.pitcherPlantModifier = this.getAndValidateGrowth("PitcherPlant"); // Paper
}
public double itemMerge;