Started by
wectorjb
on
Topic category: Help with Minecraft modding (Java Edition)
So basically I'm making a small mod for burning stuff and I ran into a problem: my cobblestone won't turn into the burnt one. I tried
If x y z is cobblestone
Do: If x y+1 z is fire
Do: replace x y z to burnt cobblestone.
It won't budge. Any ideas?
well, if you have both blocks already, you could just tell it to only do it when it checks fire in a 1 block radius around it, and if true, replace the cobblestone with burnt cobblestone.
that's literally what I tried... Also I kinda have no access to changing cobblestone's triggers.
Only thing I can think is, use one of the global triggers "when player uses item", "when player finishes using item", "when player right clicks with item", or "when player right clicks block" (I don't know which would give better results, or if it makes a difference).
Check if the provided itemstack (or item in the player's main hand, if the trigger you pick doesn't provide an itemstack variable) is flint and steel.
If yes, then check if the block at x/y/z is cobblestone (or fire). (I don't know whether the triggers I listed pass the coordinates of the block you clicked on, or the empty space adjacent to the block face you clicked on; would have to test this, and it might depend on which trigger, idk.)
If yes it is cobblestone, check if the block above is fire; or if yes it is fire, check if the block below is cobblestone. If yes to one of the above, replace the cobblestone.
Now, this would only work for fires lit by the player with flint and steel, not fires caused by lightning or spreading by flammable blocks burning.
Although there is a "when entity struck by lightning" global trigger you could put a similar check in, for the block at x / y-1 / z. And possibly you could use the "block is broken" global trigger to check if it was replaced by fire, and then if the block below it is cobblestone, but I'm not sure if that global trigger fires whenever a block is broken, or only when broken by a player directly.
I can't think of any other way to trigger it when fire spreads naturally, since there aren't any global triggers related to fire. Best I can think of there is to possibly use the "on player tick" trigger or something, to have it check if the block the player's cursor is targeting is either fire or cobblestone, and go from there. You probably don't want to put a whole lot into "on player tick" since it fires every game tick (and thus has a lot of potential to generate lag)... but it might work well enough, depending on your use case. In any case, those are the things I would try, if I was implementing something like this myself.