Search in sources :

Example 1 with ItemBlockPlacer

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

the class GemsCommonEvents method onItemPickup.

@SubscribeEvent
public void onItemPickup(EntityItemPickupEvent event) {
    ItemStack entityStack = event.getItem().getEntityItem();
    if (entityStack.getItem() instanceof ItemBlock) {
        for (ItemStack stack : PlayerHelper.getNonEmptyStacks(event.getEntityPlayer())) {
            if (stack.getItem() instanceof ItemBlockPlacer) {
                ItemBlockPlacer itemPlacer = (ItemBlockPlacer) stack.getItem();
                IBlockState state = ((ItemBlock) entityStack.getItem()).block.getStateFromMeta(entityStack.getItemDamage());
                if (state.equals(itemPlacer.getBlockPlaced(stack))) {
                    // event.getItem().setDead();
                    break;
                }
            }
        }
    }
}
Also used : ItemBlockPlacer(net.silentchaos512.gems.item.ItemBlockPlacer) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with ItemBlockPlacer

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

the class RecipeHoldingGemSetBlock method matches.

@Override
public boolean matches(InventoryCrafting inv, World world) {
    int countGem = 0;
    int countBlock = 0;
    for (ItemStack stack : getNonEmptyStacks(inv)) {
        // Empty holding gem
        Item item = stack.getItem();
        if (item instanceof ItemHoldingGem && ((ItemBlockPlacer) item).getRemainingBlocks(stack) == 0)
            ++countGem;
        else // Block item
        if (item instanceof ItemBlock)
            ++countBlock;
        else
            return false;
    }
    return countGem == 1 && countBlock == 1;
}
Also used : ItemBlockPlacer(net.silentchaos512.gems.item.ItemBlockPlacer) Item(net.minecraft.item.Item) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) ItemHoldingGem(net.silentchaos512.gems.item.ItemHoldingGem)

Aggregations

ItemBlock (net.minecraft.item.ItemBlock)2 ItemStack (net.minecraft.item.ItemStack)2 ItemBlockPlacer (net.silentchaos512.gems.item.ItemBlockPlacer)2 IBlockState (net.minecraft.block.state.IBlockState)1 Item (net.minecraft.item.Item)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 ItemHoldingGem (net.silentchaos512.gems.item.ItemHoldingGem)1