mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-03 21:37:28 +01:00
Add pitcher plant api (#9286)
This commit is contained in:
parent
3553730d51
commit
8405a53d88
2 changed files with 36 additions and 2 deletions
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
|
||||
Date: Fri, 9 Jun 2023 13:04:42 +0200
|
||||
Subject: [PATCH] Call BlockGrowEvent for the pitcher crop
|
||||
|
||||
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
|
||||
@@ -0,0 +0,0 @@ public class PitcherCropBlock extends DoublePlantBlock implements BonemealableBl
|
||||
private void grow(ServerLevel world, BlockState state, BlockPos pos, int amount) {
|
||||
int i = Math.min(state.getValue(AGE) + amount, 4);
|
||||
if (this.canGrow(world, pos, state, i)) {
|
||||
- world.setBlock(pos, state.setValue(AGE, Integer.valueOf(i)), 2);
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, pos, state.setValue(AGE, Integer.valueOf(i)), 2)) return; // Paper
|
||||
if (i >= 3) {
|
||||
BlockPos blockPos = pos.above();
|
||||
world.setBlock(blockPos, copyWaterloggedFrom(world, pos, this.defaultBlockState().setValue(AGE, Integer.valueOf(i)).setValue(HALF, DoubleBlockHalf.UPPER)), 3);
|
|
@ -4,8 +4,8 @@ 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
|
||||
and torchflower 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>
|
||||
|
@ -87,6 +87,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/PitcherCropBlock.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
|
@ -104,6 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
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 );
|
||||
|
@ -120,6 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue