use of com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe in project Create by Creators-of-Create.
the class BeltDeployerCallbacks method activate.
public static void activate(TransportedItemStack transported, TransportedItemStackHandlerBehaviour handler, DeployerTileEntity deployerTileEntity, Recipe<?> recipe) {
List<TransportedItemStack> collect = InWorldProcessing.applyRecipeOn(ItemHandlerHelper.copyStackWithSize(transported.stack, 1), recipe).stream().map(stack -> {
TransportedItemStack copy = transported.copy();
boolean centered = BeltHelper.isItemUpright(stack);
copy.stack = stack;
copy.locked = true;
copy.angle = centered ? 180 : Create.RANDOM.nextInt(360);
return copy;
}).map(t -> {
t.locked = false;
return t;
}).collect(Collectors.toList());
TransportedItemStack left = transported.copy();
deployerTileEntity.player.spawnedItemEffects = transported.stack.copy();
left.stack.shrink(1);
if (collect.isEmpty())
handler.handleProcessingOnItem(transported, TransportedResult.convertTo(left));
else
handler.handleProcessingOnItem(transported, TransportedResult.convertToAndLeaveHeld(collect, left));
ItemStack heldItem = deployerTileEntity.player.getMainHandItem();
boolean unbreakable = heldItem.hasTag() && heldItem.getTag().getBoolean("Unbreakable");
boolean keepHeld = recipe instanceof DeployerApplicationRecipe && ((DeployerApplicationRecipe) recipe).shouldKeepHeldItem();
if (!unbreakable && !keepHeld) {
if (heldItem.isDamageableItem())
heldItem.hurtAndBreak(1, deployerTileEntity.player, s -> s.broadcastBreakEvent(InteractionHand.MAIN_HAND));
else
heldItem.shrink(1);
}
BlockPos pos = deployerTileEntity.getBlockPos();
Level world = deployerTileEntity.getLevel();
if (heldItem.isEmpty())
world.playSound(null, pos, SoundEvents.ITEM_BREAK, SoundSource.BLOCKS, .25f, 1);
world.playSound(null, pos, SoundEvents.ITEM_PICKUP, SoundSource.BLOCKS, .25f, .75f);
if (recipe instanceof SandPaperPolishingRecipe)
AllSoundEvents.SANDING_SHORT.playOnServer(world, pos, .35f, 1f);
deployerTileEntity.sendData();
}
Aggregations