#make a script to pump out Liquid from Botania Manapool

45 messages · Page 1 of 1 (latest)

dusky zephyr
#

Is there a way to make a script that allows me to pump out [insert liquid] from the Botania Manapool and update the contents in the pool itself?
Like iirc the Pool stores an integer value of max 1'000'000 Mana. Is there a way to write it so that 1 MB = 10 mana when it's pulled out from the pool?
I have a script already that creates a new fluid that i obviously labeled Mana, but I don't know how I would be able to write a script to make any Fluid Pipe interact with the Manapool, pump out the Mana and convert it immediately to the Mana Liquid for transportation.

cyan aspenBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

dusky zephyr
#

Maybe even make the Manapool register as a tank

errant pantherBOT
#

Adds Forge's Capability system integration for KubeJS. With PowerfulJS, you can retrieve, attach capabilities supported for ItemStacks, Block Entities and so on!

Mod by @glacial rune


dusky zephyr
#

@ashen ermine thanks man!

#

there is no documentation for me to look up anything tho....

errant pantherBOT
#

ProbeJS is an addon mod for KubeJS that generates typings files for VSCode, allowing VSCode to offer autocompletions for a ton of things!

Mod by @glacial rune

dusky zephyr
#

well, i wish i had the experience required to just look at anything ProbeJS gives you in VSCode and know what to do with it
sadly i dont and need to rely on documentation and explanations to guide me

rancid compass
#

Well, you can get documentation with the KubeJSOffline mod; just remember to run the /kubejsoffline command after you add more kubejs plugins.

#

It's not easy documentation to read, though.

#

Instead of documentation, are you looking for more like a tutorial?

dusky zephyr
dusky zephyr
#

@rancid compass sorry for bothering, can you help me in some way shape or form?

rancid compass
#

I'm not really good at writing guides, or tutorials, or creating examples. I also haven't worked with Capabilities at all.

dusky zephyr
#

damn... guess i'll just have to scrap the idea then

ashen ermine
#

i haven't had time to look at this but i will try... let me cook

ashen ermine
#

just editing the example

CapabilityEvents.blockEntity(event => {
    event.attach("create:fluid_tank",
        BotaniaCapabilityBuilder.MANA.blockEntity()
            .receiveMana((be, amount) => {
                let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                fluid.fill(Fluid.water(amount), 'execute') 
            })
            .getCurrentMana(be => {
                let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                return fluid.getFluidInTank(0).amount
            })
            .isFull(be => {
                let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                return fluid.getFluidInTank(0).amount >= fluid.getTankCapacity(0)
            })
    )
})```
#

but i think you want to use normal pipes or pumps to remove the liquid from the mana pool, right?

ashen ermine
#

okay, this doesn't work but might be the idea

#
event.attach('botania:mana_pool',
        CapabilityBuilder.FLUID.customBlockEntity()
            .getCapacity(be => {
               return be.persistentData.getInt('manaCap')
            })
            .getFluid(be => {
                return Fluid.of('lava', be.persistentData.getInt('manaCap'))
            })
            .onDrain((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0 
                let mana = be.persistentData.getInt('mana')
                let extracted = Math.min(mana, fluidStack.amount)
                if(!simulate){
                    be.persistentData.putInt('mana', mana - extracted)
                }
                return extracted
            })
            .onFill((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0 
                let mana = be.persistentData.getInt('mana')
                let received = Math.min(be.persistentData.getInt('manaCap') - mana, fluidStack.amount)
                if(!simulate){
                    be.persistentData.putInt('mana', mana + received)
                }
                return received
            })
    )
ashen ermine
#

Okay still doesn't work but getting there, you can pump and remove lava from the mana pool but the the mana doesn't change

#
 event.attach('botania:mana_pool',
        CapabilityBuilder.FLUID.customBlockEntity()
            .getCapacity(be => {
               return be.updateTag.getInt('manaCap')
            })
            .getFluid(be => {
                return Fluid.of('lava', be.updateTag.getInt('manaCap'))
            })
            .onDrain((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0
                //let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                let mana = be.updateTag.getInt('mana')
                let extracted = Math.min(mana, fluidStack.amount)
                if(!simulate){
                    be.updateTag.putInt('mana', mana - extracted)
                    //fluid.drain(fluidStack, 'execute')
                }
                return extracted
            })
            .onFill((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0 
                
                //let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                let mana = be.updateTag.getInt('mana')
                let received = Math.min(be.updateTag.getInt('manaCap') - mana, fluidStack.amount)
                if(!simulate){
                    be.updateTag.putInt('mana', mana + received)
                    //fluid.fill(fluidStack, 'execute')
                }
                return received
            })
    )```
