#How to make custom fluids work with modded buckets
6 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
i think you need to create two bucket items for that, one empty and one filled
then use item right click event
const targetFluid = {
'minecraft:water': 'water_filled item id',
'minecraft:lava': 'lava_filled item id'
}
ItemEvents.rightClicked('empty', e => {
//should be more complex, since there are waterlogged blocks
const {block} = e.target;
if(!block) return;
const data = targetFluid[block.id];
if(!data) return;
block.set('air');
e.player.setItemInHand(e.hand, data)
})
const fluidReversed = {
'water_filled item id': 'minecraft:water',
'lava_filled item id': 'minecraft:lava'
}
Object.keys(fluidReversed).forEach(key => {
const fluid = fluidReversed[key];
ItemEvents.rightClicked(key, e => {
const targetBlock = e.target.block;
if(!targetBlock) return;
const {block} = targetBlock[e.facing];
if(!block.blockState.canBeReplaced()) return;
block.set(fluid);
e.player.setItemInHand(e.hand, data)
})
})
[➤](#1256350576044675194 message) Basically, for each fluid that exists (which I don't have an easy way of grabbing), you need to make a new item. Then you need to use BlockEvents to find out when you right clicked a block while holding that item. If you were holding it, place the fluid block, delete the item, and give a replacement item.
the code there might help