Skip to content

Commit

Permalink
Revamp item registry, change wooden tongs recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Sep 12, 2021
1 parent 87d508a commit 76fb578
Show file tree
Hide file tree
Showing 16 changed files with 408 additions and 519 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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.6
modVersion=1.1.7
modBaseName=HotOrNotPlus
forgeVersion=1.12.2-14.23.5.2847
mcpVersion=stable_39
335 changes: 5 additions & 330 deletions src/main/java/com/buuz135/hotornot/HotOrNot.java

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions src/main/java/com/buuz135/hotornot/client/HotTooltip.java
Original file line number Diff line number Diff line change
@@ -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<FluidStack> isValid;
public final Consumer<EntityPlayerMP> interactPlayer;
public final TextFormatting color;
public final String tooltip;

FluidEffect(Predicate<FluidStack> isValid, Consumer<EntityPlayerMP> interactPlayer, TextFormatting color, String tooltip)
{
this.isValid = isValid;
this.interactPlayer = interactPlayer;
this.color = color;
this.tooltip = tooltip;
}
}
}
6 changes: 5 additions & 1 deletion src/main/java/com/buuz135/hotornot/config/HotConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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"));
}
}
19 changes: 19 additions & 0 deletions src/main/java/com/buuz135/hotornot/handler/RegistryHandler.java
Original file line number Diff line number Diff line change
@@ -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<Item> event)
{
event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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
Expand Down
41 changes: 0 additions & 41 deletions src/main/java/com/buuz135/hotornot/item/IronTongsItem.java

This file was deleted.

17 changes: 17 additions & 0 deletions src/main/java/com/buuz135/hotornot/item/ModItems.java
Original file line number Diff line number Diff line change
@@ -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<Item> 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);
}
41 changes: 0 additions & 41 deletions src/main/java/com/buuz135/hotornot/item/WoodenTongsItem.java

This file was deleted.

37 changes: 0 additions & 37 deletions src/main/java/com/buuz135/hotornot/proxy/ClientProxy.java

This file was deleted.

Loading

0 comments on commit 76fb578

Please sign in to comment.