#How can I modify some block flammable.
17 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
try 1 ~~ ~~
I tried this
let burnableBlocks = [
"minecraft:stone",
"exmode:exmodeblock"
];
const Integer = Java.loadClass("java.lang.Integer");
BlockEvents.modification(event => {
burnableBlocks.forEach(burnableBlock =>{
event.modify(burnableBlock, block =>{
let setFlammable = Blocks.FIRE.class.getDeclaredMethod("m_53444_", Blocks.WATER.getClass().getSuperclass(), Integer.TYPE, Integer.TYPE)
setFlammable.setAccessible(true);
setFlammable.invoke(Blocks.FIRE.class, block, 20, 20)
})
})
})
From
#archived-support-1-19 message
But i have this.
[20:01:01] [ERROR] ! Error in 'BlockEvents.modification': object is not an instance of declaring class
[20:01:01] [ERROR] ! java.lang.IllegalArgumentException: object is not an instance of declaring class
try 2~~ ~~
#1263344017249271828 message
But there is no method invokeSetFlammable
[➤](#1263344017249271828 message)
I saw this question asked many times on here and no one actually gave the real answer...
The true answer is
you have to do it in the blockmodification event with fire, and "invokeSetFlammable'
It has to be in the BlockEvents.modification or you get an error "tried to set air on fire" when doing it on custom blocks.
BlockEvents.modification((event) => {
Blocks.FIRE.invokeSetFlammable('ulszsurvival:moldy_acacia_planks', 5, 20)
});
Also remember to give it a material that is valid for fire, such as "wood" or you wont be able to even use flint and steal on it. (Doing that without setting it as flammable with invokeSetFlammable results in a block that can be lit on fire but never actually burns away.)
Inside ```js
StartupEvents.registry('block', event => { ...
```js
event.create('ulszsurvival:moldy_acacia_planks',"basic")
.material('wood')
.hardness(1.5)
.resistance(2.5)
.textureAll("surv:block/moldy_acacia_planks")
.tagBlock("minecraft:mineable/axe")
.tagBlock("minecraft:planks")
.tagBlock("immersive_weathering:cracked")
.tagItem("immersive_weathering:flammable_planks")
.randomTick(tick =>{
applyMold(tick);
})
try 3 ~~ ~~
But there is no setFlammable and it's look same as #1296078114039795762 message
[➤](#1252113564034928660 message) U can use the block modification event to modify fire block and call .setFlammable(block, igniteOdds, burnOdds)
[➤](#1296078114039795762 message)
try 1 ~~ ~~
I tried this
let burnableBlocks = [
"minecraft:stone",
"exmode:exmodeblock"
];
const Integer = Java.loadClass("java.lang.Integer");
BlockEvents.modification(event => {
burnableBlocks.forEach(burnableBlock =>{
event.modify(burnableBlock, block =>{
let setFlammable = Blocks.FIRE.class.getDeclaredMethod("m_53444_", Blocks.WATER.getClass().getSuperclass(), Integer.TYPE, Integer.TYPE)
setFlammable.setAccessible(true);
setFlammable.invoke(Blocks.FIRE.class, block, 20, 20)
})
})
})
From
#archived-support-1-19 message
But i have this.
[20:01:01] [ERROR] ! Error in 'BlockEvents.modification': object is not an instance of declaring class
[20:01:01] [ERROR] ! java.lang.IllegalArgumentException: object is not an instance of declaring class
I use
console.info(Blocks.FIRE.class.getDeclaredMethods)
and there is no setFlammable but i found m_53444_ private method what have same property
I found the way
#off-topic message
let burnableBlocks = [
];
let fieldName = [
"f_221147_",
"f_53422_"
]
const Integer = Java.loadClass("java.lang.Integer");
const Object2IntMap = Java.loadClass("it.unimi.dsi.fastutil.objects.Object2IntMap");
const Blocks = Java.loadClass("net.minecraft.world.level.block.Blocks");
BlockEvents.modification(event => {
burnableBlocks.forEach(burnableBlock => {
event.modify(burnableBlock, block => {
fieldName.forEach(name => {
let oddsField = Blocks.FIRE.class.getDeclaredField(name);
oddsField.setAccessible(true);
let oddsMap = oddsField.get(Blocks.FIRE);
oddsMap.put(block, 10);
})
});
});
});
Ticket closed!
works well
let burnableBlocks = [
"minecraft:stone",
"exmod:exblock"
];
const oddsValue = 100;
const Integer = Java.loadClass("java.lang.Integer");
const Object2IntMap = Java.loadClass("it.unimi.dsi.fastutil.objects.Object2IntMap");
const Blocks = Java.loadClass("net.minecraft.world.level.block.Blocks");
BlockEvents.modification(event => {
burnableBlocks.forEach(burnableBlock => {
let fields = Blocks.FIRE.class.getDeclaredFields();
fields.forEach(field => {
if (field.getType().getName().includes("Object2IntMap")) {
field.setAccessible(true);
event.modify(burnableBlock, block => {
let oddsMap = field.get(Blocks.FIRE);
oddsMap.put(block, oddsValue);
console.info("success : " + field.getName() + ", " + block);
})
}
});
});
});
this works well too, lets goooooo
burn and flame them all
ProbeJS isn’t always completely accurate in its code hints, but the invokeSetFlammable method does indeed exist. I literally use it in my modpack. The linter complains but it absolutely works.
Solved and share code