Search in sources :

Example 51 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class WorkableTieredMetaTileEntity method canInputFluid.

protected boolean canInputFluid(FluidStack inputFluid) {
    RecipeMap<?> recipeMap = workable.getRecipeMap();
    if (recipeMap.canInputFluidForce(inputFluid.getFluid()))
        // if recipe map forces input of given fluid, return true
        return true;
    Set<Recipe> matchingRecipes = null;
    for (IFluidTank fluidTank : importFluids) {
        FluidStack fluidInTank = fluidTank.getFluid();
        if (fluidInTank != null) {
            if (matchingRecipes == null) {
                // if we didn't have a list of recipes with any fluids, obtain it from first tank with fluid
                matchingRecipes = new HashSet<>(recipeMap.getRecipesForFluid(fluidInTank));
            } else {
                // retain recipes which use the fluid in this tank
                matchingRecipes.retainAll(recipeMap.getRecipesForFluid(fluidInTank));
            }
        }
    }
    if (matchingRecipes == null) {
        // if all tanks are empty, generally fluid can be inserted if there are recipes for it
        return !recipeMap.getRecipesForFluid(inputFluid).isEmpty();
    } else {
        matchingRecipes.retainAll(recipeMap.getRecipesForFluid(inputFluid));
        return !matchingRecipes.isEmpty();
    }
}
Also used : Recipe(gregtech.api.recipes.Recipe) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 52 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class TricorderBehavior method getScannerInfo.

