#How to make a custom block like tinted glass?

108 messages · Page 1 of 1 (latest)

woeful elk
#

I am trying to make an unbreakable block that behaves like tinted glass (i.e. it can be seen through but does not allow light through) but I cannot figure out the right combination of transparency and render type settings to make it look the same as vanilla tinted glass. Anyone have any ideas?

blazing swanBOT
#

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

mellow pumice
#
e.create('fancy_glass').defaultTranslucent()
woeful elk
#

This is mostly correct, but the block still lets light through. To clarify, I want it to act like the new tinted glass introduced in 1.17, not the coloured stained glass.

mellow pumice
#

hmmm

#

leme try something

fathom hazel
#

if you wanted to use that class exactly you'd use event.custom(id, object) in the registry event

mellow pumice
#

wait wha hmmm

#

public CustomBuilderObject(ResourceLocation i, T object, RegistryObjectBuilderTypes<T> registry) dis?

#
public CustomBuilderObject(ResourceLocation i, T object, RegistryObjectBuilderTypes<T> registry)
#

maybe this

#
public BuilderBase.CustomBuilderObject<T> custom(String id, T object)
#

ye

#

that crashed heh

#

oh fuck me

woeful elk
#

This is far more complicated than I thought it would be

mellow pumice
#

its cuz i wrote event instead of e

mellow pumice
fathom hazel
#
const $TintedGlassBlock = Java.loadClass('net.minecraft.world.level.block.TintedGlassBlock')
const $Blocks = Java.loadClass('net.minecraft.world.level.block.Blocks')
const $Properties = Java.loadClass('net.minecraft.world.level.block.state.BlockBehaviour$Properties')
StartupEvents.registry('block', event => {
  let customGlass = new $TintedGlassBlock($Properties.copy($Blocks.TINTED_GLASS))
  event.custom('new_glass', customGlass)
})

something like that (untested)

mellow pumice
#

oh thats not at all what i have

#

leme try that

fathom hazel
#

there was an example somewhere from chief about using custom block classes when it was added as a feature to kjs6

mellow pumice
#

they should be added to #1048591172165189632 and the stupid simple examples being yeeted cuz it just spams it

#

i'll add this once i get it working

fathom hazel
#

it was before the forum switch, so probably in #archived-example-scripts

fathom hazel
#

I did write the whole thing in discord without an editor lol

mellow pumice
#

uhh

#

im experiencing something weird

#

the blocks dont have an item version xd

#

so i cant pick them up lol

fathom hazel
#

well it's still expecting a texture file lol

mellow pumice
#

no not that

#

im not that dumb

#

w>

fathom hazel
#

cough

mellow pumice
#

:o

fathom hazel
#

I kid

#

did you silk touch?

mellow pumice
#

im middle clicking in creative

fathom hazel
#

out, wait the loot table wouldn't be made lol

#

yeah you have to generate the item too

mellow pumice
#

yeah i can do this

fathom hazel
#

found the example I was looking for

#

<#archived-example-scripts message>

#

I got pretty close for making it up from memory

mellow pumice
#

huge

#

leme try again

fathom hazel
#
const $TintedGlassBlock = Java.loadClass('net.minecraft.world.level.block.TintedGlassBlock')
const $Blocks = Java.loadClass('net.minecraft.world.level.block.Blocks')
const $BProperties = Java.loadClass('net.minecraft.world.level.block.state.BlockBehaviour$Properties')
const $BlockItem = java('net.minecraft.world.item.BlockItem')
const $IProperties = java('net.minecraft.world.item.Item$Properties')
StartupEvents.registry('block', event => {
  let customGlass = event.custom('new_glass', new $TintedGlassBlock($Properties.copy($Blocks.TINTED_GLASS)))
})
StartupEvents.registry('item', event => {
  event.custom('new_glass', new $BlockItem(customGlass.get(), new $IProperties()))
})
mellow pumice
#

im getting mixed things

#
const $TintedGlassBlock = Java.loadClass('net.minecraft.world.level.block.TintedGlassBlock')
const $Blocks = Java.loadClass('net.minecraft.world.level.block.Blocks')
const $Properties = Java.loadClass('net.minecraft.world.level.block.state.BlockBehaviour$Properties')
const BlockItem = Java.loadClass('net.minecraft.world.item.BlockItem')
const IProperties = Java.loadClass('net.minecraft.world.item.Item$Properties')

let tintedGlass

StartupEvents.registry('block', e => {
  tintedGlass = e.custom('test_block', new $TintedGlassBlock($Properties.copy($Blocks.TINTED_GLASS)))
})

StartupEvents.registry('item', e => {
  e.custom('test_block', new BlockItem(tintedGlass.get(), new IProperties()))
})

this is what i have, but its still not blocking light hmmm

fathom hazel
#

hmmm

mellow pumice
#

boxed in ^

fathom hazel
#

you'd think that would work....

mellow pumice
#

also do i just append stuff to that custom like it was a normal builder thonk

#

cuz i dun wanna make model jsons and shit, id rather just append the json lol

#

oh

#

hol up

fathom hazel
#

don't think so

mellow pumice
fathom hazel
#

nice

mellow pumice
#

this was odd

#

when building the box, it didnt update the air blocks inside

#

i had to fill the inside and then destroy it

#

wtf thonk

mellow pumice
# fathom hazel don't think so

i still seem to have some methods o.o

getClass, clientRegistry, wait, transformObject, translationKey, displayName, newID, notifyAll, createAdditionalObjects, notify, registryType, hashCode, get, tag, id, generateDataJsons, class, translationKeyGroup, generateAssetJsons, getTranslationKeyGroup, generateLang, createObject, addResourcePackLocations, getRegistryType, equals, toString
#

generateDataJsons thonk

#

nevermind

#

making progress but still not done

#

got this far, but the texture is not transparent xD

woeful elk
#

I've just written my own model json files, but I think I've got it working

#

I just included "render_type": "translucent" in the model file

mellow pumice
#

o.o

#

leme try

woeful elk
#

I think this was added in 1.19

mellow pumice
#

huge

#

putting it in #1048591172165189632 now

woeful elk
#

I've noticed something odd though. I'm using the vanilla tinted glass texture for the new block, but it appears to be lighter than the vanilla block

#

The new block is on the left and the vanilla tinted glass is on the right

mellow pumice
#

hmmm

#

i think i know

#

sec

woeful elk
#

Also my item model doesn't render transparent blocks behind it

#

But these are just minor issues

mellow pumice
#

what did you do for item model?

#

in the json

#

check the post i made, see if yours is similar

woeful elk
#

I think my jsons are the same as yours

mellow pumice
#

more specifically what have you tried

#

mine renders hmmm

woeful elk
#

I think I may have found the problem

mellow pumice
#

o?

woeful elk
#

Waiting for the world to load...

#

It seems to be a problem with the shaders I was using

fathom hazel
#

when in doubt, blame optifine/iris/oculus 😉

woeful elk
#

It's odd that it works with vanilla tinted glass but not this new block

#

Anyway, it looks like the new block works how I wanted. Thanks so much for the help!