Search in sources :

Example 1 with ItemChaosGem

use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.

the class MessageToggleChaosGem method handleMessage.

@Override
public IMessage handleMessage(MessageContext context) {
    if (context.side != Side.SERVER)
        return null;
    EntityPlayer player = context.getServerHandler().player;
    Predicate<ItemStack> predicate = s -> s.getItem() instanceof ItemChaosGem;
    ItemStackList stacks = BaublesCompat.getBaubles(player, predicate);
    stacks.addAll(PlayerHelper.getNonEmptyStacks(player, predicate));
    for (ItemStack stack : stacks) {
        if (stack.getItem() instanceof ItemChaosGem) {
            ItemChaosGem item = (ItemChaosGem) stack.getItem();
            item.setEnabled(stack, !item.isEnabled(stack));
            if (item.isEnabled(stack))
                item.applyEffects(stack, player);
            else
                item.removeEffects(stack, player);
            if (!all)
                return null;
        }
    }
    return null;
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemStackList(net.silentchaos512.lib.collection.ItemStackList) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) Predicate(com.google.common.base.Predicate) Side(net.minecraftforge.fml.relauncher.Side) EntityPlayer(net.minecraft.entity.player.EntityPlayer) IMessage(net.minecraftforge.fml.common.network.simpleimpl.IMessage) Message(net.silentchaos512.gems.network.Message) PlayerHelper(net.silentchaos512.lib.util.PlayerHelper) BaublesCompat(net.silentchaos512.gems.compat.BaublesCompat) ItemChaosGem(net.silentchaos512.gems.item.ItemChaosGem) ItemStackList(net.silentchaos512.lib.collection.ItemStackList) ItemChaosGem(net.silentchaos512.gems.item.ItemChaosGem) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemChaosGem

use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.

the class RecipeChaosGemUpgrade method getCraftingResult.

@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack chaosGem = StackHelper.empty();
    // Find the Chaos Gem.
    for (ItemStack stack : getNonEmptyStacks(inv)) {
        if (stack.getItem() instanceof ItemChaosGem) {
            chaosGem = StackHelper.safeCopy(stack);
        }
    }
    // Found Chaos Gem?
    if (StackHelper.isEmpty(chaosGem)) {
        return StackHelper.empty();
    }
    ItemChaosGem itemGem = (ItemChaosGem) chaosGem.getItem();
    // Find runes and apply them.
    for (ItemStack stack : getNonEmptyStacks(inv)) {
        if (stack.getItem() instanceof ItemChaosRune) {
            ItemChaosRune itemRune = (ItemChaosRune) stack.getItem();
            if (!itemGem.addBuff(chaosGem, itemRune.getBuff(stack)))
                return StackHelper.empty();
        }
    }
    return chaosGem;
}
Also used : ItemChaosGem(net.silentchaos512.gems.item.ItemChaosGem) ItemChaosRune(net.silentchaos512.gems.item.ItemChaosRune) ItemStack(net.minecraft.item.ItemStack)

Example 3 with ItemChaosGem

use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.

the class BlockChaosPlinth method clOnBlockActivated.

@Override
protected boolean clOnBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack heldItem = player.getHeldItem(hand);
    TileEntity t = world.getTileEntity(pos);
    if (t != null && t instanceof TileChaosPlinth) {
        TileChaosPlinth tile = (TileChaosPlinth) t;
        ItemStack currentGem = tile.getStackInSlot(0);
        if (StackHelper.isValid(heldItem) && heldItem.getItem() instanceof ItemChaosGem) {
            player.setHeldItem(hand, currentGem);
            tile.setInventorySlotContents(0, heldItem);
            return true;
        } else if (StackHelper.isValid(currentGem) && StackHelper.isEmpty(heldItem)) {
        // TODO
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ItemChaosGem(net.silentchaos512.gems.item.ItemChaosGem) ItemStack(net.minecraft.item.ItemStack) TileChaosPlinth(net.silentchaos512.gems.tile.TileChaosPlinth)

Example 4 with ItemChaosGem

use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.

the class RecipeChaosGemUpgrade method matches.

@Override
public boolean matches(InventoryCrafting inv, World world) {
    int countGem = 0;
    int countRune = 0;
    // Count number of chaos gems and chaos runes.
    for (ItemStack stack : getNonEmptyStacks(inv)) {
        // Chaos Gem
        if (stack.getItem() instanceof ItemChaosGem)
            ++countGem;
        else // Chaos Rune
        if (stack.getItem() instanceof ItemChaosRune)
            ++countRune;
        else
            return false;
    }
    // Must have only one chaos gem and one or more chaos runes.
    return countGem == 1 && countRune > 0;
}
Also used : ItemChaosGem(net.silentchaos512.gems.item.ItemChaosGem) ItemChaosRune(net.silentchaos512.gems.item.ItemChaosRune) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemChaosGem

use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.

the class TileChaosPlinth method update.

@Override
public void update() {
    if (world.isRemote)
        return;
    // Get the Chaos Gem (if any)
    ItemStack stack = getStackInSlot(0);
    if (StackHelper.isEmpty(stack) || !(stack.getItem() instanceof ItemChaosGem))
        return;
    ItemChaosGem item = (ItemChaosGem) stack.getItem();
// TODO
}
Also used : ItemChaosGem(net.silentchaos512.gems.item.ItemChaosGem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)5 ItemChaosGem (net.silentchaos512.gems.item.ItemChaosGem)5 ItemChaosRune (net.silentchaos512.gems.item.ItemChaosRune)2 Predicate (com.google.common.base.Predicate)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IMessage (net.minecraftforge.fml.common.network.simpleimpl.IMessage)1 MessageContext (net.minecraftforge.fml.common.network.simpleimpl.MessageContext)1 Side (net.minecraftforge.fml.relauncher.Side)1 BaublesCompat (net.silentchaos512.gems.compat.BaublesCompat)1 Message (net.silentchaos512.gems.network.Message)1 TileChaosPlinth (net.silentchaos512.gems.tile.TileChaosPlinth)1 ItemStackList (net.silentchaos512.lib.collection.ItemStackList)1 PlayerHelper (net.silentchaos512.lib.util.PlayerHelper)1