package com.yolp900.itsjustacharm.common.events; import baubles.api.BaublesApi; import baubles.api.IBauble; import com.yolp900.itsjustacharm.api.IJCConstants; import com.yolp900.itsjustacharm.util.NBTHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import java.util.ArrayList; import java.util.List; public class EventBaubleTick { @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { EntityPlayer player = event.player; if (!player.worldObj.isRemote) { IInventory baublesInventory = BaublesApi.getBaubles(player); List<ItemStack> rings = new ArrayList<>(); rings.add(baublesInventory.getStackInSlot(1)); rings.add(baublesInventory.getStackInSlot(2)); for (ItemStack ring : rings) { if (ring != null && ring.getItem() instanceof IBauble && NBTHelper.getBoolean(ring, IJCConstants.NBT.BAUBLE_HOLDER)) { ItemStack baubleAttached0 = NBTHelper.getItemStack(ring, IJCConstants.NBT.BAUBLE_ATTACHED(0)); if (baubleAttached0 != null) { ((IBauble) baubleAttached0.getItem()).onWornTick(baubleAttached0, player); } if (NBTHelper.getBoolean(ring, IJCConstants.NBT.ADVANCED_BAUBLE_HOLDER)) { ItemStack baubleAttached1 = NBTHelper.getItemStack(ring, IJCConstants.NBT.BAUBLE_ATTACHED(1)); if (baubleAttached1 != null) { ((IBauble) baubleAttached1.getItem()).onWornTick(baubleAttached1, player); } } } } } } }