use of convenientadditions.api.item.ICompostable in project ConvenientAdditions by Necr0.
the class ComposterItemStackHandler method insertItem.
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
int simulate_content = composter.getContentValue(stack);
stack = stack.copy();
while (!stack.isEmpty()) {
if (!(composter.content < ModConfigMisc.composter_capacity && composter.getContentValue(stack) > 0) || (simulate && simulate_content > ModConfigMisc.composter_capacity))
return stack;
if (!simulate) {
composter.content += composter.getContentValue(stack);
composter.processing = (composter.content >= ModConfigMisc.composter_progressContent);
if (stack.getItem() instanceof ICompostable && ((ICompostable) stack.getItem()).hasShroomSpores(stack))
composter.spores = true;
else if (stack.getItem() == Items.MUSHROOM_STEW || stack.getItem() == ItemBlock.getItemFromBlock(Blocks.RED_MUSHROOM) || stack.getItem() == ItemBlock.getItemFromBlock(Blocks.BROWN_MUSHROOM))
composter.spores = true;
composter.markDirty();
IBlockState state = composter.getWorld().getBlockState(composter.getPos());
composter.getWorld().notifyBlockUpdate(composter.getPos(), state, state, 2);
} else {
simulate_content += composter.getContentValue(stack);
}
stack.shrink(1);
}
return stack;
}
use of convenientadditions.api.item.ICompostable in project ConvenientAdditions by Necr0.
the class ComposterItemStackHandler method insertItem.
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
int simulate_content = composter.getContentValue(stack);
stack = stack.copy();
while (stack.stackSize != 0) {
if (!(composter.content < ModConfig.composter_capacity && composter.getContentValue(stack) > 0) || (simulate && simulate_content < ModConfig.composter_capacity))
return stack;
if (!simulate) {
composter.content += composter.getContentValue(stack);
composter.processing = (composter.content >= ModConfig.composter_progressContent);
if (stack.getItem() instanceof ICompostable && ((ICompostable) stack.getItem()).hasShroomSpores(stack))
composter.spores = true;
else if (stack.getItem() == Items.MUSHROOM_STEW || stack.getItem() == ItemBlock.getItemFromBlock(Blocks.RED_MUSHROOM) || stack.getItem() == ItemBlock.getItemFromBlock(Blocks.BROWN_MUSHROOM))
composter.spores = true;
composter.markDirty();
IBlockState state = composter.getWorld().getBlockState(composter.getPos());
composter.getWorld().notifyBlockUpdate(composter.getPos(), state, state, 2);
} else {
simulate_content += composter.getContentValue(stack);
}
stack.stackSize--;
}
return stack;
}
Aggregations