ashen ermine
#
event.attach('botania:mana_pool',
        CapabilityBuilder.FLUID.customBlockEntity()
            .getCapacity(be => {
               return be.updateTag.getInt('manaCap')
            })
            .getFluid(be => {
                return Fluid.of('lava', be.updateTag.getInt('manaCap'))
            })
            .onDrain((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0
                //let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                let mana = be.updateTag.getInt('mana')
                let extracted = Math.min(mana, fluidStack.amount)
                if(!simulate){
                    be.updateTag.putInt('mana', mana - extracted)
                    be.setChanged()
                    //fluid.drain(fluidStack, 'execute')
                }
                return extracted
            })
            .onFill((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0 
                
                //let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                let mana = be.updateTag.getInt('mana')
                let received = Math.min(be.updateTag.getInt('manaCap') - mana, fluidStack.amount)
                if(!simulate){
                    be.updateTag.putInt('mana', mana + received)
                    be.setChanged()
                    //fluid.fill(fluidStack, 'execute')
                }
                return received
            })
    )```
#

still doesn't work

dusky zephyr
#

woah dude

#

you are an absolute legend!!!

#

thank you so much!

#

@ashen ermine salute

ashen ermine
#

but do you want to pump liquid in and out, like basically transport mana in liquid form or just pump out?

dusky zephyr
#

no, mostly out

dusky zephyr
ashen ermine
#

okay, i finally had some time to do this and it works now. i was having trouble with the nbt data not updating but now it works. maybe you have to filter if is the server side or client side to work on server but just create a new post here

#
CapabilityEvents.blockEntity(event => {
    event.attach('botania:mana_pool',
        CapabilityBuilder.FLUID.customBlockEntity()
            .getCapacity(be => {
               return be.updateTag.getInt('manaCap')
            })
            .getFluid(be => {
                return Fluid.of('lava', be.updateTag.getInt('mana'))
            })
            .onDrain((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0
                //let fluid = be.getCapability(ForgeCapabilities.FLUID_HANDLER).orElse(null)
                let mana = be.updateTag.getInt('mana')
                let extracted = Math.min(mana, fluidStack.amount)
                if(!simulate){
                    let data = Utils.server.getLevel('minecraft:overworld').getBlock(be.blockPos).entityData
                    data.merge({'mana':mana - extracted})
                    Utils.server.getLevel('minecraft:overworld').getBlock(be.blockPos).setEntityData(data)
                }
                return extracted
            })
    )
})
#

you just need to change lava for your mana fluid

dusky zephyr
#

Oh damn thank you so much man!
you really saved a whole idea chain for my project!

#

I see that it's specified which Mana Pool can be extracted from, would the script go insane if i'd just copy paste it and implement it for the creative pool and the upgraded Mana pool?

ashen ermine
#

i remember seeing the creative mana pool with the 1kB in jade, but i forgot to test on it. but i should be as simple as copy pasting and changing the name of the block

#

okay i just notice something, this will only work in the overworld, damn

ashen ermine
#

okay, so it works on all dimensions now but there still have a small visual bug that if you pump fluid out of the mana pool, it will still look like it has mana

#

CapabilityEvents.blockEntity(event => {
    event.attach('botania:mana_pool',
        CapabilityBuilder.FLUID.customBlockEntity()
            .getCapacity(be => {
               return be.updateTag.getInt('manaCap')
            })
            .getFluid(be => {
                return Fluid.of('lava', be.updateTag.getInt('mana'))
            })
            .onDrain((be, fluidStack, simulate) => {
                if(!(fluidStack.id == 'minecraft:lava')) return 0
                let mana = be.updateTag.getInt('mana')
                let extracted = Math.min(mana, fluidStack.amount)
                if(!simulate){
                    if(be.level.isClientSide()) return extracted
                    let data = Utils.server.getLevel(be.level.dimension).getBlock(be.blockPos).entityData
                    data.merge({'mana':mana - extracted})
                    Utils.server.getLevel(be.level.dimension).getBlock(be.blockPos).setEntityData(data)
                }
                return extracted
            })
    )
})```
#

but it does work in all 3 mana pools that vanilla botania has

#

incluiding the creative one