#Make custom amethyst-like crystal growth

247 messages · Page 1 of 1 (latest)

warm depot
#

I want to make Biomes O plenty rose quartz clusters grow out of BOP rose quartz blocks like amethyst does but i have no idea where to even start with this. I have all the blocks i want now i just need the growth mechanic

craggy karmaBOT
#

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

tall sequoia
#

You will need to be creative with that, gl

#

you will probably need BeJS

stuck vigilBOT
#

Choose one of the addons below:

#

WIP

tall sequoia
#

sorry, BeJS is 1.19 only

radiant veldt
#

if we had block entities in 1.18 itd be easy to dohmmm

warm depot
#

so theres no way i can clone the amethyst class or anything?

radiant veldt
stuck vigilBOT
#

Just because someone said it isn't possible doesn't mean it actually is. Instead they meant that no one has successfully done it yet.

Be the first!

warm depot
#

fair enough, i dont know JS well enough for that so im looking into using the buddingcrystals mod

warm depot
#

okay i am fully aware this syntax is wrong but would something like this work?

onEvent('server.tick', event => {

    if (block == 'kubejs:budding_rose_quartz') {

        if (block+1 == None) {
            event.setBlock(y+1, 'biomesoplenty:small_rose_quartz_bud')
        }

        else if (block+1 == 'biomesoplenty:small_rose_quartz_bud') {
            event.setBlock(y+1, 'biomesoplenty:medium_rose_quartz_bud')
        }

        else if (block+1 == 'biomesoplenty:medium_rose_quartz_bud') {
            event.setBlock(y+1, 'biomesoplenty:large_rose_quartz_bud')
        }

        else if (block+1 == 'biomesoplenty:large_rose_quartz_bud') {
            event.setBlock(y+1, 'biomesoplenty:rose_quartz_cluster')
        }
    }
})
radiant veldt
#

oh boy

warm depot
#

:') im trying, js is not what i am used to

#

do i at least have the right idea?

radiant veldt
warm depot
#

scrap that, it needs to do that for each budding rose quartz

#

but idk how id do that every few ticks

radiant veldt
#

workin on it

#

btw that script has no chance of working

#

dont waste your time on it

#

ill see if i can register a new block

warm depot
#
    event.create("budding_rose_quartz")
        .displayName("Budding Rose Quartz")
        .material('amethyst')
        .hardness(2.0)
        .noDrops()
        .tagBlock('forge:budding_blocks')
        .tagBlock('forge:mineable/paxel')
        .tagBlock('minecraft:crystal_sound_blocks')
        .tagBlock('minecraft:mineable/pickaxe')
        .tagBlock('tconstruct:mineable/pickadze')
#

thats the code im using to create the budding block if u want to do some testing

radiant veldt
#

not like that

warm depot
#

okay okay mb

radiant veldt
#

thanks tho

warm depot
#

thanks for helping with this :)

radiant veldt
#

sure, no promises this will work tho

warm depot
#

hmm okay

#

i dont understand too much of that but from the bits i get, its almost copying and filling out a new AE2 disk

#

ig youd do the same for budding amethyst

radiant veldt
#

try this in startup scripts

const DeferredRegister = java('dev.architectury.registry.registries.DeferredRegister');
const Registry = java('net.minecraft.core.Registry');
const Block = java('net.minecraft.world.level.block.Block');
const Item = java('net.minecraft.world.item.Item');
const BlockItem = java('net.minecraft.world.item.BlockItem');
const Material = java('net.minecraft.world.level.material.Material');
const AmethystClusterBlock = java('net.minecraft.world.level.block.AmethystClusterBlock');

const BLOCKS = DeferredRegister.create('kubejs', Registry.BLOCK_REGISTRY);
const ITEMS = DeferredRegister.create('kubejs', Registry.ITEM_REGISTRY);

// Register a new budding amethyst block called "new_budding_amethyst"
const NEW_BUDDING_AMETHYST = BLOCKS.register('new_budding_amethyst', () => {
  return new AmethystClusterBlock(Block.Properties.of(Material.STONE)); // Customize properties as needed
});

// Register a corresponding block item for "new_budding_amethyst"
const NEW_BUDDING_AMETHYST_ITEM = ITEMS.register('new_budding_amethyst', () => {
  return new BlockItem(NEW_BUDDING_AMETHYST.get(), new Item.Properties());
});
stuck vigilBOT
#

Paste version of crash-2023-11-27_18.54.30-fml.txt from @warm depot

radiant veldt
#

sec

#

send your startup logs

#

??kjslogs

stuck vigilBOT
# radiant veldt ??kjslogs

