Search in sources :

Example 1 with BeltProcessingBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project createaddition by mrh0.

the class TeslaCoilTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    super.addBehaviours(behaviours);
    processingBehaviour = new BeltProcessingBehaviour(this).whenItemEnters((s, i) -> TeslaCoilBeltCallbacks.onItemReceived(s, i, this)).whileItemHeld((s, i) -> TeslaCoilBeltCallbacks.whenItemHeld(s, i, this));
    behaviours.add(processingBehaviour);
}
Also used : LivingEntity(net.minecraft.world.entity.LivingEntity) AABB(net.minecraft.world.phys.AABB) Config(com.mrh0.createaddition.config.Config) Direction(net.minecraft.core.Direction) BlockState(net.minecraft.world.level.block.state.BlockState) AllItems(com.simibubi.create.AllItems) ArrayList(java.util.ArrayList) CAItems(com.mrh0.createaddition.index.CAItems) ProcessingResult(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult) DamageSource(net.minecraft.world.damagesource.DamageSource) TransportedResult(com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult) CABlocks(com.mrh0.createaddition.index.CABlocks) CapabilityEnergy(net.minecraftforge.energy.CapabilityEnergy) TransportedItemStackHandlerBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour) CreateAddition(com.mrh0.createaddition.CreateAddition) TileEntityBehaviour(com.simibubi.create.foundation.tileEntity.TileEntityBehaviour) MobEffectInstance(net.minecraft.world.effect.MobEffectInstance) BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour) Player(net.minecraft.world.entity.player.Player) List(java.util.List) BaseElectricTileEntity(com.mrh0.createaddition.energy.BaseElectricTileEntity) IHaveGoggleInformation(com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation) BlockPos(net.minecraft.core.BlockPos) BlockEntityType(net.minecraft.world.level.block.entity.BlockEntityType) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) ItemStack(net.minecraft.world.item.ItemStack) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) AE2(com.mrh0.createaddition.compat.applied_energistics.AE2) ChargingChromaticCompound(com.mrh0.createaddition.item.ChargingChromaticCompound) CAEffects(com.mrh0.createaddition.index.CAEffects) BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour)

Example 2 with BeltProcessingBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.

the class SpoutTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    tank = SmartFluidTankBehaviour.single(this, 1000);
    behaviours.add(tank);
    beltProcessing = new BeltProcessingBehaviour(this).whenItemEnters(this::onItemReceived).whileItemHeld(this::whenItemHeld);
    behaviours.add(beltProcessing);
}
Also used : BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour)

Example 3 with BeltProcessingBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.

the class DepotBehaviour method tick.

@Override
public void tick() {
    super.tick();
    Level world = tileEntity.getLevel();
    for (Iterator<TransportedItemStack> iterator = incoming.iterator(); iterator.hasNext(); ) {
        TransportedItemStack ts = iterator.next();
        if (!tick(ts))
            continue;
        if (world.isClientSide && !tileEntity.isVirtual())
            continue;
        if (heldItem == null) {
            heldItem = ts;
        } else {
            if (!ItemHelper.canItemStackAmountsStack(heldItem.stack, ts.stack)) {
                Vec3 vec = VecHelper.getCenterOf(tileEntity.getBlockPos());
                Containers.dropItemStack(tileEntity.getLevel(), vec.x, vec.y + .5f, vec.z, ts.stack);
            } else {
                heldItem.stack.grow(ts.stack.getCount());
            }
        }
        iterator.remove();
        tileEntity.notifyUpdate();
    }
    if (heldItem == null)
        return;
    if (!tick(heldItem))
        return;
    BlockPos pos = tileEntity.getBlockPos();
    if (world.isClientSide)
        return;
    if (handleBeltFunnelOutput())
        return;
    BeltProcessingBehaviour processingBehaviour = TileEntityBehaviour.get(world, pos.above(2), BeltProcessingBehaviour.TYPE);
    if (processingBehaviour == null)
        return;
    if (!heldItem.locked && BeltProcessingBehaviour.isBlocked(world, pos))
        return;
    ItemStack previousItem = heldItem.stack;
    boolean wasLocked = heldItem.locked;
    ProcessingResult result = wasLocked ? processingBehaviour.handleHeldItem(heldItem, transportedHandler) : processingBehaviour.handleReceivedItem(heldItem, transportedHandler);
    if (result == ProcessingResult.REMOVE) {
        heldItem = null;
        tileEntity.sendData();
        return;
    }
    heldItem.locked = result == ProcessingResult.HOLD;
    if (heldItem.locked != wasLocked || !previousItem.equals(heldItem.stack, false))
        tileEntity.sendData();
}
Also used : TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) Vec3(net.minecraft.world.phys.Vec3) ProcessingResult(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult) Level(net.minecraft.world.level.Level) BlockPos(net.minecraft.core.BlockPos) BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour) TransportedItemStack(com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack) ItemStack(net.minecraft.world.item.ItemStack)

