Skip to content

implement '.auto' for drop configurations in decaying blocks. #2386

Closed

Description

@tillpp

#2382 (comment)

For this, callback.init might need more context

Activity

  1. IntegratedQuantum commented on Dec 8, 2025

    @IntegratedQuantum
    Member

    @Argmaster what do you think about adding extra state to the Callback.init function so it knows what block (or item) it belongs to?

  2. tillpp commented on Dec 8, 2025

    @tillpp
    ContributorAuthor

    Since #2381 also uses callbacks but for items i would suggest having variadic inits, such that block callbacks can have the block info, and item callbacks item infos

  3. Argmaster commented on Dec 9, 2025

    @Argmaster
    Collaborator

    Edit: I assume we are considering change from

    pub fn init(zon: ZonElement) ?*@This() {

    To

    pub fn init(zon: ZonElement, owner: *something) ?*@This() {

    Since use case is this simple, I don't think we have a reason to produce more complicated solution.
    Callbacks are inherently bound to the context of their owner, they can't be exchanged between different owners (an owner would be a block, an item etc.) so I don't think it reduces the usefulness of the solution. This is a reasonable extension of passing zon object to init.
    There should be no separate info object. It should be just an reference to incomplete (as in not fully initialized) owner object.
    Tbd how exactly the state of the object should be defined. You cannot guarantee the order of the callbacks, maybe you can guarantee that callbacks are initialized last. This is quite important, because callbacks can do basically anything if they have a pointer to the object.
    Implementation should be flexible enough to handle typical path of evolution - use without an owner and use with modded owner (eg. Custom item type). I am not sure if implementation can be done though comp time generics or anytype pointers or union enums.

  4. tillpp commented on Dec 9, 2025

    @tillpp
    ContributorAuthor

    There should be no separate info object. It should be just an reference to incomplete (as in not fully initialized) owner object.

    I am not advocating for a separate info object.
    when i said block info, i meant either the incomplete the block object or just the BlockID

    Tbd how exactly the state of the object should be defined. You cannot guarantee the order of the callbacks, maybe you can guarantee that callbacks are initialized last. This is quite important, because callbacks can do basically anything if they have a pointer to the object.

    I think callbacks are currently initialized last.

  5. IntegratedQuantum commented on Dec 11, 2025

    @IntegratedQuantum
    Member

    Implementation should be flexible enough to handle typical path of evolution - use without an owner and use with modded owner (eg. Custom item type). I am not sure if implementation can be done though comp time generics or anytype pointers or union enums.

    What I would suggest is just use the generic type, i.e. just the block index (which we desparately should make into its own type), or the item index.
    It might also make sense to make them optional in the future, however for now I'd suggest to keep it non-optional until we have a use-case for it.

    And custom item types, if we choose to open this can of worms, can probably have custom callback creation functions as well.

  6. added
    contributor friendlythis issue is limited in scope and/or knowledge of Cubyz internals, good for newcomers
    refactorshuffle code around
    on Dec 13, 2025
  7. added a commit that references this issue on Jun 15, 2026
    2682475
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlythis issue is limited in scope and/or knowledge of Cubyz internals, good for newcomersrefactorshuffle code around

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions