@SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) public void getSubItems( Item par1, CreativeTabs par2CreativeTabs, @SuppressWarnings("rawtypes") List par3List) { if (par1.equals(emptyItem)) par3List.add(new ItemStack(par1, 1, 0)); if (par1.equals(filledItem)) for (int i = 0, e = LiquidRegistry.getRegisteredLiquidCount(); i++ < e; ) par3List.add(new ItemStack(par1, 1, i)); }
@SubscribeEvent public void onPlayerOpenContainer(PlayerOpenContainerEvent event) { if (event.entityPlayer instanceof EntityPlayerMP) { if (event.entityPlayer.openContainer instanceof net.minecraft.inventory.ContainerWorkbench && event.entityPlayer.openContainer.inventoryItemStacks.get(0) != null) { EntityPlayerMP playerMP = (EntityPlayerMP) event.entityPlayer; PlayerData player = PlayerStore.getInstance().getPlayer(playerMP.getUniqueID().toString()); Item item = (Item) ((ItemStack) event.entityPlayer.openContainer.inventoryItemStacks.get(0)).getItem(); ArrayList<ItemPerk> entitylist = PerkStore.getPerksForItem(item.getUnlocalizedName()); boolean requiresPerk = false; if (entitylist != null) { requiresPerk = true; } for (ItemSkill skill : SkillStore.getInstance().getItemSkill()) { ArrayList<ItemXP> temp = skill.getExp(); for (int i = 0; i < temp.size(); i++) { Item compareItem = ((ItemXP) temp.get(i)).getItem(); if (item.equals(compareItem)) { if (requiresPerk) { if (PlayerHandler.hasPerk(player, entitylist)) { } else { PlayerHandler.taskFail((EntityPlayer) playerMP); event.entityPlayer.closeScreen(); break; } } } } } } } }
public static boolean isPlayerWearing(EntityPlayer player, Item item) { if (player == null || item == null || !(item instanceof ItemArmor)) return false; int index = getSlotFromIndex(((ItemArmor) item).armorType); if (index == -1) return false; ItemStack tempStack = player.inventory.armorItemInSlot(index); if (tempStack != null) return item.equals(tempStack.getItem()); return false; }
@SubscribeEvent // Assumed that crafting wasn't blocked public void onItemCraftedEvent(ItemCraftedEvent event) { if (event.player instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP) event.player; PlayerData player = PlayerStore.getInstance().getPlayer(playerMP.getUniqueID().toString()); Item item = (Item) ((ItemStack) event.player.openContainer.inventoryItemStacks.get(0)).getItem(); ArrayList<ItemPerk> entitylist = PerkStore.getPerksForItem(item.getUnlocalizedName()); boolean requiresPerk = false; if (entitylist != null) { requiresPerk = true; } for (ItemSkill skill : SkillStore.getInstance().getItemSkill()) { ArrayList<ItemXP> temp = skill.getExp(); for (int i = 0; i < temp.size(); i++) { Item compareItem = ((ItemXP) temp.get(i)).getItem(); if (item.equals(compareItem)) { if (requiresPerk) { if (PlayerHandler.hasPerk(player, entitylist)) { // if (event.entity.isDead){ PlayerHandler.awardXP(player, skill.name, temp.get(i).getXp(), playerMP); // } } // else // { // PlayerHandler.taskFail((EntityPlayer) playerMP); // event.player.closeScreen(); // } } else { // if (event.entity.isDead){ PlayerHandler.awardXP(player, skill.name, temp.get(i).getXp(), playerMP); // } } } } } } }