Skip to content

Commit

Permalink
Addable/removable items via config
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Jun 12, 2021
1 parent 437b3bb commit 52ccd7e
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 66 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Hot Or Not
==========

TFC-1.1.4 (2021-03-27 16:42:13 +0100)
-------------------------------------
* Item tooltips + configurable temperatures (ACGaming)

TFC-1.1.3 (2021-03-03 18:26:18 +0100)
-------------------------------------
* Altered recipe (ACGaming)
Expand Down
8 changes: 4 additions & 4 deletions HotOrNot.iml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<content url="file://$MODULE_DIR$/">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
Expand Down Expand Up @@ -765,11 +765,11 @@
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2768/snapshot/20180508/forgeSrc-1.12.2-14.23.5.2768.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2847/stable/39/forgeSrc-1.12.2-14.23.5.2847.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2768/snapshot/20180508/forgeSrc-1.12.2-14.23.5.2768-sources.jar!/" />
<root url="jar://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2847/stable/39/forgeSrc-1.12.2-14.23.5.2847-sources.jar!/" />
</SOURCES>
</library>
</orderEntry>
Expand Down Expand Up @@ -803,7 +803,7 @@
<orderEntry type="module-library" scope="RUNTIME">
<library>
<CLASSES>
<root url="file://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2768/start" />
<root url="file://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2847/start" />
</CLASSES>
<JAVADOC />
<SOURCES />
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modGroup=com.buuz135
minecraftVersion=1.12
modVersion=1.1.4
minecraftVersion=1.12.2
modVersion=1.1.5
modBaseName=HotOrNotTFC
forgeVersion=1.12.2-14.23.5.2768
mcpVersion=snapshot_20180508
forgeVersion=1.12.2-14.23.5.2847
mcpVersion=stable_39
126 changes: 70 additions & 56 deletions src/main/java/com/buuz135/hotornot/HotOrNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
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.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
Expand All @@ -53,6 +50,8 @@
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;
Expand All @@ -67,7 +66,7 @@ public class HotOrNot
{
public static final String MOD_ID = "hotornot";
public static final String MOD_NAME = "HotOrNot for TFC";
public static final String VERSION = "1.1.4";
public static final String VERSION = "1.1.5";

@SidedProxy(clientSide = "com.buuz135.hotornot.proxy.ClientProxy", serverSide = "com.buuz135.hotornot.proxy.CommonProxy")
public static CommonProxy proxy;
Expand All @@ -92,13 +91,13 @@ public void postInit(FMLPostInitializationEvent event)

public enum FluidEffect
{
HOT(fluidStack -> fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.HOT_FLUID + 273, entityPlayerMP -> entityPlayerMP.setFire(1), TextFormatting.RED, "tooltip.hotornot.toohot"),
COLD(fluidStack -> fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.COLD_FLUID + 273, entityPlayerMP ->
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, entityPlayerMP -> entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1)), TextFormatting.YELLOW, "tooltip.hotornot.toolight");
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<FluidStack> isValid;
private final Consumer<EntityPlayerMP> interactPlayer;
Expand Down Expand Up @@ -147,7 +146,9 @@ public static void onTick(TickEvent.WorldTickEvent event)
for (int i = 0; i < handler.getSlots(); i++)
{
ItemStack stack = handler.getStackInSlot(i);
if (HotConfig.HOT_FLUIDS && !stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))

// 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);
Expand Down Expand Up @@ -175,10 +176,34 @@ else if (event.world.getTotalWorldTime() % 20 == 0)
}
}
}
if (HotConfig.HOT_ITEMS && !stack.isEmpty() && stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null))

if (HotConfig.HOT_ITEMS && !stack.isEmpty() && !HotLists.isRemoved(stack))
{
IItemHeat heatHandlerItem = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null);
if (heatHandlerItem.getTemperature() >= HotConfig.HOT_ITEM)
// 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))
{
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))
Expand All @@ -195,6 +220,27 @@ else if (event.world.getTotalWorldTime() % 10 == 0)
}
}
}
else if (HotLists.isCold(stack))
{
ItemStack offHand = entityPlayerMP.getHeldItemOffhand();
if (offHand.getItem().equals(CommonProxy.MITTS))
{
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));
}
}

}
}
}
Expand All @@ -203,58 +249,14 @@ else if (event.world.getTotalWorldTime() % 10 == 0)
}
}

