Search in sources :

Example 1 with ItemCruxiteArtifact

use of com.mraof.minestuck.item.ItemCruxiteArtifact in project Minestuck by mraof.

the class ContainerEditmode method updateInventory.

private void updateInventory() {
    ArrayList<ItemStack> itemList = new ArrayList<ItemStack>();
    SburbConnection c = SkaianetHandler.getClientConnection(ServerEditHandler.getData(player).getTarget());
    ArrayList<ItemStack> tools = new ArrayList<ItemStack>();
    // Fill list with tool items when implemented
    ArrayList<ItemStack> deployItems = DeployList.getItemList();
    Iterator<ItemStack> iter = deployItems.iterator();
    int playerTier = SburbHandler.availableTier(c.getClientIdentifier());
    while (iter.hasNext()) {
        ItemStack stack = iter.next();
        if (DeployList.getTier(stack) > playerTier)
            iter.remove();
        else if (DeployList.getSecondaryCost(stack) == null && c.givenItems()[DeployList.getOrdinal(stack)])
            iter.remove();
        else if (stack.getItem().equals(MinestuckItems.captchaCard) && AlchemyRecipeHandler.getDecodedItem(stack).getItem() instanceof ItemCruxiteArtifact)
            if (c.enteredGame())
                iter.remove();
            else
                stack.setTagCompound(AlchemyRecipeHandler.createCard(SburbHandler.getEntryItem(c.getClientIdentifier()), true).getTagCompound());
        else if (stack.getItem().equals(Item.getItemFromBlock(MinestuckBlocks.sburbMachine)) && stack.getMetadata() == 0) {
            NBTTagCompound nbt = new NBTTagCompound();
            nbt.setInteger("color", MinestuckPlayerData.getData(c.getClientIdentifier()).color);
            stack.setTagCompound(nbt);
        }
    }
    for (int i = 0; i < Math.max(tools.size(), deployItems.size()); i++) {
        itemList.add(i >= tools.size() ? ItemStack.EMPTY : tools.get(i));
        itemList.add(i >= deployItems.size() ? ItemStack.EMPTY : deployItems.get(i));
    }
    boolean changed = false;
    if (itemList.size() != this.items.size())
        changed = true;
    else
        for (int i = 0; i < itemList.size(); i++) if (!ItemStack.areItemStacksEqual(itemList.get(i), this.items.get(i))) {
            changed = true;
            break;
        }
    if (changed) {
        this.items = itemList;
        sendPacket();
    }
}
Also used : ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) ItemCruxiteArtifact(com.mraof.minestuck.item.ItemCruxiteArtifact) SburbConnection(com.mraof.minestuck.network.skaianet.SburbConnection)

Example 2 with ItemCruxiteArtifact

use of com.mraof.minestuck.item.ItemCruxiteArtifact in project Minestuck by mraof.

the class DeployList method cleanStack.

@Nonnull
private static ItemStack cleanStack(ItemStack stack) {
    if (stack.isEmpty())
        return ItemStack.EMPTY;
    stack = stack.copy();
    stack.setCount(1);
    if (!stack.hasTagCompound())
        stack.setTagCompound(new NBTTagCompound());
    else {
        stack.getTagCompound().removeTag("display");
        if (stack.getItem().equals(MinestuckItems.captchaCard) && AlchemyRecipeHandler.getDecodedItem(stack) != null && AlchemyRecipeHandler.getDecodedItem(stack).getItem() instanceof ItemCruxiteArtifact)
            stack = AlchemyRecipeHandler.createCard(new ItemStack(MinestuckItems.cruxiteApple), true);
        if (stack.getItem().equals(Item.getItemFromBlock(MinestuckBlocks.sburbMachine)))
            stack.getTagCompound().removeTag("color");
    }
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) ItemCruxiteArtifact(com.mraof.minestuck.item.ItemCruxiteArtifact) Nonnull(javax.annotation.Nonnull)

Aggregations

ItemCruxiteArtifact (com.mraof.minestuck.item.ItemCruxiteArtifact)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 SburbConnection (com.mraof.minestuck.network.skaianet.SburbConnection)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1