diff --git a/src/main/java/noppes/npcs/constants/EnumAuctionSort.java b/core/src/main/java/noppes/npcs/constants/EnumAuctionSort.java similarity index 90% rename from src/main/java/noppes/npcs/constants/EnumAuctionSort.java rename to core/src/main/java/noppes/npcs/constants/EnumAuctionSort.java index 115f13dc9..d7849b3c0 100644 --- a/src/main/java/noppes/npcs/constants/EnumAuctionSort.java +++ b/core/src/main/java/noppes/npcs/constants/EnumAuctionSort.java @@ -1,7 +1,5 @@ package noppes.npcs.constants; -import net.minecraft.util.StatCollector; - public enum EnumAuctionSort { NEWEST("auction.sort.newest"), ENDING_SOON("auction.sort.endingSoon"), @@ -20,7 +18,7 @@ public enum EnumAuctionSort { } public String getDisplayName() { - return StatCollector.translateToLocal(langKey); + return langKey; } public static String[] getDisplayNames() { diff --git a/src/main/java/noppes/npcs/controllers/data/AuctionFilter.java b/core/src/main/java/noppes/npcs/controllers/data/AuctionFilter.java similarity index 86% rename from src/main/java/noppes/npcs/controllers/data/AuctionFilter.java rename to core/src/main/java/noppes/npcs/controllers/data/AuctionFilter.java index e6841fcea..dba39f7c7 100644 --- a/src/main/java/noppes/npcs/controllers/data/AuctionFilter.java +++ b/core/src/main/java/noppes/npcs/controllers/data/AuctionFilter.java @@ -1,14 +1,17 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; +import noppes.npcs.platform.nbt.INBTCompound; import noppes.npcs.constants.EnumAuctionSort; +import java.util.regex.Pattern; + /** * Filter for auction listings. * Supports search by item name or seller name and sorting options. */ public class AuctionFilter { + private static final Pattern FORMATTING_PATTERN = Pattern.compile("\u00a7."); + private String searchText; public EnumAuctionSort sortBy; @@ -30,8 +33,8 @@ public class AuctionFilter { */ public static String normalizeForSearch(String input) { if (input == null || input.isEmpty()) return ""; - String stripped = EnumChatFormatting.getTextWithoutFormattingCodes(input); - return stripped != null ? stripped.toLowerCase().trim() : input.toLowerCase().trim(); + String stripped = FORMATTING_PATTERN.matcher(input).replaceAll(""); + return stripped.toLowerCase().trim(); } /** @@ -84,24 +87,18 @@ public class AuctionFilter { normalizedSearch = ""; } - public NBTTagCompound writeToNBT(NBTTagCompound compound) { + public INBTCompound writeToNBT(INBTCompound compound) { compound.setString("SearchText", searchText != null ? searchText : ""); compound.setInteger("SortBy", sortBy.ordinal()); return compound; } - public void readFromNBT(NBTTagCompound compound) { + public void readFromNBT(INBTCompound compound) { searchText = compound.getString("SearchText"); normalizedSearch = normalizeForSearch(searchText); sortBy = EnumAuctionSort.fromOrdinal(compound.getInteger("SortBy")); } - public static AuctionFilter fromNBT(NBTTagCompound compound) { - AuctionFilter filter = new AuctionFilter(); - filter.readFromNBT(compound); - return filter; - } - public AuctionFilter copy() { AuctionFilter copy = new AuctionFilter(); copy.searchText = this.searchText; diff --git a/src/main/java/noppes/npcs/controllers/data/HitboxData.java b/core/src/main/java/noppes/npcs/controllers/data/HitboxData.java similarity index 66% rename from src/main/java/noppes/npcs/controllers/data/HitboxData.java rename to core/src/main/java/noppes/npcs/controllers/data/HitboxData.java index 4ccf9f823..224807c0c 100644 --- a/src/main/java/noppes/npcs/controllers/data/HitboxData.java +++ b/core/src/main/java/noppes/npcs/controllers/data/HitboxData.java @@ -1,8 +1,8 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.entity.data.IHitboxData; -import noppes.npcs.config.ConfigMain; +import noppes.npcs.platform.nbt.INBTCompound; +import noppes.npcs.core.CoreConfig; public class HitboxData implements IHitboxData { @@ -10,30 +10,30 @@ public class HitboxData implements IHitboxData { private float heightScale = 1f; private boolean hitboxEnabled = false; - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { + public INBTCompound writeToNBT(INBTCompound nbttagcompound) { nbttagcompound.setBoolean("HitboxEnabled", hitboxEnabled); if (hitboxEnabled) { - if (widthScale > ConfigMain.HitBoxScaleMax) - widthScale = ConfigMain.HitBoxScaleMax; + if (widthScale > CoreConfig.HitBoxScaleMax) + widthScale = CoreConfig.HitBoxScaleMax; nbttagcompound.setFloat("HitboxWidthScale", widthScale); - if (heightScale > ConfigMain.HitBoxScaleMax) - heightScale = ConfigMain.HitBoxScaleMax; + if (heightScale > CoreConfig.HitBoxScaleMax) + heightScale = CoreConfig.HitBoxScaleMax; nbttagcompound.setFloat("HitboxHeightScale", heightScale); } return nbttagcompound; } - public void readFromNBT(NBTTagCompound nbttagcompound) { + public void readFromNBT(INBTCompound nbttagcompound) { hitboxEnabled = nbttagcompound.getBoolean("HitboxEnabled"); if (hitboxEnabled) { widthScale = nbttagcompound.getFloat("HitboxWidthScale"); - if (widthScale > ConfigMain.HitBoxScaleMax) - widthScale = ConfigMain.HitBoxScaleMax; + if (widthScale > CoreConfig.HitBoxScaleMax) + widthScale = CoreConfig.HitBoxScaleMax; heightScale = nbttagcompound.getFloat("HitboxHeightScale"); - if (heightScale > ConfigMain.HitBoxScaleMax) - heightScale = ConfigMain.HitBoxScaleMax; + if (heightScale > CoreConfig.HitBoxScaleMax) + heightScale = CoreConfig.HitBoxScaleMax; } } diff --git a/src/main/java/noppes/npcs/controllers/data/Line.java b/core/src/main/java/noppes/npcs/controllers/data/Line.java similarity index 58% rename from src/main/java/noppes/npcs/controllers/data/Line.java rename to core/src/main/java/noppes/npcs/controllers/data/Line.java index 9571e6f92..fdac25d39 100644 --- a/src/main/java/noppes/npcs/controllers/data/Line.java +++ b/core/src/main/java/noppes/npcs/controllers/data/Line.java @@ -1,8 +1,5 @@ package noppes.npcs.controllers.data; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import noppes.npcs.api.entity.IEntityLivingBase; import noppes.npcs.api.handler.data.ILine; @@ -27,21 +24,6 @@ public class Line implements ILine { return line; } - public ILine formatTarget(EntityLivingBase entity) { - if (entity == null) - return this; - Line line = (Line) copy(); - if (entity instanceof EntityPlayer) - line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName()); - else - line.text = line.text.replace("@target", entity.getCommandSenderName()); - return line; - } - - public ILine formatTarget(IEntityLivingBase entityLivingBase) { - return this.formatTarget(entityLivingBase.getMCEntity()); - } - @Override public String getText() { return this.text; diff --git a/src/main/java/noppes/npcs/controllers/data/Lines.java b/core/src/main/java/noppes/npcs/controllers/data/Lines.java similarity index 76% rename from src/main/java/noppes/npcs/controllers/data/Lines.java rename to core/src/main/java/noppes/npcs/controllers/data/Lines.java index a103532a0..4d6d602b2 100644 --- a/src/main/java/noppes/npcs/controllers/data/Lines.java +++ b/core/src/main/java/noppes/npcs/controllers/data/Lines.java @@ -1,9 +1,10 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import noppes.npcs.api.handler.data.ILine; import noppes.npcs.api.handler.data.ILines; +import noppes.npcs.platform.nbt.INBTCompound; +import noppes.npcs.platform.nbt.INBTList; +import noppes.npcs.core.NBT; import java.util.ArrayList; import java.util.HashMap; @@ -16,30 +17,30 @@ public class Lines implements ILines { public HashMap lines = new HashMap(); - public NBTTagCompound writeToNBT() { - NBTTagCompound compound = new NBTTagCompound(); + public INBTCompound writeToNBT() { + INBTCompound compound = NBT.compound(); - NBTTagList nbttaglist = new NBTTagList(); + INBTList nbttaglist = NBT.list(); for (int slot : lines.keySet()) { Line line = lines.get(slot); - NBTTagCompound nbttagcompound = new NBTTagCompound(); + INBTCompound nbttagcompound = NBT.compound(); nbttagcompound.setInteger("Slot", slot); nbttagcompound.setString("Line", line.text); nbttagcompound.setString("Song", line.sound); - nbttaglist.appendTag(nbttagcompound); + nbttaglist.addCompound(nbttagcompound); } - compound.setTag("Lines", nbttaglist); + compound.setList("Lines", nbttaglist); return compound; } - public void readNBT(NBTTagCompound compound) { - NBTTagList nbttaglist = compound.getTagList("Lines", 10); + public void readNBT(INBTCompound compound) { + INBTList nbttaglist = compound.getList("Lines", 10); HashMap map = new HashMap(); - for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); + for (int i = 0; i < nbttaglist.size(); i++) { + INBTCompound nbttagcompound = nbttaglist.getCompound(i); Line line = new Line(); line.text = nbttagcompound.getString("Line"); line.sound = nbttagcompound.getString("Song"); diff --git a/src/main/java/noppes/npcs/controllers/data/PartyOptions.java b/core/src/main/java/noppes/npcs/controllers/data/PartyOptions.java similarity index 94% rename from src/main/java/noppes/npcs/controllers/data/PartyOptions.java rename to core/src/main/java/noppes/npcs/controllers/data/PartyOptions.java index 7fb46a717..156825b6b 100644 --- a/src/main/java/noppes/npcs/controllers/data/PartyOptions.java +++ b/core/src/main/java/noppes/npcs/controllers/data/PartyOptions.java @@ -1,8 +1,9 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.handler.data.IPartyOptions; -import noppes.npcs.config.ConfigMain; +import noppes.npcs.platform.nbt.INBTCompound; +import noppes.npcs.core.NBT; +import noppes.npcs.core.CoreConfig; import noppes.npcs.constants.EnumPartyExchange; import noppes.npcs.constants.EnumPartyObjectives; import noppes.npcs.constants.EnumPartyRequirements; @@ -21,10 +22,10 @@ public class PartyOptions implements IPartyOptions { public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared; - public int minPartySize = ConfigMain.DefaultMinPartySize; - public int maxPartySize = ConfigMain.DefaultMaxPartySize; + public int minPartySize = CoreConfig.DefaultMinPartySize; + public int maxPartySize = CoreConfig.DefaultMaxPartySize; - public void readFromNBT(NBTTagCompound compound) { + public void readFromNBT(INBTCompound compound) { // Party Management allowParty = compound.getBoolean("AllowParty"); if (allowParty) { @@ -67,14 +68,14 @@ public class PartyOptions implements IPartyOptions { rewardControl = EnumPartyExchange.Leader; completeFor = EnumPartyExchange.Leader; executeCommand = EnumPartyExchange.Leader; - minPartySize = ConfigMain.DefaultMinPartySize; - maxPartySize = ConfigMain.DefaultMaxPartySize; + minPartySize = CoreConfig.DefaultMinPartySize; + maxPartySize = CoreConfig.DefaultMaxPartySize; objectiveRequirement = EnumPartyObjectives.Shared; } } - public NBTTagCompound writeToNBT() { - NBTTagCompound compound = new NBTTagCompound(); + public INBTCompound writeToNBT() { + INBTCompound compound = NBT.compound(); compound.setBoolean("AllowParty", allowParty); if (allowParty) { compound.setBoolean("OnlyParty", onlyParty); diff --git a/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java b/core/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java similarity index 82% rename from src/main/java/noppes/npcs/controllers/data/SkinOverlay.java rename to core/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java index 43a13a074..ab99060a1 100644 --- a/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java +++ b/core/src/main/java/noppes/npcs/controllers/data/SkinOverlay.java @@ -1,11 +1,10 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.ISkinOverlay; -import noppes.npcs.entity.data.DataSkinOverlays; +import noppes.npcs.platform.nbt.INBTCompound; public class SkinOverlay implements ISkinOverlay { - public DataSkinOverlays parent; + private Runnable onChanged; public String texture; public boolean glow = true; @@ -35,9 +34,13 @@ public class SkinOverlay implements ISkinOverlay { this.texture = texture; } + public void setOnChanged(Runnable onChanged) { + this.onChanged = onChanged; + } + public void setTexture(String texture) { this.texture = texture; - this.updateClient(); + this.notifyChanged(); } public String getTexture() { @@ -46,7 +49,7 @@ public class SkinOverlay implements ISkinOverlay { public void setGlow(boolean glow) { this.glow = glow; - this.updateClient(); + this.notifyChanged(); } public boolean getGlow() { @@ -55,7 +58,7 @@ public class SkinOverlay implements ISkinOverlay { public void setBlend(boolean blend) { this.blend = blend; - this.updateClient(); + this.notifyChanged(); } public boolean getBlend() { @@ -64,7 +67,7 @@ public class SkinOverlay implements ISkinOverlay { public void setAlpha(float alpha) { this.alpha = alpha; - this.updateClient(); + this.notifyChanged(); } public float getAlpha() { @@ -73,7 +76,7 @@ public class SkinOverlay implements ISkinOverlay { public void setSize(float size) { this.size = size; - this.updateClient(); + this.notifyChanged(); } public float getSize() { @@ -82,7 +85,7 @@ public class SkinOverlay implements ISkinOverlay { public void setColor(int color) { this.color = Math.max(0, color); - this.updateClient(); + this.notifyChanged(); } public int getColor() { @@ -92,7 +95,7 @@ public class SkinOverlay implements ISkinOverlay { public void setTextureScale(float scaleX, float scaleY) { this.scaleX = scaleX; this.scaleY = scaleY; - this.updateClient(); + this.notifyChanged(); } public float getTextureScaleX() { @@ -106,7 +109,7 @@ public class SkinOverlay implements ISkinOverlay { public void setSpeed(float speedX, float speedY) { this.speedX = speedX; this.speedY = speedY; - this.updateClient(); + this.notifyChanged(); } public float getSpeedX() { @@ -121,7 +124,7 @@ public class SkinOverlay implements ISkinOverlay { this.offsetX = offsetX; this.offsetY = offsetY; this.offsetZ = offsetZ; - this.updateClient(); + this.notifyChanged(); } public float getOffsetX() { @@ -136,13 +139,13 @@ public class SkinOverlay implements ISkinOverlay { return offsetZ; } - public void readFromNBT(NBTTagCompound compound) { + public void readFromNBT(INBTCompound compound) { this.texture = compound.getString("SkinOverlayTexture"); this.glow = compound.getBoolean("SkinOverlayGlow"); this.blend = compound.getBoolean("SkinOverlayBlend"); this.alpha = compound.getFloat("SkinOverlayAlpha"); this.size = compound.getFloat("SkinOverlaySize"); - if(compound.hasKey("SkinOverlayColor")){ + if (compound.hasKey("SkinOverlayColor")) { this.color = compound.getInteger("SkinOverlayColor"); } else { this.color = 0xFFFFFF; @@ -156,7 +159,7 @@ public class SkinOverlay implements ISkinOverlay { this.offsetZ = compound.getFloat("SkinOverlayOffsetZ"); } - public NBTTagCompound writeToNBT(NBTTagCompound compound) { + public INBTCompound writeToNBT(INBTCompound compound) { compound.setString("SkinOverlayTexture", this.getTexture()); compound.setBoolean("SkinOverlayGlow", this.getGlow()); compound.setBoolean("SkinOverlayBlend", this.getBlend()); @@ -174,16 +177,9 @@ public class SkinOverlay implements ISkinOverlay { return compound; } - public static ISkinOverlay overlayFromNBT(NBTTagCompound compound) { - SkinOverlay overlay = new SkinOverlay(); - overlay.readFromNBT(compound); - return overlay; - } - - private void updateClient() { - if (this.parent != null) { - this.parent.updateClient(); - this.parent.save(); + private void notifyChanged() { + if (this.onChanged != null) { + this.onChanged.run(); } } } diff --git a/src/main/java/noppes/npcs/controllers/data/Tag.java b/core/src/main/java/noppes/npcs/controllers/data/Tag.java similarity index 81% rename from src/main/java/noppes/npcs/controllers/data/Tag.java rename to core/src/main/java/noppes/npcs/controllers/data/Tag.java index bb530fe61..b862f7494 100644 --- a/src/main/java/noppes/npcs/controllers/data/Tag.java +++ b/core/src/main/java/noppes/npcs/controllers/data/Tag.java @@ -1,8 +1,7 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.handler.data.ITag; -import noppes.npcs.controllers.TagController; +import noppes.npcs.platform.nbt.INBTCompound; import java.util.UUID; @@ -15,6 +14,8 @@ public class Tag implements ITag { public UUID uuid = randomUUID(); public boolean hideTag = false; + private Runnable saveHandler; + public Tag() { } @@ -24,12 +25,16 @@ public class Tag implements ITag { this.id = id; } + public void setSaveHandler(Runnable saveHandler) { + this.saveHandler = saveHandler; + } + public static String formatName(String name) { name = name.toLowerCase().trim(); return name.substring(0, 1).toUpperCase() + name.substring(1); } - public void readNBT(NBTTagCompound compound) { + public void readNBT(INBTCompound compound) { name = compound.getString("Name"); color = compound.getInteger("Color"); id = compound.getInteger("Slot"); @@ -37,7 +42,7 @@ public class Tag implements ITag { uuid = UUID.fromString(compound.getString("Uuid")); } - public void writeNBT(NBTTagCompound compound) { + public void writeNBT(INBTCompound compound) { compound.setInteger("Slot", id); compound.setString("Name", name); compound.setInteger("Color", color); @@ -45,12 +50,12 @@ public class Tag implements ITag { compound.setBoolean("HideTag", hideTag); } - public void readShortNBT(NBTTagCompound compound) { + public void readShortNBT(INBTCompound compound) { name = compound.getString("Name"); uuid = UUID.fromString(compound.getString("Uuid")); } - public void writeShortNBT(NBTTagCompound compound) { + public void writeShortNBT(INBTCompound compound) { compound.setString("Name", name); compound.setString("Uuid", uuid.toString()); } @@ -88,6 +93,7 @@ public class Tag implements ITag { } public void save() { - TagController.getInstance().saveTag(this); + if (saveHandler != null) + saveHandler.run(); } } diff --git a/src/main/java/noppes/npcs/controllers/data/TransportCategory.java b/core/src/main/java/noppes/npcs/controllers/data/TransportCategory.java similarity index 58% rename from src/main/java/noppes/npcs/controllers/data/TransportCategory.java rename to core/src/main/java/noppes/npcs/controllers/data/TransportCategory.java index f95159d5a..19b9705d4 100644 --- a/src/main/java/noppes/npcs/controllers/data/TransportCategory.java +++ b/core/src/main/java/noppes/npcs/controllers/data/TransportCategory.java @@ -1,10 +1,10 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import noppes.npcs.api.handler.data.ITransportCategory; import noppes.npcs.api.handler.data.ITransportLocation; -import noppes.npcs.controllers.TransportController; +import noppes.npcs.platform.nbt.INBTCompound; +import noppes.npcs.platform.nbt.INBTList; +import noppes.npcs.core.NBT; import java.util.HashMap; import java.util.Map; @@ -27,30 +27,30 @@ public class TransportCategory implements ITransportCategory { return list; } - public void readNBT(NBTTagCompound compound) { + public void readNBT(INBTCompound compound) { id = compound.getInteger("CategoryId"); title = compound.getString("CategoryTitle"); - NBTTagList locs = compound.getTagList("CategoryLocations", 10); - if (locs == null || locs.tagCount() == 0) + INBTList locs = compound.getList("CategoryLocations", 10); + if (locs == null || locs.size() == 0) return; - for (int ii = 0; ii < locs.tagCount(); ii++) { + for (int ii = 0; ii < locs.size(); ii++) { TransportLocation location = new TransportLocation(); - location.readNBT(locs.getCompoundTagAt(ii)); + location.readNBT(locs.getCompound(ii)); location.category = this; locations.put(location.id, location); } } - public void writeNBT(NBTTagCompound compound) { + public void writeNBT(INBTCompound compound) { compound.setInteger("CategoryId", id); compound.setString("CategoryTitle", title); - NBTTagList locs = new NBTTagList(); + INBTList locs = NBT.list(); for (TransportLocation location : locations.values()) { - locs.appendTag(location.writeNBT()); + locs.addCompound(location.writeNBT()); } - compound.setTag("CategoryLocations", locs); + compound.setList("CategoryLocations", locs); } public int getId() { @@ -66,13 +66,7 @@ public class TransportCategory implements ITransportCategory { } public void addLocation(String name) { - int id = TransportController.getInstance().getUniqueIdLocation(); - TransportLocation location = new TransportLocation(); - location.id = id; - location.name = name; - location.category = this; - - TransportController.getInstance().setLocation(location); + // Overridden in version-specific code } public ITransportLocation getLocation(String name) { @@ -88,18 +82,6 @@ public class TransportCategory implements ITransportCategory { } public void removeLocation(String name) { - int id = -1; - for (Map.Entry entry : locations.entrySet()) { - if (entry.getValue().getName().equals(name)) { - id = entry.getKey(); - ; - locations.remove(entry.getKey()); - break; - } - } - - if (id >= 0) { - TransportController.getInstance().removeLocation(id); - } + // Overridden in version-specific code } } diff --git a/src/main/java/noppes/npcs/controllers/data/TransportLocation.java b/core/src/main/java/noppes/npcs/controllers/data/TransportLocation.java similarity index 82% rename from src/main/java/noppes/npcs/controllers/data/TransportLocation.java rename to core/src/main/java/noppes/npcs/controllers/data/TransportLocation.java index cd2d78ab3..7cec188a0 100644 --- a/src/main/java/noppes/npcs/controllers/data/TransportLocation.java +++ b/core/src/main/java/noppes/npcs/controllers/data/TransportLocation.java @@ -1,10 +1,9 @@ package noppes.npcs.controllers.data; -import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.api.IPos; import noppes.npcs.api.handler.data.ITransportLocation; -import noppes.npcs.controllers.TransportController; -import noppes.npcs.scripted.NpcAPI; +import noppes.npcs.platform.nbt.INBTCompound; +import noppes.npcs.core.NBT; public class TransportLocation implements ITransportLocation { public int id = -1; @@ -18,7 +17,13 @@ public class TransportLocation implements ITransportLocation { public TransportCategory category; - public void readNBT(NBTTagCompound compound) { + private Runnable saveHandler; + + public void setSaveHandler(Runnable saveHandler) { + this.saveHandler = saveHandler; + } + + public void readNBT(INBTCompound compound) { if (compound == null) return; id = compound.getInteger("Id"); @@ -30,8 +35,8 @@ public class TransportLocation implements ITransportLocation { name = compound.getString("Name"); } - public NBTTagCompound writeNBT() { - NBTTagCompound compound = new NBTTagCompound(); + public INBTCompound writeNBT() { + INBTCompound compound = NBT.compound(); compound.setInteger("Id", id); compound.setDouble("PosX", posX); compound.setDouble("PosY", posY); @@ -87,7 +92,7 @@ public class TransportLocation implements ITransportLocation { } public IPos getPos() { - return NpcAPI.Instance().getIPos(this.posX, this.posY, this.posZ); + return null; // Overridden in version-specific code } public double getX() { @@ -103,6 +108,7 @@ public class TransportLocation implements ITransportLocation { } public void save() { - TransportController.getInstance().saveLocation(this.category.id, this); + if (saveHandler != null) + saveHandler.run(); } } diff --git a/core/src/main/java/noppes/npcs/core/CoreConfig.java b/core/src/main/java/noppes/npcs/core/CoreConfig.java new file mode 100644 index 000000000..9e9a90aa0 --- /dev/null +++ b/core/src/main/java/noppes/npcs/core/CoreConfig.java @@ -0,0 +1,20 @@ +package noppes.npcs.core; + +/** + * Static config values accessible to core module code. + * Values are populated by the platform-specific config system at startup. + * Defaults match the original ConfigMain defaults. + */ +public final class CoreConfig { + // NPC Hitbox + public static int HitBoxScaleMax = 15; + + // Party defaults + public static int DefaultMinPartySize = 1; + public static int DefaultMaxPartySize = 4; + + // Dialog + public static int DialogImageLimit = 10; + + private CoreConfig() {} +} diff --git a/src/main/java/noppes/npcs/util/CacheHashMap.java b/core/src/main/java/noppes/npcs/util/CacheHashMap.java similarity index 100% rename from src/main/java/noppes/npcs/util/CacheHashMap.java rename to core/src/main/java/noppes/npcs/util/CacheHashMap.java diff --git a/src/main/java/noppes/npcs/util/CustomNPCsThreader.java b/core/src/main/java/noppes/npcs/util/CustomNPCsThreader.java similarity index 100% rename from src/main/java/noppes/npcs/util/CustomNPCsThreader.java rename to core/src/main/java/noppes/npcs/util/CustomNPCsThreader.java diff --git a/src/main/java/noppes/npcs/util/LRUHashMap.java b/core/src/main/java/noppes/npcs/util/LRUHashMap.java similarity index 100% rename from src/main/java/noppes/npcs/util/LRUHashMap.java rename to core/src/main/java/noppes/npcs/util/LRUHashMap.java diff --git a/src/main/java/noppes/npcs/util/MillisTimer.java b/core/src/main/java/noppes/npcs/util/MillisTimer.java similarity index 100% rename from src/main/java/noppes/npcs/util/MillisTimer.java rename to core/src/main/java/noppes/npcs/util/MillisTimer.java diff --git a/src/main/java/noppes/npcs/util/SizeOfObjectUtil.java b/core/src/main/java/noppes/npcs/util/SizeOfObjectUtil.java similarity index 100% rename from src/main/java/noppes/npcs/util/SizeOfObjectUtil.java rename to core/src/main/java/noppes/npcs/util/SizeOfObjectUtil.java diff --git a/src/main/java/noppes/npcs/util/ValueUtil.java b/core/src/main/java/noppes/npcs/util/ValueUtil.java similarity index 100% rename from src/main/java/noppes/npcs/util/ValueUtil.java rename to core/src/main/java/noppes/npcs/util/ValueUtil.java diff --git a/platform-api/src/main/java/noppes/npcs/api/IPos.java b/platform-api/src/main/java/noppes/npcs/api/IPos.java new file mode 100644 index 000000000..886f0bdae --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/IPos.java @@ -0,0 +1,70 @@ +package noppes.npcs.api; + +public interface IPos { + + int getX(); + + int getY(); + + int getZ(); + + double getXD(); + + double getYD(); + + double getZD(); + + IPos up(); + + IPos up(double n); + + IPos down(); + + IPos down(double n); + + IPos north(); + + IPos north(double n); + + IPos east(); + + IPos east(double n); + + IPos south(); + + IPos south(double n); + + IPos west(); + + IPos west(double n); + + IPos add(double x, double y, double z); + + IPos add(IPos pos); + + IPos subtract(double x, double y, double z); + + IPos subtract(IPos pos); + + IPos normalize(); + + double[] normalizeDouble(); + + IPos offset(int direction); + + IPos offset(int direction, double n); + + IPos crossProduct(double x, double y, double z); + + IPos crossProduct(IPos pos); + + IPos divide(double scalar); + + long toLong(); + + IPos fromLong(long serialized); + + double distanceTo(IPos pos); + + double distanceTo(double x, double y, double z); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/ISkinOverlay.java b/platform-api/src/main/java/noppes/npcs/api/ISkinOverlay.java new file mode 100644 index 000000000..5d7834d2f --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/ISkinOverlay.java @@ -0,0 +1,91 @@ +package noppes.npcs.api; + +/** + * A skin overlay object for both NPCs and players. Several skin overlays at a time can be layered on top of each other. + * In an NPC's case, the old overlay texture is now the skin overlay with ID 0. + *

+ * Modifying these attributes, an overlay can be made to look like a powered creeper effect, just a new skin, or both! + */ +public interface ISkinOverlay { + /** + * Sets the directory texture of the overlay. Does not support URLs. + * @param texture the texture path + */ + void setTexture(String texture); + + String getTexture(); + + /** + * Sets whether this overlay glows in the dark or not. + * @param glow whether to glow + */ + void setGlow(boolean glow); + + boolean getGlow(); + + /** + * Sets whether this overlay blends on top of bottom textures at any alpha value. + * @param blend whether to blend + */ + void setBlend(boolean blend); + + boolean getBlend(); + + /** + * Sets the transparency of the overlay, from 0 to 1. + * @param alpha the alpha value + */ + void setAlpha(float alpha); + + float getAlpha(); + + /** + * Sets the size of the entire overlay when rendered on the entity. By default, overlays render slightly on top of + * the entity's model. + * @param size the overlay size + */ + void setSize(float size); + + float getSize(); + + void setColor(int color); + + int getColor(); + + /** + * Sets the texture scale of the overlay. Higher values will "zoom in" to the texture more. + * @param scaleX horizontal scale + * @param scaleY vertical scale + */ + void setTextureScale(float scaleX, float scaleY); + + float getTextureScaleX(); + + float getTextureScaleY(); + + /** + * Sets the "texture speed" by which the texture shifts on each render tick. Used to create a powered creeper effect! + * This does not move the entire overlay, it just moves the position at which the texture begins rendering. + * @param speedX horizontal speed + * @param speedY vertical speed + */ + void setSpeed(float speedX, float speedY); + + float getSpeedX(); + + float getSpeedY(); + + /** + * Sets the amount in each direction by which the overlay will be offset from the entity. + * @param offsetX horizontal render offset + * @param offsetY vertical render offset + * @param offsetZ depth render offset + */ + void setOffset(float offsetX, float offsetY, float offsetZ); + + float getOffsetX(); + + float getOffsetY(); + + float getOffsetZ(); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/entity/data/IHitboxData.java b/platform-api/src/main/java/noppes/npcs/api/entity/data/IHitboxData.java new file mode 100644 index 000000000..eb5a2448f --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/entity/data/IHitboxData.java @@ -0,0 +1,54 @@ +package noppes.npcs.api.entity.data; + +/** + * Provides configuration data for an NPC's custom hitbox dimensions. + *

+ * When enabled, allows independent scaling of the NPC's collision box + * width and height beyond the default model-based sizing. + */ +public interface IHitboxData { + + /** + * Returns whether the custom hitbox is enabled. + * + * @return true if the custom hitbox is enabled, false otherwise. + */ + boolean isHitboxEnabled(); + + /** + * Sets whether the custom hitbox is enabled. + * + * @param enabled true to enable, false to disable. + */ + void setHitboxEnabled(boolean enabled); + + /** + * Returns the width scale factor for the hitbox. + * + * @return the width scale factor (1.0 = default). + */ + float getWidthScale(); + + /** + * Sets the width scale factor for the hitbox. + * Clamped to the server-configured maximum. + * + * @param widthScale the width scale factor. + */ + void setWidthScale(float widthScale); + + /** + * Returns the height scale factor for the hitbox. + * + * @return the height scale factor (1.0 = default). + */ + float getHeightScale(); + + /** + * Sets the height scale factor for the hitbox. + * Clamped to the server-configured maximum. + * + * @param heightScale the height scale factor. + */ + void setHeightScale(float heightScale); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/handler/data/ILine.java b/platform-api/src/main/java/noppes/npcs/api/handler/data/ILine.java new file mode 100644 index 000000000..ff462d584 --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/handler/data/ILine.java @@ -0,0 +1,37 @@ +package noppes.npcs.api.handler.data; + +/** + * Represents a single NPC dialog line with text, an optional sound, and target formatting. + */ +public interface ILine { + + /** @return the text content of this line. */ + String getText(); + + /** + * Sets the text content of this line. + * + * @param text the new text. + */ + void setText(String text); + + /** @return the sound resource to play with this line, or null if none. */ + String getSound(); + + /** + * Sets the sound resource to play with this line. + * + * @param sound the sound resource path, or null for none. + */ + void setSound(String sound); + + /** + * Sets whether the text of this line should be hidden when spoken. + * + * @param hide true to hide the text; false to show. + */ + void hideText(boolean hide); + + /** @return true if the text is hidden when this line is spoken. */ + boolean hideText(); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/handler/data/ILines.java b/platform-api/src/main/java/noppes/npcs/api/handler/data/ILines.java new file mode 100644 index 000000000..0c692517f --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/handler/data/ILines.java @@ -0,0 +1,57 @@ +package noppes.npcs.api.handler.data; + +/** + * A collection of dialog lines, supporting creation, indexed access, and random retrieval. + */ +public interface ILines { + + /** + * Creates and adds a new line with the given text. + * + * @param text the line text. + * @return the created line. + */ + ILine createLine(String text); + + /** + * Returns a line, either randomly or sequentially. + * + * @param isRandom true to return a random line; false for sequential. + * @return the selected line, or null if empty. + */ + ILine getLine(boolean isRandom); + + /** + * Returns the line at the given index. + * + * @param lineIndex the line index. + * @return the line, or null if the index is invalid. + */ + ILine getLine(int lineIndex); + + /** + * Sets the line at the given index. + * + * @param lineIndex the line index. + * @param line the line to set. + */ + void setLine(int lineIndex, ILine line); + + /** + * Removes the line at the given index. + * + * @param lineIndex the line index. + */ + void removeLine(int lineIndex); + + /** + * Removes all lines. + */ + void clear(); + + /** @return true if there are no lines. */ + boolean isEmpty(); + + /** @return the indices of all stored lines. */ + Integer[] getKeys(); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/handler/data/IPartyOptions.java b/platform-api/src/main/java/noppes/npcs/api/handler/data/IPartyOptions.java new file mode 100644 index 000000000..2205500d4 --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/handler/data/IPartyOptions.java @@ -0,0 +1,82 @@ +package noppes.npcs.api.handler.data; + +/** + * Configures party-related options for quests, controlling membership requirements, + * reward distribution, completion rules, and party size limits. + */ +public interface IPartyOptions { + + /** @return true if party participation is allowed. */ + boolean isAllowParty(); + + /** @param allowParty true to allow party participation. */ + void setAllowParty(boolean allowParty); + + /** @return true if only party members can participate. */ + boolean isOnlyParty(); + + /** @param onlyParty true to require party membership. */ + void setOnlyParty(boolean onlyParty); + + /** + * @return 0:Leader, 1:All, 2:Valid + */ + public int getPartyRequirements(); + + /** + * @param partyRequirements 0:Leader, 1:All, 2:Valid + */ + public void setPartyRequirements(int partyRequirements); + + /** + * @return 0:Leader, 1:All, 2:Enrolled, 3:Valid + */ + public int getRewardControl(); + + /** + * @param rewardControl 0:Leader, 1:All, 2:Enrolled, 3:Valid + */ + public void setRewardControl(int rewardControl); + + /** + * @return 0:Leader, 1:All, 2:Enrolled, 3:Valid + */ + public int getCompleteFor(); + + /** + * @param completeFor 0:Leader, 1:All, 2:Enrolled, 3:Valid + */ + public void setCompleteFor(int completeFor); + + /** + * @return 0:Leader, 1:All, 2:Enrolled, 3:Valid + */ + int getExecuteCommandFor(); + + /** + * @param commandFor 0:Leader, 1:All, 2:Enrolled, 3:Valid + */ + void setExecuteCommandFor(int commandFor); + + /** + * @return 0:Shard, 1:All, 2:Leader + */ + public int getObjectiveRequirement(); + + /** + * @param requirement 0:Shard, 1:All, 2:Leader + */ + public void setObjectiveRequirement(int requirement); + + /** @return the minimum party size required. */ + int getMinPartySize(); + + /** @param newSize the minimum party size. */ + void setMinPartySize(int newSize); + + /** @return the maximum party size allowed. */ + int getMaxPartySize(); + + /** @param newSize the maximum party size. */ + void setMaxPartySize(int newSize); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/handler/data/ITag.java b/platform-api/src/main/java/noppes/npcs/api/handler/data/ITag.java new file mode 100644 index 000000000..1ef328bc8 --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/handler/data/ITag.java @@ -0,0 +1,34 @@ +package noppes.npcs.api.handler.data; + +/** + * Represents a tag that can be applied to NPCs for categorization and filtering. + */ +public interface ITag { + + /** @return the unique UUID string for this tag. */ + String getUuid(); + + /** @return the tag display name. */ + String getName(); + + /** @param name the tag display name. */ + void setName(String name); + + /** @param c the tag color as a packed RGB integer. */ + void setColor(int c); + + /** @return the unique tag ID. */ + int getId(); + + /** @return the tag color as a packed RGB integer. */ + int getColor(); + + /** @return true if this tag is hidden from display. */ + boolean getIsHidden(); + + /** @param hidden true to hide this tag from display. */ + void setIsHidden(boolean hidden); + + /** Saves this tag to disk. */ + void save(); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/handler/data/ITransportCategory.java b/platform-api/src/main/java/noppes/npcs/api/handler/data/ITransportCategory.java new file mode 100644 index 000000000..73d1ec11a --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/handler/data/ITransportCategory.java @@ -0,0 +1,38 @@ +package noppes.npcs.api.handler.data; + +/** + * Represents a category that groups transport locations together. + */ +public interface ITransportCategory { + + /** @return the unique category ID. */ + int getId(); + + /** @param title the category title. */ + void setTitle(String title); + + /** @return the category title. */ + String getTitle(); + + /** + * Adds a new transport location with the given name to this category. + * + * @param name the location name. + */ + void addLocation(String name); + + /** + * Returns the transport location with the given name. + * + * @param name the location name. + * @return the transport location, or null if not found. + */ + ITransportLocation getLocation(String name); + + /** + * Removes the transport location with the given name. + * + * @param name the location name. + */ + void removeLocation(String name); +} diff --git a/platform-api/src/main/java/noppes/npcs/api/handler/data/ITransportLocation.java b/platform-api/src/main/java/noppes/npcs/api/handler/data/ITransportLocation.java new file mode 100644 index 000000000..9ed0c15ea --- /dev/null +++ b/platform-api/src/main/java/noppes/npcs/api/handler/data/ITransportLocation.java @@ -0,0 +1,62 @@ +package noppes.npcs.api.handler.data; + +import noppes.npcs.api.IPos; + +/** + * Represents a transport destination that players can teleport to. + */ +public interface ITransportLocation { + + /** @return the unique transport location ID. */ + int getId(); + + /** @param name the location display name. */ + void setName(String name); + + /** @return the location display name. */ + String getName(); + + /** @param dimension the dimension ID where this transport is located. */ + void setDimension(int dimension); + + /** @return the dimension ID. */ + int getDimension(); + + /** + * Sets the transport type. + * + * @param type the type ordinal. + */ + void setType(int type); + + /** @return the transport type ordinal. */ + int getType(); + + /** + * Sets the transport destination coordinates. + * + * @param x the x coordinate. + * @param y the y coordinate. + * @param z the z coordinate. + */ + void setPosition(int x, int y, int z); + + /** + * Sets the transport destination position. + * + * @param pos the position. + */ + void setPosition(IPos pos); + + /** @return the x coordinate. */ + double getX(); + + /** @return the y coordinate. */ + double getY(); + + /** @return the z coordinate. */ + double getZ(); + + /** Saves this transport location to disk. */ + void save(); +} diff --git a/src/main/java/kamkeel/npcs/network/packets/player/AuctionActionPacket.java b/src/main/java/kamkeel/npcs/network/packets/player/AuctionActionPacket.java index cf0fb3a36..1ba8ff586 100644 --- a/src/main/java/kamkeel/npcs/network/packets/player/AuctionActionPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/player/AuctionActionPacket.java @@ -24,6 +24,7 @@ import noppes.npcs.controllers.AuctionController; import noppes.npcs.controllers.data.AuctionClaim; import noppes.npcs.controllers.data.AuctionFilter; import noppes.npcs.controllers.data.AuctionListing; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; import java.util.List; @@ -127,7 +128,7 @@ public class AuctionActionPacket extends AbstractPacket { public static void requestListings(AuctionFilter filter, int page) { AuctionActionPacket packet = new AuctionActionPacket(Action.RequestListings); packet.amount = page; - packet.data = filter.writeToNBT(new NBTTagCompound()); + packet.data = ((MC1710NBTCompound) filter.writeToNBT(new MC1710NBTCompound(new NBTTagCompound()))).getMCTag(); PacketClient.sendClient(packet); } @@ -412,7 +413,7 @@ public class AuctionActionPacket extends AbstractPacket { AuctionFilter filter = new AuctionFilter(); if (filterNBT != null) { - filter.readFromNBT(filterNBT); + filter.readFromNBT(new MC1710NBTCompound(filterNBT)); } // Get listings for this page diff --git a/src/main/java/kamkeel/npcs/network/packets/request/auction/ManageAuctionPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/auction/ManageAuctionPacket.java index f2ad4c961..96aff6b4f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/auction/ManageAuctionPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/auction/ManageAuctionPacket.java @@ -24,6 +24,7 @@ import noppes.npcs.controllers.AuctionController; import noppes.npcs.controllers.data.AuctionClaim; import noppes.npcs.controllers.data.AuctionFilter; import noppes.npcs.controllers.data.AuctionListing; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; import java.util.ArrayList; @@ -79,7 +80,7 @@ public class ManageAuctionPacket extends AbstractPacket { public static void requestListings(AuctionFilter filter, int page) { ManageAuctionPacket packet = new ManageAuctionPacket(Action.REQUEST_LISTINGS); packet.page = page; - packet.data = filter != null ? filter.writeToNBT(new NBTTagCompound()) : new NBTTagCompound(); + packet.data = filter != null ? ((MC1710NBTCompound) filter.writeToNBT(new MC1710NBTCompound(new NBTTagCompound()))).getMCTag() : new NBTTagCompound(); PacketClient.sendClient(packet); } @@ -229,7 +230,7 @@ public class ManageAuctionPacket extends AbstractPacket { AuctionFilter filter = new AuctionFilter(); if (filterNbt != null) { - filter.readFromNBT(filterNbt); + filter.readFromNBT(new MC1710NBTCompound(filterNbt)); } int totalListings = controller.getTotalActiveListings(filter); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java index bc4b360ec..689ca9f20 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsPacket.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.TagController; import noppes.npcs.controllers.data.Tag; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; import java.util.HashSet; @@ -53,7 +54,7 @@ public final class CloneAllTagsPacket extends AbstractPacket { NBTTagList validTagList = new NBTTagList(); for (Tag tag : validTags) { NBTTagCompound tagCompound = new NBTTagCompound(); - tag.writeNBT(tagCompound); + tag.writeNBT(new MC1710NBTCompound(tagCompound)); validTagList.appendTag(tagCompound); } compound.setTag("AllTags", validTagList); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java index 349032e7d..46f5ee175 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/clone/CloneAllTagsShortPacket.java @@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import noppes.npcs.controllers.TagController; import noppes.npcs.controllers.data.Tag; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; import java.util.HashSet; @@ -53,7 +54,7 @@ public final class CloneAllTagsShortPacket extends AbstractPacket { NBTTagList validTagList = new NBTTagList(); for (Tag tag : validTags) { NBTTagCompound tagCompound = new NBTTagCompound(); - tag.writeShortNBT(tagCompound); + tag.writeShortNBT(new MC1710NBTCompound(tagCompound)); validTagList.appendTag(tagCompound); } compound.setTag("ShortTags", validTagList); diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java index 2a565c828..ee652dac0 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagGetPacket.java @@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.controllers.TagController; import noppes.npcs.controllers.data.Tag; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; @@ -53,7 +54,7 @@ public final class TagGetPacket extends AbstractPacket { NBTTagCompound compound = new NBTTagCompound(); Tag tag = TagController.getInstance().get(in.readInt()); - tag.writeNBT(compound); + tag.writeNBT(new MC1710NBTCompound(compound)); GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java index fb2207ec7..d95e25821 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagRemovePacket.java @@ -17,6 +17,7 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.TagController; import noppes.npcs.controllers.data.Tag; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; @@ -65,7 +66,7 @@ public final class TagRemovePacket extends AbstractPacket { TagController.getInstance().delete(id); NoppesUtilServer.sendTagDataAll((EntityPlayerMP) player); NBTTagCompound comp = new NBTTagCompound(); - (new Tag()).writeNBT(comp); + (new Tag()).writeNBT(new MC1710NBTCompound(comp)); GuiDataPacket.sendGuiData((EntityPlayerMP) player, comp); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java index 0577ba8d7..b731795e8 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/tags/TagSavePacket.java @@ -18,6 +18,7 @@ import noppes.npcs.CustomNpcsPermissions; import noppes.npcs.NoppesUtilServer; import noppes.npcs.controllers.TagController; import noppes.npcs.controllers.data.Tag; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; @@ -63,11 +64,11 @@ public final class TagSavePacket extends AbstractPacket { return; Tag tag = new Tag(); - tag.readNBT(ByteBufUtils.readNBT(in)); + tag.readNBT(new MC1710NBTCompound(ByteBufUtils.readNBT(in))); TagController.getInstance().saveTag(tag); NoppesUtilServer.sendTagDataAll((EntityPlayerMP) player); NBTTagCompound comp = new NBTTagCompound(); - tag.writeNBT(comp); + tag.writeNBT(new MC1710NBTCompound(comp)); GuiDataPacket.sendGuiData((EntityPlayerMP) player, comp); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java index acbbe8016..5f8805572 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/transport/TransportGetLocationPacket.java @@ -15,6 +15,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import noppes.npcs.constants.EnumRoleType; import noppes.npcs.roles.RoleTransporter; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.IOException; @@ -57,7 +58,7 @@ public final class TransportGetLocationPacket extends AbstractPacket { RoleTransporter role = (RoleTransporter) npc.roleInterface; if (role.hasTransport()) { - GuiDataPacket.sendGuiData((EntityPlayerMP) player, role.getLocation().writeNBT()); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, ((MC1710NBTCompound) role.getLocation().writeNBT()).getMCTag()); ScrollSelectedPacket.setSelectedList((EntityPlayerMP) player, role.getLocation().category.title); } } diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index 23bc6333c..cb6c62cf7 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -67,6 +67,7 @@ import noppes.npcs.compat.PixelmonHelper; import noppes.npcs.platform.PlatformServiceHolder; import noppes.npcs.wrapper.MC1710PlatformService; import noppes.npcs.config.ConfigMain; +import noppes.npcs.core.CoreConfig; import noppes.npcs.config.LoadConfiguration; import noppes.npcs.config.legacy.LegacyConfig; import noppes.npcs.controllers.APIRegistry; @@ -250,6 +251,12 @@ public class CustomNpcs { configPath += File.separator; LoadConfiguration.init(configPath); + // Sync config values to core module + CoreConfig.HitBoxScaleMax = ConfigMain.HitBoxScaleMax; + CoreConfig.DefaultMinPartySize = ConfigMain.DefaultMinPartySize; + CoreConfig.DefaultMaxPartySize = ConfigMain.DefaultMaxPartySize; + CoreConfig.DialogImageLimit = ConfigMain.DialogImageLimit; + EnchantInterface.load(); CustomItems.load(); diff --git a/src/main/java/noppes/npcs/DataAdvanced.java b/src/main/java/noppes/npcs/DataAdvanced.java index f03714506..1943bc0fa 100644 --- a/src/main/java/noppes/npcs/DataAdvanced.java +++ b/src/main/java/noppes/npcs/DataAdvanced.java @@ -10,6 +10,7 @@ import noppes.npcs.controllers.data.FactionOptions; import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.data.Lines; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import noppes.npcs.roles.JobBard; import noppes.npcs.roles.JobChunkLoader; import noppes.npcs.roles.JobConversation; @@ -68,11 +69,11 @@ public class DataAdvanced { } public NBTTagCompound writeToNBT(NBTTagCompound compound) { - compound.setTag("NpcLines", worldLines.writeToNBT()); - compound.setTag("NpcKilledLines", killedLines.writeToNBT()); - compound.setTag("NpcInteractLines", interactLines.writeToNBT()); - compound.setTag("NpcAttackLines", attackLines.writeToNBT()); - compound.setTag("NpcKillLines", killLines.writeToNBT()); + compound.setTag("NpcLines", ((MC1710NBTCompound) worldLines.writeToNBT()).getMCTag()); + compound.setTag("NpcKilledLines", ((MC1710NBTCompound) killedLines.writeToNBT()).getMCTag()); + compound.setTag("NpcInteractLines", ((MC1710NBTCompound) interactLines.writeToNBT()).getMCTag()); + compound.setTag("NpcAttackLines", ((MC1710NBTCompound) attackLines.writeToNBT()).getMCTag()); + compound.setTag("NpcKillLines", ((MC1710NBTCompound) killLines.writeToNBT()).getMCTag()); compound.setString("NpcIdleSound", idleSound); compound.setString("NpcAngrySound", angrySound); @@ -109,11 +110,11 @@ public class DataAdvanced { } public void readToNBT(NBTTagCompound compound) { - interactLines.readNBT(compound.getCompoundTag("NpcInteractLines")); - worldLines.readNBT(compound.getCompoundTag("NpcLines")); - attackLines.readNBT(compound.getCompoundTag("NpcAttackLines")); - killedLines.readNBT(compound.getCompoundTag("NpcKilledLines")); - killLines.readNBT(compound.getCompoundTag("NpcKillLines")); + interactLines.readNBT(new MC1710NBTCompound(compound.getCompoundTag("NpcInteractLines"))); + worldLines.readNBT(new MC1710NBTCompound(compound.getCompoundTag("NpcLines"))); + attackLines.readNBT(new MC1710NBTCompound(compound.getCompoundTag("NpcAttackLines"))); + killedLines.readNBT(new MC1710NBTCompound(compound.getCompoundTag("NpcKilledLines"))); + killLines.readNBT(new MC1710NBTCompound(compound.getCompoundTag("NpcKillLines"))); idleSound = compound.getString("NpcIdleSound"); angrySound = compound.getString("NpcAngrySound"); diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 74c89dd5e..6d965bafe 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -102,7 +102,7 @@ public class DataDisplay { nbttagcompound = skinOverlayData.writeToNBT(nbttagcompound); nbttagcompound = animationData.writeToNBT(nbttagcompound); - nbttagcompound = hitboxData.writeToNBT(nbttagcompound); + nbttagcompound = ((MC1710NBTCompound) hitboxData.writeToNBT(new MC1710NBTCompound(nbttagcompound))).getMCTag(); nbttagcompound = ((MC1710NBTCompound) tintData.writeToNBT(new MC1710NBTCompound(nbttagcompound))).getMCTag(); if (this.playerProfile != null) { @@ -175,7 +175,7 @@ public class DataDisplay { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", 0); //unique glow texture ID - (new SkinOverlay(glowTexture)).writeToNBT(compound); + (new SkinOverlay(glowTexture)).writeToNBT(new MC1710NBTCompound(compound)); if (!nbttagcompound.hasKey("SkinOverlayData")) { NBTTagList tagList = new NBTTagList(); @@ -190,7 +190,7 @@ public class DataDisplay { skinOverlayData.readFromNBT(nbttagcompound); animationData.readFromNBT(nbttagcompound); - hitboxData.readFromNBT(nbttagcompound); + hitboxData.readFromNBT(new MC1710NBTCompound(nbttagcompound)); tintData.readFromNBT(new MC1710NBTCompound(nbttagcompound)); modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE); diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 803d35287..994e47263 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -87,6 +87,7 @@ import noppes.npcs.controllers.data.QuestCategory; import noppes.npcs.controllers.data.QuestData; import noppes.npcs.controllers.data.RecipeAnvil; import noppes.npcs.controllers.data.RecipeCarpentry; +import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.data.Tag; import noppes.npcs.controllers.data.TransportCategory; import noppes.npcs.controllers.data.TransportLocation; @@ -1265,4 +1266,20 @@ public class NoppesUtilServer { SyncController.syncPlayer((EntityPlayerMP) pl); } } + + /** + * Formats a Line's @target placeholder using a vanilla EntityLivingBase. + * This bridges the gap between the core Line class (which only has formatTarget(IEntityLivingBase)) + * and mc1710 callers that have a raw EntityLivingBase. + */ + public static Line formatLineTarget(Line line, EntityLivingBase entity) { + if (line == null || entity == null) + return line; + Line formatted = (Line) line.copy(); + if (entity instanceof EntityPlayer) + formatted.text = formatted.text.replace("@target", ((EntityPlayer) entity).getDisplayName()); + else + formatted.text = formatted.text.replace("@target", entity.getCommandSenderName()); + return formatted; + } } diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java index 04e0406d8..ab3cd75e0 100644 --- a/src/main/java/noppes/npcs/ServerEventsHandler.java +++ b/src/main/java/noppes/npcs/ServerEventsHandler.java @@ -311,7 +311,7 @@ public class ServerEventsHandler { EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity(); Line line = npc.advanced.getKillLine(); if (line != null) - npc.saySurrounding(line.formatTarget(event.entityLiving)); + npc.saySurrounding(NoppesUtilServer.formatLineTarget(line, event.entityLiving)); EventHooks.onNPCKilledEntity(npc, event.entityLiving); } diff --git a/src/main/java/noppes/npcs/VersionCompatibility.java b/src/main/java/noppes/npcs/VersionCompatibility.java index 98dd6c20e..efd7c962b 100644 --- a/src/main/java/noppes/npcs/VersionCompatibility.java +++ b/src/main/java/noppes/npcs/VersionCompatibility.java @@ -8,6 +8,7 @@ import noppes.npcs.controllers.data.Line; import noppes.npcs.controllers.data.Lines; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.entity.data.ModelRotate; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.util.Collection; import java.util.List; @@ -71,7 +72,7 @@ public class VersionCompatibility { line.text = (String) interactLines.toArray()[i]; lines.lines.put(i, line); } - compound.setTag("NpcInteractLines", lines.writeToNBT()); + compound.setTag("NpcInteractLines", ((MC1710NBTCompound) lines.writeToNBT()).getMCTag()); List worldLines = NBTTags.getStringList(compound.getTagList("NpcLines", 10)); lines = new Lines(); @@ -80,7 +81,7 @@ public class VersionCompatibility { line.text = (String) worldLines.toArray()[i]; lines.lines.put(i, line); } - compound.setTag("NpcLines", lines.writeToNBT()); + compound.setTag("NpcLines", ((MC1710NBTCompound) lines.writeToNBT()).getMCTag()); List attackLines = NBTTags.getStringList(compound.getTagList("NpcAttackLines", 10)); lines = new Lines(); @@ -89,7 +90,7 @@ public class VersionCompatibility { line.text = (String) attackLines.toArray()[i]; lines.lines.put(i, line); } - compound.setTag("NpcAttackLines", lines.writeToNBT()); + compound.setTag("NpcAttackLines", ((MC1710NBTCompound) lines.writeToNBT()).getMCTag()); List killedLines = NBTTags.getStringList(compound.getTagList("NpcKilledLines", 10)); lines = new Lines(); @@ -98,7 +99,7 @@ public class VersionCompatibility { line.text = (String) killedLines.toArray()[i]; lines.lines.put(i, line); } - compound.setTag("NpcKilledLines", lines.writeToNBT()); + compound.setTag("NpcKilledLines", ((MC1710NBTCompound) lines.writeToNBT()).getMCTag()); } if (npc.npcVersion == 12) { diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index b27299111..05737a51c 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -61,7 +61,8 @@ public class NoppesUtil { for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - SkinOverlay overlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); + SkinOverlay overlay = new SkinOverlay(); + overlay.readFromNBT(new MC1710NBTCompound(skinOverlayList.getCompoundTagAt(i))); if (oldOverlays.containsKey(tagID)) { overlay.ticks = oldOverlays.get(tagID).ticks; } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java index 51a583e3f..ad539d509 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawner.java @@ -606,7 +606,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData, ICust for (int j = 0; j < validTags.tagCount(); j++) { NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); Tag tag = new Tag(); - tag.readNBT(tagStructure); + tag.readNBT(new MC1710NBTCompound(tagStructure)); tagsUpdate.put(tag.uuid, tag); tagNamesUpdate.put(tag.name, tag.uuid); } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java index e16fb3742..310aafb38 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerAdd.java @@ -317,7 +317,7 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall for (int j = 0; j < validTags.tagCount(); j++) { NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); Tag tag = new Tag(); - tag.readShortNBT(tagStructure); + tag.readShortNBT(new MC1710NBTCompound(tagStructure)); tagMap.put(tag.name, tag.uuid); addTagUUIDs.add(tag.uuid); } diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerFullscreen.java b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerFullscreen.java index cab9e2d3d..10e21b2e9 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerFullscreen.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcMobSpawnerFullscreen.java @@ -1015,7 +1015,7 @@ public class GuiNpcMobSpawnerFullscreen extends GuiDirectory implements IGuiData for (int j = 0; j < validTags.tagCount(); j++) { NBTTagCompound tagStructure = validTags.getCompoundTagAt(j); Tag tag = new Tag(); - tag.readNBT(tagStructure); + tag.readNBT(new MC1710NBTCompound(tagStructure)); tagsUpdate.put(tag.uuid, tag); tagNamesUpdate.put(tag.name, tag.uuid); } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java index 0872c3cb5..7fed18529 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageTags.java @@ -22,6 +22,7 @@ import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.constants.EnumScrollData; import noppes.npcs.controllers.data.Tag; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.util.ArrayList; import java.util.HashMap; @@ -113,7 +114,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData, I Tag tag = new Tag(-1, name, 0x00FF00); NBTTagCompound compound = new NBTTagCompound(); - tag.writeNBT(compound); + tag.writeNBT(new MC1710NBTCompound(compound)); PacketClient.sendClient(new TagSavePacket(compound)); } if (button.id == 1) { @@ -135,7 +136,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData, I @Override public void setGuiData(NBTTagCompound compound) { this.tag = new Tag(); - tag.readNBT(compound); + tag.readNBT(new MC1710NBTCompound(compound)); setSelected(tag.name); initGui(); @@ -170,7 +171,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData, I public void save() { if (selected != null && data.containsKey(selected) && tag != null) { NBTTagCompound compound = new NBTTagCompound(); - tag.writeNBT(compound); + tag.writeNBT(new MC1710NBTCompound(compound)); PacketClient.sendClient(new TagSavePacket(compound)); } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java index 39cf78d46..df2b313b0 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcTransporter.java @@ -16,6 +16,7 @@ import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.constants.EnumScrollData; import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.util.HashMap; import java.util.Vector; @@ -70,7 +71,7 @@ public class GuiNpcTransporter extends GuiNPCInterface2 implements IScrollData, location.dimension = player.dimension; int cat = data.get(scroll.getSelected()); - PacketClient.sendClient(new TransportSavePacket(cat, location.writeNBT())); + PacketClient.sendClient(new TransportSavePacket(cat, ((MC1710NBTCompound) location.writeNBT()).getMCTag())); } @Override @@ -87,7 +88,7 @@ public class GuiNpcTransporter extends GuiNPCInterface2 implements IScrollData, @Override public void setGuiData(NBTTagCompound compound) { TransportLocation loc = new TransportLocation(); - loc.readNBT(compound); + loc.readNBT(new MC1710NBTCompound(compound)); location = loc; initGui(); } diff --git a/src/main/java/noppes/npcs/controllers/TagController.java b/src/main/java/noppes/npcs/controllers/TagController.java index 738418a13..ab73550d5 100644 --- a/src/main/java/noppes/npcs/controllers/TagController.java +++ b/src/main/java/noppes/npcs/controllers/TagController.java @@ -11,6 +11,7 @@ import noppes.npcs.LogWriter; import noppes.npcs.api.handler.ITagHandler; import noppes.npcs.api.handler.data.ITag; import noppes.npcs.controllers.data.Tag; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; @@ -92,7 +93,7 @@ public class TagController implements ITagHandler { for (int i = 0; i < list.tagCount(); i++) { NBTTagCompound nbttagcompound = list.getCompoundTagAt(i); Tag tag = new Tag(); - tag.readNBT(nbttagcompound); + tag.readNBT(new MC1710NBTCompound(nbttagcompound)); tags.put(tag.id, tag); tagUUIDs.put(tag.uuid, tag.id); } @@ -105,7 +106,7 @@ public class TagController implements ITagHandler { for (int slot : tags.keySet()) { Tag tag = tags.get(slot); NBTTagCompound nbtfactions = new NBTTagCompound(); - tag.writeNBT(nbtfactions); + tag.writeNBT(new MC1710NBTCompound(nbtfactions)); list.appendTag(nbtfactions); } NBTTagCompound nbttagcompound = new NBTTagCompound(); diff --git a/src/main/java/noppes/npcs/controllers/TransportController.java b/src/main/java/noppes/npcs/controllers/TransportController.java index d7fa6fa57..e4e9a1ec3 100644 --- a/src/main/java/noppes/npcs/controllers/TransportController.java +++ b/src/main/java/noppes/npcs/controllers/TransportController.java @@ -12,6 +12,7 @@ import noppes.npcs.controllers.data.TransportCategory; import noppes.npcs.controllers.data.TransportLocation; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.roles.RoleTransporter; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import java.io.File; import java.io.FileInputStream; @@ -78,7 +79,7 @@ public class TransportController implements ITransportHandler { for (int i = 0; i < list.tagCount(); i++) { TransportCategory category = new TransportCategory(); NBTTagCompound compound = list.getCompoundTagAt(i); - category.readNBT(compound); + category.readNBT(new MC1710NBTCompound(compound)); for (TransportLocation location : category.locations.values()) locations.put(location.id, location); @@ -93,7 +94,7 @@ public class TransportController implements ITransportHandler { NBTTagList list = new NBTTagList(); for (TransportCategory category : categories.values()) { NBTTagCompound compound = new NBTTagCompound(); - category.writeNBT(compound); + category.writeNBT(new MC1710NBTCompound(compound)); list.appendTag(compound); } NBTTagCompound nbttagcompound = new NBTTagCompound(); @@ -259,7 +260,7 @@ public class TransportController implements ITransportHandler { return null; RoleTransporter role = (RoleTransporter) npc.roleInterface; TransportLocation location = new TransportLocation(); - location.readNBT(compound); + location.readNBT(new MC1710NBTCompound(compound)); location.category = category; if (role.hasTransport()) location.id = role.transportId; diff --git a/src/main/java/noppes/npcs/controllers/data/Quest.java b/src/main/java/noppes/npcs/controllers/data/Quest.java index 41bb624b8..e727498de 100644 --- a/src/main/java/noppes/npcs/controllers/data/Quest.java +++ b/src/main/java/noppes/npcs/controllers/data/Quest.java @@ -93,7 +93,7 @@ public class Quest implements ICompatibilty, IQuest { questInterface.readEntityFromNBT(compound); factionOptions.readFromNBT(compound.getCompoundTag("QuestFactionPoints")); - partyOptions.readFromNBT(compound.getCompoundTag("PartyOptions")); + partyOptions.readFromNBT(new MC1710NBTCompound(compound.getCompoundTag("PartyOptions"))); profileOptions.readFromNBT(new MC1710NBTCompound(compound.getCompoundTag("ProfileOptions"))); mail.readNBT(compound.getCompoundTag("QuestMail")); @@ -141,7 +141,7 @@ public class Quest implements ICompatibilty, IQuest { this.questInterface.writeEntityToNBT(compound); compound.setTag("QuestFactionPoints", factionOptions.writeToNBT(new NBTTagCompound())); - compound.setTag("PartyOptions", partyOptions.writeToNBT()); + compound.setTag("PartyOptions", ((MC1710NBTCompound) partyOptions.writeToNBT()).getMCTag()); compound.setTag("ProfileOptions", ((MC1710NBTCompound) profileOptions.writeToNBT()).getMCTag()); compound.setTag("QuestMail", mail.writeNBT()); diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 77927d4b1..70c1de15a 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -821,7 +821,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (entity != null && entity != this && ais.onAttack != 3 && !isAttacking()) { Line line = advanced.getAttackLine(); if (line != null) - saySurrounding(line.formatTarget(entity)); + saySurrounding(NoppesUtilServer.formatLineTarget(line, entity)); } } @@ -1545,7 +1545,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } Line line = advanced.getKilledLine(); if (line != null) - saySurrounding(line.formatTarget(attackingEntity)); + saySurrounding(NoppesUtilServer.formatLineTarget(line, attackingEntity)); } super.onDeath(damagesource); } diff --git a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java index 569dafeb2..c6bfefe28 100644 --- a/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java +++ b/src/main/java/noppes/npcs/entity/data/DataSkinOverlays.java @@ -9,6 +9,7 @@ import noppes.npcs.api.handler.IOverlayHandler; import noppes.npcs.config.ConfigMain; import noppes.npcs.controllers.data.PlayerData; import noppes.npcs.controllers.data.SkinOverlay; +import noppes.npcs.wrapper.nbt.MC1710NBTCompound; import noppes.npcs.entity.EntityNPCInterface; import java.util.HashMap; @@ -27,8 +28,9 @@ public class DataSkinOverlays implements IOverlayHandler { NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData", 10); for (int i = 0; i < skinOverlayList.tagCount(); i++) { int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID"); - SkinOverlay skinOverlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i)); - skinOverlay.parent = this; + SkinOverlay skinOverlay = new SkinOverlay(); + skinOverlay.readFromNBT(new MC1710NBTCompound(skinOverlayList.getCompoundTagAt(i))); + skinOverlay.setOnChanged(() -> { updateClient(); save(); }); skinOverlays.put(tagID, skinOverlay); } this.overlayList = skinOverlays; @@ -41,7 +43,7 @@ public class DataSkinOverlays implements IOverlayHandler { for (Map.Entry overlayData : this.overlayList.entrySet()) { NBTTagCompound compound = new NBTTagCompound(); compound.setInteger("SkinOverlayID", overlayData.getKey()); - compound = ((SkinOverlay) overlayData.getValue()).writeToNBT(compound); + ((SkinOverlay) overlayData.getValue()).writeToNBT(new MC1710NBTCompound(compound)); overlayList.appendTag(compound); } } @@ -72,7 +74,7 @@ public class DataSkinOverlays implements IOverlayHandler { return; } - ((SkinOverlay) data).parent = this; + ((SkinOverlay) data).setOnChanged(() -> { updateClient(); save(); }); this.overlayList.put(id, data); updateClient(); save();