Page 1 of 1

unknown block callback?

PostPosted: Thu Jul 21, 2016 19:31
by taikedz
Hello

I did a quick search for "Unknown blocks" in this forum and the related-projects forum, and the dev wiki, and turned up suprisingly little.... so here's my question:

Would it be of relevance/desire to add a "on_unknownblock(itemstring)", "on_unknownitem" and "on_unknownentity(itemstring)" set of callbacks so that we could control behaviour on "Unknown"?

So that when a mod is removed or changed, instead of having lots of unknown blocks lying around we could define their replacements dynamically

For example this pseudocode (I am gradually learning lua, the below may contain some python or bash :-/)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
global.on_unknowitem = function(itemstring)
    case itemstring in:
        "farming:bread":
            return "default:apple 10"
        "ethereal:fancywood":
            return "default:wood_pine"
    end-case
    return itemstring -- just leave it actually unknown
end-function

global.on_unknownblock = function(itemstring)
    return "default:dirt" -- just replace any block with dirt
end-function

global.on_unknownentity = function(itemstring)
    return null -- remove the item from the world
     -- return "mobs:rat" -- example of replacing all unknown mobs with rats...
end-function

Re: unknown block callback?

PostPosted: Wed Aug 10, 2016 13:17
by taikedz
Not of interest? Or is there already a way to achieve this?

Re: unknown block callback?

PostPosted: Wed Aug 10, 2016 13:32
by rubenwardy
The name of the unknown node is "unknown", I'm not sure if unknown items are aliases to this. If unknown nodes are aliased to "unknown" you could write an ABM.

Re: unknown block callback?

PostPosted: Wed Aug 10, 2016 16:46
by taikedz
Hmmm it's not particularly granular, and wont cover craft items and mobs...

I'll have a try with the abm nonetheless.

Re: unknown block callback?

PostPosted: Wed Aug 10, 2016 22:30
by kaeza
Not exactly what you're looking for, but try "clean" mod. It needs manual configuration though.

Re: unknown block callback?

PostPosted: Thu Aug 11, 2016 08:59
by taikedz
kaeza - that is much closer to what I am looking for, thanks! As long as I or a player do/es no have to manually go replacing nodes and the players don't have to see the old nodes, that's fine :-p

I'll probably need to combine it with a perl script to extract all nodes, entities and tools from a mod dir to automatically generate the pre-config, and then I'll be good to do some mod cleanup!

Merci buckets :-p

Huzzah!