mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-23 08:13:48 -07:00
API patches
This commit is contained in:
79
patches/unapplied/server/Fix-Spigot-growth-modifiers.patch
Normal file
79
patches/unapplied/server/Fix-Spigot-growth-modifiers.patch
Normal file
@@ -0,0 +1,79 @@
|
||||
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
|
||||
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>
|
||||
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CaveVinesBlock.java
|
||||
@@ -0,0 +0,0 @@ public class CaveVinesBlock extends GrowingPlantHeadBlock implements Bonemealabl
|
||||
|
||||
@Override
|
||||
protected BlockState getGrowIntoState(BlockState state, RandomSource random) {
|
||||
- return (BlockState) super.getGrowIntoState(state, random).setValue(CaveVinesBlock.BERRIES, 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/GrowingPlantHeadBlock.java b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
|
||||
@@ -0,0 +0,0 @@ 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/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -0,0 +0,0 @@ public class SpigotWorldConfig
|
||||
public int twistingVinesModifier;
|
||||
public int weepingVinesModifier;
|
||||
public int caveVinesModifier;
|
||||
+ public int glowBerryModifier; // Paper
|
||||
private int getAndValidateGrowth(String crop)
|
||||
{
|
||||
int modifier = this.getInt( "growth." + crop.toLowerCase(java.util.Locale.ENGLISH) + "-modifier", 100 );
|
||||
@@ -0,0 +0,0 @@ public class SpigotWorldConfig
|
||||
this.twistingVinesModifier = this.getAndValidateGrowth( "TwistingVines" );
|
||||
this.weepingVinesModifier = this.getAndValidateGrowth( "WeepingVines" );
|
||||
this.caveVinesModifier = this.getAndValidateGrowth( "CaveVines" );
|
||||
+ this.glowBerryModifier = this.getAndValidateGrowth("GlowBerry"); // Paper
|
||||
}
|
||||
|
||||
public double itemMerge;
|
Reference in New Issue
Block a user