Search in sources :

Example 1 with BasinTileEntity

use of com.simibubi.create.content.contraptions.processing.BasinTileEntity in project Create by Creators-of-Create.

the class BlazeBurnerBlock method onPlace.

@Override
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState p_220082_4_, boolean p_220082_5_) {
    if (world.isClientSide)
        return;
    BlockEntity tileEntity = world.getBlockEntity(pos.above());
    if (!(tileEntity instanceof BasinTileEntity))
        return;
    BasinTileEntity basin = (BasinTileEntity) tileEntity;
    basin.notifyChangeOfContents();
}
Also used : BasinTileEntity(com.simibubi.create.content.contraptions.processing.BasinTileEntity) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 2 with BasinTileEntity

use of com.simibubi.create.content.contraptions.processing.BasinTileEntity in project Create by Creators-of-Create.

the class MechanicalMixerTileEntity method getMatchingRecipes.

@Override
protected List<Recipe<?>> getMatchingRecipes() {
    List<Recipe<?>> matchingRecipes = super.getMatchingRecipes();
    Optional<BasinTileEntity> basin = getBasin();
    if (!basin.isPresent())
        return matchingRecipes;
    IItemHandler availableItems = basin.get().getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
    if (availableItems == null)
        return matchingRecipes;
    for (int i = 0; i < availableItems.getSlots(); i++) {
        ItemStack stack = availableItems.getStackInSlot(i);
        if (stack.isEmpty())
            continue;
        List<MixingRecipe> list = PotionMixingRecipes.BY_ITEM.get(stack.getItem());
        if (list == null)
            continue;
        for (MixingRecipe mixingRecipe : list) if (matchBasinRecipe(mixingRecipe))
            matchingRecipes.add(mixingRecipe);
    }
    return matchingRecipes;
}
Also used : BasinTileEntity(com.simibubi.create.content.contraptions.processing.BasinTileEntity) IItemHandler(net.minecraftforge.items.IItemHandler) IShapedRecipe(net.minecraftforge.common.crafting.IShapedRecipe) ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) CraftingRecipe(net.minecraft.world.item.crafting.CraftingRecipe) Recipe(net.minecraft.world.item.crafting.Recipe) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with BasinTileEntity

use of com.simibubi.create.content.contraptions.processing.BasinTileEntity in project Create by Creators-of-Create.

the class MechanicalPressTileEntity method applyCompactingOnBasin.

protected void applyCompactingOnBasin() {
    if (level.isClientSide)
        return;
    pressedItems.clear();
    applyBasinRecipe();
    Optional<BasinTileEntity> basin = getBasin();
    if (basin.isPresent()) {
        SmartInventory inputs = basin.get().getInputInventory();
        for (int slot = 0; slot < inputs.getSlots(); slot++) {
            ItemStack stackInSlot = inputs.getItem(slot);
            if (stackInSlot.isEmpty())
                continue;
            pressedItems.add(stackInSlot);
        }
    }
    sendData();
}
Also used : BasinTileEntity(com.simibubi.create.content.contraptions.processing.BasinTileEntity) SmartInventory(com.simibubi.create.foundation.item.SmartInventory) ItemStack(net.minecraft.world.item.ItemStack)

Example 4 with BasinTileEntity

use of com.simibubi.create.content.contraptions.processing.BasinTileEntity in project Create by Creators-of-Create.

the class MechanicalMixerTileEntity method renderParticles.

public void renderParticles() {
    Optional<BasinTileEntity> basin = getBasin();
    if (!basin.isPresent() || level == null)
        return;
    for (SmartInventory inv : basin.get().getInvs()) {
        for (int slot = 0; slot < inv.getSlots(); slot++) {
            ItemStack stackInSlot = inv.getItem(slot);
            if (stackInSlot.isEmpty())
                continue;
            ItemParticleOption data = new ItemParticleOption(ParticleTypes.ITEM, stackInSlot);
            spillParticle(data);
        }
    }
    for (SmartFluidTankBehaviour behaviour : basin.get().getTanks()) {
        if (behaviour == null)
            continue;
        for (TankSegment tankSegment : behaviour.getTanks()) {
            if (tankSegment.isEmpty(0))
                continue;
            spillParticle(FluidFX.getFluidParticle(tankSegment.getRenderedFluid()));
        }
    }
}
Also used : BasinTileEntity(com.simibubi.create.content.contraptions.processing.BasinTileEntity) SmartInventory(com.simibubi.create.foundation.item.SmartInventory) SmartFluidTankBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour) ItemParticleOption(net.minecraft.core.particles.ItemParticleOption) TankSegment(com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment) ItemStack(net.minecraft.world.item.ItemStack)

