Skip to content

Commit

Permalink
Consolidate code, fix item tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Feb 6, 2022
1 parent 765d314 commit f0ead63
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 137 deletions.
7 changes: 5 additions & 2 deletions HotOrNot.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="HotOrNot" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.buuz135" external.system.module.version="1.1.8" type="JAVA_MODULE" version="4">
<module external.linked.project.id="HotOrNot" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.buuz135" external.system.module.version="1.1.9" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
Expand All @@ -11,7 +11,10 @@
</facet>
</component>
<component name="McpModuleSettings">
<option name="srgType" value="SRG" />
<option name="mappingFile" value="D:\Spiele\Minecraft\Meine Mods\HotOrNot\build\createMcpToSrg\output.tsrg" />
<option name="mcpVersion" value="stable_39-1.12" />
<option name="minecraftVersion" value="1.12.2" />
<option name="srgType" value="TSRG" />
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.1.8'
version = '1.1.9'
group = 'com.buuz135' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'HotOrNotPlus-1.12.2'

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modGroup=com.buuz135
minecraftVersion=1.12.2
modVersion=1.1.8
modVersion=1.1.9
modBaseName=HotOrNotPlus
forgeVersion=1.12.2-14.23.5.2860
mcpVersion=stable_39
2 changes: 1 addition & 1 deletion src/main/java/com/buuz135/hotornot/HotOrNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class HotOrNot
{
public static final String MOD_ID = "hotornot";
public static final String MOD_NAME = "Hot or Not +";
public static final String VERSION = "1.1.8";
public static final String VERSION = "1.1.9";
public static final CreativeTabs HOTORNOT_TAB = new HotOrNotTab();

@Mod.EventHandler
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/buuz135/hotornot/client/HotTooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ else if (HotLists.isGaseousItem(stack))
{
event.getToolTip().add(FluidEffect.GAS.color + new TextComponentTranslation(FluidEffect.GAS.tooltip).getUnformattedText());
}
else if (Loader.isModLoaded("tfc"))
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)
if (heat.getTemperature() >= HotConfig.HOT_ITEM_TEMP)
{
event.getToolTip().add(FluidEffect.HOT.color + new TextComponentTranslation(FluidEffect.HOT.tooltip).getUnformattedText());
}
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/com/buuz135/hotornot/config/HotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
@Config(modid = HotOrNot.MOD_ID)
public class HotConfig
{
@Config.Comment("If true, effects for items will be enabled")
public static boolean ITEM_EFFECTS = true;
@Config.Comment("If true, hot effects for items will be enabled")
public static boolean HOT_ITEMS = true;

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

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

@Config.Comment("If true, hot effects for fluids will be enabled")
public static boolean HOT_FLUIDS = true;
Expand All @@ -30,13 +36,13 @@ public class HotConfig
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;
public static int HOT_FLUID_TEMP = 480;

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

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

@Config.RequiresMcRestart()
@Config.Comment("Max durability of the wooden tongs, 0 for infinite durability")
Expand Down
37 changes: 23 additions & 14 deletions src/main/java/com/buuz135/hotornot/config/HotLists.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public class HotLists
{
public static boolean isHotFluid(FluidStack fluidStack)
{
return HotConfig.HOT_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.HOT_FLUID + 273;
return HotConfig.HOT_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) >= HotConfig.HOT_FLUID_TEMP + 273;
}

public static boolean isColdFluid(FluidStack fluidStack)
{
return HotConfig.COLD_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.COLD_FLUID + 273;
return HotConfig.COLD_FLUIDS && fluidStack.getFluid().getTemperature(fluidStack) <= HotConfig.COLD_FLUID_TEMP + 273;
}

public static boolean isGaseousFluid(FluidStack fluidStack)
Expand All @@ -35,38 +35,47 @@ public static boolean isRemovedItem(ItemStack stack)

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

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

public static boolean isGaseousItem(ItemStack stack)
{
String regName = stack.getItem().getRegistryName().toString();
for (String s : HotConfig.GASEOUS_ITEM_ADDITIONS)
if (HotConfig.GASEOUS_ITEMS)
{
if (regName.equals(s))
String regName = stack.getItem().getRegistryName().toString();
for (String s : HotConfig.GASEOUS_ITEM_ADDITIONS)
{
return true;
if (regName.equals(s))
{
return true;
}
}
}
return false;
Expand Down
186 changes: 75 additions & 111 deletions src/main/java/com/buuz135/hotornot/server/ServerTick.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,141 +48,54 @@ public static void onTick(TickEvent.WorldTickEvent event)
{
if (HotLists.isHotFluid(fluidStack) || HotLists.isColdFluid(fluidStack) || HotLists.isGaseousFluid(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)
if (!damageProtectionItem(entityPlayerMP) && event.world.getTotalWorldTime() % 20 == 0)
{
if (HotLists.isHotFluid(fluidStack))
{
entityPlayerMP.setFire(1);
if (HotConfig.YEET)
{
entityPlayerMP.dropItem(stack, false, true);
entityPlayerMP.inventory.decrStackSize(i, 1);
}
applyHotEffect(entityPlayerMP, stack, i);
}
else if (HotLists.isColdFluid(fluidStack))
{
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1));
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1));
applyColdEffect(entityPlayerMP);
}
else if (HotLists.isGaseousFluid(fluidStack))
{
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1));
applyGaseousEffect(entityPlayerMP);
}
}
}
}
}
// ITEMS
if (HotConfig.ITEM_EFFECTS)
// CONFIG-ADDED ITEMS
else if (HotLists.isHotItem(stack) || HotLists.isColdItem(stack) || HotLists.isGaseousItem(stack))
{
// TFC ITEMS
if (Loader.isModLoaded("tfc"))
{
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.decrStackSize(i, 1);
}
}
}
}
}
// MANUALLY ADDED ITEMS
if (HotLists.isHotItem(stack) || HotLists.isColdItem(stack) || HotLists.isGaseousItem(stack))
if (!damageProtectionItem(entityPlayerMP) && event.world.getTotalWorldTime() % 20 == 0)
{
ItemStack offHand = entityPlayerMP.getHeldItemOffhand();
if (offHand.getItem().equals(ModItems.MITTS))
if (HotLists.isHotItem(stack))
{
if (HotConfig.MITTS_DURABILITY != 0)
{
offHand.damageItem(1, entityPlayerMP);
}
applyHotEffect(entityPlayerMP, stack, i);
}
else if (offHand.getItem().equals(ModItems.WOODEN_TONGS))
else if (HotLists.isColdItem(stack))
{
if (HotConfig.WOODEN_TONGS_DURABILITY != 0)
{
offHand.damageItem(1, entityPlayerMP);
}
applyColdEffect(entityPlayerMP);
}
else if (offHand.getItem().equals(ModItems.IRON_TONGS))
else if (HotLists.isGaseousItem(stack))
{
if (HotConfig.IRON_TONGS_DURABILITY != 0)
{
offHand.damageItem(1, entityPlayerMP);
}
applyGaseousEffect(entityPlayerMP);
}
else if (event.world.getTotalWorldTime() % 10 == 0)
}
}
// TFC ITEMS
else if (Loader.isModLoaded("tfc") && HotConfig.HOT_ITEMS)
{
if (stack.hasCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null))
{
IItemHeat heatHandlerItem = stack.getCapability(CapabilityItemHeat.ITEM_HEAT_CAPABILITY, null);
if (heatHandlerItem.getTemperature() >= HotConfig.HOT_ITEM_TEMP)
{
if (HotLists.isHotItem(stack))
if (!damageProtectionItem(entityPlayerMP) && event.world.getTotalWorldTime() % 20 == 0)
{
entityPlayerMP.setFire(1);
if (HotConfig.YEET)
{
entityPlayerMP.dropItem(stack, false, true);
entityPlayerMP.inventory.decrStackSize(i, 1);
}
}
else if (HotLists.isColdItem(stack))
{
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1));
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1));
}
else if (HotLists.isGaseousItem(stack))
{
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1));
applyHotEffect(entityPlayerMP, stack, i);
}
}
}
Expand All @@ -193,4 +106,55 @@ else if (HotLists.isGaseousItem(stack))
}
}
}

