I'm attempting to make a mod that changes properties of some vanilla blocks. (such as reducing the blast resistance of obsidian or making snow slippery)
I've found multiple threads saying this can be done using an event handler and I have managed to get that working, but all the threads that I have seen either don't explain how to do it or are for older versions.
If anyone knows how or another way to do this and wouldn't mind helping me out, I would be so thankful!
Without mentioning the modloader you are using (Forge/Rift/Fabric) or the version you are modding for it will be hard to help. Please respond with the necessary information and I'll see what I can find.
You may be able to adjust this using an event handler (try reading through https://mcforge.readthedocs.io/en/latest/events/intro/#:~:text=Forge%20uses%20an%20event%20bus,events%20is%20located%20at%20MinecraftForge. ). Basically you write an event handler to intercept a certain event and write code to be executed when the event fires. As far as block properties goes, there might be an event which fires when a block is registered (I don't know where to find a list of events but just snoop around in the decompiled source code as all of the events will be in the same package).
If there is no such event, you will unfortunately need to access the method defining the property you wish to adjust using Java Reflection and then modify it yourself. This is usually a more difficult subject to tackle for users with no prior Java knowledge to modding Minecraft, but is an essential functionality for these kind of procedures to work.
You can also research the use of Mixins, however I think this is more applicable to the Rift and/or Fabric modloaders and requires Java bytecode knowledge (=core modding).
Hope these possibilities help you further. I won't be able to provide you with solid source code examples but as far as I am aware giving the code is generally frowned upon as the people don't learn anything from it (in other words, figuring things out yourself is advised).
I'm attempting to make a mod that changes properties of some vanilla blocks. (such as reducing the blast resistance of obsidian or making snow slippery)
I've found multiple threads saying this can be done using an event handler and I have managed to get that working, but all the threads that I have seen either don't explain how to do it or are for older versions.
If anyone knows how or another way to do this and wouldn't mind helping me out, I would be so thankful!
edit: I'm using forge 1.15.2
Without mentioning the modloader you are using (Forge/Rift/Fabric) or the version you are modding for it will be hard to help. Please respond with the necessary information and I'll see what I can find.
Have the day you deserve.
oh yes, sorry. I'm using forge 1.15.2
You may be able to adjust this using an event handler (try reading through https://mcforge.readthedocs.io/en/latest/events/intro/#:~:text=Forge%20uses%20an%20event%20bus,events%20is%20located%20at%20MinecraftForge. ). Basically you write an event handler to intercept a certain event and write code to be executed when the event fires. As far as block properties goes, there might be an event which fires when a block is registered (I don't know where to find a list of events but just snoop around in the decompiled source code as all of the events will be in the same package).
If there is no such event, you will unfortunately need to access the method defining the property you wish to adjust using Java Reflection and then modify it yourself. This is usually a more difficult subject to tackle for users with no prior Java knowledge to modding Minecraft, but is an essential functionality for these kind of procedures to work.
You can also research the use of Mixins, however I think this is more applicable to the Rift and/or Fabric modloaders and requires Java bytecode knowledge (=core modding).
Hope these possibilities help you further. I won't be able to provide you with solid source code examples but as far as I am aware giving the code is generally frowned upon as the people don't learn anything from it (in other words, figuring things out yourself is advised).
Have the day you deserve.