public List<ITextComponent> getScannerInfo(EntityPlayer player, World world, BlockPos pos) {
    int energyCost = 100;
    List<ITextComponent> list = new ArrayList<>();
    TileEntity tileEntity = world.getTileEntity(pos);
    Block block = world.getBlockState(pos).getBlock();
    // coordinates of the block
    list.add(new TextComponentTranslation("behavior.tricorder.position", new TextComponentTranslation(GTUtility.formatNumbers(pos.getX())).setStyle(new Style().setColor(TextFormatting.AQUA)), new TextComponentTranslation(GTUtility.formatNumbers(pos.getY())).setStyle(new Style().setColor(TextFormatting.AQUA)), new TextComponentTranslation(GTUtility.formatNumbers(pos.getZ())).setStyle(new Style().setColor(TextFormatting.AQUA)), new TextComponentTranslation(GTUtility.formatNumbers(world.provider.getDimension())).setStyle(new Style().setColor(TextFormatting.AQUA))));
    // hardness and blast resistance
    list.add(new TextComponentTranslation("behavior.tricorder.block_hardness", new TextComponentTranslation(GTUtility.formatNumbers(block.blockHardness)).setStyle(new Style().setColor(TextFormatting.YELLOW)), new TextComponentTranslation(GTUtility.formatNumbers(block.getExplosionResistance(player))).setStyle(new Style().setColor(TextFormatting.YELLOW))));
    MetaTileEntity metaTileEntity;
    if (tileEntity instanceof MetaTileEntityHolder) {
        metaTileEntity = ((MetaTileEntityHolder) tileEntity).getMetaTileEntity();
        if (metaTileEntity == null)
            return list;
        // name of the machine
        list.add(new TextComponentTranslation("behavior.tricorder.block_name", new TextComponentTranslation(LocalizationUtils.format(metaTileEntity.getMetaFullName())).setStyle(new Style().setColor(TextFormatting.BLUE)), new TextComponentTranslation(GTUtility.formatNumbers(GregTechAPI.MTE_REGISTRY.getIdByObjectName(metaTileEntity.metaTileEntityId))).setStyle(new Style().setColor(TextFormatting.BLUE))));
        list.add(new TextComponentTranslation("behavior.tricorder.divider"));
        // fluid tanks
        FluidTankList tanks = metaTileEntity.getImportFluids();
        int tankIndex = 0;
        boolean allTanksEmpty = true;
        if (tanks != null && !tanks.getFluidTanks().isEmpty()) {
            energyCost += 500;
            for (int i = 0; i < tanks.getFluidTanks().size(); i++) {
                IFluidTank tank = tanks.getTankAt(i);
                if (tank.getFluid() == null)
                    continue;
                allTanksEmpty = false;
                list.add(new TextComponentTranslation("behavior.tricorder.tank", i, new TextComponentTranslation(GTUtility.formatNumbers(tank.getFluid().amount)).setStyle(new Style().setColor(TextFormatting.GREEN)), new TextComponentTranslation(GTUtility.formatNumbers(tank.getCapacity())).setStyle(new Style().setColor(TextFormatting.YELLOW)), new TextComponentTranslation(tank.getFluid().getLocalizedName()).setStyle(new Style().setColor(TextFormatting.GOLD))));
            }
            tankIndex += tanks.getFluidTanks().size();
        }
        tanks = metaTileEntity.getExportFluids();
        if (tanks != null && !tanks.getFluidTanks().isEmpty()) {
            energyCost += 500;
            for (int i = 0; i < tanks.getFluidTanks().size(); i++) {
                IFluidTank tank = tanks.getTankAt(i);
                if (tank.getFluid() == null)
                    continue;
                allTanksEmpty = false;
                list.add(new TextComponentTranslation("behavior.tricorder.tank", tankIndex + i, new TextComponentTranslation(GTUtility.formatNumbers(tank.getFluid().amount)).setStyle(new Style().setColor(TextFormatting.GREEN)), new TextComponentTranslation(GTUtility.formatNumbers(tank.getCapacity())).setStyle(new Style().setColor(TextFormatting.YELLOW)), new TextComponentTranslation(tank.getFluid().getLocalizedName()).setStyle(new Style().setColor(TextFormatting.GOLD))));
            }
        }
        if (allTanksEmpty && (metaTileEntity.getImportFluids() != null || metaTileEntity.getExportFluids() != null))
            list.add(new TextComponentTranslation("behavior.tricorder.tanks_empty"));
        // sound muffling
        energyCost += 500;
        if (metaTileEntity.isMuffled())
            list.add(new TextComponentTranslation("behavior.tricorder.muffled").setStyle(new Style().setColor(TextFormatting.GREEN)));
        // workable progress info
        IWorkable workable = metaTileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_WORKABLE, null);
        if (workable != null) {
            if (!workable.isWorkingEnabled()) {
                list.add(new TextComponentTranslation("behavior.tricorder.machine_disabled").setStyle(new Style().setColor(TextFormatting.RED)));
            }
            // if (workable.wasShutdown()) { //todo
            // list.add(new TextComponentTranslation("behavior.tricorder.machine_power_loss").setStyle(new Style().setColor(TextFormatting.RED)));
            // }
            energyCost += 400;
            if (workable.getMaxProgress() > 0) {
                list.add(new TextComponentTranslation("behavior.tricorder.machine_progress", new TextComponentTranslation(GTUtility.formatNumbers(workable.getProgress())).setStyle(new Style().setColor(TextFormatting.GREEN)), new TextComponentTranslation(GTUtility.formatNumbers(workable.getMaxProgress())).setStyle(new Style().setColor(TextFormatting.YELLOW))));
            }
        }
        // energy container
        IEnergyContainer container = metaTileEntity.getCapability(GregtechCapabilities.CAPABILITY_ENERGY_CONTAINER, null);
        if (container != null && container.getEnergyCapacity() > 0) {
            list.add(new TextComponentTranslation("behavior.tricorder.divider"));
            if (container.getInputVoltage() > 0) {
                list.add(new TextComponentTranslation("behavior.tricorder.energy_container_in", new TextComponentTranslation(GTUtility.formatNumbers(container.getInputVoltage())).setStyle(new Style().setColor(TextFormatting.RED)), new TextComponentTranslation(GTValues.VN[GTUtility.getTierByVoltage(container.getInputVoltage())]).setStyle(new Style().setColor(TextFormatting.RED)), new TextComponentTranslation(GTUtility.formatNumbers(container.getInputAmperage())).setStyle(new Style().setColor(TextFormatting.RED))));
            }
            if (container.getOutputVoltage() > 0) {
                list.add(new TextComponentTranslation("behavior.tricorder.energy_container_out", new TextComponentTranslation(GTUtility.formatNumbers(container.getOutputVoltage())).setStyle(new Style().setColor(TextFormatting.RED)), new TextComponentTranslation(GTValues.VN[GTUtility.getTierByVoltage(container.getOutputVoltage())]).setStyle(new Style().setColor(TextFormatting.RED)), new TextComponentTranslation(GTUtility.formatNumbers(container.getOutputAmperage())).setStyle(new Style().setColor(TextFormatting.RED))));
            }
            list.add(new TextComponentTranslation("behavior.tricorder.energy_container_storage", new TextComponentTranslation(GTUtility.formatNumbers(container.getEnergyStored())).setStyle(new Style().setColor(TextFormatting.GREEN)), new TextComponentTranslation(GTUtility.formatNumbers(container.getEnergyCapacity())).setStyle(new Style().setColor(TextFormatting.YELLOW))));
        }
        // machine-specific info
        IDataInfoProvider provider = null;
        if (tileEntity instanceof IDataInfoProvider)
            provider = (IDataInfoProvider) tileEntity;
        else if (metaTileEntity instanceof IDataInfoProvider)
            provider = (IDataInfoProvider) metaTileEntity;
        if (provider != null) {
            list.add(new TextComponentTranslation("behavior.tricorder.divider"));
            list.addAll(provider.getDataInfo());
        }
    } else if (tileEntity instanceof IPipeTile) {
        // pipes need special name handling
        IPipeTile<?, ?> pipeTile = (IPipeTile<?, ?>) tileEntity;
        if (pipeTile.getPipeBlock().getRegistryName() != null) {
            list.add(new TextComponentTranslation("behavior.tricorder.block_name", new TextComponentTranslation(LocalizationUtils.format(pipeTile.getPipeBlock().getTranslationKey())).setStyle(new Style().setColor(TextFormatting.BLUE)), new TextComponentTranslation(GTUtility.formatNumbers(block.getMetaFromState(world.getBlockState(pos)))).setStyle(new Style().setColor(TextFormatting.BLUE))));
        }
        // pipe-specific info
        if (tileEntity instanceof IDataInfoProvider) {
            IDataInfoProvider provider = (IDataInfoProvider) tileEntity;
            list.add(new TextComponentTranslation("behavior.tricorder.divider"));
            list.addAll(provider.getDataInfo());
        }
        if (tileEntity instanceof TileEntityFluidPipe) {
            // getting fluid info always costs 500
            energyCost += 500;
        }
    } else if (tileEntity instanceof IDataInfoProvider) {
        IDataInfoProvider provider = (IDataInfoProvider) tileEntity;
        list.add(new TextComponentTranslation("behavior.tricorder.divider"));
        list.addAll(provider.getDataInfo());
    } else {
        list.add(new TextComponentTranslation("behavior.tricorder.block_name", new TextComponentTranslation(LocalizationUtils.format(block.getLocalizedName())).setStyle(new Style().setColor(TextFormatting.BLUE)), new TextComponentTranslation(GTUtility.formatNumbers(block.getMetaFromState(world.getBlockState(pos)))).setStyle(new Style().setColor(TextFormatting.BLUE))));
    }
    // crops (adds 1000EU)
    // bedrock fluids
    list.add(new TextComponentTranslation("behavior.tricorder.divider"));
    // -# to only read
    Fluid fluid = BedrockFluidVeinHandler.getFluidInChunk(world, pos.getX() / 16, pos.getZ() / 16);
    if (fluid != null) {
        FluidStack stack = new FluidStack(fluid, BedrockFluidVeinHandler.getOperationsRemaining(world, pos.getX() / 16, pos.getZ() / 16));
        double fluidPercent = stack.amount * 100.0 / BedrockFluidVeinHandler.MAXIMUM_VEIN_OPERATIONS;
        if (player.isCreative()) {
            list.add(new TextComponentTranslation("behavior.tricorder.bedrock_fluid.amount", new TextComponentTranslation(fluid.getLocalizedName(stack)).setStyle(new Style().setColor(TextFormatting.GOLD)), new TextComponentTranslation("" + BedrockFluidVeinHandler.getFluidYield(world, pos.getX() / 16, pos.getZ() / 16)).setStyle(new Style().setColor(TextFormatting.GOLD)), new TextComponentTranslation("" + fluidPercent).setStyle(new Style().setColor(TextFormatting.YELLOW))));
        } else {
            list.add(new TextComponentTranslation("behavior.tricorder.bedrock_fluid.amount_unknown", new TextComponentTranslation("" + fluidPercent).setStyle(new Style().setColor(TextFormatting.YELLOW))));
        }
    } else {
        list.add(new TextComponentTranslation("behavior.tricorder.bedrock_fluid.nothing"));
    }
    // debug
    if (tileEntity instanceof MetaTileEntityHolder) {
        list.addAll(((MetaTileEntityHolder) tileEntity).getDebugInfo(player, debugLevel));
    }
    this.energyCost = energyCost;
    return list;
}
Also used : IPipeTile(gregtech.api.pipenet.tile.IPipeTile) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) MetaTileEntityHolder(gregtech.api.metatileentity.MetaTileEntityHolder) IDataInfoProvider(gregtech.api.metatileentity.IDataInfoProvider) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) FluidTankList(gregtech.api.capability.impl.FluidTankList) Block(net.minecraft.block.Block) Style(net.minecraft.util.text.Style) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) IFluidTank(net.minecraftforge.fluids.IFluidTank) TileEntityFluidPipe(gregtech.common.pipelike.fluidpipe.tile.TileEntityFluidPipe)

