Search in sources :

Example 26 with TransportedItemStack

use of com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack in project Create by Creators-of-Create.

the class DepotRenderer method renderItemsOf.

public static void renderItemsOf(SmartTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay, DepotBehaviour depotBehaviour) {
    TransportedItemStack transported = depotBehaviour.heldItem;
    TransformStack msr = TransformStack.cast(ms);
    Vec3 itemPosition = VecHelper.getCenterOf(te.getBlockPos());
    ms.pushPose();
    ms.translate(.5f, 15 / 16f, .5f);
    if (transported != null)
        depotBehaviour.incoming.add(transported);
    // Render main items
    for (TransportedItemStack tis : depotBehaviour.incoming) {
        ms.pushPose();
        msr.nudge(0);
        float offset = Mth.lerp(partialTicks, tis.prevBeltPosition, tis.beltPosition);
        float sideOffset = Mth.lerp(partialTicks, tis.prevSideOffset, tis.sideOffset);
        if (tis.insertedFrom.getAxis().isHorizontal()) {
            Vec3 offsetVec = Vec3.atLowerCornerOf(tis.insertedFrom.getOpposite().getNormal()).scale(.5f - offset);
            ms.translate(offsetVec.x, offsetVec.y, offsetVec.z);
            boolean alongX = tis.insertedFrom.getClockWise().getAxis() == Axis.X;
            if (!alongX)
                sideOffset *= -1;
            ms.translate(alongX ? sideOffset : 0, 0, alongX ? 0 : sideOffset);
        }
        ItemStack itemStack = tis.stack;
        int angle = tis.angle;
        Random r = new Random(0);
        renderItem(ms, buffer, light, overlay, itemStack, angle, r, itemPosition);
        ms.popPose();
    }
    if (transported != null)
        depotBehaviour.incoming.remove(transported);
    // Render output items
    for (int i = 0; i < depotBehaviour.processingOutputBuffer.getSlots(); i++) {
        ItemStack stack = depotBehaviour.processingOutputBuffer.getStackInSlot(i);
        if (stack.isEmpty())
            continue;
        ms.pushPose();
        msr.nudge(i);
        boolean renderUpright = BeltHelper.isItemUpright(stack);
        msr.rotateY(360 / 8f * i);
        ms.translate(.35f, 0, 0);
        if (renderUpright)
            msr.rotateY(-(360 / 8f * i));
        Random r = new Random(i + 1);
        int angle = (int) (360 * r.nextFloat());
        renderItem(ms, buffer, light, overlay, stack, renderUpright ? angle + 90 : angle, r, itemPosition);
        ms.popPose();
    }
    ms.popPose();
}
Also used : TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) Random(java.util.Random) Vec3(net.minecraft.world.phys.Vec3) TransformStack(com.jozufozu.flywheel.util.transform.TransformStack) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

TransportedItemStack (com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack)26 ItemStack (net.minecraft.world.item.ItemStack)20 BlockState (net.minecraft.world.level.block.state.BlockState)8 Vec3 (net.minecraft.world.phys.Vec3)8 BlockPos (net.minecraft.core.BlockPos)6 Direction (net.minecraft.core.Direction)6 BeltInventory (com.simibubi.create.content.contraptions.relays.belt.transport.BeltInventory)3 ProcessingResult (com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult)3 TransportedItemStackHandlerBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour)3 TransportedResult (com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult)3 ArrayList (java.util.ArrayList)3 Random (java.util.Random)3 Entity (net.minecraft.world.entity.Entity)3 ItemEntity (net.minecraft.world.entity.item.ItemEntity)3 Level (net.minecraft.world.level.Level)3 TransformStack (com.jozufozu.flywheel.util.transform.TransformStack)2 Create (com.simibubi.create.Create)2 InWorldProcessing (com.simibubi.create.content.contraptions.processing.InWorldProcessing)2 BeltHelper (com.simibubi.create.content.contraptions.relays.belt.BeltHelper)2 List (java.util.List)2