Skip to content

Commit 79338fd

Browse files
authored
Merge pull request #438 from sj-hub9796/fix-quality-food-compat
2 parents 1a4152f + 1ea71cb commit 79338fd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

patches/minecraft/net/minecraft/world/level/block/SugarCaneBlock.java.patch

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public static final IntegerProperty AGE = BlockStateProperties.AGE_15;
1010
protected static final float AABB_OFFSET = 6.0F;
1111
protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 16.0D, 14.0D);
12-
@@ -47,11 +_,15 @@
12+
@@ -47,11 +_,17 @@
1313

1414
if (i < 3) {
1515
int j = p_222548_.getValue(AGE);
@@ -21,8 +21,10 @@
2121
+ if (net.minecraftforge.common.ForgeHooks.onCropsGrowPre(p_222549_, p_222550_, p_222548_, true)) {
2222
+ int modifier = p_222549_.spigotConfig.caneModifier; // Spigot - SPIGOT-7159: Better modifier resolution
2323
+ if (j >= 15 || (modifier != 100 && p_222551_.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution
24+
+ org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.handleBlockGrowUpdate.set(false); // Ketting - mixin compat
2425
+ org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.handleBlockGrowEvent(p_222549_, p_222550_.above(), this.defaultBlockState()); // CraftBukkit
2526
+ net.minecraftforge.common.ForgeHooks.onCropsGrowPost(p_222549_, p_222550_.above(), this.defaultBlockState());
27+
+ p_222549_.setBlockAndUpdate(p_222550_.above(), this.defaultBlockState()); // Ketting - mixin compat
2628
+ p_222549_.setBlock(p_222550_, p_222548_.setValue(AGE, Integer.valueOf(0)), 4);
2729
+ } else {
2830
+ p_222549_.setBlock(p_222550_, p_222548_.setValue(AGE, Integer.valueOf(j + 1)), 4);

src/main/java/org/bukkit/craftbukkit/v1_20_R1/event/CraftEventFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecr
12101210
return handleBlockGrowEvent(world, pos, block, 3);
12111211
}
12121212

1213+
public static AtomicBoolean handleBlockGrowUpdate = new AtomicBoolean(true); // Ketting
12131214
public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState newData, int flag) {
12141215
Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
12151216
CraftBlockState state = (CraftBlockState) block.getState();
@@ -1219,7 +1220,11 @@ public static boolean handleBlockGrowEvent(Level world, BlockPos pos, net.minecr
12191220
Bukkit.getPluginManager().callEvent(event);
12201221

12211222
if (!event.isCancelled()) {
1222-
state.update(true);
1223+
// ketting start - Possibility to move the handle to the vanilla method
1224+
if (handleBlockGrowUpdate.getAndSet(true)) {
1225+
state.update(true);
1226+
}
1227+
// Ketting end
12231228
}
12241229

12251230
return !event.isCancelled();

0 commit comments

Comments
 (0)