From 62b99be11764ef4c830ae5c9cd0e6398372e5701 Mon Sep 17 00:00:00 2001 From: sciwhiz12 Date: Mon, 10 Jan 2022 05:18:27 +0800 Subject: [PATCH] Fix custom climbable blocks not sending a death message (#8372) Fixes #8370 --- .../minecraft/world/entity/LivingEntity.java.patch | 6 ++++-- .../java/net/minecraftforge/common/ForgeHooks.java | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index bbe9465979..139e3ebb6c 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -227,7 +227,7 @@ p_147241_ *= 1.0D - this.m_21133_(Attributes.f_22278_); if (!(p_147241_ <= 0.0D)) { this.f_19812_ = true; -@@ -1388,15 +_,7 @@ +@@ -1388,15 +_,9 @@ } else { BlockPos blockpos = this.m_142538_(); BlockState blockstate = this.m_146900_(); @@ -240,7 +240,9 @@ - } else { - return false; - } -+ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, f_19853_, blockpos, this); ++ Optional ladderPos = net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, f_19853_, blockpos, this); ++ if (ladderPos.isPresent()) this.f_20957_ = ladderPos; ++ return ladderPos.isPresent(); } } diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 72d0f315fc..3800bb6a16 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; @@ -352,13 +353,13 @@ public class ForgeHooks return Math.max(0,event.getVisibilityModifier()); } - public static boolean isLivingOnLadder(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) + public static Optional isLivingOnLadder(@Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull LivingEntity entity) { - boolean isSpectator = (entity instanceof Player && ((Player)entity).isSpectator()); - if (isSpectator) return false; + boolean isSpectator = (entity instanceof Player && entity.isSpectator()); + if (isSpectator) return Optional.empty(); if (!ForgeConfig.SERVER.fullBoundingBoxLadders.get()) { - return state.isLadder(world, pos, entity); + return state.isLadder(world, pos, entity) ? Optional.of(pos) : Optional.empty(); } else { @@ -376,12 +377,12 @@ public class ForgeHooks state = world.getBlockState(tmp); if (state.isLadder(world, tmp, entity)) { - return true; + return Optional.of(tmp); } } } } - return false; + return Optional.empty(); } }