#Block Overwriting (Having some issues with the block's functions)

39 messages · Page 1 of 1 (latest)

blissful kiln
#

Hey so i've been having some issues with overwriting blocks, for my modpack and all that 😅 . Basically i'm attempting to change some properties of the Weather Forecast block, added by the Weather2 Mod (Weather and Tornados mod)

I've created a new startup script that does the following ->

 // priority: 0
 // CLIENT SIDE ONLY
 // credits: aurora_luciri, from Vulpin Skies

 console.info('Setting up custom Weather blocks');

 const $ItemBlockRenderTypes = Java.loadClass('net.minecraft.client.renderer.ItemBlockRenderTypes');
 const $RenderType = Java.loadClass('net.minecraft.client.renderer.RenderType');
 const $Blocks = Java.loadClass('weather2.WeatherBlocks');
 const $ForecastBlock = Java.loadClass('weather2.block.ForecastBlock');

 StartupEvents.registry("block", (event) => {
    event.create('weather2:weather_forecast')
      .hardness(2.0)
      .resistance(6.0)
      .notSolid()
      .requiresTool(true)
      //.box(0, 0, 0, 16, 32, 16, false)
    })

StartupEvents.postInit((event) => {    
    $ItemBlockRenderTypes['setRenderLayer(net.minecraft.world.level.block.Block,java.util.function.Predicate)']($Blocks.BLOCK_FORECAST.get(), renderType => {
        return (renderType == $RenderType.cutout())
    });    
})

It should render the block model as a cutout + change some of its properties yk, but every time i do this, it breaks the block's functionality, which's when you right click it, it gives you some valuable feedback on the weather around you, chances of tornados, etc...

Here's a video i've asked a friend of mine to record and edit (he chose to hide his discord id idk why but yeah) -
https://www.youtube.com/watch?v=0EzmqdTR2XU

I've took most of my references from this post: https://discord.com/channels/303440391124942858/1143589372462121000 , but we've been unsuccessful in finding the root cause of the problem, mainly because, we get nothing on logs 😦

GitHub

Minecraft Forge Mod - Localized Weather - A rewrite of weather & tornados with a focus on localized storm systems - GitHub - Corosauce/weather2: Minecraft Forge Mod - Localized Weather - A ...

ocean steepleBOT
#

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

glacial peak
#

Isn't there a specific function for block modification?

#

rather than overriding the whole block

blissful kiln
#

and i think i'm also unable to change the box

blissful kiln
#

...

blissful kiln
glacial peak
#

and editing the rendering type of a block might require something not standard

#

I very much doubt its 'a bug'

blissful kiln
blissful kiln
#

Here's his

// priority: 0

console.info('Setting up custom Weather blocks');

const $ItemBlockRenderTypes = java('net.minecraft.client.renderer.ItemBlockRenderTypes');
const $RenderType = java('net.minecraft.client.renderer.RenderType');
const $Blocks = java('weather2.WeatherBlocks');
const $DeflectorBlock = java('weather2.block.DeflectorBlock');

onEvent('block.registry', event => {
    event.create('weather2:weather_deflector')
        .material('metal')
        .hardness(2.0)
        .resistance(6.0)
        .notSolid()
        .requiresTool(true);
    
})

onEvent('postinit', event => {
        
    $ItemBlockRenderTypes['setRenderLayer(net.minecraft.world.level.block.Block,java.util.function.Predicate)']($Blocks.BLOCK_DEFLECTOR.get(), renderType => {
        return (renderType == $RenderType.cutout())
    });    
})
glacial peak
#

that's not 1.19.2

#

that's 1.18.2

#

a lot changed between the versions

#

KubeJs was completely rewritten

#

and overwriting blocks to change properties wasn't really supposed to work in the first place

#

it's overall just a bad idea

blissful kiln
blissful kiln
pseudo owlBOT
#

You can modify various properties of existing blocks with KubeJS, and the wiki has a page on that!

glacial peak
#

(just looking myself)

blissful kiln
#

yes i know abt the wiki lol, but you can't modify a block's box with that yk

glacial peak
#

I wouldn't advise trying to

#

I think the best way to go around it would be create a new block, get rid of the old one and use reflection to access properties

blissful kiln
#

is there any docs on reflection and its usage?

glacial peak
#

syntax is like this though:

    const $GearData = Java.loadClass('net.silentchaos512.gear.util.GearData')
blissful kiln
#

ic

glacial peak
#

example from something I've used

#

then it's just like $Class.function()

blissful kiln
blissful kiln
#

I'll try that and see how it goes, if i have any problems i'll open a new thread k?

glacial peak
#

k