use of net.silentchaos512.gems.item.ItemHoldingGem in project SilentGems by SilentChaos512.
the class RecipeHoldingGemSetBlock method getCraftingResult.
@SuppressWarnings("deprecation")
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack holdingGem = StackHelper.empty();
ItemStack blockStack = StackHelper.empty();
ItemStack stack;
for (int i = 0; i < inv.getSizeInventory(); ++i) {
stack = inv.getStackInSlot(i);
if (StackHelper.isValid(stack)) {
if (stack.getItem() instanceof ItemHoldingGem) {
if (StackHelper.isValid(holdingGem) || stack.getItemDamage() < stack.getMaxDamage())
return StackHelper.empty();
holdingGem = stack;
} else if (stack.getItem() instanceof ItemBlock) {
if (StackHelper.isValid(blockStack))
return StackHelper.empty();
blockStack = stack;
}
}
}
if (StackHelper.isEmpty(holdingGem) || StackHelper.isEmpty(blockStack))
return StackHelper.empty();
ItemStack result = StackHelper.safeCopy(holdingGem);
Block block = ((ItemBlock) blockStack.getItem()).block;
int meta = blockStack.getItemDamage();
IBlockState state = block.getStateFromMeta(meta);
((ItemHoldingGem) result.getItem()).setBlockPlaced(result, state);
result.setItemDamage(result.getMaxDamage() - 1);
return result;
}
use of net.silentchaos512.gems.item.ItemHoldingGem 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;
}
Aggregations