use of betterwithaddons.crafting.manager.CraftingManagerNet in project BetterWithAddons by DaedalusGame.
the class TileEntityNettedScreen method captureDroppedItems.
private boolean captureDroppedItems() {
List<EntityItem> items = this.getCaptureItems(world, pos);
if (items.size() > 0) {
for (EntityItem item : items) {
ItemStack stack = item.getItem();
if (stack.getItem() == Item.getItemFromBlock(Blocks.SAND))
handleSandCase(item);
}
CraftingManagerNet manager = getCraftingManager(getSifterType());
if (manager != null) {
NetRecipe recipe = manager.getMostValidRecipe(items, getSandCount());
if (recipe != null) {
List<ItemStack> ret = recipe.getOutput();
if (ret != null && ret.size() > 0) {
ItemUtil.consumeItem(items, recipe.input);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
for (int i = 0; i < ret.size(); i++) {
ItemStack item = ret.get(i);
if (item.isEmpty())
continue;
EntityItem result = new EntityItem(world, pos.getX() + 0.5f, pos.getY() + (i % 2 == 0 ? 1.2f : -0.5f), pos.getZ() + 0.5f, item.copy());
result.setDefaultPickupDelay();
if (!world.isRemote) {
world.spawnEntity(result);
}
}
if (recipe.getSandRequired() > 0)
increaseSandCount(-recipe.getSandRequired());
return true;
}
}
}
}
return false;
}
Aggregations