-
Notifications
You must be signed in to change notification settings - Fork 71
Entity Data additions #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Entity Data additions #1056
Conversation
bc83555 to
5db4599
Compare
5db4599 to
d685d5d
Compare
This comment was marked as outdated.
This comment was marked as outdated.
- "disable-slots" (bool) - to EntityData and "armorstand" spell effect where it's "true" by default - "disable-slots" (EquipmentSlot enum list) - "equipment-locks" (list of sections with EquipmentSlot "slot" and ArmorStand.LockType "lock")
d685d5d to
cd6684b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
I'm also considering whether we should add a |
50ad41c to
8a6768c
Compare
core/src/main/java/com/nisovin/magicspells/spells/targeted/EntityDataApplySpell.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/nisovin/magicspells/spells/targeted/EntityDataApplySpell.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/nisovin/magicspells/spells/targeted/EntityDataApplySpell.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/nisovin/magicspells/spells/targeted/EntityRemoveSpell.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/nisovin/magicspells/util/EntityData.java
Outdated
Show resolved
Hide resolved
| addOptSkinParts(transformers, config, "mannequin.skin-parts.right-pants", SkinParts.Mutable::setRightPantsEnabled); | ||
| addOptSkinParts(transformers, config, "mannequin.skin-parts.hats", SkinParts.Mutable::setHatsEnabled); | ||
|
|
||
| addComponent(transformers, config, "mannequin.description", Mannequin.class, Mannequin::setDescription, null, forceOptional); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have a default value for this option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a custom name is set on a Mannequin, it is shifted up so that a description component shows up below it, with the default one being "NPC" (<lang:entity.minecraft.mannequin.label>). To hide the description, you can set it to an empty string, but the nameplate remains shifted. If you can set the description to null, the nameplate is at its usual elevation.
I figured our users would favour the nameplate not shifting over having the default description, which can still be accessed with the MiniMessage translation component.
core/src/main/java/com/nisovin/magicspells/util/EntityData.java
Outdated
Show resolved
Hide resolved
| // Mob Goals | ||
| ConfigurationSection mobGoals = config.getConfigurationSection("mob-goals"); | ||
| if (mobGoals != null) { | ||
| if (mobGoals.getBoolean("remove-all")) | ||
| transformers.put(Mob.class, (Mob mob, SpellData data) -> Bukkit.getMobGoals().removeAllGoals(mob)); | ||
|
|
||
| for (String string : mobGoals.getStringList("remove-types")) { | ||
| ConfigData<GoalType> typeData = ConfigDataUtil.getEnum(string, GoalType.class, null); | ||
|
|
||
| transformers.put(Mob.class, (Mob mob, SpellData data) -> { | ||
| GoalType type = typeData.get(data); | ||
| if (type == null) return; | ||
|
|
||
| Bukkit.getMobGoals().removeAllGoals(mob, type); | ||
| }); | ||
| } | ||
|
|
||
| for (String string : mobGoals.getStringList("remove")) { | ||
| ConfigData<NamespacedKey> keyData = ConfigDataUtil.getNamespacedKey(string, null); | ||
|
|
||
| transformers.put(Mob.class, (Mob mob, SpellData data) -> { | ||
| NamespacedKey key = keyData.get(data); | ||
| if (key == null) return; | ||
|
|
||
| Bukkit.getMobGoals().removeGoal(mob, GoalKey.of(Mob.class, key)); | ||
| }); | ||
| } | ||
|
|
||
| for (String string : mobGoals.getStringList("remove-vanilla")) { | ||
| ConfigData<String> stringData = ConfigDataUtil.getString(string); | ||
|
|
||
| transformers.put(Mob.class, (Mob mob, SpellData data) -> { | ||
| String value = stringData.get(data); | ||
| if (value == null) return; | ||
|
|
||
| GoalKey<?> key = MagicSpells.getCustomGoalsManager().getVanillaGoal(value); | ||
| if (key == null) return; | ||
|
|
||
| // We have to loop through because casting to parameter types is tricky. | ||
| // It loops through on each MobGoals#removeGoal call anyway. | ||
| for (Goal<@NotNull Mob> goal : Bukkit.getMobGoals().getAllGoals(mob)) { | ||
| if (!goal.getKey().equals(key)) continue; | ||
| Bukkit.getMobGoals().removeGoal(mob, goal); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| for (Object object : mobGoals.getList("add", new ArrayList<>())) { | ||
| if (!(object instanceof Map<?, ?> map)) continue; | ||
| ConfigurationSection section = ConfigReaderUtil.mapToSection(map); | ||
|
|
||
| ConfigData<Integer> priorityData = ConfigDataUtil.getInteger(section, "priority", 0); | ||
| ConfigData<String> goalNameData = ConfigDataUtil.getString(section, "goal", ""); | ||
|
|
||
| ConfigurationSection goalSection = section.getConfigurationSection("data"); | ||
| if (goalSection == null) continue; | ||
|
|
||
| transformers.put(Mob.class, (Mob mob, SpellData data) -> { | ||
| int priority = priorityData.get(data); | ||
| String goalName = goalNameData.get(data); | ||
|
|
||
| CustomGoal goal = MagicSpells.getCustomGoalsManager().getGoal(goalName, mob, data); | ||
| if (goal == null) return; | ||
|
|
||
| boolean success = goal.initialize(goalSection); | ||
| if (success) Bukkit.getMobGoals().addGoal(mob, priority, goal); | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be structured more like what you did for scoreboard-tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually regret the new format for scoreboard-tags as a list of ordered actions, since clear only ever makes sense if done first, and add or remove order doesn't matter, so the format should've probably been a bool clear action that holds priority, followed by a list of add and remove strings. mob-goals is a bit more complex to be switched to a string list in a similar structure, and this format was copied from MobGoalEditSpell, so I think it's more fitting.
8a6768c to
269e8b2
Compare
Changelog:
Additions:
disable-slotstoarmorstandspell effect. Boolean, defaulting totrue.no-physics,persistent, andinvulnerable- Booleanfire-ticksandfreeze-ticks- Integervisual-fire-true,false, ornot_set.scoreboard-tags- Aside from a list of strings of tags to add, you can now specify a list of configuration sections withoperation(defaultadd,remove, andclear), andtagstring option toaddorremove.passengers- List of Entity Datacan-pickup-items- Booleanmax-health- Doubleaware- Booleanmob-goals:remove-all- Booleanremove-types- List of GoalTyperemove-vanilla- List of VanillaGoalremove- List of Namespaced Keysadd- List of Mob Goal configurationstamed-owner- Boolean - sets the entity as tamed and the recipient as its owner (caster of the spell or target of a Buff).armor_stand:disable-slots- Bool or a list of EquipmentSlot.equipment-locks- List of configuration sections with optionsslot(EquipmentSlot) andlock(LockType).chicken:chicken-variant- Chicken Variantcopper_golem:copper_golemsection:weathering-state- WeatheringCopperStateoxidizing- May beunset, in which case oxidation happens naturally;waxed, in which case it is disabled; or a (Long type) number of ticks until the next weathering state.command_minecart:command- Stringcow:cow-variant- Cow Variantfalling_block:cancel-dropandhurt-entities- Booleandamage-per-block- Floatmax-damage- Integerfriction-state-true,false, ornot_setgoat:left-horn,right-horn, andscreaming- Booleanhoglin:immune-to-zombificationandable-to-be-hunted- Booleanmannequin:mannequinsection:immovable- Booleanskin-partssection, boolean options forcape,jacket,left-sleeve,right-sleeve,left-pants,right-pants, andhats.description- Rich Textmain-hand- MainHandprofilesection:name- Stringuuid- UUID formatted Stringbody,cape,elytra- Namespaced Keymodel- SkinModelitem:item- Vanilla item format or Magic Item Stringmax-speed- Doubleslow-when-empty- Booleandisplay-block-offset- Integerdisplay-block- Block Datapiglin:able-to-hunt- Booleandancing- Integer ticksimmune-to-zombification- Booleanpatrol-leader,can-join-raid, andcelebrating- Booleansalmon:salmon-variant- Salmon Variantvindicator:johnny- Booleanzombie_villager:villager-profession- Villager Professionvillager-type- Villager Type.targeted.ApplyEntityDataSpellwithentityEntity Data option. This spell applies the configured Entity Data to the targeted entity..targeted.EntityRemoveSpell, which removes non-player entity targets from the world without the death animation.