Example 4 with BeltProcessingBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.

the class BeltInventory method handleBeltProcessingAndCheckIfRemoved.

protected boolean handleBeltProcessingAndCheckIfRemoved(TransportedItemStack currentItem, float nextOffset, boolean noMovement) {
    int currentSegment = (int) currentItem.beltPosition;
    // Continue processing if held
    if (currentItem.locked) {
        BeltProcessingBehaviour processingBehaviour = getBeltProcessingAtSegment(currentSegment);
        TransportedItemStackHandlerBehaviour stackHandlerBehaviour = getTransportedItemStackHandlerAtSegment(currentSegment);
        if (stackHandlerBehaviour == null)
            return false;
        if (processingBehaviour == null) {
            currentItem.locked = false;
            belt.sendData();
            return false;
        }
        ProcessingResult result = processingBehaviour.handleHeldItem(currentItem, stackHandlerBehaviour);
        if (result == ProcessingResult.REMOVE)
            return true;
        if (result == ProcessingResult.HOLD)
            return false;
        currentItem.locked = false;
        belt.sendData();
        return false;
    }
    if (noMovement)
        return false;
    // See if any new belt processing catches the item
    if (currentItem.beltPosition > .5f || beltMovementPositive) {
        int firstUpcomingSegment = (int) (currentItem.beltPosition + (beltMovementPositive ? .5f : -.5f));
        int step = beltMovementPositive ? 1 : -1;
        for (int segment = firstUpcomingSegment; beltMovementPositive ? segment + .5f <= nextOffset : segment + .5f >= nextOffset; segment += step) {
            BeltProcessingBehaviour processingBehaviour = getBeltProcessingAtSegment(segment);
            TransportedItemStackHandlerBehaviour stackHandlerBehaviour = getTransportedItemStackHandlerAtSegment(segment);
            if (processingBehaviour == null)
                continue;
            if (stackHandlerBehaviour == null)
                continue;
            if (BeltProcessingBehaviour.isBlocked(belt.getLevel(), BeltHelper.getPositionForOffset(belt, segment)))
                continue;
            ProcessingResult result = processingBehaviour.handleReceivedItem(currentItem, stackHandlerBehaviour);
            if (result == ProcessingResult.REMOVE)
                return true;
            if (result == ProcessingResult.HOLD) {
                currentItem.beltPosition = segment + .5f + (beltMovementPositive ? 1 / 512f : -1 / 512f);
                currentItem.locked = true;
                belt.sendData();
                return false;
            }
        }
    }
    return false;
}
Also used : ProcessingResult(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult) BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour) TransportedItemStackHandlerBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour)

Example 5 with BeltProcessingBehaviour

use of com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour in project Create by Creators-of-Create.