@Config(modid = MOD_ID)
public static class HotConfig
{
@Config.Comment("If true, damage from hot items will be enabled")
public static boolean HOT_ITEMS = true;

@Config.Comment("If true, damage from hot fluids will be enabled")
public static boolean HOT_FLUIDS = true;

@Config.Comment("If true, gaseous effects for the fluids will be enabled")
public static boolean GASEOUS = true;

@Config.Comment("If true, the items that contain hot fluid will have a tooltip that will show that they are too hot")
public static boolean TOOLTIP = true;

@Config.Comment("If true, hot items make the player yeet them")
public static boolean YEET = true;

@Config.Comment("How hot a fluid should be to start burning the player (in Celsius)")
public static int HOT_FLUID = 480;

@Config.Comment("How cold a fluid should be to start adding effects the player (in Celsius)")
public static int COLD_FLUID = 0;

@Config.Comment("How hot an item should be to start burning the player (in Celsius)")
public static int HOT_ITEM = 480;

@Config.Comment("Max durability of the mitts")
public static int MITTS_DURABILITY = 20 * 60 * 10;

@Mod.EventBusSubscriber(modid = MOD_ID)
private static class EventHandler
{
@SubscribeEvent
public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event)
{
if (event.getModID().equals(MOD_ID))
{
ConfigManager.sync(MOD_ID, Config.Type.INSTANCE);
}
}
}
}

@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())
if (HotConfig.TOOLTIP && !stack.isEmpty() && !HotLists.isRemoved(stack))
{
if (stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null))
{
Expand All @@ -279,6 +281,18 @@ else if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null))
event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.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());
}
}
}
}
Expand Down
68 changes: 68 additions & 0 deletions src/main/java/com/buuz135/hotornot/config/HotConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.buuz135.hotornot.config;

import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import com.buuz135.hotornot.HotOrNot;

@Config(modid = HotOrNot.MOD_ID)
public class HotConfig
{
@Config.Comment("If true, hot effects for items will be enabled")
public static boolean HOT_ITEMS = true;

@Config.Comment("If true, hot effects for fluids will be enabled")
public static boolean HOT_FLUIDS = true;

@Config.Comment("If true, cold effects for fluids will be enabled")
public static boolean COLD_FLUIDS = true;

@Config.Comment("If true, gaseous effects for fluids will be enabled")
public static boolean GASEOUS_FLUIDS = true;

@Config.Comment("If true, items causing effects will get a tooltip")
public static boolean TOOLTIP = true;

@Config.Comment("If true, hot items make the player yeet them")
public static boolean YEET = true;

@Config.Comment("How hot a fluid should be to start burning the player (in Celsius)")
public static int HOT_FLUID = 480;

@Config.Comment("How cold a fluid should be to start adding effects the player (in Celsius)")
public static int COLD_FLUID = 0;

@Config.Comment("How hot an item should be to start burning the player (in Celsius)")
public static int HOT_ITEM = 480;

@Config.Comment("Max durability of the mitts")
public static int MITTS_DURABILITY = 20 * 60 * 10;

@Config.Comment("Hot items that are included manually")
public static String[] HOT_ITEM_ADDITIONS = new String[] {"minecraft:blaze_rod"};

@Config.Comment("Cold items that are included manually")
public static String[] COLD_ITEM_ADDITIONS = new String[] {"minecraft:ice", "minecraft:packed_ice"};

@Config.Comment("Gaseous items that are included manually")
public static String[] GASEOUS_ITEM_ADDITIONS = new String[] {"mod_id:item"};

@Config.Comment("Items that are excluded")
public static String[] ITEM_REMOVALS = new String[] {"immersiveengineering:drill", "immersiveengineering:chemthrower", "immersivepetroleum:fluid_diesel", "immersivepetroleum:fluid_gasoline"};

@Mod.EventBusSubscriber(modid = HotOrNot.MOD_ID)
private static class EventHandler
{
@SubscribeEvent
public static void onConfigChanged(final ConfigChangedEvent.OnConfigChangedEvent event)
{
if (event.getModID().equals(HotOrNot.MOD_ID))
{
ConfigManager.sync(HotOrNot.MOD_ID, Config.Type.INSTANCE);
}
}
}
}
58 changes: 58 additions & 0 deletions src/main/java/com/buuz135/hotornot/config/HotLists.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.buuz135.hotornot.config;

import net.minecraft.item.ItemStack;

public class HotLists
{
public static boolean isRemoved(ItemStack stack)
{
String regName = stack.getItem().getRegistryName().toString();
for (String s : HotConfig.ITEM_REMOVALS)
{
if (regName.equals(s))
{
return true;
}
}
return false;
}

public static boolean isHot(ItemStack stack)
{
String regName = stack.getItem().getRegistryName().toString();
for (String s : HotConfig.HOT_ITEM_ADDITIONS)
{
if (regName.equals(s))
{
return true;
}
}
return false;
}

public static boolean isCold(ItemStack stack)
{
String regName = stack.getItem().getRegistryName().toString();
for (String s : HotConfig.COLD_ITEM_ADDITIONS)
{
if (regName.equals(s))
{
return true;
}
}
return false;
}

public static boolean isGaseous(ItemStack stack)
{
String regName = stack.getItem().getRegistryName().toString();
for (String s : HotConfig.GASEOUS_ITEM_ADDITIONS)
{
if (regName.equals(s))
{
return true;
}
}
return false;
}
}
Loading

0 comments on commit 52ccd7e

Please sign in to comment.