RedPxnda / RespawnObelisks

MIT License
5 stars 3 forks source link

[BUG] Item duplication #7

Closed Embalde closed 10 months ago

Embalde commented 11 months ago

Describe the bug Easy method of duplicating items using the respawn entity mechanic.

To Reproduce Steps to reproduce the behavior: 1.Take an obelisk core

  1. Click on an entity with storage (like a donkey with chest)
  2. Place the core in the obelisk
  3. Kill the entity, get the drops
  4. Respawn the saved entity with the undying totem

Expected behavior Once you save an entity in the core, the entity inventory/storage data will be saved too, making it so that if that entity respawns, it will respawn with the same storage data that it had at the moment of the save, meaning that you can just remove the items from the original entity, kill it, take the loot if it is droppable, and then spawn a new one that will include all the loot that the entity had when you stored it in the core. /

Screenshots -- no screenshot available --

Versions

Additional notes This was found and tested inside a custom modpack, the issue could be present in something that altered the mod functionality. I would like to point that the items saved in the tags: HandItems, ArmorItems, Items and SaddleItem are the ones I think could reproduce this bug. Awesome mod, good work!

RedPxnda commented 10 months ago

Sorry for getting to this so late! For some reason I didn't get an email about it. I thought I remember specifically giving the respawned entity a tag that prevents drops, but I guess it doesn't work for containers? I'll take a look into this and push an update when I get time.

RedPxnda commented 10 months ago

How do you imagine I should fix this? I could add dedicated support that clears donkeys' inventories, but that doesn't fix issues with modded entities' inventories. And it's not like I can just stop the entity being revived from dropping items, because then you can still open the inventory and take the items out.

RedPxnda commented 10 months ago

Alright, to allow for easy mod compatibility, I decided to create a very simple system that allows users to customize (via datapack... respawnobelisks/revived_nbt) parts of nbt to be dropped when saving an entity to be revived. I'll include stuff for vanilla entities by default, but most modded entities will have to have separate support added.

image By default, there are 4 files for data. One for horse armor, one for horse saddles, one for horse chests(llamas and donkeys), and a general purpose on for entities that can hold items. (eg. zombies)

image The format is very simple. There's an "entities" field, which determines which entities this should apply to. Can either be the id of a single entity, an array of entity ids, a * meaning all entities, or a builtin group marked by a $ prefix. Then there's an "adjusters" field, which is an array of "adjuster" objects(can also be one). Right now there's only one type of adjuster, and it just removes the specified tag ("target") from the entity's nbt.

This feature will be added in the next update, which is in the process of being built.

ViMayer commented 9 months ago

Hi! I was the one that opened the issue, sorry for not answering your question, that was not the account I intended to publish the issue as, resulting in me not seeing the updates.

But as far as I can see, Im glad I didn't, because I would suggest just removing all the inventory tags from the entity, and you went beyond that and implemented a way of customizing it, which I appreciate heavily.

Loved the mod concept, amazing work!