Example 5 with BasinTileEntity

use of com.simibubi.create.content.contraptions.processing.BasinTileEntity in project Create by Creators-of-Create.

the class MechanicalPressTileEntity method tick.

@Override
public void tick() {
    super.tick();
    if (!running || level == null) {
        if (hasLevel() && !level.isClientSide) {
            if (getSpeed() == 0)
                return;
            if (entityScanCooldown > 0)
                entityScanCooldown--;
            if (entityScanCooldown <= 0) {
                entityScanCooldown = ENTITY_SCAN;
                if (TileEntityBehaviour.get(level, worldPosition.below(2), TransportedItemStackHandlerBehaviour.TYPE) != null)
                    return;
                if (AllBlocks.BASIN.has(level.getBlockState(worldPosition.below(2))))
                    return;
                for (ItemEntity itemEntity : level.getEntitiesOfClass(ItemEntity.class, new AABB(worldPosition.below()).deflate(.125f))) {
                    if (!itemEntity.isAlive() || !itemEntity.isOnGround())
                        continue;
                    ItemStack stack = itemEntity.getItem();
                    Optional<PressingRecipe> recipe = getRecipe(stack);
                    if (!recipe.isPresent())
                        continue;
                    start(Mode.WORLD);
                    return;
                }
            }
        }
        return;
    }
    if (level.isClientSide && runningTicks == -CYCLE / 2) {
        prevRunningTicks = CYCLE / 2;
        return;
    }
    if (runningTicks == CYCLE / 2 && getSpeed() != 0) {
        if (inWorld())
            applyPressingInWorld();
        if (onBasin())
            applyCompactingOnBasin();
        if (level.getBlockState(worldPosition.below(2)).getSoundType() == SoundType.WOOL)
            AllSoundEvents.MECHANICAL_PRESS_ACTIVATION_ON_BELT.playOnServer(level, worldPosition);
        else
            AllSoundEvents.MECHANICAL_PRESS_ACTIVATION.playOnServer(level, worldPosition, .5f, .75f + (Math.abs(getSpeed()) / 1024f));
        if (!level.isClientSide)
            sendData();
    }
    if (!level.isClientSide && runningTicks > CYCLE) {
        finished = true;
        running = false;
        if (onBasin() && matchBasinRecipe(currentRecipe) && getBasin().filter(BasinTileEntity::canContinueProcessing).isPresent())
            startProcessingBasin();
        else
            basinChecker.scheduleUpdate();
        pressedItems.clear();
        sendData();
        return;
    }
    prevRunningTicks = runningTicks;
    runningTicks += getRunningTickSpeed();
    if (prevRunningTicks < CYCLE / 2 && runningTicks >= CYCLE / 2) {
        runningTicks = CYCLE / 2;
        // Pause the ticks until a packet is received
        if (level.isClientSide && !isVirtual())
            runningTicks = -(CYCLE / 2);
    }
}
Also used : BasinTileEntity(com.simibubi.create.content.contraptions.processing.BasinTileEntity) ItemEntity(net.minecraft.world.entity.item.ItemEntity) ItemStack(net.minecraft.world.item.ItemStack) AABB(net.minecraft.world.phys.AABB)

Aggregations

BasinTileEntity (com.simibubi.create.content.contraptions.processing.BasinTileEntity)6 ItemStack (net.minecraft.world.item.ItemStack)4 SmartInventory (com.simibubi.create.foundation.item.SmartInventory)2 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)2 ProcessingRecipe (com.simibubi.create.content.contraptions.processing.ProcessingRecipe)1 SmartFluidTankBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour)1 TankSegment (com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment)1 ItemParticleOption (net.minecraft.core.particles.ItemParticleOption)1 ItemEntity (net.minecraft.world.entity.item.ItemEntity)1 CraftingRecipe (net.minecraft.world.item.crafting.CraftingRecipe)1 Recipe (net.minecraft.world.item.crafting.Recipe)1 AABB (net.minecraft.world.phys.AABB)1 Vec3 (net.minecraft.world.phys.Vec3)1 IShapedRecipe (net.minecraftforge.common.crafting.IShapedRecipe)1 IItemHandler (net.minecraftforge.items.IItemHandler)1