mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 02:42:18 +00:00
Completed Tag Support for Auras, Forms, Outlines, Effects, Linked Items, Abilities
This commit is contained in:
1 parent
0eeeec5d22
commit
111156da5a
15 files changed
+503
-5
No files matched your search
@@ -52,6 +52,7 @@ import noppes.npcs.api.ability.IChainedAbility;
|
||||
import noppes.npcs.api.handler.IAbilityHandler;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.CategoryManager;
|
||||
import noppes.npcs.controllers.TagController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
import kamkeel.npcs.util.FileNameHelper;
|
||||
@@ -369,6 +370,8 @@ public class AbilityController implements IAbilityHandler {
|
||||
}
|
||||
}
|
||||
|
||||
TagController.validateTagUUIDs(ability.getTagUUIDs());
|
||||
|
||||
File dir = getCustomAbilityDir(name);
|
||||
File fileNew = new File(dir, name + ".json_new");
|
||||
File fileCurrent = new File(dir, name + ".json");
|
||||
@@ -526,6 +529,17 @@ public class AbilityController implements IAbilityHandler {
|
||||
return map;
|
||||
}
|
||||
|
||||
public HashMap<String, HashSet<UUID>> getCustomAbilityTagMapForCategory(int catId) {
|
||||
HashMap<String, HashSet<UUID>> tagMap = new HashMap<>();
|
||||
for (Map.Entry<String, Ability> entry : customAbilities.entrySet()) {
|
||||
int assignedCat = customAbilityCatMap.getOrDefault(entry.getKey(), CategoryManager.UNCATEGORIZED_ID);
|
||||
if (assignedCat == catId && !entry.getValue().getTagUUIDs().isEmpty()) {
|
||||
tagMap.put(entry.getKey(), entry.getValue().getTagUUIDs());
|
||||
}
|
||||
}
|
||||
return tagMap;
|
||||
}
|
||||
|
||||
public void moveCustomAbilityToCategory(String name, int destCatId) {
|
||||
Ability ability = customAbilities.get(name);
|
||||
if (ability == null) return;
|
||||
|
||||
@@ -47,6 +47,7 @@ import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.TagController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.AbilityScript;
|
||||
@@ -63,8 +64,10 @@ import noppes.npcs.scripted.event.AbilityEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public abstract class Ability implements IAbility, IAbilityAction {
|
||||
@@ -129,6 +132,9 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
// Custom data for external mods
|
||||
protected NBTTagCompound customData = new NBTTagCompound();
|
||||
|
||||
// Tags
|
||||
protected HashSet<UUID> tagUUIDs = new HashSet<>();
|
||||
|
||||
// Magic data — defines magic types and damage splits for this ability
|
||||
protected MagicData magicData = new MagicData();
|
||||
|
||||
@@ -1526,6 +1532,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
nbt.setString("telegraphType", telegraphType.name());
|
||||
nbt.setFloat("telegraphHeightOffset", telegraphHeightOffset);
|
||||
nbt.setTag("customData", (NBTTagCompound) customData.copy());
|
||||
TagController.writeTagUUIDs(nbt, "TagUUIDs", tagUUIDs);
|
||||
magicData.writeToNBT(nbt);
|
||||
nbt.setInteger("allowedBy", allowedBy.ordinal());
|
||||
nbt.setBoolean("ignoreCooldown", ignoreCooldown);
|
||||
@@ -1625,6 +1632,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
}
|
||||
telegraphHeightOffset = nbt.getFloat("telegraphHeightOffset");
|
||||
customData = (NBTTagCompound) nbt.getCompoundTag("customData").copy();
|
||||
tagUUIDs = TagController.readTagUUIDs(nbt, "TagUUIDs");
|
||||
magicData.readToNBT(nbt);
|
||||
allowedBy = UserType.fromOrdinal(nbt.getInteger("allowedBy"));
|
||||
ignoreCooldown = nbt.getBoolean("ignoreCooldown");
|
||||
@@ -2330,6 +2338,14 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
return customData;
|
||||
}
|
||||
|
||||
public HashSet<UUID> getTagUUIDs() {
|
||||
return tagUUIDs;
|
||||
}
|
||||
|
||||
public void setTagUUIDs(HashSet<UUID> tagUUIDs) {
|
||||
this.tagUUIDs = tagUUIDs;
|
||||
}
|
||||
|
||||
public MagicData getMagicData() {
|
||||
return magicData;
|
||||
}
|
||||
|
||||
+18
@@ -18,10 +18,13 @@ import noppes.npcs.constants.EnumScrollData;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.LinkedItemController;
|
||||
import noppes.npcs.controllers.TagController;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class CategoryItemsRequestPacket extends AbstractPacket {
|
||||
public static String packetName = "NPC|CatItems";
|
||||
@@ -67,6 +70,12 @@ public final class CategoryItemsRequestPacket extends AbstractPacket {
|
||||
|
||||
Map<String, Integer> items = getItemsByCat(type, categoryId);
|
||||
ScrollDataPacket.sendScrollData((EntityPlayerMP) player, items, EnumScrollData.CATEGORY_GROUP);
|
||||
|
||||
// Send tag map for the items
|
||||
HashMap<String, HashSet<UUID>> tagMap = getTagMapByCat(type, categoryId);
|
||||
if (tagMap != null && !tagMap.isEmpty()) {
|
||||
TagController.sendCategoryTagMap((EntityPlayerMP) player, tagMap);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, Integer> getItemsByCat(int type, int catId) {
|
||||
@@ -79,4 +88,13 @@ public final class CategoryItemsRequestPacket extends AbstractPacket {
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
private static HashMap<String, HashSet<UUID>> getTagMapByCat(int type, int catId) {
|
||||
switch (type) {
|
||||
case EnumCategoryType.EFFECT: return CustomEffectController.getInstance().getItemTagMapForCategory(catId);
|
||||
case EnumCategoryType.LINKED_ITEM: return LinkedItemController.getInstance().getItemTagMapForCategory(catId);
|
||||
case EnumCategoryType.ABILITY: return AbilityController.Instance.getCustomAbilityTagMapForCategory(catId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user