More Core Class Conversion

This commit is contained in:
Kam committed 2026-03-13 16:22:48 -04:00
1 parent 43a52ad407
commit 89f81f96bc
51 files changed
+744 -189

No files matched your search

@@ -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
@@ -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);
@@ -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);
@@ -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);
@@ -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);
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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();
+11 -10
View File
@@ -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");
+3 -3
View File
@@ -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);
@@ -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;
}
}
@@ -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);
}
@@ -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<String> 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<String> 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<String> 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) {
@@ -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;
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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));
}
@@ -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();
}
@@ -1,40 +0,0 @@
package noppes.npcs.constants;
import net.minecraft.util.StatCollector;
public enum EnumAuctionSort {
NEWEST("auction.sort.newest"),
ENDING_SOON("auction.sort.endingSoon"),
PRICE_LOW("auction.sort.priceLow"),
PRICE_HIGH("auction.sort.priceHigh"),
MOST_BIDS("auction.sort.mostBids");
private final String langKey;
EnumAuctionSort(String langKey) {
this.langKey = langKey;
}
public String getLangKey() {
return langKey;
}
public String getDisplayName() {
return StatCollector.translateToLocal(langKey);
}
public static String[] getDisplayNames() {
String[] names = new String[values().length];
for (int i = 0; i < values().length; i++) {
names[i] = values()[i].getDisplayName();
}
return names;
}
public static EnumAuctionSort fromOrdinal(int ordinal) {
if (ordinal >= 0 && ordinal < values().length) {
return values()[ordinal];
}
return NEWEST;
}
}
@@ -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();
@@ -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;
@@ -1,130 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import noppes.npcs.constants.EnumAuctionSort;
/**
* Filter for auction listings.
* Supports search by item name or seller name and sorting options.
*/
public class AuctionFilter {
private String searchText;
public EnumAuctionSort sortBy;
// Cached normalized search for efficiency
private String normalizedSearch;
public AuctionFilter() {
this.searchText = "";
this.sortBy = EnumAuctionSort.NEWEST;
this.normalizedSearch = "";
}
public boolean hasSearchText() {
return searchText != null && !searchText.trim().isEmpty();
}
/**
* Normalize string for search (strip colors, lowercase, trim)
*/
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();
}
/**
* Check if item name or seller name matches search text
*/
public boolean matchesSearch(String itemName, String sellerName) {
if (!hasSearchText()) return true;
String normalizedItem = normalizeForSearch(itemName);
String normalizedSeller = normalizeForSearch(sellerName);
// Match if search text is found in either item name or seller name
return normalizedItem.contains(normalizedSearch) || normalizedSeller.contains(normalizedSearch);
}
/**
* Legacy method - only checks item name
*/
public boolean matchesSearch(String itemName) {
return matchesSearch(itemName, "");
}
/**
* Advanced search - all words must be present in item name OR seller name
*/
public boolean matchesSearchAdvanced(String itemName, String sellerName) {
if (!hasSearchText()) return true;
String normalizedItem = normalizeForSearch(itemName);
String normalizedSeller = normalizeForSearch(sellerName);
String[] words = normalizedSearch.split("\\s+");
for (String word : words) {
if (!word.isEmpty()) {
// Word must be in item name OR seller name
if (!normalizedItem.contains(word) && !normalizedSeller.contains(word)) {
return false;
}
}
}
return true;
}
/**
* Legacy method - only checks item name
*/
public boolean matchesSearchAdvanced(String itemName) {
return matchesSearchAdvanced(itemName, "");
}
public void reset() {
searchText = "";
sortBy = EnumAuctionSort.NEWEST;
normalizedSearch = "";
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setString("SearchText", searchText != null ? searchText : "");
compound.setInteger("SortBy", sortBy.ordinal());
return compound;
}
public void readFromNBT(NBTTagCompound 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;
copy.normalizedSearch = this.normalizedSearch;
copy.sortBy = this.sortBy;
return copy;
}
// Getters and setters
public String getSearchText() {
return searchText;
}
public void setSearchText(String searchText) {
this.searchText = searchText;
this.normalizedSearch = normalizeForSearch(searchText);
}
public EnumAuctionSort getSortBy() {
return sortBy;
}
public void setSortBy(EnumAuctionSort sortBy) {
this.sortBy = sortBy;
}
}
@@ -1,63 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.entity.data.IHitboxData;
import noppes.npcs.config.ConfigMain;
public class HitboxData implements IHitboxData {
private float widthScale = 1f;
private float heightScale = 1f;
private boolean hitboxEnabled = false;
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("HitboxEnabled", hitboxEnabled);
if (hitboxEnabled) {
if (widthScale > ConfigMain.HitBoxScaleMax)
widthScale = ConfigMain.HitBoxScaleMax;
nbttagcompound.setFloat("HitboxWidthScale", widthScale);
if (heightScale > ConfigMain.HitBoxScaleMax)
heightScale = ConfigMain.HitBoxScaleMax;
nbttagcompound.setFloat("HitboxHeightScale", heightScale);
}
return nbttagcompound;
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
hitboxEnabled = nbttagcompound.getBoolean("HitboxEnabled");
if (hitboxEnabled) {
widthScale = nbttagcompound.getFloat("HitboxWidthScale");
if (widthScale > ConfigMain.HitBoxScaleMax)
widthScale = ConfigMain.HitBoxScaleMax;
heightScale = nbttagcompound.getFloat("HitboxHeightScale");
if (heightScale > ConfigMain.HitBoxScaleMax)
heightScale = ConfigMain.HitBoxScaleMax;
}
}
public float getWidthScale() {
return widthScale;
}
public void setWidthScale(float widthScale) {
this.widthScale = widthScale;
}
public float getHeightScale() {
return heightScale;
}
public void setHeightScale(float heightScale) {
this.heightScale = heightScale;
}
public boolean isHitboxEnabled() {
return hitboxEnabled;
}
public void setHitboxEnabled(boolean hitboxEnabled) {
this.hitboxEnabled = hitboxEnabled;
}
}
@@ -1,74 +0,0 @@
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;
public class Line implements ILine {
public Line() {
}
public Line(String text) {
this.text = text;
}
public String text = "";
public String sound = "";
public boolean hideText = false;
public ILine copy() {
Line line = new Line(text);
line.sound = sound;
line.hideText = hideText;
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;
}
@Override
public void setText(String text) {
this.text = text;
}
@Override
public String getSound() {
return this.sound;
}
@Override
public void setSound(String sound) {
this.sound = sound;
}
@Override
public void hideText(boolean hide) {
this.hideText = hide;
}
@Override
public boolean hideText() {
return this.hideText;
}
}
@@ -1,96 +0,0 @@
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 java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
public class Lines implements ILines {
private static final Random random = new Random();
private int lastLine = -1;
public HashMap<Integer, Line> lines = new HashMap<Integer, Line>();
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
NBTTagList nbttaglist = new NBTTagList();
for (int slot : lines.keySet()) {
Line line = lines.get(slot);
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setString("Line", line.text);
nbttagcompound.setString("Song", line.sound);
nbttaglist.appendTag(nbttagcompound);
}
compound.setTag("Lines", nbttaglist);
return compound;
}
public void readNBT(NBTTagCompound compound) {
NBTTagList nbttaglist = compound.getTagList("Lines", 10);
HashMap<Integer, Line> map = new HashMap<Integer, Line>();
for (int i = 0; i < nbttaglist.tagCount(); i++) {
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
Line line = new Line();
line.text = nbttagcompound.getString("Line");
line.sound = nbttagcompound.getString("Song");
map.put(nbttagcompound.getInteger("Slot"), line);
}
lines = map;
}
public ILine createLine(String text) {
return new Line(text);
}
public ILine getLine(boolean isRandom) {
if (lines.isEmpty())
return null;
if (isRandom) {
List<Line> lines = new ArrayList<Line>(this.lines.values());
return lines.get(random.nextInt(lines.size()));
}
lastLine++;
while (true) {
lastLine %= 8;
Line line = lines.get(lastLine);
if (line != null)
return line.copy();
lastLine++;
}
}
public ILine getLine(int lineIndex) {
return lines.get(lineIndex);
}
public void setLine(int lineIndex, ILine line) {
lines.put(lineIndex, (Line) line);
}
public void removeLine(int lineIndex) {
lines.remove(lineIndex);
}
public void clear() {
lines.clear();
}
public boolean isEmpty() {
return lines.isEmpty();
}
public Integer[] getKeys() {
return lines.keySet().toArray(new Integer[0]);
}
}
@@ -1,245 +0,0 @@
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.constants.EnumPartyExchange;
import noppes.npcs.constants.EnumPartyObjectives;
import noppes.npcs.constants.EnumPartyRequirements;
import java.util.Vector;
public class PartyOptions implements IPartyOptions {
public boolean allowParty = false;
public boolean onlyParty = false;
public EnumPartyRequirements partyRequirements = EnumPartyRequirements.Leader;
public EnumPartyExchange rewardControl = EnumPartyExchange.Leader;
public EnumPartyExchange completeFor = EnumPartyExchange.Leader;
public EnumPartyExchange executeCommand = EnumPartyExchange.Leader;
public EnumPartyObjectives objectiveRequirement = EnumPartyObjectives.Shared;
public int minPartySize = ConfigMain.DefaultMinPartySize;
public int maxPartySize = ConfigMain.DefaultMaxPartySize;
public void readFromNBT(NBTTagCompound compound) {
// Party Management
allowParty = compound.getBoolean("AllowParty");
if (allowParty) {
onlyParty = compound.getBoolean("OnlyParty");
partyRequirements = EnumPartyRequirements.values()[compound.getInteger("PartyRequirements")];
rewardControl = EnumPartyExchange.values()[compound.getInteger("RewardControl")];
completeFor = EnumPartyExchange.values()[compound.getInteger("CompleteFor")];
executeCommand = EnumPartyExchange.values()[compound.getInteger("ExecuteCommand")];
minPartySize = compound.getInteger("MinPartySize");
maxPartySize = compound.getInteger("MaxPartySize");
objectiveRequirement = EnumPartyObjectives.values()[compound.getInteger("ObjectiveRequirement")];
} else {
if (compound.hasKey("OnlyParty")) {
compound.removeTag("OnlyParty");
}
if (compound.hasKey("PartyRequirements")) {
compound.removeTag("PartyRequirements");
}
if (compound.hasKey("RewardControl")) {
compound.removeTag("RewardControl");
}
if (compound.hasKey("CompleteFor")) {
compound.removeTag("CompleteFor");
}
if (compound.hasKey("ExecuteCommand")) {
compound.removeTag("ExecuteCommand");
}
if (compound.hasKey("MinPartySize")) {
compound.removeTag("MinPartySize");
}
if (compound.hasKey("MaxPartySize")) {
compound.removeTag("MaxPartySize");
}
if (compound.hasKey("ObjectiveRequirement")) {
compound.removeTag("ObjectiveRequirement");
}
onlyParty = false;
partyRequirements = EnumPartyRequirements.Leader;
rewardControl = EnumPartyExchange.Leader;
completeFor = EnumPartyExchange.Leader;
executeCommand = EnumPartyExchange.Leader;
minPartySize = ConfigMain.DefaultMinPartySize;
maxPartySize = ConfigMain.DefaultMaxPartySize;
objectiveRequirement = EnumPartyObjectives.Shared;
}
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("AllowParty", allowParty);
if (allowParty) {
compound.setBoolean("OnlyParty", onlyParty);
compound.setInteger("PartyRequirements", partyRequirements.ordinal());
compound.setInteger("RewardControl", rewardControl.ordinal());
compound.setInteger("CompleteFor", completeFor.ordinal());
compound.setInteger("ExecuteCommand", executeCommand.ordinal());
compound.setInteger("MinPartySize", minPartySize);
compound.setInteger("MaxPartySize", maxPartySize);
compound.setInteger("ObjectiveRequirement", objectiveRequirement.ordinal());
} else {
if (compound.hasKey("OnlyParty")) {
compound.removeTag("OnlyParty");
}
if (compound.hasKey("PartyRequirements")) {
compound.removeTag("PartyRequirements");
}
if (compound.hasKey("RewardControl")) {
compound.removeTag("RewardControl");
}
if (compound.hasKey("CompleteFor")) {
compound.removeTag("CompleteFor");
}
if (compound.hasKey("ExecuteCommand")) {
compound.removeTag("ExecuteCommand");
}
if (compound.hasKey("MinPartySize")) {
compound.removeTag("MinPartySize");
}
if (compound.hasKey("MaxPartySize")) {
compound.removeTag("MaxPartySize");
}
if (compound.hasKey("ObjectiveRequirement")) {
compound.removeTag("ObjectiveRequirement");
}
}
return compound;
}
@Override
public boolean isAllowParty() {
return allowParty;
}
@Override
public void setAllowParty(boolean allowParty) {
this.allowParty = allowParty;
}
@Override
public boolean isOnlyParty() {
return onlyParty;
}
@Override
public void setOnlyParty(boolean onlyParty) {
this.onlyParty = onlyParty;
}
@Override
public int getPartyRequirements() {
return partyRequirements.ordinal();
}
@Override
public void setPartyRequirements(int partyReq) {
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
return;
}
this.partyRequirements = EnumPartyRequirements.values()[partyReq];
}
@Override
public int getRewardControl() {
return rewardControl.ordinal();
}
@Override
public void setRewardControl(int rewardCon) {
if (rewardCon < 0 || rewardCon >= EnumPartyExchange.values().length) {
return;
}
this.rewardControl = EnumPartyExchange.values()[rewardCon];
}
@Override
public int getCompleteFor() {
return completeFor.ordinal();
}
@Override
public void setCompleteFor(int compFor) {
if (compFor < 0 || compFor >= EnumPartyExchange.values().length) {
return;
}
this.completeFor = EnumPartyExchange.values()[compFor];
}
@Override
public int getExecuteCommandFor() {
return executeCommand.ordinal();
}
@Override
public void setExecuteCommandFor(int commandFor) {
if (commandFor < 0 || commandFor >= EnumPartyExchange.values().length) {
return;
}
this.executeCommand = EnumPartyExchange.values()[commandFor];
}
@Override
public int getObjectiveRequirement() {
return objectiveRequirement.ordinal();
}
@Override
public void setObjectiveRequirement(int requirement) {
if (requirement < 0 || requirement >= EnumPartyObjectives.values().length) {
return;
}
this.objectiveRequirement = EnumPartyObjectives.values()[requirement];
}
@Override
public int getMinPartySize() {
return minPartySize;
}
@Override
public void setMinPartySize(int newSize) {
if (newSize < 1)
newSize = 1;
if (newSize > maxPartySize)
newSize = maxPartySize;
minPartySize = newSize;
}
@Override
public int getMaxPartySize() {
return maxPartySize;
}
@Override
public void setMaxPartySize(int newSize) {
if (newSize < minPartySize)
newSize = minPartySize;
maxPartySize = newSize;
}
public Vector<String> getPartyOptionsList() {
Vector<String> vec = new Vector<String>();
if (onlyParty) {
vec.add("party.only" + ":" + "gui.yes");
}
vec.add("party.partyRequirements" + ":" + partyRequirements.name);
vec.add("quest.objectives" + ":" + objectiveRequirement.name);
vec.add("party.completeFor" + ":" + completeFor.name);
vec.add("quest.reward" + ":" + rewardControl.name);
vec.add("party.minPartySize" + ":" + minPartySize);
vec.add("party.maxPartySize" + ":" + maxPartySize);
return vec;
}
}
@@ -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());
@@ -1,189 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ISkinOverlay;
import noppes.npcs.entity.data.DataSkinOverlays;
public class SkinOverlay implements ISkinOverlay {
public DataSkinOverlays parent;
public String texture;
public boolean glow = true;
public boolean blend = true;
public float alpha = 1.0F;
public float size = 1.0F;
public int color = 0xFFFFFF;
public float speedX = 0.0F;
public float speedY = 0.0F;
public float scaleX = 1.0F;
public float scaleY = 1.0F;
public float offsetX = 0.0F;
public float offsetY = 0.0F;
public float offsetZ = 0.0F;
//Client-sided
public long ticks = 0;
public SkinOverlay() {
}
public SkinOverlay(String texture) {
this.texture = texture;
}
public void setTexture(String texture) {
this.texture = texture;
this.updateClient();
}
public String getTexture() {
return this.texture;
}
public void setGlow(boolean glow) {
this.glow = glow;
this.updateClient();
}
public boolean getGlow() {
return glow;
}
public void setBlend(boolean blend) {
this.blend = blend;
this.updateClient();
}
public boolean getBlend() {
return blend;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
this.updateClient();
}
public float getAlpha() {
return alpha;
}
public void setSize(float size) {
this.size = size;
this.updateClient();
}
public float getSize() {
return size;
}
public void setColor(int color) {
this.color = Math.max(0, color);
this.updateClient();
}
public int getColor() {
return color;
}
public void setTextureScale(float scaleX, float scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
this.updateClient();
}
public float getTextureScaleX() {
return scaleX;
}
public float getTextureScaleY() {
return scaleY;
}
public void setSpeed(float speedX, float speedY) {
this.speedX = speedX;
this.speedY = speedY;
this.updateClient();
}
public float getSpeedX() {
return speedX;
}
public float getSpeedY() {
return speedY;
}
public void setOffset(float offsetX, float offsetY, float offsetZ) {
this.offsetX = offsetX;
this.offsetY = offsetY;
this.offsetZ = offsetZ;
this.updateClient();
}
public float getOffsetX() {
return offsetX;
}
public float getOffsetY() {
return offsetY;
}
public float getOffsetZ() {
return offsetZ;
}
public void readFromNBT(NBTTagCompound 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")){
this.color = compound.getInteger("SkinOverlayColor");
} else {
this.color = 0xFFFFFF;
}
this.speedX = compound.getFloat("SkinOverlaySpeedX");
this.speedY = compound.getFloat("SkinOverlaySpeedY");
this.scaleX = compound.getFloat("SkinOverlayScaleX");
this.scaleY = compound.getFloat("SkinOverlayScaleY");
this.offsetX = compound.getFloat("SkinOverlayOffsetX");
this.offsetY = compound.getFloat("SkinOverlayOffsetY");
this.offsetZ = compound.getFloat("SkinOverlayOffsetZ");
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setString("SkinOverlayTexture", this.getTexture());
compound.setBoolean("SkinOverlayGlow", this.getGlow());
compound.setBoolean("SkinOverlayBlend", this.getBlend());
compound.setFloat("SkinOverlayAlpha", this.getAlpha());
compound.setFloat("SkinOverlaySize", this.getSize());
compound.setInteger("SkinOverlayColor", this.getColor());
compound.setFloat("SkinOverlaySpeedX", this.getSpeedX());
compound.setFloat("SkinOverlaySpeedY", this.getSpeedY());
compound.setFloat("SkinOverlayScaleX", this.getTextureScaleX());
compound.setFloat("SkinOverlayScaleY", this.getTextureScaleY());
compound.setFloat("SkinOverlayOffsetX", this.getOffsetX());
compound.setFloat("SkinOverlayOffsetY", this.getOffsetY());
compound.setFloat("SkinOverlayOffsetZ", this.getOffsetZ());
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();
}
}
}
@@ -1,93 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.ITag;
import noppes.npcs.controllers.TagController;
import java.util.UUID;
import static java.util.UUID.randomUUID;
public class Tag implements ITag {
public String name = "";
public int color = Integer.parseInt("FF00", 16);
public int id = -1;
public UUID uuid = randomUUID();
public boolean hideTag = false;
public Tag() {
}
public Tag(int id, String name, int color) {
this.name = name;
this.color = color;
this.id = id;
}
public static String formatName(String name) {
name = name.toLowerCase().trim();
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
public void readNBT(NBTTagCompound compound) {
name = compound.getString("Name");
color = compound.getInteger("Color");
id = compound.getInteger("Slot");
hideTag = compound.getBoolean("HideTag");
uuid = UUID.fromString(compound.getString("Uuid"));
}
public void writeNBT(NBTTagCompound compound) {
compound.setInteger("Slot", id);
compound.setString("Name", name);
compound.setInteger("Color", color);
compound.setString("Uuid", uuid.toString());
compound.setBoolean("HideTag", hideTag);
}
public void readShortNBT(NBTTagCompound compound) {
name = compound.getString("Name");
uuid = UUID.fromString(compound.getString("Uuid"));
}
public void writeShortNBT(NBTTagCompound compound) {
compound.setString("Name", name);
compound.setString("Uuid", uuid.toString());
}
public int getId() {
return this.id;
}
public String getUuid() {
return this.uuid.toString();
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public void setColor(int color) {
this.color = color;
}
public int getColor() {
return this.color;
}
public boolean getIsHidden() {
return this.hideTag;
}
public void setIsHidden(boolean bo) {
this.hideTag = bo;
}
public void save() {
TagController.getInstance().saveTag(this);
}
}
@@ -1,105 +0,0 @@
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 java.util.HashMap;
import java.util.Map;
import java.util.Vector;
public class TransportCategory implements ITransportCategory {
public int id = -1;
public String title = "";
public HashMap<Integer, TransportLocation> locations;
public TransportCategory() {
locations = new HashMap<Integer, TransportLocation>();
}
public Vector<TransportLocation> getDefaultLocations() {
Vector<TransportLocation> list = new Vector<TransportLocation>();
for (TransportLocation loc : locations.values())
if (loc.isDefault())
list.add(loc);
return list;
}
public void readNBT(NBTTagCompound compound) {
id = compound.getInteger("CategoryId");
title = compound.getString("CategoryTitle");
NBTTagList locs = compound.getTagList("CategoryLocations", 10);
if (locs == null || locs.tagCount() == 0)
return;
for (int ii = 0; ii < locs.tagCount(); ii++) {
TransportLocation location = new TransportLocation();
location.readNBT(locs.getCompoundTagAt(ii));
location.category = this;
locations.put(location.id, location);
}
}
public void writeNBT(NBTTagCompound compound) {
compound.setInteger("CategoryId", id);
compound.setString("CategoryTitle", title);
NBTTagList locs = new NBTTagList();
for (TransportLocation location : locations.values()) {
locs.appendTag(location.writeNBT());
}
compound.setTag("CategoryLocations", locs);
}
public int getId() {
return id;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
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);
}
public ITransportLocation getLocation(String name) {
TransportLocation location = null;
for (TransportLocation l : locations.values()) {
if (l.getName().equals(name)) {
location = l;
break;
}
}
return location;
}
public void removeLocation(String name) {
int id = -1;
for (Map.Entry<Integer, TransportLocation> entry : locations.entrySet()) {
if (entry.getValue().getName().equals(name)) {
id = entry.getKey();
;
locations.remove(entry.getKey());
break;
}
}
if (id >= 0) {
TransportController.getInstance().removeLocation(id);
}
}
}
@@ -1,108 +0,0 @@
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;
public class TransportLocation implements ITransportLocation {
public int id = -1;
public String name = "default name";
public double posX;
public double posY;
public double posZ;
public int type = 0;
public int dimension = 0;
public TransportCategory category;
public void readNBT(NBTTagCompound compound) {
if (compound == null)
return;
id = compound.getInteger("Id");
posX = compound.getDouble("PosX");
posY = compound.getDouble("PosY");
posZ = compound.getDouble("PosZ");
type = compound.getInteger("Type");
dimension = compound.getInteger("Dimension");
name = compound.getString("Name");
}
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Id", id);
compound.setDouble("PosX", posX);
compound.setDouble("PosY", posY);
compound.setDouble("PosZ", posZ);
compound.setInteger("Type", type);
compound.setInteger("Dimension", dimension);
compound.setString("Name", name);
return compound;
}
public boolean isDefault() {
return type == 1;
}
public int getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setDimension(int dimension) {
this.dimension = dimension;
}
public int getDimension() {
return dimension;
}
public void setType(int type) {
this.type = type;
}
public int getType() {
return type;
}
public void setPosition(int x, int y, int z) {
this.posX = x;
this.posY = y;
this.posZ = z;
}
public void setPosition(IPos pos) {
this.posX = pos.getX();
this.posY = pos.getY();
this.posZ = pos.getZ();
}
public IPos getPos() {
return NpcAPI.Instance().getIPos(this.posX, this.posY, this.posZ);
}
public double getX() {
return posX;
}
public double getY() {
return posY;
}
public double getZ() {
return posZ;
}
public void save() {
TransportController.getInstance().saveLocation(this.category.id, this);
}
}
@@ -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);
}
@@ -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<Integer, ISkinOverlay> 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();
@@ -1,78 +0,0 @@
package noppes.npcs.util;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class CacheHashMap<K, V extends CacheHashMap.CachedObject<?>> extends HashMap<K, V> {
private final long maxCacheTime;
private long saveInterval;
public CacheHashMap(long maxCacheTime) {
this.maxCacheTime = maxCacheTime;
}
public CacheHashMap(long maxCacheTime, long saveInterval) {
this.maxCacheTime = maxCacheTime;
this.saveInterval = saveInterval;
}
@Override
public V get(Object key) {
V object = super.get(key);
object.updateTimeAccessed();
Iterator<Map.Entry<K, V>> iterator = this.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<K, V> entry = iterator.next();
long lifeTimeDiff = entry.getValue().timeSinceAccessed();
if (lifeTimeDiff > this.maxCacheTime) {
entry.getValue().save();
iterator.remove();
} else if (this.saveInterval > 0) {
long saveTimeDiff = entry.getValue().timeSinceSaved();
if (saveTimeDiff > this.saveInterval) {
entry.getValue().save();
entry.getValue().updateSaveTime();
}
}
}
return object;
}
public static class CachedObject<T> {
private long timeSaved;
private long lastTimeAccessed;
private final T object;
public CachedObject(T object) {
this.object = object;
this.lastTimeAccessed = System.currentTimeMillis();
this.timeSaved = System.currentTimeMillis();
}
public long timeSinceAccessed() {
return System.currentTimeMillis() - this.lastTimeAccessed;
}
public long timeSinceSaved() {
return System.currentTimeMillis() - this.timeSaved;
}
public void updateTimeAccessed() {
this.lastTimeAccessed = System.currentTimeMillis();
}
public void updateSaveTime() {
this.timeSaved = System.currentTimeMillis();
}
public void save() {
}
public T getObject() {
return this.object;
}
}
}
@@ -1,13 +0,0 @@
package noppes.npcs.util;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class CustomNPCsThreader {
/**
* Executor used for all asynchronous profile and player data saves.
* It is single-threaded so submitted tasks run sequentially and the
* save order for a given player is preserved.
*/
public static final Executor customNPCThread = Executors.newSingleThreadExecutor();
}
@@ -1,17 +0,0 @@
package noppes.npcs.util;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
public class LRUHashMap<K, V> extends LinkedHashMap<K, V> {
private final int maxSize;
public LRUHashMap(int size) {
super(size, 0.75F, true);
this.maxSize = size;
}
protected boolean removeEldestEntry(Entry<K, V> eldest) {
return this.size() > this.maxSize;
}
}
@@ -1,74 +0,0 @@
package noppes.npcs.util;
public class MillisTimer {
float ticksPerSecond;
private double lastHRTime;
public int elapsedTicks;
public float renderPartialTicks;
public float timerSpeed = 1.0F;
public float elapsedPartialTicks;
private long lastSyncSysClock;
private long lastSyncHRClock;
private long field_74285_i;
private double timeSyncAdjustment = 1.0D;
public MillisTimer(float p_i1018_1_) {
this.ticksPerSecond = p_i1018_1_;
this.lastSyncSysClock = this.getLastSyncSysClock();
this.lastSyncHRClock = System.nanoTime() / 1000000L;
}
/**
* Updates all fields of the Timer using the current time
*/
public void updateTimer() {
long i = this.getLastSyncSysClock();
long j = i - this.lastSyncSysClock;
long k = System.nanoTime() / 1000000L;
double d0 = (double) k / 1000.0D;
if (j <= 1000L && j >= 0L) {
this.field_74285_i += j;
if (this.field_74285_i > 1000L) {
long l = k - this.lastSyncHRClock;
double d1 = (double) this.field_74285_i / (double) l;
this.timeSyncAdjustment += (d1 - this.timeSyncAdjustment) * 0.20000000298023224D;
this.lastSyncHRClock = k;
this.field_74285_i = 0L;
}
if (this.field_74285_i < 0L) {
this.lastSyncHRClock = k;
}
} else {
this.lastHRTime = d0;
}
this.lastSyncSysClock = i;
double d2 = (d0 - this.lastHRTime) * this.timeSyncAdjustment;
this.lastHRTime = d0;
if (d2 < 0.0D) {
d2 = 0.0D;
}
if (d2 > 1.0D) {
d2 = 1.0D;
}
this.elapsedPartialTicks = (float) ((double) this.elapsedPartialTicks + d2 * (double) this.timerSpeed * (double) this.ticksPerSecond);
this.elapsedTicks = (int) this.elapsedPartialTicks;
this.elapsedPartialTicks -= (float) this.elapsedTicks;
if (this.elapsedTicks > 10) {
this.elapsedTicks = 10;
}
this.renderPartialTicks = this.elapsedPartialTicks;
}
private long getLastSyncSysClock() {
return System.nanoTime() / 1_000_000L;
}
}
@@ -1,34 +0,0 @@
package noppes.npcs.util;
import java.lang.reflect.Field;
public class SizeOfObjectUtil {
public static long sizeOfObject(Object obj) {
long size = 0;
for (Field field : obj.getClass().getDeclaredFields()) {
try {
field.setAccessible(true);
Class<?> type = field.getType();
if (type == int.class || type == Integer.class) {
size += Integer.BYTES;
} else if (type == long.class || type == Long.class) {
size += Long.BYTES;
} else if (type == byte.class || type == Byte.class) {
size += Byte.BYTES;
} else if (type == boolean.class || type == Boolean.class) {
size += 1; // Assuming 1 byte for boolean
} // Add more cases for other primitive types if needed
else {
// If it's a reference type, recursively calculate its size
Object value = field.get(obj);
if (value != null) {
size += sizeOfObject(value);
}
}
} catch (IllegalAccessException e) {
// Handle exception
}
}
return size;
}
}
@@ -1,72 +0,0 @@
package noppes.npcs.util;
public class ValueUtil {
public static float lerp(float start, float end, float delta) {
return start + delta * (end - start);
}
public static double lerp(double start, double end, double delta) {
return start + delta * (end - start);
}
public static float clamp(float given, float min, float max) {
if (given < min)
return min;
return Math.min(given, max);
}
public static int clamp(int given, int min, int max) {
if (given < min)
return min;
return Math.min(given, max);
}
public static byte clamp(byte given, byte min, byte max) {
if (given < min)
return min;
if (given > max)
return max;
return given;
}
public static double clamp(double given, double min, double max) {
if (given < min)
return min;
return Math.min(given, max);
}
public static long clamp(long given, long min, long max) {
if (given < min)
return min;
return Math.min(given, max);
}
public static float correctFloat(float given, float min, float max) {
if (given < min)
return min;
if (given > max)
return max;
return given;
}
public static int CorrectInt(int given, int min, int max) {
if (given < min)
return min;
if (given > max)
return max;
return given;
}
public static String format(double value) {
return (value % 1 == 0) ? String.format("%.0f", value) : String.format("%.2f", value);
}
public static String format(String precision, float value) {
return (value % 1 == 0) ? String.format("%.0f", value) : String.format(precision, value);
}
public static String format(String precision, double value) {
return (value % 1 == 0) ? String.format("%.0f", value) : String.format(precision, value);
}
}