From 4278a7283c8057a5d1c65f36f0675f7784a44ae0 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Sat, 16 Jul 2022 19:12:27 +0200 Subject: [PATCH] Implement custom protection items --- .../com/buuz135/hotornot/config/HotConfig.java | 6 +++++- .../com/buuz135/hotornot/server/ServerTick.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/buuz135/hotornot/config/HotConfig.java b/src/main/java/com/buuz135/hotornot/config/HotConfig.java index 589024b..4e2e111 100644 --- a/src/main/java/com/buuz135/hotornot/config/HotConfig.java +++ b/src/main/java/com/buuz135/hotornot/config/HotConfig.java @@ -92,12 +92,16 @@ public class HotConfig @Config.Name("Custom gaseous items") @Config.Comment("Gaseous items that are included manually") - public static String[] CUSTOM_GASEOUS_ITEMS = new String[] {"mod_id:item"}; + public static String[] CUSTOM_GASEOUS_ITEMS = new String[] {}; @Config.Name("Excluded items") @Config.Comment("Items that are exempt from effects") public static String[] CUSTOM_REMOVALS = new String[] {"immersiveengineering:drill", "immersiveengineering:chemthrower", "immersivepetroleum:fluid_diesel", "immersivepetroleum:fluid_gasoline"}; + @Config.Name("Custom protection items") + @Config.Comment("Additional items that protect the player from effects") + public static String[] CUSTOM_PROTECTION_ITEM = new String[] {}; + @SuppressWarnings("unused") @Mod.EventBusSubscriber(modid = HotOrNot.MOD_ID) private static class EventHandler diff --git a/src/main/java/com/buuz135/hotornot/server/ServerTick.java b/src/main/java/com/buuz135/hotornot/server/ServerTick.java index 4931c1b..09a6b82 100644 --- a/src/main/java/com/buuz135/hotornot/server/ServerTick.java +++ b/src/main/java/com/buuz135/hotornot/server/ServerTick.java @@ -135,7 +135,19 @@ else if (offHand.getItem().equals(ModItems.IRON_TONGS)) } return true; } - return false; + else + { + String regName = offHand.getItem().getRegistryName().toString(); + for (String s : HotConfig.CUSTOM_PROTECTION_ITEM) + { + if (regName.equals(s)) + { + offHand.damageItem(HotConfig.ITEM_DAMAGE, player); + return true; + } + } + return false; + } } public static void applyHotEffect(EntityPlayer player, int index)