Skip to content

Commit

Permalink
fix(1.21.1): Backport cherry-pick
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 30, 2024
1 parent 7932723 commit 3499dbb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.hardcorerevival.api.PlayerAboutToKnockOutEvent;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.Items;

public class InventoryTotemAddon {
public InventoryTotemAddon() {
Expand All @@ -11,8 +11,7 @@ public InventoryTotemAddon() {
final var inventory = player.getInventory();
for (int i = 0; i < inventory.getContainerSize(); i++) {
final var itemStack = inventory.getItem(i);
final var deathProtection = itemStack.get(DataComponents.DEATH_PROTECTION);
if (deathProtection != null) {
if (itemStack.is(Items.TOTEM_OF_UNDYING)) {
event.setCanceled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.blay09.mods.hardcorerevival.capability.HardcoreRevivalData;
import net.blay09.mods.hardcorerevival.config.HardcoreRevivalConfig;
import net.blay09.mods.hardcorerevival.HardcoreRevivalManager;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.Registries;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tags.DamageTypeTags;
Expand All @@ -18,6 +17,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.item.Items;


public class KnockoutHandler {
Expand Down Expand Up @@ -60,8 +60,7 @@ public static void onPlayerDamage(LivingDamageEvent event) {
private static boolean holdsDeathProtectionItem(ServerPlayer player) {
for (final var hand : InteractionHand.values()) {
final var itemStack = player.getItemInHand(hand);
final var deathProtection = itemStack.get(DataComponents.DEATH_PROTECTION);
if (deathProtection != null) {
if (itemStack.is(Items.TOTEM_OF_UNDYING)) {
return true;
}
}
Expand Down

0 comments on commit 3499dbb

Please sign in to comment.