Implemented ghost items for the inventory - will be adjusted.

This commit is contained in:
WayofTime 2016-01-14 08:27:09 -05:00
parent ec7676a69c
commit ac919c7882
12 changed files with 424 additions and 66 deletions

View file

@ -0,0 +1,50 @@
package WayofTime.bloodmagic.util;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
public class GhostItemHelper
{
public static void setItemGhostAmount(ItemStack stack, int amount)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
tag.setInteger(Constants.NBT.GHOST_STACK_SIZE, amount);
}
public static int getItemGhostAmount(ItemStack stack)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
return tag.getInteger(Constants.NBT.GHOST_STACK_SIZE);
}
public static boolean hasGhostAmount(ItemStack stack)
{
if (!stack.hasTagCompound())
{
return false;
}
NBTTagCompound tag = stack.getTagCompound();
return tag.hasKey(Constants.NBT.GHOST_STACK_SIZE);
}
public static void incrementGhostAmout(ItemStack stack, int value)
{
int amount = getItemGhostAmount(stack);
amount += value;
setItemGhostAmount(stack, amount);
}
public static void decrementGhostAmout(ItemStack stack, int value)
{
int amount = getItemGhostAmount(stack);
amount -= value;
setItemGhostAmount(stack, amount);
}
}

View file

@ -1,10 +1,31 @@
package WayofTime.bloodmagic.util.handler;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import WayofTime.bloodmagic.util.GhostItemHelper;
public class ClientEventHandler
{
// @SubscribeEvent
// public void onFOVUpdate(FOVUpdateEvent event)
// {
// event.newfov = event.fov;
// }
@SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event)
{
ItemStack stack = event.itemStack;
if (stack == null)
{
return;
}
if (GhostItemHelper.hasGhostAmount(stack))
{
int amount = GhostItemHelper.getItemGhostAmount(stack);
if (amount == 0)
{
event.toolTip.add("Everything");
} else
{
event.toolTip.add("Ghost item amount: " + amount);
}
}
}
}