public static boolean damageProtectionItem(EntityPlayerMP entityPlayerMP)
{
ItemStack offHand = entityPlayerMP.getHeldItemOffhand();
if (offHand.getItem().equals(ModItems.MITTS))
{
if (HotConfig.MITTS_DURABILITY != 0)
{
offHand.damageItem(1, entityPlayerMP);
}
return true;
}
else if (offHand.getItem().equals(ModItems.WOODEN_TONGS))
{
if (HotConfig.WOODEN_TONGS_DURABILITY != 0)
{
offHand.damageItem(1, entityPlayerMP);
}
return true;
}
else if (offHand.getItem().equals(ModItems.IRON_TONGS))
{
if (HotConfig.IRON_TONGS_DURABILITY != 0)
{
offHand.damageItem(1, entityPlayerMP);
}
return true;
}
return false;
}

public static void applyHotEffect(EntityPlayerMP entityPlayerMP, ItemStack stack, int index)
{
entityPlayerMP.setFire(1);
if (HotConfig.YEET)
{
entityPlayerMP.dropItem(stack, false, true);
entityPlayerMP.inventory.decrStackSize(index, 1);
}
}

public static void applyColdEffect(EntityPlayerMP entityPlayerMP)
{
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 21, 1));
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 21, 1));
}

public static void applyGaseousEffect(EntityPlayerMP entityPlayerMP)
{
entityPlayerMP.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 21, 1));
}
}

0 comments on commit f0ead63

Please sign in to comment.