From 76fb578c9a270d34147611b46ecb3bef845933ed Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Sun, 12 Sep 2021 13:40:21 +0200 Subject: [PATCH] Revamp item registry, change wooden tongs recipe --- CHANGELOG.md | 4 + gradle.properties | 2 +- .../java/com/buuz135/hotornot/HotOrNot.java | 335 +----------------- .../buuz135/hotornot/client/HotTooltip.java | 99 ++++++ .../buuz135/hotornot/config/HotConfig.java | 6 +- .../handler/ClientRegistryHandler.java | 29 ++ .../hotornot/handler/RegistryHandler.java | 19 + .../item/{MittsItem.java => HotItem.java} | 22 +- .../buuz135/hotornot/item/IronTongsItem.java | 41 --- .../com/buuz135/hotornot/item/ModItems.java | 17 + .../hotornot/item/WoodenTongsItem.java | 41 --- .../buuz135/hotornot/proxy/ClientProxy.java | 37 -- .../buuz135/hotornot/proxy/CommonProxy.java | 49 --- .../buuz135/hotornot/server/ServerTick.java | 212 +++++++++++ .../resources/assets/hotornot/lang/en_us.lang | 9 +- .../assets/hotornot/recipes/wooden_tongs.json | 5 +- 16 files changed, 408 insertions(+), 519 deletions(-) create mode 100644 src/main/java/com/buuz135/hotornot/client/HotTooltip.java create mode 100644 src/main/java/com/buuz135/hotornot/handler/ClientRegistryHandler.java create mode 100644 src/main/java/com/buuz135/hotornot/handler/RegistryHandler.java rename src/main/java/com/buuz135/hotornot/item/{MittsItem.java => HotItem.java} (63%) delete mode 100644 src/main/java/com/buuz135/hotornot/item/IronTongsItem.java create mode 100644 src/main/java/com/buuz135/hotornot/item/ModItems.java delete mode 100644 src/main/java/com/buuz135/hotornot/item/WoodenTongsItem.java delete mode 100644 src/main/java/com/buuz135/hotornot/proxy/ClientProxy.java delete mode 100644 src/main/java/com/buuz135/hotornot/proxy/CommonProxy.java create mode 100644 src/main/java/com/buuz135/hotornot/server/ServerTick.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f51cd..bb1ea2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Hot Or Not Unreleased ---------- +* Fix Wooden Tongs texture (ACGaming) + +1.1.6 (2021-07-02 16:10:41 +0200) +--------------------------------- * Tongs, TFC is optional (ACGaming) TFC-1.1.5 (2021-06-12 16:06:55 +0200) diff --git a/gradle.properties b/gradle.properties index 8f49aad..9b32a92 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ modGroup=com.buuz135 minecraftVersion=1.12.2 -modVersion=1.1.6 +modVersion=1.1.7 modBaseName=HotOrNotPlus forgeVersion=1.12.2-14.23.5.2847 mcpVersion=stable_39 \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/HotOrNot.java b/src/main/java/com/buuz135/hotornot/HotOrNot.java index a27bd64..432c7c9 100644 --- a/src/main/java/com/buuz135/hotornot/HotOrNot.java +++ b/src/main/java/com/buuz135/hotornot/HotOrNot.java @@ -21,42 +21,11 @@ */ package com.buuz135.hotornot; -import java.util.function.Consumer; -import java.util.function.Predicate; - import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.MobEffects; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import net.minecraftforge.fluids.capability.IFluidHandlerItem; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandler; - -import com.buuz135.hotornot.config.HotConfig; -import com.buuz135.hotornot.config.HotLists; -import com.buuz135.hotornot.proxy.CommonProxy; -import net.dries007.tfc.api.capability.heat.CapabilityItemHeat; -import net.dries007.tfc.api.capability.heat.IItemHeat; @Mod( modid = HotOrNot.MOD_ID, @@ -67,310 +36,16 @@ public class HotOrNot { public static final String MOD_ID = "hotornot"; - public static final String MOD_NAME = "HotOrNot+"; - public static final String VERSION = "1.1.6"; - + public static final String MOD_NAME = "Hot or Not +"; + public static final String VERSION = "1.1.7"; public static final CreativeTabs HOTORNOT_TAB = new HotOrNotTab(); - @SidedProxy(clientSide = "com.buuz135.hotornot.proxy.ClientProxy", serverSide = "com.buuz135.hotornot.proxy.CommonProxy") - public static CommonProxy proxy; - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) - { - proxy.preInit(event); - } + public void preInit(FMLPreInitializationEvent event) {} @Mod.EventHandler - public void init(FMLInitializationEvent event) - { - proxy.init(event); - } + public void init(FMLInitializationEvent event) {} @Mod.EventHandler - public void postInit(FMLPostInitializationEvent event) - { - proxy.postInit(event); - } - - public enum FluidEffect - { - HOT(fluidStack -> fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.HOT_FLUID + 273 && HotConfig.HOT_FLUIDS, entityPlayerMP -> entityPlayerMP.setFire(1), TextFormatting.RED, "tooltip.hotornot.toohot"), - COLD(fluidStack -> fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.COLD_FLUID + 273 && HotConfig.COLD_FLUIDS, entityPlayerMP -> - { - entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1)); - entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1)); - }, TextFormatting.AQUA, "tooltip.hotornot.toocold"), - GAS(fluidStack -> fluidStack.getFluid().isGaseous(fluidStack) && HotConfig.GASEOUS_FLUIDS, entityPlayerMP -> entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1)), TextFormatting.YELLOW, "tooltip.hotornot.toolight"); - - private final Predicate isValid; - private final Consumer interactPlayer; - private final TextFormatting color; - private final String tooltip; - - FluidEffect(Predicate isValid, Consumer interactPlayer, TextFormatting color, String tooltip) - { - this.isValid = isValid; - this.interactPlayer = interactPlayer; - this.color = color; - this.tooltip = tooltip; - } - } - - @Mod.EventBusSubscriber - public static class ObjectRegistryHandler - { - @SubscribeEvent - public static void addItems(RegistryEvent.Register event) - { - proxy.registerItems(event); - } - - @SubscribeEvent - @SideOnly(Side.CLIENT) - public static void modelRegistryEvent(ModelRegistryEvent event) - { - proxy.modelRegistryEvent(event); - } - } - - @Mod.EventBusSubscriber - public static class ServerTick - { - @SubscribeEvent - public static void onTick(TickEvent.WorldTickEvent event) - { - if (event.phase == TickEvent.Phase.START) - { - for (EntityPlayerMP entityPlayerMP : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) - { - if (!entityPlayerMP.isBurning() && !entityPlayerMP.isCreative() && entityPlayerMP.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) - { - IItemHandler handler = entityPlayerMP.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - for (int i = 0; i < handler.getSlots(); i++) - { - ItemStack stack = handler.getStackInSlot(i); - - // FLUIDS - if (!stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) && !HotLists.isRemoved(stack)) - { - IFluidHandlerItem fluidHandlerItem = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); - FluidStack fluidStack = fluidHandlerItem.drain(1000, false); - if (fluidStack != null) - { - for (FluidEffect effect : FluidEffect.values()) - { - if (effect.isValid.test(fluidStack)) - { - ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); - if (offHand.getItem().equals(CommonProxy.MITTS)) - { - if (HotConfig.MITTS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.WOODEN_TONGS)) - { - if (HotConfig.WOODEN_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.IRON_TONGS)) - { - if (HotConfig.IRON_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (event.world.getTotalWorldTime() % 20 == 0) - { - effect.interactPlayer.accept(entityPlayerMP); - if (HotConfig.YEET) - { - entityPlayerMP.dropItem(stack, false, true); - entityPlayerMP.inventory.deleteStack(stack); - } - } - } - } - } - } - - if (HotConfig.HOT_ITEMS && !stack.isEmpty() && !HotLists.isRemoved(stack)) - { - if (Loader.isModLoaded("tfc")) - { - // TFC ITEMS - if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null)) - { - IItemHeat heatHandlerItem = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); - if (heatHandlerItem.getTemperature() >= HotConfig.HOT_ITEM) - { - ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); - if (offHand.getItem().equals(CommonProxy.MITTS)) - { - if (HotConfig.MITTS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.WOODEN_TONGS)) - { - if (HotConfig.WOODEN_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.IRON_TONGS)) - { - if (HotConfig.IRON_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (event.world.getTotalWorldTime() % 10 == 0) - { - entityPlayerMP.setFire(1); - if (HotConfig.YEET) - { - entityPlayerMP.dropItem(stack, false, true); - entityPlayerMP.inventory.deleteStack(stack); - } - } - } - } - } - // MANUALLY ADDED ITEMS - else if (HotLists.isHot(stack)) - { - ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); - if (offHand.getItem().equals(CommonProxy.MITTS)) - { - if (HotConfig.MITTS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.WOODEN_TONGS)) - { - if (HotConfig.WOODEN_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.IRON_TONGS)) - { - if (HotConfig.IRON_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (event.world.getTotalWorldTime() % 10 == 0) - { - entityPlayerMP.setFire(1); - if (HotConfig.YEET) - { - entityPlayerMP.dropItem(stack, false, true); - entityPlayerMP.inventory.deleteStack(stack); - } - } - } - else if (HotLists.isCold(stack)) - { - ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); - if (offHand.getItem().equals(CommonProxy.MITTS)) - { - if (HotConfig.MITTS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.WOODEN_TONGS)) - { - if (HotConfig.WOODEN_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (offHand.getItem().equals(CommonProxy.IRON_TONGS)) - { - if (HotConfig.IRON_TONGS_DURABILITY != 0) - { - offHand.damageItem(1, entityPlayerMP); - } - } - else if (event.world.getTotalWorldTime() % 10 == 0) - { - entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1)); - entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1)); - } - } - else if (HotLists.isGaseous(stack)) - { - if (event.world.getTotalWorldTime() % 10 == 0) - { - entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1)); - } - } - - } - } - } - } - } - } - } - - @Mod.EventBusSubscriber(value = Side.CLIENT) - public static class HotTooltip - { - @SubscribeEvent - public static void onTooltip(ItemTooltipEvent event) - { - ItemStack stack = event.getItemStack(); - if (HotConfig.TOOLTIP && !stack.isEmpty() && !HotLists.isRemoved(stack)) - { - if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) - { - IFluidHandlerItem fluidHandlerItem = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); - FluidStack fluidStack = fluidHandlerItem.drain(1000, false); - if (fluidStack != null) - { - for (FluidEffect effect : FluidEffect.values()) - { - if (effect.isValid.test(fluidStack)) - { - event.getToolTip().add(effect.color + new TextComponentTranslation(effect.tooltip).getUnformattedText()); - } - } - } - } - else if (HotLists.isHot(stack)) - { - event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText()); - } - else if (HotLists.isCold(stack)) - { - event.getToolTip().add(FluidEffect.COLD.color + new TextComponentTranslation(FluidEffect.COLD.tooltip).getUnformattedText()); - } - else if (HotLists.isGaseous(stack)) - { - event.getToolTip().add(FluidEffect.GAS.color + new TextComponentTranslation(FluidEffect.GAS.tooltip).getUnformattedText()); - } - else if (Loader.isModLoaded("tfc")) - { - if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null)) - { - IItemHeat heat = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); - if (heat.getTemperature() >= HotConfig.HOT_ITEM) - { - event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText()); - } - } - } - } - } - } + public void postInit(FMLPostInitializationEvent event) {} } \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/client/HotTooltip.java b/src/main/java/com/buuz135/hotornot/client/HotTooltip.java new file mode 100644 index 0000000..3ed8311 --- /dev/null +++ b/src/main/java/com/buuz135/hotornot/client/HotTooltip.java @@ -0,0 +1,99 @@ +package com.buuz135.hotornot.client; + +import java.util.function.Consumer; +import java.util.function.Predicate; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.MobEffects; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandlerItem; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; + +import com.buuz135.hotornot.config.HotConfig; +import com.buuz135.hotornot.config.HotLists; +import net.dries007.tfc.api.capability.heat.CapabilityItemHeat; +import net.dries007.tfc.api.capability.heat.IItemHeat; + +@Mod.EventBusSubscriber(value = Side.CLIENT) +public class HotTooltip +{ + @SubscribeEvent + public static void onTooltip(ItemTooltipEvent event) + { + ItemStack stack = event.getItemStack(); + if (HotConfig.TOOLTIP && !stack.isEmpty() && !HotLists.isRemoved(stack)) + { + if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)) + { + IFluidHandlerItem fluidHandlerItem = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); + FluidStack fluidStack = fluidHandlerItem.drain(1000, false); + if (fluidStack != null) + { + for (FluidEffect effect : FluidEffect.values()) + { + if (effect.isValid.test(fluidStack)) + { + event.getToolTip().add(effect.color + new TextComponentTranslation(effect.tooltip).getUnformattedText()); + } + } + } + } + else if (HotLists.isHot(stack)) + { + event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText()); + } + else if (HotLists.isCold(stack)) + { + event.getToolTip().add(FluidEffect.COLD.color + new TextComponentTranslation(FluidEffect.COLD.tooltip).getUnformattedText()); + } + else if (HotLists.isGaseous(stack)) + { + event.getToolTip().add(FluidEffect.GAS.color + new TextComponentTranslation(FluidEffect.GAS.tooltip).getUnformattedText()); + } + else if (Loader.isModLoaded("tfc")) + { + if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null)) + { + IItemHeat heat = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); + if (heat.getTemperature() >= HotConfig.HOT_ITEM) + { + event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText()); + } + } + } + } + } + + public enum FluidEffect + { + HOT(fluidStack -> fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.HOT_FLUID + 273 && HotConfig.HOT_FLUIDS, entityPlayerMP -> entityPlayerMP.setFire(1), TextFormatting.RED, "tooltip.hotornot.toohot"), + COLD(fluidStack -> fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.COLD_FLUID + 273 && HotConfig.COLD_FLUIDS, entityPlayerMP -> + { + entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1)); + entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1)); + }, TextFormatting.AQUA, "tooltip.hotornot.toocold"), + GAS(fluidStack -> fluidStack.getFluid().isGaseous(fluidStack) && HotConfig.GASEOUS_FLUIDS, entityPlayerMP -> entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1)), TextFormatting.YELLOW, "tooltip.hotornot.toolight"); + + public final Predicate isValid; + public final Consumer interactPlayer; + public final TextFormatting color; + public final String tooltip; + + FluidEffect(Predicate isValid, Consumer interactPlayer, TextFormatting color, String tooltip) + { + this.isValid = isValid; + this.interactPlayer = interactPlayer; + this.color = color; + this.tooltip = tooltip; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/config/HotConfig.java b/src/main/java/com/buuz135/hotornot/config/HotConfig.java index 62b2c29..f2bac71 100644 --- a/src/main/java/com/buuz135/hotornot/config/HotConfig.java +++ b/src/main/java/com/buuz135/hotornot/config/HotConfig.java @@ -38,12 +38,15 @@ public class HotConfig @Config.Comment("How hot an item should be to start burning the player (in Celsius)") public static int HOT_ITEM = 480; + @Config.RequiresMcRestart() @Config.Comment("Max durability of the wooden tongs, 0 for infinite durability") public static int WOODEN_TONGS_DURABILITY = 1200; + @Config.RequiresMcRestart() @Config.Comment("Max durability of the mitts, 0 for infinite durability") public static int MITTS_DURABILITY = 12000; + @Config.RequiresMcRestart() @Config.Comment("Max durability of the tongs, 0 for infinite durability") public static int IRON_TONGS_DURABILITY = 0; @@ -59,11 +62,12 @@ public class HotConfig @Config.Comment("Items that are excluded") public static String[] ITEM_REMOVALS = new String[] {"immersiveengineering:drill", "immersiveengineering:chemthrower", "immersivepetroleum:fluid_diesel", "immersivepetroleum:fluid_gasoline"}; + @SuppressWarnings("unused") @Mod.EventBusSubscriber(modid = HotOrNot.MOD_ID) private static class EventHandler { @SubscribeEvent - public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event) + public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { if (event.getModID().equals(HotOrNot.MOD_ID)) { diff --git a/src/main/java/com/buuz135/hotornot/handler/ClientRegistryHandler.java b/src/main/java/com/buuz135/hotornot/handler/ClientRegistryHandler.java new file mode 100644 index 0000000..54a1f4d --- /dev/null +++ b/src/main/java/com/buuz135/hotornot/handler/ClientRegistryHandler.java @@ -0,0 +1,29 @@ +package com.buuz135.hotornot.handler; + +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.relauncher.Side; + +import com.buuz135.hotornot.HotOrNot; +import com.buuz135.hotornot.item.ModItems; + +@Mod.EventBusSubscriber(value = Side.CLIENT, modid = HotOrNot.MOD_ID) +public class ClientRegistryHandler +{ + @SubscribeEvent + public static void registerModels(ModelRegistryEvent event) + { + registerModel(ModItems.WOODEN_TONGS, 0); + registerModel(ModItems.MITTS, 0); + registerModel(ModItems.IRON_TONGS, 0); + } + + private static void registerModel(Item item, int meta) + { + ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory")); + } +} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/handler/RegistryHandler.java b/src/main/java/com/buuz135/hotornot/handler/RegistryHandler.java new file mode 100644 index 0000000..78fffa8 --- /dev/null +++ b/src/main/java/com/buuz135/hotornot/handler/RegistryHandler.java @@ -0,0 +1,19 @@ +package com.buuz135.hotornot.handler; + +import net.minecraft.item.Item; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import com.buuz135.hotornot.HotOrNot; +import com.buuz135.hotornot.item.ModItems; + +@Mod.EventBusSubscriber(modid = HotOrNot.MOD_ID) +public class RegistryHandler +{ + @SubscribeEvent + public static void registerItems(RegistryEvent.Register event) + { + event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0])); + } +} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/item/MittsItem.java b/src/main/java/com/buuz135/hotornot/item/HotItem.java similarity index 63% rename from src/main/java/com/buuz135/hotornot/item/MittsItem.java rename to src/main/java/com/buuz135/hotornot/item/HotItem.java index 3a63a54..203016f 100644 --- a/src/main/java/com/buuz135/hotornot/item/MittsItem.java +++ b/src/main/java/com/buuz135/hotornot/item/HotItem.java @@ -10,27 +10,29 @@ import net.minecraft.world.World; import com.buuz135.hotornot.HotOrNot; -import com.buuz135.hotornot.config.HotConfig; -public class MittsItem extends Item +public class HotItem extends Item { - public MittsItem() + public HotItem(String name, int durability) { - setRegistryName(HotOrNot.MOD_ID, "mitts"); - setTranslationKey(HotOrNot.MOD_ID + ".mitts"); - setMaxStackSize(1); - if (HotConfig.MITTS_DURABILITY != 0) + super(); + this.setRegistryName(HotOrNot.MOD_ID, name); + this.setTranslationKey(HotOrNot.MOD_ID + "." + name); + this.setMaxStackSize(1); + if (durability != 0) { - setMaxDamage(HotConfig.MITTS_DURABILITY); + this.setMaxDamage(durability); } - setCreativeTab(HotOrNot.HOTORNOT_TAB); + this.setCreativeTab(HotOrNot.HOTORNOT_TAB); + + ModItems.ITEMS.add(this); } @Override public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, tooltip, flagIn); - tooltip.add(new TextComponentTranslation("item.hotornot.mitts.tooltip").getUnformattedComponentText()); + tooltip.add(new TextComponentTranslation("item.hotornot.hot_item.tooltip").getUnformattedComponentText()); } @Override diff --git a/src/main/java/com/buuz135/hotornot/item/IronTongsItem.java b/src/main/java/com/buuz135/hotornot/item/IronTongsItem.java deleted file mode 100644 index d5d6703..0000000 --- a/src/main/java/com/buuz135/hotornot/item/IronTongsItem.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.buuz135.hotornot.item; - -import java.util.List; -import javax.annotation.Nullable; - -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.world.World; - -import com.buuz135.hotornot.HotOrNot; -import com.buuz135.hotornot.config.HotConfig; - -public class IronTongsItem extends Item -{ - public IronTongsItem() - { - setRegistryName(HotOrNot.MOD_ID, "iron_tongs"); - setTranslationKey(HotOrNot.MOD_ID + ".iron_tongs"); - setMaxStackSize(1); - if (HotConfig.IRON_TONGS_DURABILITY != 0) - { - setMaxDamage(HotConfig.IRON_TONGS_DURABILITY); - } - setCreativeTab(HotOrNot.HOTORNOT_TAB); - } - - @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) - { - super.addInformation(stack, worldIn, tooltip, flagIn); - tooltip.add(new TextComponentTranslation("item.hotornot.iron_tongs.tooltip").getUnformattedComponentText()); - } - - @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/item/ModItems.java b/src/main/java/com/buuz135/hotornot/item/ModItems.java new file mode 100644 index 0000000..0c64bf2 --- /dev/null +++ b/src/main/java/com/buuz135/hotornot/item/ModItems.java @@ -0,0 +1,17 @@ +package com.buuz135.hotornot.item; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.Item; + +import com.buuz135.hotornot.config.HotConfig; + +public class ModItems +{ + public static List ITEMS = new ArrayList<>(); + + public static Item WOODEN_TONGS = new HotItem("wooden_tongs", HotConfig.WOODEN_TONGS_DURABILITY); + public static Item MITTS = new HotItem("mitts", HotConfig.MITTS_DURABILITY); + public static Item IRON_TONGS = new HotItem("iron_tongs", HotConfig.IRON_TONGS_DURABILITY); +} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/item/WoodenTongsItem.java b/src/main/java/com/buuz135/hotornot/item/WoodenTongsItem.java deleted file mode 100644 index 940433d..0000000 --- a/src/main/java/com/buuz135/hotornot/item/WoodenTongsItem.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.buuz135.hotornot.item; - -import java.util.List; -import javax.annotation.Nullable; - -import net.minecraft.client.util.ITooltipFlag; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.world.World; - -import com.buuz135.hotornot.HotOrNot; -import com.buuz135.hotornot.config.HotConfig; - -public class WoodenTongsItem extends Item -{ - public WoodenTongsItem() - { - setRegistryName(HotOrNot.MOD_ID, "wooden_tongs"); - setTranslationKey(HotOrNot.MOD_ID + ".wooden_tongs"); - setMaxStackSize(1); - if (HotConfig.WOODEN_TONGS_DURABILITY != 0) - { - setMaxDamage(HotConfig.WOODEN_TONGS_DURABILITY); - } - setCreativeTab(HotOrNot.HOTORNOT_TAB); - } - - @Override - public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) - { - super.addInformation(stack, worldIn, tooltip, flagIn); - tooltip.add(new TextComponentTranslation("item.hotornot.wooden_tongs.tooltip").getUnformattedComponentText()); - } - - @Override - public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) - { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/proxy/ClientProxy.java b/src/main/java/com/buuz135/hotornot/proxy/ClientProxy.java deleted file mode 100644 index 1cf41f8..0000000 --- a/src/main/java/com/buuz135/hotornot/proxy/ClientProxy.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.buuz135.hotornot.proxy; - -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class ClientProxy extends CommonProxy -{ - @Override - public void preInit(FMLPreInitializationEvent event) - { - super.preInit(event); - } - - @Override - public void init(FMLInitializationEvent event) - { - super.init(event); - } - - @Override - public void postInit(FMLPostInitializationEvent event) - { - super.postInit(event); - } - - @Override - public void modelRegistryEvent(ModelRegistryEvent event) - { - ModelLoader.setCustomModelResourceLocation(WOODEN_TONGS, 0, new ModelResourceLocation(WOODEN_TONGS.getRegistryName(), "inventory")); - ModelLoader.setCustomModelResourceLocation(MITTS, 0, new ModelResourceLocation(MITTS.getRegistryName(), "inventory")); - ModelLoader.setCustomModelResourceLocation(IRON_TONGS, 0, new ModelResourceLocation(IRON_TONGS.getRegistryName(), "inventory")); - } -} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/proxy/CommonProxy.java b/src/main/java/com/buuz135/hotornot/proxy/CommonProxy.java deleted file mode 100644 index e9ef59f..0000000 --- a/src/main/java/com/buuz135/hotornot/proxy/CommonProxy.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.buuz135.hotornot.proxy; - -import net.minecraft.item.Item; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import com.buuz135.hotornot.item.IronTongsItem; -import com.buuz135.hotornot.item.MittsItem; -import com.buuz135.hotornot.item.WoodenTongsItem; - -public class CommonProxy -{ - public static WoodenTongsItem WOODEN_TONGS = new WoodenTongsItem(); - public static MittsItem MITTS = new MittsItem(); - public static IronTongsItem IRON_TONGS = new IronTongsItem(); - - public void preInit(FMLPreInitializationEvent event) - { - - } - - public void init(FMLInitializationEvent event) - { - - } - - public void postInit(FMLPostInitializationEvent event) - { - - } - - public void registerItems(RegistryEvent.Register event) - { - event.getRegistry().register(WOODEN_TONGS); - event.getRegistry().register(MITTS); - event.getRegistry().register(IRON_TONGS); - } - - @SideOnly(Side.CLIENT) - public void modelRegistryEvent(ModelRegistryEvent event) - { - - } -} \ No newline at end of file diff --git a/src/main/java/com/buuz135/hotornot/server/ServerTick.java b/src/main/java/com/buuz135/hotornot/server/ServerTick.java new file mode 100644 index 0000000..652a34d --- /dev/null +++ b/src/main/java/com/buuz135/hotornot/server/ServerTick.java @@ -0,0 +1,212 @@ +package com.buuz135.hotornot.server; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.MobEffects; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; +import net.minecraftforge.fluids.capability.IFluidHandlerItem; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; + +import com.buuz135.hotornot.client.HotTooltip; +import com.buuz135.hotornot.config.HotConfig; +import com.buuz135.hotornot.config.HotLists; +import com.buuz135.hotornot.item.ModItems; +import net.dries007.tfc.api.capability.heat.CapabilityItemHeat; +import net.dries007.tfc.api.capability.heat.IItemHeat; + +@Mod.EventBusSubscriber +public class ServerTick +{ + @SubscribeEvent + public static void onTick(TickEvent.WorldTickEvent event) + { + if (event.phase == TickEvent.Phase.START) + { + for (EntityPlayerMP entityPlayerMP : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) + { + if (!entityPlayerMP.isBurning() && !entityPlayerMP.isCreative() && entityPlayerMP.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) + { + IItemHandler handler = entityPlayerMP.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + for (int i = 0; i < handler.getSlots(); i++) + { + ItemStack stack = handler.getStackInSlot(i); + + // FLUIDS + if (!stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null) && !HotLists.isRemoved(stack)) + { + IFluidHandlerItem fluidHandlerItem = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); + FluidStack fluidStack = fluidHandlerItem.drain(1000, false); + if (fluidStack != null) + { + for (HotTooltip.FluidEffect effect : HotTooltip.FluidEffect.values()) + { + if (effect.isValid.test(fluidStack)) + { + ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); + if (offHand.getItem().equals(ModItems.MITTS)) + { + if (HotConfig.MITTS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.WOODEN_TONGS)) + { + if (HotConfig.WOODEN_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.IRON_TONGS)) + { + if (HotConfig.IRON_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (event.world.getTotalWorldTime() % 20 == 0) + { + effect.interactPlayer.accept(entityPlayerMP); + if (HotConfig.YEET) + { + entityPlayerMP.dropItem(stack, false, true); + entityPlayerMP.inventory.deleteStack(stack); + } + } + } + } + } + } + + if (HotConfig.HOT_ITEMS && !stack.isEmpty() && !HotLists.isRemoved(stack)) + { + if (Loader.isModLoaded("tfc")) + { + // TFC ITEMS + if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null)) + { + IItemHeat heatHandlerItem = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null); + if (heatHandlerItem.getTemperature() >= HotConfig.HOT_ITEM) + { + ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); + if (offHand.getItem().equals(ModItems.MITTS)) + { + if (HotConfig.MITTS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.WOODEN_TONGS)) + { + if (HotConfig.WOODEN_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.IRON_TONGS)) + { + if (HotConfig.IRON_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (event.world.getTotalWorldTime() % 10 == 0) + { + entityPlayerMP.setFire(1); + if (HotConfig.YEET) + { + entityPlayerMP.dropItem(stack, false, true); + entityPlayerMP.inventory.deleteStack(stack); + } + } + } + } + } + // MANUALLY ADDED ITEMS + else if (HotLists.isHot(stack)) + { + ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); + if (offHand.getItem().equals(ModItems.MITTS)) + { + if (HotConfig.MITTS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.WOODEN_TONGS)) + { + if (HotConfig.WOODEN_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.IRON_TONGS)) + { + if (HotConfig.IRON_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (event.world.getTotalWorldTime() % 10 == 0) + { + entityPlayerMP.setFire(1); + if (HotConfig.YEET) + { + entityPlayerMP.dropItem(stack, false, true); + entityPlayerMP.inventory.deleteStack(stack); + } + } + } + else if (HotLists.isCold(stack)) + { + ItemStack offHand = entityPlayerMP.getHeldItemOffhand(); + if (offHand.getItem().equals(ModItems.MITTS)) + { + if (HotConfig.MITTS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.WOODEN_TONGS)) + { + if (HotConfig.WOODEN_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (offHand.getItem().equals(ModItems.IRON_TONGS)) + { + if (HotConfig.IRON_TONGS_DURABILITY != 0) + { + offHand.damageItem(1, entityPlayerMP); + } + } + else if (event.world.getTotalWorldTime() % 10 == 0) + { + entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1)); + entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1)); + } + } + else if (HotLists.isGaseous(stack)) + { + if (event.world.getTotalWorldTime() % 10 == 0) + { + entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1)); + } + } + + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/hotornot/lang/en_us.lang b/src/main/resources/assets/hotornot/lang/en_us.lang index 37aca0c..2dd407d 100644 --- a/src/main/resources/assets/hotornot/lang/en_us.lang +++ b/src/main/resources/assets/hotornot/lang/en_us.lang @@ -3,12 +3,9 @@ tooltip.hotornot.toocold=Too cold to handle! Wear protection. tooltip.hotornot.toolight=Too light to handle! Wear protection. item.hotornot.wooden_tongs.name=Wooden Tongs -item.hotornot.wooden_tongs.tooltip=Tier I - Wear in the offhand to avoid bad effects - item.hotornot.mitts.name=Mitts -item.hotornot.mitts.tooltip=Tier II - Wear in the offhand to avoid bad effects - item.hotornot.iron_tongs.name=Tongs -item.hotornot.iron_tongs.tooltip=Tier III - Wear in the offhand to avoid bad effects -itemGroup.hotornot=Hot or Not \ No newline at end of file +item.hotornot.hot_item.tooltip=Wear in the offhand to avoid bad effects + +itemGroup.hotornot=Hot or Not + \ No newline at end of file diff --git a/src/main/resources/assets/hotornot/recipes/wooden_tongs.json b/src/main/resources/assets/hotornot/recipes/wooden_tongs.json index 2af6a0a..91d39a4 100644 --- a/src/main/resources/assets/hotornot/recipes/wooden_tongs.json +++ b/src/main/resources/assets/hotornot/recipes/wooden_tongs.json @@ -3,9 +3,8 @@ "item": "hotornot:wooden_tongs" }, "pattern": [ - "W W", - " W ", - "W W" + " W", + "WW" ], "type": "forge:ore_shaped", "key": {