GT5-Unofficial/src/main/java/gregtech/common/items/GT_FluidDisplayItem.java

93 lines
3.4 KiB
Java
Raw Normal View History

2015-06-23 22:29:05 +00:00
package gregtech.common.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.enums.GT_Values;
import gregtech.api.enums.ItemList;
import gregtech.api.items.GT_Generic_Item;
import gregtech.api.util.GT_Utility;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
2016-04-01 18:52:48 +00:00
import net.minecraft.entity.player.EntityPlayer;
2015-06-23 22:29:05 +00:00
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
2015-10-22 02:15:09 +00:00
import java.util.List;
2015-06-23 22:29:05 +00:00
public class GT_FluidDisplayItem
2015-10-22 02:15:09 +00:00
extends GT_Generic_Item {
public GT_FluidDisplayItem() {
super("GregTech_FluidDisplay", "Fluid Display", null);
ItemList.Display_Fluid.set(this);
}
2016-04-01 18:52:48 +00:00
protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) {
2015-10-22 02:15:09 +00:00
NBTTagCompound aNBT = aStack.getTagCompound();
if (GT_Values.D1) {
Fluid tFluid = FluidRegistry.getFluid(aStack.getItemDamage());
if (tFluid != null) {
aList.add("Registry: " + tFluid.getName());
}
}
if (aNBT != null) {
long tToolTipAmount = aNBT.getLong("mFluidDisplayAmount");
if (tToolTipAmount > 0L) {
aList.add(EnumChatFormatting.BLUE + "Amount: " + tToolTipAmount + EnumChatFormatting.GRAY);
}
aList.add(EnumChatFormatting.RED + "Temperature: " + aNBT.getLong("mFluidDisplayHeat") + " K" + EnumChatFormatting.GRAY);
aList.add(EnumChatFormatting.GREEN + "State: " + (aNBT.getBoolean("mFluidState") ? "Gas" : "Liquid") + EnumChatFormatting.GRAY);
}
2015-06-23 22:29:05 +00:00
}
2015-10-22 02:15:09 +00:00
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister aIconRegister) {
2015-06-23 22:29:05 +00:00
}
2015-10-22 02:15:09 +00:00
public IIcon getIconFromDamage(int aMeta) {
Fluid tFluid = FluidRegistry.getFluid(aMeta);
return tFluid == null ? FluidRegistry.WATER.getStillIcon() : tFluid.getStillIcon();
2015-06-23 22:29:05 +00:00
}
2015-10-22 02:15:09 +00:00
@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack aStack, int aRenderPass) {
Fluid tFluid = FluidRegistry.getFluid(aStack.getItemDamage());
return tFluid == null ? 16777215 : tFluid.getColor();
2015-06-23 22:29:05 +00:00
}
2015-10-22 02:15:09 +00:00
public int getSpriteNumber() {
return 0;
}
public String getUnlocalizedName(ItemStack aStack) {
if (aStack != null) {
return GT_Utility.getFluidName(FluidRegistry.getFluid(aStack.getItemDamage()), false);
}
return "";
}
public String getItemStackDisplayName(ItemStack aStack) {
if (aStack != null) {
return GT_Utility.getFluidName(FluidRegistry.getFluid(aStack.getItemDamage()), true);
}
return "";
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item aItem, CreativeTabs aTab, List aList) {
if (GT_Values.D1) {
int i = 0;
for (int j = FluidRegistry.getMaxID(); i < j; i++) {
ItemStack tStack = GT_Utility.getFluidDisplayStack(FluidRegistry.getFluid(i));
if (tStack != null) {
aList.add(tStack);
}
}
2015-06-23 22:29:05 +00:00
}
}
}