You can find your KubeJS startup log in /minecraft/logs/kubejs/startup.log.
If you are on 1.18 or below it will be called startup.txt.
Please send it if asked, as it contains helpful information.

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

warm depot
#

TypeError

#

redeclaration or var Item

radiant veldt
#

yeah i see it

warm depot
#

line 19 right?

radiant veldt
#

try this

const DeferredRegister = java('dev.architectury.registry.registries.DeferredRegister');
const Registry = java('net.minecraft.core.Registry');
const ItemRegistry = java('net.minecraft.world.item.Item');
const BlockItemRegistry = java('net.minecraft.world.item.BlockItem');
const AmethystClusterBlock = java('net.minecraft.world.level.block.AmethystClusterBlock');
const Block = java('net.minecraft.world.level.block.Block');
const Material = java('net.minecraft.world.level.material.Material');

const ITEMS = DeferredRegister.create('kubejs', Registry.ITEM_REGISTRY);

ITEMS.register('new_budding_amethyst', () => {
    return new BlockItemRegistry(Registry.BLOCK.get('kubejs:new_budding_amethyst'), new ItemRegistry.Properties());
});
#

squoshis better at this stuff than me tbh lol

#

we'll see if this works though

warm depot
#

sending startup

radiant veldt
#

kk

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

warm depot
#

lol now its block redeclaration

radiant veldt
#

bruh

#

try that ```js
const DeferredRegister = java('dev.architectury.registry.registries.DeferredRegister');
const Registry = java('net.minecraft.core.Registry');
const ItemRegistry = java('net.minecraft.world.item.Item');
const BlockItemRegistry = java('net.minecraft.world.item.BlockItem');
const AmethystClusterBlock = java('net.minecraft.world.level.block.AmethystClusterBlock');
const Material = java('net.minecraft.world.level.material.Material');

const ITEMS = DeferredRegister.create('kubejs', Registry.ITEM_REGISTRY);

ITEMS.register('new_budding_amethyst', () => {
return new BlockItemRegistry(
new AmethystClusterBlock(Block.Properties.of(Material.STONE)),
new ItemRegistry.Properties()
);
});

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

warm depot
#

ooo different error

tall sequoia
#

@radiant veldt do you know if amethyst block also is a block entity?

radiant veldt
#

i think it should be though re registering it should inherit the class

#

try that blue i edited the most recent one

#

if that doesnt work i got another one to try

tall sequoia
#

if it is a block entity you will need lated to register this block that entity type or it won't tick

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

tall sequoia
#

later*

warm depot
#

same error

radiant veldt
#

i edited it again

#

would we do it like how reverter did that one script then or you mean we have to somehow tick it later

tall sequoia
#

why are you using this instead or event.custom?

radiant veldt
#

oh yeah maybe we do that then

warm depot
#

you can use e.custom for blocks?

radiant veldt
#

did the newest script work?

tall sequoia
#

for any register

warm depot
radiant veldt
#

kk

#

we'll try event.custom next then

#

if it doesnt work

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

warm depot
#

same again :/

tall sequoia
#

use ITEMS["register(java.lang.String,java.util.function.Supplier)"]
instead of ITEMS.register

radiant veldt
#

oo

#

like this? ```js
const DeferredRegister = java('dev.architectury.registry.registries.DeferredRegister');
const Registry = java('net.minecraft.core.Registry');
const ItemRegistry = java('net.minecraft.world.item.Item');
const BlockItemRegistry = java('net.minecraft.world.item.BlockItem');
const AmethystClusterBlock = java('net.minecraft.world.level.block.AmethystClusterBlock');
const Material = java('net.minecraft.world.level.material.Material');

const ITEMS = DeferredRegister.create('kubejs', Registry.ITEM_REGISTRY);

ITEMS["register(java.lang.String,java.util.function.Supplier)"]('new_budding_amethyst', () => {
return new BlockItemRegistry(
new AmethystClusterBlock(Block.Properties.of(Material.STONE)),
new ItemRegistry.Properties()
);
});

tall sequoia
#

yes

radiant veldt
#

try that blue

#

also

stuck vigilBOT
#