Example 53 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project GregTech by GregTechCEu.

the class VirtualTankApp method readUpdateInfo.

@Override
public void readUpdateInfo(int id, PacketBuffer buffer) {
    if (id == -1) {
        // update all info
        int size = buffer.readVarInt();
        cacheClient.clear();
        try {
            for (int i = 0; i < size; i++) {
                UUID uuid = null;
                if (buffer.readBoolean()) {
                    uuid = UUID.fromString(buffer.readString(32767));
                }
                String key = buffer.readString(32767);
                IFluidTank fluidTank = new FluidTank(64000);
                if (buffer.readBoolean()) {
                    fluidTank.fill(FluidStack.loadFluidStackFromNBT(buffer.readCompoundTag()), true);
                }
                cacheClient.put(new ImmutablePair<>(uuid, key), fluidTank);
            }
        } catch (Exception e) {
            GTLog.logger.error("error sync fluid", e);
        }
        reloadWidgets(cacheClient);
    } else if (id == -2) {
        int size = buffer.readVarInt();
        try {
            for (int i = 0; i < size; i++) {
                UUID uuid = null;
                if (buffer.readBoolean()) {
                    uuid = UUID.fromString(buffer.readString(32767));
                }
                String key = buffer.readString(32767);
                FluidStack fluidStack = null;
                if (buffer.readBoolean()) {
                    fluidStack = FluidStack.loadFluidStackFromNBT(buffer.readCompoundTag());
                }
                IFluidTank fluidTank = cacheClient.get(new ImmutablePair<>(uuid, key));
                if (fluidTank != null) {
                    fluidTank.drain(64000, true);
                    if (fluidStack != null) {
                        fluidTank.fill(fluidStack, true);
                    }
                }
            }
        } catch (Exception e) {
            GTLog.logger.error("error sync fluid", e);
        }
    } else {
        super.readUpdateInfo(id, buffer);
    }
}
Also used : FluidTank(net.minecraftforge.fluids.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

Example 54 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project Create by Creators-of-Create.

the class Contraption method readNBT.

public void readNBT(Level world, CompoundTag nbt, boolean spawnData) {
    blocks.clear();
    presentTileEntities.clear();
    specialRenderedTileEntities.clear();
    Tag blocks = nbt.get("Blocks");
    // used to differentiate between the 'old' and the paletted serialization
    boolean usePalettedDeserialization = blocks != null && blocks.getId() == 10 && ((CompoundTag) blocks).contains("Palette");
    readBlocksCompound(blocks, world, usePalettedDeserialization);
    actors.clear();
    nbt.getList("Actors", 10).forEach(c -> {
        CompoundTag comp = (CompoundTag) c;
        StructureBlockInfo info = this.blocks.get(NbtUtils.readBlockPos(comp.getCompound("Pos")));
        MovementContext context = MovementContext.readNBT(world, info, comp, this);
        getActors().add(MutablePair.of(info, context));
    });
    superglue.clear();
    NBTHelper.iterateCompoundList(nbt.getList("Superglue", Tag.TAG_COMPOUND), c -> superglue.add(Pair.of(NbtUtils.readBlockPos(c.getCompound("Pos")), Direction.from3DDataValue(c.getByte("Direction")))));
    seats.clear();
    NBTHelper.iterateCompoundList(nbt.getList("Seats", Tag.TAG_COMPOUND), c -> seats.add(NbtUtils.readBlockPos(c)));
    seatMapping.clear();
    NBTHelper.iterateCompoundList(nbt.getList("Passengers", Tag.TAG_COMPOUND), c -> seatMapping.put(NbtUtils.loadUUID(NBTHelper.getINBT(c, "Id")), c.getInt("Seat")));
    stabilizedSubContraptions.clear();
    NBTHelper.iterateCompoundList(nbt.getList("SubContraptions", Tag.TAG_COMPOUND), c -> stabilizedSubContraptions.put(c.getUUID("Id"), BlockFace.fromNBT(c.getCompound("Location"))));
    storage.clear();
    NBTHelper.iterateCompoundList(nbt.getList("Storage", Tag.TAG_COMPOUND), c -> storage.put(NbtUtils.readBlockPos(c.getCompound("Pos")), MountedStorage.deserialize(c.getCompound("Data"))));
    fluidStorage.clear();
    NBTHelper.iterateCompoundList(nbt.getList("FluidStorage", Tag.TAG_COMPOUND), c -> fluidStorage.put(NbtUtils.readBlockPos(c.getCompound("Pos")), MountedFluidStorage.deserialize(c.getCompound("Data"))));
    interactors.clear();
    NBTHelper.iterateCompoundList(nbt.getList("Interactors", Tag.TAG_COMPOUND), c -> {
        BlockPos pos = NbtUtils.readBlockPos(c.getCompound("Pos"));
        MovingInteractionBehaviour behaviour = AllInteractionBehaviours.of(getBlocks().get(pos).state.getBlock());
        if (behaviour != null)
            interactors.put(pos, behaviour);
    });
    if (spawnData)
        fluidStorage.forEach((pos, mfs) -> {
            BlockEntity tileEntity = presentTileEntities.get(pos);
            if (!(tileEntity instanceof FluidTankTileEntity))
                return;
            FluidTankTileEntity tank = (FluidTankTileEntity) tileEntity;
            IFluidTank tankInventory = tank.getTankInventory();
            if (tankInventory instanceof FluidTank)
                ((FluidTank) tankInventory).setFluid(mfs.tank.getFluid());
            tank.getFluidLevel().start(tank.getFillState());
            mfs.assignTileEntity(tank);
        });
    IItemHandlerModifiable[] handlers = new IItemHandlerModifiable[storage.size()];
    int index = 0;
    for (MountedStorage mountedStorage : storage.values()) handlers[index++] = mountedStorage.getItemHandler();
    IFluidHandler[] fluidHandlers = new IFluidHandler[fluidStorage.size()];
    index = 0;
    for (MountedFluidStorage mountedStorage : fluidStorage.values()) fluidHandlers[index++] = mountedStorage.getFluidHandler();
    inventory = new ContraptionInvWrapper(handlers);
    fluidInventory = new CombinedTankWrapper(fluidHandlers);
    if (nbt.contains("BoundsFront"))
        bounds = NBTHelper.readAABB(nbt.getList("BoundsFront", 5));
    stalled = nbt.getBoolean("Stalled");
    hasUniversalCreativeCrate = nbt.getBoolean("BottomlessSupply");
    anchor = NbtUtils.readBlockPos(nbt.getCompound("Anchor"));
}
Also used : BeltBlock(com.simibubi.create.content.contraptions.relays.belt.BeltBlock) Arrays(java.util.Arrays) AABB(net.minecraft.world.phys.AABB) SeatBlock(com.simibubi.create.content.contraptions.components.actors.SeatBlock) DebugPackets(net.minecraft.network.protocol.game.DebugPackets) Dist(net.minecraftforge.api.distmarker.Dist) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) CombinedInvWrapper(net.minecraftforge.items.wrapper.CombinedInvWrapper) NbtUtils(net.minecraft.nbt.NbtUtils) ChestBlock(net.minecraft.world.level.block.ChestBlock) SimpleWaterloggedBlock(net.minecraft.world.level.block.SimpleWaterloggedBlock) Set(java.util.Set) PoiType(net.minecraft.world.entity.ai.village.poi.PoiType) BooleanOp(net.minecraft.world.phys.shapes.BooleanOp) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) AllInteractionBehaviours(com.simibubi.create.AllInteractionBehaviours) WindmillBearingBlock(com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingBlock) MechanicalPistonHeadBlock(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonHeadBlock) FluidState(net.minecraft.world.level.material.FluidState) PulleyBlock(com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.world.item.ItemStack) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) GantryShaftBlock(com.simibubi.create.content.contraptions.relays.advanced.GantryShaftBlock) ICoordinate(com.simibubi.create.foundation.utility.ICoordinate) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) BlockState(net.minecraft.world.level.block.state.BlockState) CreativeCrateTileEntity(com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity) FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) ArrayList(java.util.ArrayList) StickerBlock(com.simibubi.create.content.contraptions.components.structureMovement.chassis.StickerBlock) BiConsumer(java.util.function.BiConsumer) BlockFace(com.simibubi.create.foundation.utility.BlockFace) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) Nullable(javax.annotation.Nullable) SeatEntity(com.simibubi.create.content.contraptions.components.actors.SeatEntity) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) Iterate(com.simibubi.create.foundation.utility.Iterate) AllMovementBehaviours(com.simibubi.create.AllMovementBehaviours) MechanicalBearingBlock(com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingBlock) CombinedTankWrapper(com.simibubi.create.foundation.fluid.CombinedTankWrapper) NBTHelper(com.simibubi.create.foundation.utility.NBTHelper) FluidTankTileEntity(com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity) ListTag(net.minecraft.nbt.ListTag) SuperGlueEntity(com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity) EmptyLighter(com.simibubi.create.content.contraptions.components.structureMovement.render.EmptyLighter) IMultiTileContainer(com.simibubi.create.foundation.tileEntity.IMultiTileContainer) Direction(net.minecraft.core.Direction) RedstoneContactBlock(com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock) PressurePlateBlock(net.minecraft.world.level.block.PressurePlateBlock) FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) GantryCarriageBlock(com.simibubi.create.content.contraptions.components.structureMovement.gantry.GantryCarriageBlock) Rotation(net.minecraft.world.level.block.Rotation) MutablePair(org.apache.commons.lang3.tuple.MutablePair) GameData(net.minecraftforge.registries.GameData) RopeBlock(com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock.RopeBlock) MechanicalPistonBlock(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock) AllConfigs(com.simibubi.create.foundation.config.AllConfigs) PulleyTileEntity(com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity) UniqueLinkedList(com.simibubi.create.foundation.utility.UniqueLinkedList) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) NBTProcessors(com.simibubi.create.foundation.utility.NBTProcessors) UUID(java.util.UUID) StabilizedContraption(com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedContraption) MagnetBlock(com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyBlock.MagnetBlock) Collectors(java.util.stream.Collectors) Blocks(net.minecraft.world.level.block.Blocks) Objects(java.util.Objects) AbstractChassisBlock(com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock) PistonExtensionPoleBlock(com.simibubi.create.content.contraptions.components.structureMovement.piston.PistonExtensionPoleBlock) List(java.util.List) CompoundTag(net.minecraft.nbt.CompoundTag) BlockPos(net.minecraft.core.BlockPos) HashMapPalette(net.minecraft.world.level.chunk.HashMapPalette) Entry(java.util.Map.Entry) Optional(java.util.Optional) LevelAccessor(net.minecraft.world.level.LevelAccessor) IFluidTank(net.minecraftforge.fluids.IFluidTank) Queue(java.util.Queue) Shapes(net.minecraft.world.phys.shapes.Shapes) Level(net.minecraft.world.level.Level) Tag(net.minecraft.nbt.Tag) PistonType(net.minecraft.world.level.block.state.properties.PistonType) KineticTileEntity(com.simibubi.create.content.contraptions.base.KineticTileEntity) FluidAction(net.minecraftforge.fluids.capability.IFluidHandler.FluidAction) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ServerLevel(net.minecraft.server.level.ServerLevel) HashSet(java.util.HashSet) ItemVaultTileEntity(com.simibubi.create.content.logistics.block.vault.ItemVaultTileEntity) Axis(net.minecraft.core.Direction.Axis) IRotate(com.simibubi.create.content.contraptions.base.IRotate) PushReaction(net.minecraft.world.level.material.PushReaction) ButtonBlock(net.minecraft.world.level.block.ButtonBlock) Fluids(net.minecraft.world.level.material.Fluids) AllBlocks(com.simibubi.create.AllBlocks) ChestType(net.minecraft.world.level.block.state.properties.ChestType) Iterator(java.util.Iterator) SuperGlueHandler(com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueHandler) MechanicalPistonBlock.isPistonHead(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead) PistonState(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState) Entity(net.minecraft.world.entity.Entity) MechanicalPistonBlock.isExtensionPole(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole) ChassisTileEntity(com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity) Vec3(net.minecraft.world.phys.Vec3) Block(net.minecraft.world.level.block.Block) FluidTankTileEntity(com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler) FluidTank(net.minecraftforge.fluids.capability.templates.FluidTank) IFluidTank(net.minecraftforge.fluids.IFluidTank) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) BlockPos(net.minecraft.core.BlockPos) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag) Tag(net.minecraft.nbt.Tag) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) CompoundTag(net.minecraft.nbt.CompoundTag) IFluidTank(net.minecraftforge.fluids.IFluidTank) CombinedTankWrapper(com.simibubi.create.foundation.fluid.CombinedTankWrapper) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 55 with IFluidTank

