I suggest a pair of callbacks triggered whenever a chest is open. They'd use the following params
(EntityPickup chest, RNG rng,table SpawnedEntities). The AddCallback function would take PickupVariant as an additional parameter for only triggering on a specific kind of chest.
Returning any value doesn't affect the MC_POST_CHEST_OPEN callback, but the MC_PRE_CHEST_OPEN callback accepts the following table, with any combination of its values:
{boolean CanOpen whether or not a chest will actually open. If returned false, will prevent future instances of the callback from running.
table SpawnedEntities table with Type, Variant and SubType of entities spawned by it, with the following structure: {Type,(default = 0) Variant,(default = 0) SubType, (default = RandomVector()) Velocity}
boolean OpenCost whether or not opening the chest will consume any cost it usually has, such as dealing damage, or taking keys. Obviously doesn't work for regular, stone and red chests.
boolean Remain whether or not the chest will disappear on opening or keep a version of it with subtype of 1. By default is true but by default also becomes false if a collectible is present in the SpawnedEntities table
}.
Additionally, returning false is equivalent to returning {CanOpen = false, OpenCost = false}. Returning true or nil makes it behave as normal.
I suggest a pair of callbacks triggered whenever a chest is open. They'd use the following params (
EntityPickup chest
,RNG rng
,table SpawnedEntities
). TheAddCallback
function would take PickupVariant as an additional parameter for only triggering on a specific kind of chest.Returning any value doesn't affect the
MC_POST_CHEST_OPEN
callback, but theMC_PRE_CHEST_OPEN
callback accepts the following table, with any combination of its values: {boolean CanOpen
whether or not a chest will actually open. If returnedfalse
, will prevent future instances of the callback from running.table SpawnedEntities
table with Type, Variant and SubType of entities spawned by it, with the following structure: {Type,(default = 0) Variant,(default = 0) SubType, (default = RandomVector()) Velocity}boolean OpenCost
whether or not opening the chest will consume any cost it usually has, such as dealing damage, or taking keys. Obviously doesn't work for regular, stone and red chests.boolean Remain
whether or not the chest will disappear on opening or keep a version of it with subtype of 1. By default istrue
but by default also becomesfalse
if a collectible is present in theSpawnedEntities
table }.Additionally, returning
false
is equivalent to returning{CanOpen = false, OpenCost = false}
. Returningtrue
ornil
makes it behave as normal.