#Help with creating custom non-fullblock block

55 messages · Page 1 of 1 (latest)

leaden reef
#

Hi, I'm looking to extend some custom blocks from another mod's existing models and textures, but am running into an issue in regards to bounding box and blockface culling. My custom block is on the right, and the one from the mod is on the left. Here is it's model.json:

{
    "parent": "geocluster:block/ore_sample",
    "textures": {
        "particle": "minecraft:block/stone",
        "ore": "ad_astra:block/moon_ore_desh"
    }
}```

Here's it's definition in startup:

```js
StartupEvents.registry('block', e => {
    e.create('desh_ore_sample')
        .material('stone')
        .hardness('0.0')
        .displayName('Desh Sample')
        .requiresTool(false);
});```

There are two main issues I'm facing. 
1. The bounding box when highlighting it is a full block rather than the smaller box from the mod. Is there a way to change that in KubeJS?
2. The blockface culling. Is there a way to stop that?
woven boneBOT
#

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

stray topaz
#

you set the bounding box as part of the block registration

#

.box(x, y, z, x1, y1, z1, true/false)
true for pixels basically (x,y,z are 0-15)

leaden reef
#

Oh wow duh I just saw the box() function on the wiki

#

and now that I look a bit more is it fullBlock() to fix the culling

stray topaz
#

I think it's opaque

leaden reef
#

I think that's for if you're making a see through block

#

it was fullBlock(false) though

stray topaz
#

there ya go, I've done it a few times and then instantly forgot how I did it heh

leaden reef
#

appreciate the help

stray topaz
#

just as an aside you could've used the custom registration and made it the actual sampleblock class...

leaden reef
#

Like load the class from the mod?

stray topaz
#

still in 6.0 or moved up to 6.1?

leaden reef
#

I'm in 6.1 now

stray topaz
#
const $SampleBlock = Java.loadClass('dev.sterner.geocluster.common.blocks.SampleBlock')

StartupEvents.registry('block', e => {
  e.createCustom('desh_ore_sample', () => new $SampleBlock())
})
#

although you'd also have to manually add the item if you did it this way, so it's more like

const $SampleBlock = Java.loadClass('dev.sterner.geocluster.common.blocks.SampleBlock')

const $BlockItem = Java.loadClass('net.minecraft.world.item.BlockItem')
const $IProperties = Java.loadClass('net.minecraft.world.item.Item$Properties')
const $KubeJS = Java.loadClass('dev.latvian.mods.kubejs.KubeJS')

let DeshSampleBlock

StartupEvents.registry('block', e => {
  DeshSampleBlock = e.createCustom('desh_ore_sample', () => new $SampleBlock())
})

StartupEvents.registry('item', e => {
  e.createCustom('desh_ore_sample', () => new $BlockItem(DeshSampleBlock.get(), new $IProperties().tab($KubeJS.tab)))
})
leaden reef
#

Ah ok I was wondering why I couldnt find it in REI

stray topaz
#

you'd be amazed at how much the builders take care of for you when you go custom lol

#

like all the model/blockstate json creation and such

leaden reef
#

Honestly this is probably preferred for my use case

#

It will match exactly to what I'm extending off of

stray topaz
#

yea, and inclue the directional nature of the blocks

#

although kjs does have a builder for horizontal facing

#

you could also copy the itemproperties from geocluster if you wanted it to pop up in their creative tab

leaden reef
#

I'm just amazed how much you can really do especially with class loading

#

I'm not too worried about it in the creative tab tbh

#

The samples get added during worldgen and wont be something obtainable in normal gameplay anyway

leaden reef
#

Hm, the item variant is a missing texture for me

stray topaz
#

you would have to make the item model, which is usually

{
  "parent": //block model location
}
#

"kubejs:block/desh_ore_sample"

leaden reef
#

ahhh makes sense

leaden reef
#

i naively thought that using the BlockItem class would handle the model

stray topaz
#

no worries, it's working how you want though now?

leaden reef
#

Yep

stray topaz
leaden reef
#

Ok actually one more thing

#

Changing the loot table. I've added loot tables before to other geocluster samples and loaded them through a datapack, but trying to have a loot table for this custom one doesnt seem to be working

#

I placed it in kubejs/loot_tables/blocks/desh_ore_sample.json

{
    "type": "minecraft:block",
    "pools": [
        {
            "bonus_rolls": 0.0,
            "conditions": [
                {
                    "condition": "minecraft:survives_explosion"
                }
            ],
            "entries": [
                {
                    "type": "minecraft:item",
                    "name": "ad_astra:raw_desh"
                }
            ],
            "rolls": 1.0
        }
    ]
}```

But doesn't appear to be working.
stray topaz
#

hmmm

#

looks right to me

#

data folder or asset folder?

leaden reef
#

asset

stray topaz
#

it's data

leaden reef
#

why are loot tables special?

stray topaz
#

because loot tables aren't assets

#

they would go in a data pack, not a resource pack

leaden reef
#

OH

stray topaz
#

there's also an easy method and block loot event for that

leaden reef
#

i mean i already made the loot table json so its not that big of a deal

stray topaz
#

for future reference/anyone stumbles here

ServerEvents.blockLootTables(event => {
  // event.addSimpleBlock('kubejs:desh_ore_sample') // drops itself

  event.addSimpleBlock('kubejs:desh_ore_sample', 'ad_astra:raw_desh') // drops something else instead
})

would make the same json

leaden reef
#

Wouldn't it make the drop the sample itself. The JSON i have drops the respective raw ore

stray topaz
#

ah sorry, only half payed attention lol