Shopkeepers

Shopkeepers

2M Downloads

Admin Shop AI? Villager Editor Invinciblity? (NOT A BUG)

whyonly8 opened this issue ยท 3 comments

commented

I am trying to create a game mode where players fight zombies to stay alive and trade with villagers to advance. The zombies do not target the villagers thanks to Mythic Mobs customization, but players can still damage the villagers on accident. I was hoping to use an Admin Shop with AI, so that the villagers would act as normal, but there is no AI toggle. I then thought maybe I can use regular villagers whose trades have been edited through the editor, but they do not have any sort of customization in that respect. The only solution I have found is using Mythic Mobs to create custom invincible villagers and then use the editor to change the trades. This works until the server restarts and the villagers are no longer saved under Mythic Mobs, but instead Shopkeepers.

commented

I find it hard to understand when/whether you are talking about shopkeeper villagers, or when/whether you are talking about regular villagers that possibly were edited via the villager editor of the Shopkeepers plugin (https://github.com/Shopkeepers/Shopkeepers-Wiki/wiki/Editor-for-regular-villagers).

The zombies do not target the villagers thanks to Mythic Mobs customization

players can still damage the villagers on accident

In case of shopkeepers villagers:
Regular zombies should already not target shopkeeper villagers regardless. The Shopkeepers plugin cancels target attempts of mobs if they involve shopkeeper mobs.
The same goes for any kind of damage: The Shopkeepers plugin is already canceling damage events affecting shopkeeper mobs. So if players are able to damage shopkeeper mobs, this might be caused by an incompatibility with one of your other plugins.

If you are talking about regular villagers, edited via the shopkeepers plugin, but which are not actually shopkeeper villagers:
Yeah, they are regular villagers. You will have to find a plugin that prevents damage towards regular villagers. Maybe WorldGuard has a region flag for this (however, I have briefly checked, and only found one mentioning animals). But I am fairly certain that there are plugins out there which allow you to configure which types of mobs are able to receive damage.

Actually, it is even possible to make specific mobs invincible via Minecraft's built-in functionality alone, by setting their Invulnerable tag. Either spawn a villager with this tag Invulnerable: 1b via Minecraft's summon command, or edit the data of an already spawned villager via /data modify entity <entityUUID> Invulnerable set value 1b. Minecraft will let you autocomplete the entity uuid when you look at the entity while typing the command. Note that mobs with this tag will still receive damage from players in creative mode. So make sure to be in survival mode when testing this. I briefly tested this and can confirm that this tag works.

I was hoping to use an Admin Shop with AI, so that the villagers would act as normal, but there is no AI toggle.

Nope, there is not, and there are also no plans to add something like this. There are a few alternatives though: You can create Citizens shopkeepers and setup the Citizens NPC to behave in a certain way, eg. walk around, etc. (but that won't match the regular villager behavior obviously).
Or you can configure the trades of a regular villager (either via Minecraft commands, or via the editor I linked to above). However, this villager won't be managed by the Shopkeepers plugin then. It will receive damage like normal (unless you prevent this by some mean, see above), walk around like normal, may decide to change its trades if there is some vanilla behavior that does this, may decide to despawn, etc. So they may or may not be a suitable alternative to the shopkeeper villagers.

I then thought maybe I can use regular villagers whose trades have been edited through the editor, but they do not have any sort of customization in that respect.

You can edit the trades of regular villagers either via the feature I linked above, or directly via Minecraft commands. This assumes that you are on the latest version of Spigot. If you are using older Minecraft versions, you might be out of luck in this regard.

If by "they do not have any sort of customization in that respect" you mean the invincibility aspect: See my comment on that above. I can also look into adding an editor option for regular villagers to make toggling this property more convenient.

However, there may be other vanilla game mechanics which break or despawn the villager occassionally. Or there may be plugins that delete regular mobs on the server (eg. anti-lag plugins, killall commands, or similar). So if you decide to go the route of using regular villagers for your setup, you will always have the risk of something either intentionally or accidentially deleting these villagers, without there being a way to restore them (without some kind of backup).

The only solution I have found is using Mythic Mobs to create custom invincible villagers and then use the editor to change the trades. This works until the server restarts and the villagers are no longer saved under Mythic Mobs, but instead Shopkeepers.

I am not familiar with MythicMobs and its features, so I am not sure how you create these villagers and how the plugin then implements it features for this mob, and whether or not these are supposed to persist.

If this is a regular villager (or 'regular' villager spawned by the Mythic Mobs plugin), which you then edit via the editor I linked to above, persisting these mob properties would probably be something for the MythicMobs plugin to look into.

But if this is a shopkeeper villager which you then retroactively modified via MythicMobs: Yeah, this is not supported and any modifications to the villager will be lost regularly, because the Shopkeepers plugin recreates (respawns) its mobs every time the chunk unloads and loads again, including on server restarts. I have no plans to change that.

It might be possible to hook into Shopkeepers and programmatically, via a separate add-on plugin, create a custom 'shop object type' which then spawns the mob to be setup and behave however you like (similar to the Citizens integration).
Or you could write a separate addon-plugin which adds certain functionality to the mobs spawned by the shopkeepers plugin whenever they are spawned. However, the Shopkeepers plugin makes some assumptions internally about these mobs being stationary (for example, to check if a chunk contains a shopkeeper villager, it keeps an index of where it originally spawned the villager). So adding their AI back may break the plugin and is therefore not supported.
All of this would require a programmer to write an add-on plugin which then adds this functionality specific to your needs. Since this would be specific to your requirements on your server, I won't be the one doing this for you. You either have to do this yourself, or find a programmer to do it for you.

However, if all you require is to make a regular villager invincible, either use the Minecraft tag I mentioned above, or look for a plugin that offers this capability.

commented

I appreciate your help. I will try the invincible tag on the villagers with edited trades.

commented

The next version will offer an editor option for regular villagers to conveniently toggle their Minecraft invulnerability property.