Search in sources :

Example 1 with SandPaperPolishingRecipe

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();
}
Also used : SoundSource(net.minecraft.sounds.SoundSource) TransportedItemStackHandlerBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour) SandPaperPolishingRecipe(com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe) InWorldProcessing(com.simibubi.create.content.contraptions.processing.InWorldProcessing) Direction(net.minecraft.core.Direction) FACING(com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING) State(com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State) BlockState(net.minecraft.world.level.block.state.BlockState) BeltHelper(com.simibubi.create.content.contraptions.relays.belt.BeltHelper) Collectors(java.util.stream.Collectors) Mode(com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode) List(java.util.List) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) Create(com.simibubi.create.Create) BlockPos(net.minecraft.core.BlockPos) Recipe(net.minecraft.world.item.crafting.Recipe) ProcessingResult(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) TransportedResult(com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult) SoundEvents(net.minecraft.sounds.SoundEvents) InteractionHand(net.minecraft.world.InteractionHand) ItemStack(net.minecraft.world.item.ItemStack) Level(net.minecraft.world.level.Level) AllSoundEvents(com.simibubi.create.AllSoundEvents) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) SandPaperPolishingRecipe(com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe) BlockPos(net.minecraft.core.BlockPos) Level(net.minecraft.world.level.Level) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

AllSoundEvents (com.simibubi.create.AllSoundEvents)1 Create (com.simibubi.create.Create)1 FACING (com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING)1 Mode (com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode)1 State (com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State)1 InWorldProcessing (com.simibubi.create.content.contraptions.processing.InWorldProcessing)1 BeltHelper (com.simibubi.create.content.contraptions.relays.belt.BeltHelper)1 TransportedItemStack (com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack)1 SandPaperPolishingRecipe (com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe)1 ProcessingResult (com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult)1 TransportedItemStackHandlerBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour)1 TransportedResult (com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 BlockPos (net.minecraft.core.BlockPos)1 Direction (net.minecraft.core.Direction)1 SoundEvents (net.minecraft.sounds.SoundEvents)1 SoundSource (net.minecraft.sounds.SoundSource)1 InteractionHand (net.minecraft.world.InteractionHand)1 ItemStack (net.minecraft.world.item.ItemStack)1