the class DeployerTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    super.addBehaviours(behaviours);
    filtering = new FilteringBehaviour(this, new DeployerFilterSlot());
    behaviours.add(filtering);
    processingBehaviour = new BeltProcessingBehaviour(this).whenItemEnters((s, i) -> BeltDeployerCallbacks.onItemReceived(s, i, this)).whileItemHeld((s, i) -> BeltDeployerCallbacks.whenItemHeld(s, i, this));
    behaviours.add(processingBehaviour);
}
Also used : VecHelper(com.simibubi.create.foundation.utility.VecHelper) AABB(net.minecraft.world.phys.AABB) Direction(net.minecraft.core.Direction) Inventory(net.minecraft.world.entity.player.Inventory) Dist(net.minecraftforge.api.distmarker.Dist) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) TooltipHelper(com.simibubi.create.foundation.item.TooltipHelper) TransportedItemStackHandlerBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour) FACING(com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING) BlockHitResult(net.minecraft.world.phys.BlockHitResult) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) Capability(net.minecraftforge.common.capabilities.Capability) List(java.util.List) CompoundTag(net.minecraft.nbt.CompoundTag) BlockPos(net.minecraft.core.BlockPos) BlockEntityType(net.minecraft.world.level.block.entity.BlockEntityType) ItemStackHandler(net.minecraftforge.items.ItemStackHandler) PartialModel(com.jozufozu.flywheel.core.PartialModel) ItemStack(net.minecraft.world.item.ItemStack) RecipeWrapper(net.minecraftforge.items.wrapper.RecipeWrapper) Tag(net.minecraft.nbt.Tag) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) KineticTileEntity(com.simibubi.create.content.contraptions.base.KineticTileEntity) BlockState(net.minecraft.world.level.block.state.BlockState) FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) ServerLevel(net.minecraft.server.level.ServerLevel) ArrayList(java.util.ArrayList) LazyOptional(net.minecraftforge.common.util.LazyOptional) ServerPlayer(net.minecraft.server.level.ServerPlayer) Container(net.minecraft.world.Container) ClipContext(net.minecraft.world.level.ClipContext) AllRecipeTypes(com.simibubi.create.AllRecipeTypes) SequencedAssemblyRecipe(com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe) AllBlocks(com.simibubi.create.AllBlocks) Nullable(javax.annotation.Nullable) SandPaperItem(com.simibubi.create.content.curiosities.tools.SandPaperItem) AllBlockPartials(com.simibubi.create.AllBlockPartials) TileEntityBehaviour(com.simibubi.create.foundation.tileEntity.TileEntityBehaviour) Component(net.minecraft.network.chat.Component) SandPaperInv(com.simibubi.create.content.curiosities.tools.SandPaperPolishingRecipe.SandPaperInv) AllTriggers(com.simibubi.create.foundation.advancement.AllTriggers) BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour) Fluid(net.minecraft.world.level.ClipContext.Fluid) Block(net.minecraft.world.level.ClipContext.Block) MinecraftForge(net.minecraftforge.common.MinecraftForge) Recipe(net.minecraft.world.item.crafting.Recipe) Vec3(net.minecraft.world.phys.Vec3) NBTHelper(com.simibubi.create.foundation.utility.NBTHelper) InteractionHand(net.minecraft.world.InteractionHand) Mth(net.minecraft.util.Mth) LerpedFloat(com.simibubi.create.foundation.utility.animation.LerpedFloat) ListTag(net.minecraft.nbt.ListTag) FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) BeltProcessingBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour)

Aggregations

BeltProcessingBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour)6 TransportedItemStackHandlerBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour)4 BlockPos (net.minecraft.core.BlockPos)4 ItemStack (net.minecraft.world.item.ItemStack)4 TileEntityBehaviour (com.simibubi.create.foundation.tileEntity.TileEntityBehaviour)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BlockEntityType (net.minecraft.world.level.block.entity.BlockEntityType)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 AABB (net.minecraft.world.phys.AABB)3 Vec3 (net.minecraft.world.phys.Vec3)3 AllBlocks (com.simibubi.create.AllBlocks)2 AllRecipeTypes (com.simibubi.create.AllRecipeTypes)2 SequencedAssemblyRecipe (com.simibubi.create.content.contraptions.itemAssembly.SequencedAssemblyRecipe)2 TransportedItemStack (com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack)2 AllTriggers (com.simibubi.create.foundation.advancement.AllTriggers)2 ProcessingResult (com.simibubi.create.foundation.tileEntity.behaviour.belt.BeltProcessingBehaviour.ProcessingResult)2 NBTHelper (com.simibubi.create.foundation.utility.NBTHelper)2 VecHelper (com.simibubi.create.foundation.utility.VecHelper)2 CompoundTag (net.minecraft.nbt.CompoundTag)2