KubeJS

KubeJS

69M Downloads

Block Entity inventory inputfilter dont work with custom items

DevDyna opened this issue ยท 1 comments

commented

Minecraft Version

1.20.1

KubeJS Version

kubejs-forge-2001.6.4-build.138

Rhino Version

rhino-forge-2001.2.2-build.18

Architectury Version

architectury-9.2.14-forge

Forge/Fabric Version

Forge - 47.2.20

Describe your issue

when used on .inventory() a custom item as input filter , it deny all items included input filter
script used:

StartupEvents.registry("item", (event) => {
  event.create("kubejs:star")
})
StartupEvents.registry("block", (event) => {
  event.create('block_id').blockEntity((be) => {
      be.inventory(9, 1, 'kubejs:star');
      be.rightClickOpensInventory();
  })
})

Crash report/logs

No response

commented

Looks like the callback gets called immediately, which causes the string to try resolve into an Item immediately, which fails to catch custom items (and probably most modded items too) cause the registry events are still processing.

@Info("Creates a Block Entity for this block")
public BlockBuilder blockEntity(Consumer<BlockEntityInfo> callback) {
blockEntityInfo = new BlockEntityInfo(this);
callback.accept(blockEntityInfo);
return this;
}

To fix this the callback should be stored instead and only called when the block entity type is being created/registered (which is guaranteed to happen after item reg). It can't be called in block reg cause that happens before item reg (due to BlockItems needing a Block reference).