Fix issue with shields not disabling correctly (#10320)

This commit is contained in:
Jonathing authored and GitHub committed 2025-01-27 19:12:47 -08:00
1 parent bb98165ee8
commit dbd7da6885
4 files changed
+100 -2

No files matched your search

@@ -9,6 +9,8 @@ import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Supplier;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import org.jetbrains.annotations.Nullable;
import com.mojang.authlib.GameProfile;
@@ -59,6 +61,26 @@ public interface IForgeGameTestHelper {
throw new GameTestAssertException(message.get());
}
// Backported from 1.20.6
default Player makeMockPlayer(final GameType p_333981_) {
return new Player(this.self().getLevel(), BlockPos.ZERO, 0.0F, new GameProfile(UUID.randomUUID(), "test-mock-player")) {
@Override
public boolean isSpectator() {
return p_333981_ == GameType.SPECTATOR;
}
@Override
public boolean isCreative() {
return p_333981_.isCreative();
}
@Override
public boolean isLocalPlayer() {
return true;
}
};
}
default ServerPlayer makeMockServerPlayer() {
var level = self().getLevel();
var cookie = CommonListenerCookie.createInitial(new GameProfile(UUID.randomUUID(), "test-mock-player"));
@@ -644,7 +644,7 @@ public interface IForgeItem {
* @return True if this ItemStack can disable the shield in question.
*/
default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) {
return this instanceof AxeItem;
return attacker.canDisableShield();
}
/**