mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-05 06:32:17 -07:00
Add pitcher plant api (#9286)
This commit is contained in:
@@ -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
|
Subject: [PATCH] Fix Spigot growth modifiers
|
||||||
|
|
||||||
Fixes kelp modifier changing growth for other crops
|
Fixes kelp modifier changing growth for other crops
|
||||||
Also add growth modifiers for glow berries, mangrove propagules
|
Also add growth modifiers for glow berries, mangrove propagules,
|
||||||
and torchflower crops
|
torchflower crops and pitcher plant crops
|
||||||
Also fix above-mentioned modifiers from having the reverse effect
|
Also fix above-mentioned modifiers from having the reverse effect
|
||||||
|
|
||||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
@@ -87,6 +87,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
this.advanceTree(world, pos, state, random);
|
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
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||||
@@ -104,6 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
public int weepingVinesModifier;
|
public int weepingVinesModifier;
|
||||||
public int caveVinesModifier;
|
public int caveVinesModifier;
|
||||||
+ public int glowBerryModifier; // Paper
|
+ public int glowBerryModifier; // Paper
|
||||||
|
+ public int pitcherPlantModifier; // Paper
|
||||||
private int getAndValidateGrowth(String crop)
|
private int getAndValidateGrowth(String crop)
|
||||||
{
|
{
|
||||||
int modifier = this.getInt( "growth." + crop.toLowerCase(java.util.Locale.ENGLISH) + "-modifier", 100 );
|
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.weepingVinesModifier = this.getAndValidateGrowth( "WeepingVines" );
|
||||||
this.caveVinesModifier = this.getAndValidateGrowth( "CaveVines" );
|
this.caveVinesModifier = this.getAndValidateGrowth( "CaveVines" );
|
||||||
+ this.glowBerryModifier = this.getAndValidateGrowth("GlowBerry"); // Paper
|
+ this.glowBerryModifier = this.getAndValidateGrowth("GlowBerry"); // Paper
|
||||||
|
+ this.pitcherPlantModifier = this.getAndValidateGrowth("PitcherPlant"); // Paper
|
||||||
}
|
}
|
||||||
|
|
||||||
public double itemMerge;
|
public double itemMerge;
|
||||||
|
Reference in New Issue
Block a user