Skip to content

Commit

Permalink
feat: Add support for Inventory Totem #123
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 30, 2024
1 parent ab401e6 commit ae4b610
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static void initialize() {
RescueHandler.initialize();

Balm.initializeIfLoaded(Compat.MR_CRAYFISHS_GUN_MOD, "net.blay09.mods.hardcorerevival.compat.MrCrayfishsGunModAddon");
Balm.initializeIfLoaded(Compat.INVENTORY_TOTEM, "new.blay09.mods.hardcorerevival.compat.InventoryTotemAddon");
}

public static HardcoreRevivalManager getManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

public class Compat {
public static final String MR_CRAYFISHS_GUN_MOD = "cgm";
public static final String INVENTORY_TOTEM = "inventorytotem";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.blay09.mods.hardcorerevival.compat;

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

public class InventoryTotemAddon {
public InventoryTotemAddon() {
Balm.getEvents().onEvent(PlayerAboutToKnockOutEvent.class, event -> {
final var player = event.getPlayer();
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) {
event.setCanceled(true);
}
}
});
}
}

0 comments on commit ae4b610

Please sign in to comment.