Event request: on_pre_player_spilled_items
Posted: Mon Jul 20, 2020 7:40 pm
Heya,
recently, we got huge problems on public servers, where people intentionally crash servers by exploiting the inefficiency of surface.spill_item_stack() function. They mainly do it by using crafting queue, they basically fill their queue by thousands of items, then cancel whole queue at once and as their inventory cannot fit all the items, they get spilled on ground. When there is too many items spilled, server needs exponencially more cpu power to find next free position for spilled items (this causes huge lag spike once the range of filled space goes over chunk or two already), and if there isn't enough free space (for example they are on island, or on separate small surface - think about factorissimo, ribbon world, or similar), it even can cause the server to run out of cpu and basically all you can do is to shut it down.
So, if there would be something like on_pre_player_spilled_items event, I can make a script that would hook into this event, and deny the spilling by doing some action prior to spill is called, for example killing the character (as character corpse has unlimited size of inventory, thus won't spill anything). This would be great antigrief, or even just safety measure.
on_pre_player_spilled_items event would ideally contain:
- player
- buffer of items that are about to be spilled (so I can count them, plus I can just .clear() the buffer similar to on_player_mined_entity, or do any other stuff with it)
- cause : if the spill was due to change of inventory size, or cancelling crafting, or something else
- called when player is about to eject items automatically on ground around, for example due to cancelled crafting queue or due to removed armor, but before the spilling happens, so we can intercept it.
recently, we got huge problems on public servers, where people intentionally crash servers by exploiting the inefficiency of surface.spill_item_stack() function. They mainly do it by using crafting queue, they basically fill their queue by thousands of items, then cancel whole queue at once and as their inventory cannot fit all the items, they get spilled on ground. When there is too many items spilled, server needs exponencially more cpu power to find next free position for spilled items (this causes huge lag spike once the range of filled space goes over chunk or two already), and if there isn't enough free space (for example they are on island, or on separate small surface - think about factorissimo, ribbon world, or similar), it even can cause the server to run out of cpu and basically all you can do is to shut it down.
So, if there would be something like on_pre_player_spilled_items event, I can make a script that would hook into this event, and deny the spilling by doing some action prior to spill is called, for example killing the character (as character corpse has unlimited size of inventory, thus won't spill anything). This would be great antigrief, or even just safety measure.
on_pre_player_spilled_items event would ideally contain:
- player
- buffer of items that are about to be spilled (so I can count them, plus I can just .clear() the buffer similar to on_player_mined_entity, or do any other stuff with it)
- cause : if the spill was due to change of inventory size, or cancelling crafting, or something else
- called when player is about to eject items automatically on ground around, for example due to cancelled crafting queue or due to removed armor, but before the spilling happens, so we can intercept it.