/
Belyash5
/
Flu
Обзор
Документация
Войти
/
Belyash5
/
Flu
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/hbm/items/special/ItemHot.java
88 строк
2 KB
Boblet
some slight code refactoring, fun with enums
14 дек 2021, 18:12
14 дек 2021, 18:12
9e97a5c
Код
Авторство
О чём код?
package com.hbm.items.special; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.world.World; public class ItemHot extends Item { @SideOnly(Side.CLIENT) public IIcon hotIcon; protected static int heat; public ItemHot(int heat) { this.heat = heat; } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister reg) { super.registerIcons(reg); this.hotIcon = reg.registerIcon(this.getIconString() + "_hot"); } @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int meta) { return this.itemIcon; } public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean bool) { if(!world.isRemote && stack.hasTagCompound()) { int h = stack.stackTagCompound.getInteger("heat"); if(h > 0) { stack.stackTagCompound.setInteger("heat", h - 1); } else { stack.stackTagCompound = null; } } } public static ItemStack heatUp(ItemStack stack) { if(!(stack.getItem() instanceof ItemHot)) return stack; if(!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setInteger("heat", getMaxHeat(stack)); return stack; } public static ItemStack heatUp(ItemStack stack, double d) { if(!(stack.getItem() instanceof ItemHot)) return stack; if(!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setInteger("heat", (int) (d * getMaxHeat(stack))); return stack; } public static double getHeat(ItemStack stack) { if(!(stack.getItem() instanceof ItemHot)) return 0; if(!stack.hasTagCompound()) return 0; int h = stack.stackTagCompound.getInteger("heat"); return (double) h / (double) heat; } public static int getMaxHeat(ItemStack stack) { return heat; } }