use of net.minecraftforge.fluids.IFluidTank in project Create by Creators-of-Create.

the class MountedFluidStorage method updateFluid.

public void updateFluid(FluidStack fluid) {
    tank.setFluid(fluid);
    if (!(te instanceof FluidTankTileEntity))
        return;
    float fillState = tank.getFluidAmount() / (float) tank.getCapacity();
    FluidTankTileEntity tank = (FluidTankTileEntity) te;
    if (tank.getFluidLevel() == null)
        tank.setFluidLevel(new InterpolatedChasingValue().start(fillState));
    tank.getFluidLevel().target(fillState);
    IFluidTank tankInventory = tank.getTankInventory();
    if (tankInventory instanceof SmartFluidTank)
        ((SmartFluidTank) tankInventory).setFluid(fluid);
}
Also used : InterpolatedChasingValue(com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue) CreativeFluidTankTileEntity(com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTileEntity) FluidTankTileEntity(com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity) IFluidTank(net.minecraftforge.fluids.IFluidTank) CreativeSmartFluidTank(com.simibubi.create.content.contraptions.fluids.tank.CreativeFluidTankTileEntity.CreativeSmartFluidTank) SmartFluidTank(com.simibubi.create.foundation.fluid.SmartFluidTank)

Aggregations

IFluidTank (net.minecraftforge.fluids.IFluidTank)58 FluidStack (net.minecraftforge.fluids.FluidStack)30 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)10 FluidTank (net.minecraftforge.fluids.FluidTank)9 Nullable (javax.annotation.Nullable)6 Block (net.minecraft.block.Block)6 ItemStack (net.minecraft.item.ItemStack)6 TileEntity (net.minecraft.tileentity.TileEntity)5 NBTBase (net.minecraft.nbt.NBTBase)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 INBTSerializable (net.minecraftforge.common.util.INBTSerializable)4 Recipe (gregtech.api.recipes.Recipe)3 ArrayList (java.util.ArrayList)3 IItemHandlerModifiable (net.minecraftforge.items.IItemHandlerModifiable)3 FluidTankTileEntity (com.simibubi.create.content.contraptions.fluids.tank.FluidTankTileEntity)2 FluidTankGT (gregapi.fluid.FluidTankGT)2 OreDictItemData (gregapi.oredict.OreDictItemData)2 FuelRecipe (gregtech.api.recipes.recipes.FuelRecipe)2 BlockLiquid (net.minecraft.block.BlockLiquid)2