[Quote ➤](#1058263188216479834 message) A how to and example on creating custom blocks, maybe using Chief's example.

radiant veldt
#

found this

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

radiant veldt
#

what is with these redeclaration errors

#

Error loading KubeJS script: TypeError: TypeError: redeclaration of var ResourceLocation.

warm depot
#

loll

radiant veldt
#

edited it

warm depot
#

WAIT IT LAUNCHED

#

I GOT TO MAIN MENU

stuck vigilBOT
#

[Quote ➤](#1058263188216479834 message) all righty thank you very much doggo and squoshi. After some headscratching I figured out how to do blockitems lol.

const $BlockProperties = java('net.minecraft.world.level.block.state.BlockBehaviour$Properties');
const $CakeBlock = java('net.minecraft.world.level.block.CakeBlock');
const $Material = java('net.minecraft.world.level.material.Material');

const $ItemProperties = java('net.minecraft.world.item.Item$Properties');
const $BlockItem = java('net.minecraft.world.item.BlockItem');




let cakeTest = Utils.getRegistry('minecraft:block').register('kubejs:cake', () => new $CakeBlock($BlockProperties.of($Material.AMETHYST)));

Utils.getRegistry('minecraft:item').register('kubejs:cake', () => new $BlockItem(cakeTest.get(), new $ItemProperties().stacksTo(64)));

This code works and registers a cake block and its BlockItem.

tall sequoia
#

this looks like would work

warm depot
#

okay im in world

tall sequoia
#

on 1.18

radiant veldt
#

oo it worked?

#

see if it grows any amethyst

warm depot
radiant veldt
#

i guess speed up the randomtickspeed gamerule

warm depot
#

oh shit do i need to change the new_budding_amethyst to my block id

radiant veldt
#

yeah you can rename it whatever though im curious if itll inherit the block entity class

radiant veldt
tall sequoia
#

if it doesn't, when you put on the world you will have a error/warn message on console saying that it can't be ticked

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

radiant veldt
#

and there it is, uncandango calling it as per usual

warm depot
#

oh

#

hehe im dumb

radiant veldt
#

: kubejs:kubejs:budding_rose_quartzwhatcat

tall sequoia
#

don't kubejskubejs

#

lol

warm depot
#

haha

tall sequoia
#

nice emoji

radiant veldt
#

perfect

radiant veldt
#

you might have to manually add a block loot table for it

#

not sure tbh

warm depot
#

i might prefer that so it drops its own crystal

#

or i can change that later

radiant veldt
#

for the rose quartz growing on it i mean

#

right

#

is it growing stuff or nah

warm depot
#

nah

radiant veldt
#

even when you set the randomtickspeed to 1000

warm depot
#

yea its 10000 rn

radiant veldt
#

hmm

warm depot
#

regular grows fast other one nothing

tall sequoia
#

check latest.log

#

and place the block

#

check if you get

#

a warn

warm depot
stuck vigilBOT
#

Paste version of startup.txt from @warm depot

tall sequoia
#

when you place

#

latest.log

radiant veldt
#

latestlogs

warm depot
stuck vigilBOT
#

Paste version of latest.log from @warm depot

radiant veldt
#

btw theres this error in startup TypeError: Cannot find function clusterCount in object dev.latvian.mods.kubejs.level.gen.properties.AddOreProperties@7a40b362. (startup_scripts:script.js#178)

tall sequoia
#

worldgen add is not related

radiant veldt
#

fair

warm depot
#

line 232 in the latest.log

radiant veldt
#

thats also unrelated

#

and a normal occurence

warm depot
#

line 892 but i dont think thats related

radiant veldt
#

i think theres growth conditions in the block properties

tall sequoia
#

i don't see anything about block entity, maybe this is not a block entity at all

radiant veldt
#

wait

#

i might have an idea

warm depot
#

okay go on

#

if this is all too hard i can just rename quarks red corumdum and retexture it and change the loot table

radiant veldt
#

nvm

tall sequoia
#

is it supposed to be BuddingAmethystBlock or what? I'm confused what we are actually trying to register

#

isn't the block that grow stuff?

radiant veldt
#

hmm yeah maybe

#

wait is it

tall sequoia
#

and isn't it the Budding

radiant veldt
#

maybe im just dumb and registered the actual cluster

#

sec

slate estuary
radiant veldt
#

hey donRainbowPls

warm depot
#

o//

slate estuary
#

hello o/

tall sequoia
#

good news, this is not a block entity

tall sequoia
#

it just runs on random tick

radiant veldt
#

pogg

warm depot
#

okay imma go get food, if you guys get bored then dont stress it, i appreciate all the help

#

be back in a bit

radiant veldt
#
const DeferredRegister = java('dev.architectury.registry.registries.DeferredRegister');
const Registry = java('net.minecraft.core.Registry');
const BlockItemRegistry = java('net.minecraft.world.item.BlockItem');
const BuddingAmethystBlock = java('net.minecraft.world.level.block.BuddingAmethystBlock');
const Material = java('net.minecraft.world.level.material.Material');

const ITEMS = DeferredRegister.create('kubejs', Registry.ITEM_REGISTRY);

ITEMS['register(java.lang.String,java.util.function.Supplier)']('new_budding_amethyst', () => {
    return new BlockItemRegistry(
        new BuddingAmethystBlock(Block.Properties.of(Material.STONE)),
        new ItemRegistry.Properties()
    );
});


slate estuary
#

why no $ in var names ahujel

radiant veldt
#

laziness

#

sec

tall sequoia
#

what is BLOCKS.new_budding_amethyst? isnt it undefined?

radiant veldt
#

oh is it

#

crap sec

tall sequoia
#

unless BLOCKS is a map

#

or something

radiant veldt
#

like that?(edited code)

slate estuary
stuck vigilBOT
slate estuary
radiant veldt
#

well the guys gotta get back from eating firstheh

tall sequoia
#

where are you basing this on?

#

like the properties and stuff, will it work being copied from STONE?

radiant veldt
#

im just tryna get it into the game tbh

radiant veldt
#

lmao

#

i mean can you base it on the budding block itself?

tall sequoia
#

why no dev env?

radiant veldt
#

~~cause im bad~

#

point and case

#

not even gonna edit

tall sequoia
#

not budding block, you should see how mc already does that heh

#

also I'm not seeing how it will grow custom clusters 🤔 what am I missing?

#

ngl, we should just see how AE2 does that

radiant veldt
#

oh true

tall sequoia
#

inb4 mixin and some weird shenigans

radiant veldt
#

lmao

warm depot
#

but nothing is growin

radiant veldt
#

hmmm

dense dagger
#

I feel like you guys are over complicating this, for the budding block you can just register a basic kubejs block and put the logic in the randomTick callback

radiant veldt
#

and here i was gonna register a block entity itself ```js
const CAMPFIRE_BLOCK_ENTITY = BLOCK_ENTITIES.register('campfire_block_entity', () => {
return BlockEntityType.Builder
.create(SimpleContainerBlockEntity.prototype.constructor, BLOCKS.get('new_campfire'))
.build(null);
});

#

though its not really working

#

ill try the callback thing i guess

tall sequoia
radiant veldt
tall sequoia
#

nvm, it is the Survive callback that is exclusive to crop block

radiant veldt
#

got it working, pretty much exactly replicates amethyst block

#
global.amethystblock = tick => {
    const { block, level } = tick;
    const pos = block.getPos();
    const Direction = java('net.minecraft.core.Direction');
  
    const growAmethystBuds = () => {
      Direction.values().forEach(face => {
        const offsetPos = pos.relative(face);
        const adjacentBlockId = level.getBlock(offsetPos).id;
        const chanceOfGrowth = 0.1;
        const randomValue = Math.random();
  
        const blockTypes = {
          'minecraft:air': 'small_amethyst_bud',
          'minecraft:small_amethyst_bud': 'medium_amethyst_bud',
          'minecraft:medium_amethyst_bud': 'large_amethyst_bud',
          'minecraft:large_amethyst_bud': 'amethyst_cluster',
        };
  
        const blockType = blockTypes[adjacentBlockId];
        if (blockType && randomValue < chanceOfGrowth) {
          const command = `setblock ${offsetPos.getX()} ${offsetPos.getY()} ${offsetPos.getZ()} minecraft:${blockType}[facing=${face}]`;
          tick.server.runCommandSilent(command);
        }
      });
    };
  
    growAmethystBuds();
  };
  
  onEvent('block.registry', event => {
    event.create('rose_quartz_budding_block')
      .material('amethyst')
      .hardness(0.5)
      .displayName('Rose Quartz Budding Block')
      .randomTick(tick => global.amethystblock(tick));
  });
#

and before you say anything cause i know you will, yes i had to use server commands because theres no .setBlock property in level here to set the blockstate and it was either this or a bunch of reflectionraha

radiant veldt
#

which like reverter said APPARENTLY was just flat out part of kubejs block building functionality

#

@warm depot test the code out and let me know, since the functions in a global event you can edit anything in that global function and run /kubejs reload startup_scripts to reload it without having to do a full game restart

tall sequoia
#

👏👏👏

warm depot
#

just woke up, ill test it in a bit

#

man u guys are the best

#

and i assume i can change the crystals that grow on it?

radiant veldt
#

yessir

#

just need to change it to whatever you need and its not limited to just the 4 entries either

#

??closeticket

stuck vigilBOT
# radiant veldt ??closeticket

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue! This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You generally should create a new post for unrelated issues.

warm depot
#

tysm all

warm depot