diff --git a/HotOrNot.iml b/HotOrNot.iml
index a142fa2..0df6dab 100644
--- a/HotOrNot.iml
+++ b/HotOrNot.iml
@@ -1,29 +1,12 @@
-
-
-
-
- FORGE
- MCP
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
\ 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
index 072e937..4f1cb96 100644
--- a/src/main/java/com/buuz135/hotornot/client/HotTooltip.java
+++ b/src/main/java/com/buuz135/hotornot/client/HotTooltip.java
@@ -38,20 +38,25 @@ public static void onTooltip(ItemTooltipEvent event)
{
if (effect.isValid.test(fluidStack))
{
- event.getToolTip().add(effect.color + new TextComponentTranslation(effect.tooltip).getUnformattedText());
+ if ((effect.equals(FluidEffect.HOT) && HotConfig.HOT_FLUIDS) ||
+ (effect.equals(FluidEffect.COLD) && HotConfig.COLD_FLUIDS) ||
+ (effect.equals(FluidEffect.GAS) && HotConfig.GASEOUS_FLUIDS))
+ {
+ event.getToolTip().add(effect.color + new TextComponentTranslation(effect.tooltip).getUnformattedText());
+ }
}
}
}
}
- else if (HotLists.isHotItem(stack))
+ else if (HotConfig.HOT_ITEMS && HotLists.isHotItem(stack))
{
event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText());
}
- else if (HotLists.isColdItem(stack))
+ else if (HotConfig.COLD_ITEMS && HotLists.isColdItem(stack))
{
event.getToolTip().add(FluidEffect.COLD.color + new TextComponentTranslation(FluidEffect.COLD.tooltip).getUnformattedText());
}
- else if (HotLists.isGaseousItem(stack))
+ else if (HotConfig.GASEOUS_ITEMS && HotLists.isGaseousItem(stack))
{
event.getToolTip().add(FluidEffect.GAS.color + new TextComponentTranslation(FluidEffect.GAS.tooltip).getUnformattedText());
}
@@ -60,7 +65,7 @@ else if (Loader.isModLoaded("tfc") && HotConfig.HOT_ITEMS)
if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null))
{
IItemHeat heat = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null);
- if (heat.getTemperature() >= HotConfig.HOT_ITEM_TEMP)
+ if (heat.getTemperature() >= HotConfig.TEMP_HOT_ITEM)
{
event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText());
}
diff --git a/src/main/java/com/buuz135/hotornot/config/HotConfig.java b/src/main/java/com/buuz135/hotornot/config/HotConfig.java
index ccba519..589024b 100644
--- a/src/main/java/com/buuz135/hotornot/config/HotConfig.java
+++ b/src/main/java/com/buuz135/hotornot/config/HotConfig.java
@@ -43,48 +43,60 @@ public class HotConfig
@Config.Comment("If true, hot items make the player yeet them")
public static boolean YEET = true;
+ @Config.Name("Throw entire stack")
+ @Config.Comment("If true, the player yeets the entire stack of items")
+ public static boolean YEET_STACK = true;
+
@Config.Name("Hot fluid temperature")
@Config.Comment("How hot a fluid should be to start burning the player (in Celsius)")
- public static int HOT_FLUID_TEMP = 480;
+ public static int TEMP_HOT_FLUID = 480;
@Config.Name("Cold fluid temperature")
@Config.Comment("How cold a fluid should be to start adding effects the player (in Celsius)")
- public static int COLD_FLUID_TEMP = 0;
+ public static int TEMP_COLD_FLUID = 0;
- @Config.Name("Hot item temperature")
+ @Config.Name("Hot item temperature (TFC)")
@Config.Comment("How hot an item should be to start burning the player (in Celsius)")
- public static int HOT_ITEM_TEMP = 480;
+ public static int TEMP_HOT_ITEM = 480;
@Config.RequiresMcRestart()
@Config.Name("Wooden Tongs durability")
@Config.Comment("Max durability of Wooden Tongs, 0 for infinite durability")
- public static int WOODEN_TONGS_DURABILITY = 1200;
+ public static int DURABILITY_WOODEN_TONGS = 1200;
@Config.RequiresMcRestart()
@Config.Name("Mitts durability")
@Config.Comment("Max durability of Mitts, 0 for infinite durability")
- public static int MITTS_DURABILITY = 12000;
+ public static int DURABILITY_MITTS = 12000;
@Config.RequiresMcRestart()
@Config.Name("Iron Tongs durability")
@Config.Comment("Max durability of Iron Tongs, 0 for infinite durability")
- public static int IRON_TONGS_DURABILITY = 0;
+ public static int DURABILITY_IRON_TONGS = 0;
+
+ @Config.Name("Effect tick rate")
+ @Config.Comment("How frequently to check for and apply effects in ticks (performance sensitive)")
+ public static int TICK_RATE = 20;
+
+ @Config.Name("Protection item damage")
+ @Config.Comment("How much damage gets applied to the protection item per check")
+ public static int ITEM_DAMAGE = 1;
@Config.Name("Custom hot items")
@Config.Comment("Hot items that are included manually")
- public static String[] HOT_ITEM_ADDITIONS = new String[] {"minecraft:blaze_rod"};
+ public static String[] CUSTOM_HOT_ITEMS = new String[] {"minecraft:blaze_rod"};
@Config.Name("Custom cold items")
@Config.Comment("Cold items that are included manually")
- public static String[] COLD_ITEM_ADDITIONS = new String[] {"minecraft:ice", "minecraft:packed_ice"};
+ public static String[] CUSTOM_COLD_ITEMS = new String[] {"minecraft:ice", "minecraft:packed_ice"};
@Config.Name("Custom gaseous items")
@Config.Comment("Gaseous items that are included manually")
- public static String[] GASEOUS_ITEM_ADDITIONS = new String[] {"mod_id:item"};
+ public static String[] CUSTOM_GASEOUS_ITEMS = new String[] {"mod_id:item"};
@Config.Name("Excluded items")
@Config.Comment("Items that are exempt from effects")
- public static String[] ITEM_REMOVALS = new String[] {"immersiveengineering:drill", "immersiveengineering:chemthrower", "immersivepetroleum:fluid_diesel", "immersivepetroleum:fluid_gasoline"};
+ public static String[] CUSTOM_REMOVALS = new String[] {"immersiveengineering:drill", "immersiveengineering:chemthrower", "immersivepetroleum:fluid_diesel", "immersivepetroleum:fluid_gasoline"};
@SuppressWarnings("unused")
@Mod.EventBusSubscriber(modid = HotOrNot.MOD_ID)
diff --git a/src/main/java/com/buuz135/hotornot/config/HotLists.java b/src/main/java/com/buuz135/hotornot/config/HotLists.java
index b1b64a9..5e77147 100644
--- a/src/main/java/com/buuz135/hotornot/config/HotLists.java
+++ b/src/main/java/com/buuz135/hotornot/config/HotLists.java
@@ -7,12 +7,12 @@ public class HotLists
{
public static boolean isHotFluid(FluidStack fluidStack)
{
- return HotConfig.HOT_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.HOT_FLUID_TEMP + 273;
+ return HotConfig.HOT_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.TEMP_HOT_FLUID + 273;
}
public static boolean isColdFluid(FluidStack fluidStack)
{
- return HotConfig.COLD_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.COLD_FLUID_TEMP + 273;
+ return HotConfig.COLD_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.TEMP_COLD_FLUID + 273;
}
public static boolean isGaseousFluid(FluidStack fluidStack)
@@ -23,7 +23,7 @@ public static boolean isGaseousFluid(FluidStack fluidStack)
public static boolean isRemovedItem(ItemStack stack)
{
String regName = stack.getItem().getRegistryName().toString();
- for (String s : HotConfig.ITEM_REMOVALS)
+ for (String s : HotConfig.CUSTOM_REMOVALS)
{
if (regName.equals(s))
{
@@ -38,7 +38,7 @@ public static boolean isHotItem(ItemStack stack)
if (HotConfig.HOT_ITEMS)
{
String regName = stack.getItem().getRegistryName().toString();
- for (String s : HotConfig.HOT_ITEM_ADDITIONS)
+ for (String s : HotConfig.CUSTOM_HOT_ITEMS)
{
if (regName.equals(s))
{
@@ -54,7 +54,7 @@ public static boolean isColdItem(ItemStack stack)
if (HotConfig.COLD_ITEMS)
{
String regName = stack.getItem().getRegistryName().toString();
- for (String s : HotConfig.COLD_ITEM_ADDITIONS)
+ for (String s : HotConfig.CUSTOM_COLD_ITEMS)
{
if (regName.equals(s))
{
@@ -70,7 +70,7 @@ public static boolean isGaseousItem(ItemStack stack)
if (HotConfig.GASEOUS_ITEMS)
{
String regName = stack.getItem().getRegistryName().toString();
- for (String s : HotConfig.GASEOUS_ITEM_ADDITIONS)
+ for (String s : HotConfig.CUSTOM_GASEOUS_ITEMS)
{
if (regName.equals(s))
{
diff --git a/src/main/java/com/buuz135/hotornot/item/ModItems.java b/src/main/java/com/buuz135/hotornot/item/ModItems.java
index 0c64bf2..c8dd517 100644
--- a/src/main/java/com/buuz135/hotornot/item/ModItems.java
+++ b/src/main/java/com/buuz135/hotornot/item/ModItems.java
@@ -11,7 +11,7 @@ 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);
+ public static Item WOODEN_TONGS = new HotItem("wooden_tongs", HotConfig.DURABILITY_WOODEN_TONGS);
+ public static Item MITTS = new HotItem("mitts", HotConfig.DURABILITY_MITTS);
+ public static Item IRON_TONGS = new HotItem("iron_tongs", HotConfig.DURABILITY_IRON_TONGS);
}
\ 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
index aec5cef..4931c1b 100644
--- a/src/main/java/com/buuz135/hotornot/server/ServerTick.java
+++ b/src/main/java/com/buuz135/hotornot/server/ServerTick.java
@@ -1,13 +1,14 @@
package com.buuz135.hotornot.server;
-import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
+import net.minecraft.world.World;
+import net.minecraftforge.common.ForgeHooks;
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;
@@ -25,78 +26,78 @@
public class ServerTick
{
@SubscribeEvent
- public static void onTick(TickEvent.WorldTickEvent event)
+ public static void onTick(TickEvent.PlayerTickEvent event)
{
- if (event.phase == TickEvent.Phase.START)
+ World world = event.player.world;
+ EntityPlayer player = event.player;
+
+ if (event.phase == TickEvent.Phase.START && !world.isRemote && world.getTotalWorldTime() % HotConfig.TICK_RATE == 0)
{
- for (EntityPlayerMP entityPlayerMP : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers())
+ if (!player.isBurning() && !player.isCreative() && player.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
{
- if (!entityPlayerMP.isBurning() && !entityPlayerMP.isCreative() && entityPlayerMP.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
+ IItemHandler handler = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
+ for (int i = 0; i < handler.getSlots(); i++)
{
- IItemHandler handler = entityPlayerMP.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
- for (int i = 0; i < handler.getSlots(); i++)
+ ItemStack stack = handler.extractItem(i, 1, true);
+ if (!stack.isEmpty() && !HotLists.isRemovedItem(stack))
{
- ItemStack stack = handler.extractItem(i, 1, true);
- if (!stack.isEmpty() && !HotLists.isRemovedItem(stack))
+ // FLUIDS
+ if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))
{
- // FLUIDS
- 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)
{
- IFluidHandlerItem fluidHandlerItem = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
- FluidStack fluidStack = fluidHandlerItem.drain(1000, false);
- if (fluidStack != null)
+ if (HotLists.isHotFluid(fluidStack) || HotLists.isColdFluid(fluidStack) || HotLists.isGaseousFluid(fluidStack))
{
- if (HotLists.isHotFluid(fluidStack) || HotLists.isColdFluid(fluidStack) || HotLists.isGaseousFluid(fluidStack))
+ if (!damageProtectionItem(player))
{
- if (!damageProtectionItem(entityPlayerMP) && event.world.getTotalWorldTime() % 20 == 0)
+ if (HotLists.isHotFluid(fluidStack))
+ {
+ applyHotEffect(player, i);
+ }
+ else if (HotLists.isColdFluid(fluidStack))
{
- if (HotLists.isHotFluid(fluidStack))
- {
- applyHotEffect(entityPlayerMP, stack, i);
- }
- else if (HotLists.isColdFluid(fluidStack))
- {
- applyColdEffect(entityPlayerMP);
- }
- else if (HotLists.isGaseousFluid(fluidStack))
- {
- applyGaseousEffect(entityPlayerMP);
- }
+ applyColdEffect(player);
+ }
+ else if (HotLists.isGaseousFluid(fluidStack))
+ {
+ applyGaseousEffect(player);
}
}
}
}
- // CONFIG-ADDED ITEMS
- else if (HotLists.isHotItem(stack) || HotLists.isColdItem(stack) || HotLists.isGaseousItem(stack))
+ }
+ // CONFIG-ADDED ITEMS
+ else if (HotLists.isHotItem(stack) || HotLists.isColdItem(stack) || HotLists.isGaseousItem(stack))
+ {
+ if (!damageProtectionItem(player))
{
- if (!damageProtectionItem(entityPlayerMP) && event.world.getTotalWorldTime() % 20 == 0)
+ if (HotLists.isHotItem(stack))
{
- if (HotLists.isHotItem(stack))
- {
- applyHotEffect(entityPlayerMP, stack, i);
- }
- else if (HotLists.isColdItem(stack))
- {
- applyColdEffect(entityPlayerMP);
- }
- else if (HotLists.isGaseousItem(stack))
- {
- applyGaseousEffect(entityPlayerMP);
- }
+ applyHotEffect(player, i);
+ }
+ else if (HotLists.isColdItem(stack))
+ {
+ applyColdEffect(player);
+ }
+ else if (HotLists.isGaseousItem(stack))
+ {
+ applyGaseousEffect(player);
}
}
- // TFC ITEMS
- else if (Loader.isModLoaded("tfc") && HotConfig.HOT_ITEMS)
+ }
+ // TFC ITEMS
+ else if (Loader.isModLoaded("tfc") && HotConfig.HOT_ITEMS)
+ {
+ if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null))
{
- if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null))
+ IItemHeat heatHandlerItem = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null);
+ if (heatHandlerItem.getTemperature() >= HotConfig.TEMP_HOT_ITEM)
{
- IItemHeat heatHandlerItem = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null);
- if (heatHandlerItem.getTemperature() >= HotConfig.HOT_ITEM_TEMP)
+ if (!damageProtectionItem(player))
{
- if (!damageProtectionItem(entityPlayerMP) && event.world.getTotalWorldTime() % 20 == 0)
- {
- applyHotEffect(entityPlayerMP, stack, i);
- }
+ applyHotEffect(player, i);
}
}
}
@@ -107,54 +108,60 @@ else if (Loader.isModLoaded("tfc") && HotConfig.HOT_ITEMS)
}
}
- public static boolean damageProtectionItem(EntityPlayerMP entityPlayerMP)
+ public static boolean damageProtectionItem(EntityPlayer player)
{
- ItemStack offHand = entityPlayerMP.getHeldItemOffhand();
+ ItemStack offHand = player.getHeldItemOffhand();
if (offHand.getItem().equals(ModItems.MITTS))
{
- if (HotConfig.MITTS_DURABILITY != 0)
+ if (HotConfig.DURABILITY_MITTS != 0)
{
- offHand.damageItem(1, entityPlayerMP);
+ offHand.damageItem(HotConfig.ITEM_DAMAGE, player);
}
return true;
}
else if (offHand.getItem().equals(ModItems.WOODEN_TONGS))
{
- if (HotConfig.WOODEN_TONGS_DURABILITY != 0)
+ if (HotConfig.DURABILITY_WOODEN_TONGS != 0)
{
- offHand.damageItem(1, entityPlayerMP);
+ offHand.damageItem(HotConfig.ITEM_DAMAGE, player);
}
return true;
}
else if (offHand.getItem().equals(ModItems.IRON_TONGS))
{
- if (HotConfig.IRON_TONGS_DURABILITY != 0)
+ if (HotConfig.DURABILITY_IRON_TONGS != 0)
{
- offHand.damageItem(1, entityPlayerMP);
+ offHand.damageItem(HotConfig.ITEM_DAMAGE, player);
}
return true;
}
return false;
}
- public static void applyHotEffect(EntityPlayerMP entityPlayerMP, ItemStack stack, int index)
+ public static void applyHotEffect(EntityPlayer player, int index)
{
- entityPlayerMP.setFire(1);
+ player.setFire(1);
if (HotConfig.YEET)
{
- entityPlayerMP.dropItem(stack, false, true);
- entityPlayerMP.inventory.decrStackSize(index, 1);
+ if (HotConfig.YEET_STACK)
+ {
+ ForgeHooks.onPlayerTossEvent(player, player.inventory.decrStackSize(index, player.inventory.getStackInSlot(index).getCount()), true);
+ }
+ else
+ {
+ ForgeHooks.onPlayerTossEvent(player, player.inventory.decrStackSize(index, 1), true);
+ }
}
}
- public static void applyColdEffect(EntityPlayerMP entityPlayerMP)
+ public static void applyColdEffect(EntityPlayer player)
{
- entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1));
- entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1));
+ player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1));
+ player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1));
}
- public static void applyGaseousEffect(EntityPlayerMP entityPlayerMP)
+ public static void applyGaseousEffect(EntityPlayer player)
{
- entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1));
+ player.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 2dd407d..755046c 100644
--- a/src/main/resources/assets/hotornot/lang/en_us.lang
+++ b/src/main/resources/assets/hotornot/lang/en_us.lang
@@ -1,6 +1,6 @@
-tooltip.hotornot.toohot=Too hot to handle! Wear protection.
-tooltip.hotornot.toocold=Too cold to handle! Wear protection.
-tooltip.hotornot.toolight=Too light to handle! Wear protection.
+tooltip.hotornot.toohot=Too hot to handle! Wear tongs or mitts in the offhand.
+tooltip.hotornot.toocold=Too cold to handle! Wear tongs or mitts in the offhand.
+tooltip.hotornot.toolight=Too light to handle! Wear tongs or mitts in the offhand.
item.hotornot.wooden_tongs.name=Wooden Tongs
item.hotornot.mitts.name=Mitts