Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
luisc committed 2025-02-25 16:13:22 -06:00
commit e585f11bb2
305 files changed
+7832 -3047

No files matched your search

+2 -1
View File
@@ -267,7 +267,8 @@ public class CustomNpcs {
public void serverstart(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandNoppes());
event.registerServerCommand(new CommandKamkeel());
event.registerServerCommand(new CommandProfile());
if(ConfigMain.ProfilesEnabled)
event.registerServerCommand(new CommandProfile());
}
private void registerNpc(Class<? extends Entity> cl, String name) {
@@ -88,6 +88,15 @@ public class CustomNpcsPermissions{
public static final Permission SCRIPT_ITEM = new Permission("customnpcs.script.item");
public static final Permission SCRIPT_BLOCK = new Permission("customnpcs.script.block");
// Profiles
public static final Permission PROFILE_ADMIN = new Permission("customnpcs.profile.admin");
public static final Permission PROFILE_CREATE = new Permission("customnpcs.profile.create");
public static final Permission PROFILE_DELETE = new Permission("customnpcs.profile.delete");
public static final Permission PROFILE_RENAME = new Permission("customnpcs.profile.rename");
public static final Permission PROFILE_CHANGE = new Permission("customnpcs.profile.change");
public static final Permission PROFILE_REGION_BYPASS = new Permission("customnpcs.profile.region-bypass");
public static final Permission PROFILE_MAX = new Permission("customnpcs.profile.max.*");
public static CustomNpcsPermissions Instance;
private Class<?> bukkit;
private Method getPlayer;
@@ -17,7 +17,6 @@ import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.api.IWorld;
import noppes.npcs.api.entity.*;
import noppes.npcs.api.event.IAnimationEvent;
import noppes.npcs.api.event.IItemEvent;
import noppes.npcs.api.gui.ICustomGui;
import noppes.npcs.api.gui.IItemSlot;
import noppes.npcs.api.handler.data.IAnimation;
@@ -1,8 +1,6 @@
package noppes.npcs;
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumSoundOperation;
import kamkeel.npcs.network.packets.data.*;
+143 -4
View File
@@ -3,19 +3,20 @@ package noppes.npcs;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.SyncController;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.data.ParticlePacket;
import kamkeel.npcs.network.packets.data.PlayerDataInfoPacket;
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
import kamkeel.npcs.network.packets.data.gui.GuiErrorPacket;
import kamkeel.npcs.network.packets.data.gui.GuiOpenPacket;
import kamkeel.npcs.network.packets.data.gui.GuiTeleporterPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import kamkeel.npcs.network.packets.data.large.ScrollDataPacket;
import kamkeel.npcs.network.packets.data.large.ScrollListPacket;
import kamkeel.npcs.network.packets.data.npc.DialogPacket;
import kamkeel.npcs.network.packets.data.ParticlePacket;
import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket;
import kamkeel.npcs.network.packets.data.npc.DeleteNpcPacket;
import kamkeel.npcs.network.packets.data.npc.DialogPacket;
import kamkeel.npcs.network.packets.data.npc.EditNpcPacket;
import kamkeel.npcs.network.packets.data.npc.RolePacket;
import kamkeel.npcs.network.packets.data.gui.GuiTeleporterPacket;
import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.entity.Entity;
@@ -975,4 +976,142 @@ public class NoppesUtilServer {
sb.append(seconds).append(" second").append(seconds == 1 ? "" : "s");
return sb.toString();
}
/**
* Retrieves the player's data from the existing PlayerDataController and sends
* a large packet to the client containing all the maps, including categories.
*/
public static void sendPlayerDataInfo(String playerName, EntityPlayerMP player) {
PlayerData playerdata;
EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
if(pl == null)
playerdata = PlayerDataController.Instance.getDataFromUsername(playerName);
else
playerdata = PlayerDataController.Instance.getPlayerData(pl);
// Assemble quest maps:
Map<String, Integer> questActiveMap = new HashMap<>();
Map<String, Integer> questFinishedMap = new HashMap<>();
Map<String, Integer> questCategoriesMap = new HashMap<>();
QuestController qc = QuestController.Instance;
PlayerQuestData qData = playerdata.questData;
for (Integer questId : qData.activeQuests.keySet()) {
if(!qc.quests.containsKey(questId))
continue;
Quest quest = qc.quests.get(questId);
questActiveMap.put(quest.category.title + ": " + quest.title, questId);
if (!questCategoriesMap.containsKey(quest.category.title))
questCategoriesMap.put(quest.category.title, quest.category.id);
}
for (Integer questId : qData.finishedQuests.keySet()) {
if(!qc.quests.containsKey(questId))
continue;
Quest quest = qc.quests.get(questId);
questFinishedMap.put(quest.category.title + ": " + quest.title, questId);
if (!questCategoriesMap.containsKey(quest.category.title))
questCategoriesMap.put(quest.category.title, quest.category.id);
}
// Assemble dialog maps:
Map<String, Integer> dialogReadMap = new HashMap<>();
Map<String, Integer> dialogCategoriesMap = new HashMap<>();
PlayerDialogData dData = playerdata.dialogData;
for (Integer dialogId : dData.dialogsRead) {
if(!DialogController.Instance.dialogs.containsKey(dialogId))
continue;
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
dialogReadMap.put(dialog.category.title + ": " + dialog.title, dialogId);
if (!dialogCategoriesMap.containsKey(dialog.category.title))
dialogCategoriesMap.put(dialog.category.title, dialog.category.id);
}
// Assemble transport maps:
Map<String, Integer> transportLocationsMap = new HashMap<>();
Map<String, Integer> transportCategoriesMap = new HashMap<>();
PlayerTransportData tData = playerdata.transportData;
TransportController tc = TransportController.getInstance();
for (Integer id : tData.transports) {
TransportLocation location = tc.getTransport(id);
if(location == null)
continue;
transportLocationsMap.put(location.category.title + ": " + location.name, id);
if (!transportCategoriesMap.containsKey(location.category.title))
transportCategoriesMap.put(location.category.title, location.category.id);
}
// Assemble bank map:
Map<String, Integer> bankMap = new HashMap<>();
PlayerBankData bData = playerdata.bankData;
BankController bc = BankController.getInstance();
for (Integer bankId : bData.banks.keySet()) {
if(!bc.banks.containsKey(bankId))
continue;
Bank bank = bc.banks.get(bankId);
bankMap.put(bank.name, bankId);
}
// Assemble faction map:
Map<String, Integer> factionMap = new HashMap<>();
PlayerFactionData fData = playerdata.factionData;
FactionController fc = FactionController.getInstance();
for (Integer factionId : fData.factionData.keySet()) {
if(!fc.factions.containsKey(factionId))
continue;
Faction faction = fc.factions.get(factionId);
factionMap.put(faction.name + "(" + fData.getFactionPoints(factionId) + ")", factionId);
}
// Send the full packet with categories, active/finished data, dialogs, transports, banks, and factions.
PlayerDataInfoPacket packet = new PlayerDataInfoPacket(playerName,
questCategoriesMap, questActiveMap, questFinishedMap,
dialogCategoriesMap, dialogReadMap,
transportCategoriesMap, transportLocationsMap,
bankMap, factionMap);
PacketHandler.Instance.sendToPlayer(packet, player);
}
/**
* Removes a specific data entry from the player's data.
*
* The tabType parameter is used as follows:
* 0: Quest – remove from both activeQuests and finishedQuests.
* 1: Dialog – remove from dialogsRead.
* 2: Transport – remove from transports.
* 3: Bank – remove from banks.
* 4: Factions – remove from factionData.
*
* The selectedKey is expected to be the string representation of the entry's ID.
*/
public static void removePlayerDataInfo(String playerName, int tabType, int value, EntityPlayerMP player) {
EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
PlayerData playerdata;
EnumPlayerData enumPlayerData = EnumPlayerData.values()[tabType];
if(pl == null)
playerdata = PlayerDataController.Instance.getDataFromUsername(playerName);
else
playerdata = PlayerDataController.Instance.getPlayerData(pl);
if(enumPlayerData == EnumPlayerData.Quest) { // Quest removal
playerdata.questData.activeQuests.remove(value);
playerdata.questData.finishedQuests.remove(value);
}
if(enumPlayerData == EnumPlayerData.Dialog){ // Dialog removal
playerdata.dialogData.dialogsRead.remove(value);
}
if(enumPlayerData == EnumPlayerData.Transport) { // Transport removal
playerdata.transportData.transports.remove(value);
}
if(enumPlayerData == EnumPlayerData.Bank) { // Bank removal
playerdata.bankData.banks.remove(value);
}
if(enumPlayerData == EnumPlayerData.Factions) { // Faction removal
playerdata.factionData.factionData.remove(value);
}
playerdata.save();
if(pl != null) {
SyncController.syncPlayer((EntityPlayerMP) pl);
}
}
}
@@ -23,6 +23,7 @@ import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.BlockEvent;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.item.IItemCustomizable;
import noppes.npcs.attribute.PlayerAttributeManager;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.CustomEffectController;
import noppes.npcs.controllers.PartyController;
@@ -30,9 +31,9 @@ import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.*;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.quests.QuestItem;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.item.ScriptCustomItem;
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
@@ -47,7 +48,7 @@ public class ScriptPlayerEventHandler {
if (event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EntityPlayer player = event.player;
if (player.ticksExisted%10 == 0) {
if (player.ticksExisted % 10 == 0) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer);
@@ -59,6 +60,8 @@ public class ScriptPlayerEventHandler {
EventHooks.onScriptItemUpdate(isw, player);
}
}
PlayerAttributeManager.getTracker(player.getUniqueID()).updateIfChanged(player);
}
if (PlayerDataController.Instance != null) {
@@ -155,6 +158,11 @@ public class ScriptPlayerEventHandler {
if(event.getPlayer() == null || event.getPlayer().worldObj == null)
return;
if(event.getPlayer().getHeldItem() != null && event.getPlayer().getHeldItem().getItem() instanceof ItemNpcTool){
event.setCanceled(true);
return;
}
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer());
@@ -22,7 +22,6 @@ import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
@@ -41,10 +40,12 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import noppes.npcs.blocks.tiles.ITileIcon;
import noppes.npcs.blocks.tiles.TileBanner;
import noppes.npcs.config.ConfigDebug;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.*;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumPartyObjectives;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.PartyController;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.ServerCloneController;
@@ -54,7 +54,7 @@ public class ServerTickHandler {
SyncController.syncPlayer(player);
SyncController.syncEffects(player);
ProfileController.login(player);
ProfileController.Instance.login(player);
}
@SubscribeEvent
@@ -0,0 +1,30 @@
package noppes.npcs.attribute;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* AttributeController is the central registry for attribute definitions.
* It ensures that keys are unique.
*/
public class AttributeController {
private static final Map<String, AttributeDefinition> definitions = new HashMap<>();
public static AttributeDefinition registerAttribute(String key, String displayName, AttributeValueType valueType) {
if (definitions.containsKey(key)) {
throw new IllegalArgumentException("Attribute already registered with key: " + key);
}
AttributeDefinition def = new AttributeDefinition(key, displayName, valueType);
definitions.put(key, def);
return def;
}
public static AttributeDefinition getAttribute(String key) {
return definitions.get(key);
}
public static Collection<AttributeDefinition> getAllAttributes() {
return definitions.values();
}
}
@@ -0,0 +1,30 @@
package noppes.npcs.attribute;
/**
* Defines a valid attribute – for example, "cnpc:main_attack_flat" (a flat bonus)
* or "cnpc:main_attack_percent" (a percent bonus). These definitions are registered
* once in the AttributeController.
*/
public class AttributeDefinition {
private final String key; // e.g., "rpgcore:main_attack_flat"
private final String displayName; // Human‑readable name
private final AttributeValueType attributeValueType;
public AttributeDefinition(String key, String displayName, AttributeValueType attributeValueType) {
this.key = key;
this.displayName = displayName;
this.attributeValueType = attributeValueType;
}
public String getKey() {
return key;
}
public String getDisplayName() {
return displayName;
}
public AttributeValueType getOperation() {
return attributeValueType;
}
}
@@ -0,0 +1,17 @@
package noppes.npcs.attribute;
public final class AttributeKeys {
public static final String MAIN_ATTACK_FLAT = "rpgcore:main_attack_flat";
public static final String MAIN_ATTACK_PERCENT = "rpgcore:main_attack_percent";
public static final String HEALTH = "rpgcore:health";
public static final String CRITICAL_CHANCE_PERCENT = "rpgcore:critical_chance_percent";
public static final String CRITICAL_DAMAGE_FLAT = "rpgcore:critical_damage_flat";
// Magic–based attribute keys:
public static final String MAGIC_DAMAGE_FLAT = "rpgcore:magic_damage_flat";
public static final String MAGIC_DAMAGE_PERCENT = "rpgcore:magic_damage_percent";
public static final String MAGIC_DEFENSE_FLAT = "rpgcore:magic_defense_flat";
public static final String MAGIC_RESISTANCE_PERCENT = "rpgcore:magic_resistance_percent";
private AttributeKeys() { }
}
@@ -0,0 +1,37 @@
package noppes.npcs.attribute;
import java.util.UUID;
/**
* An AttributeModifier represents a bonus (or penalty) that is applied to an attribute.
* It carries a UUID, a human–readable name, an amount, and a type (FLAT, PERCENT, etc).
*/
public class AttributeModifier {
private final UUID id;
private final String name;
private final double amount;
private final AttributeValueType valueType;
public AttributeModifier(UUID id, String name, double amount, AttributeValueType valueType) {
this.id = id;
this.name = name;
this.amount = amount;
this.valueType = valueType;
}
public UUID getId() {
return id;
}
public String getName() {
return name;
}
public double getAmount() {
return amount;
}
public AttributeValueType getValueType() {
return valueType;
}
}
@@ -0,0 +1,7 @@
package noppes.npcs.attribute;
public enum AttributeValueType {
FLAT, // e.g., +10 Health or +3 Damage
PERCENT, // e.g., +0.25 means +25% bonus
MAGIC // Represents a container of magic–based values (summed up as a double)
}
@@ -0,0 +1,78 @@
package noppes.npcs.attribute;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;
/**
* Provides helper functions to write/read item attributes to/from NBT.
* Non–magic attributes are stored under a compound tag (TAG_ROOT),
* and magic attributes are stored as a compound mapping (by magic ID) under specific keys.
*/
public class CNPCItemAttributeHelper {
public static final String TAG_ROOT = "CNPCAttributes";
public static void applyAttribute(ItemStack item, String attributeKey, double value) {
if (item == null) return;
if (item.stackTagCompound == null) {
item.stackTagCompound = new NBTTagCompound();
}
NBTTagCompound root = item.stackTagCompound;
NBTTagCompound attrTag;
if (root.hasKey(TAG_ROOT)) {
attrTag = root.getCompoundTag(TAG_ROOT);
} else {
attrTag = new NBTTagCompound();
}
attrTag.setDouble(attributeKey, value);
root.setTag(TAG_ROOT, attrTag);
}
public static Map<String, Double> readAttributes(ItemStack item) {
Map<String, Double> map = new HashMap<>();
if (item == null || item.stackTagCompound == null) return map;
NBTTagCompound root = item.stackTagCompound;
if (root.hasKey(TAG_ROOT)) {
NBTTagCompound attrTag = root.getCompoundTag(TAG_ROOT);
Set<String> keys = attrTag.func_150296_c();
for (String key : keys) {
map.put(key, attrTag.getDouble(key));
}
}
return map;
}
public static Map<Integer, Double> readMagicAttributeMap(ItemStack item, String attributeTag) {
Map<Integer, Double> map = new HashMap<>();
if (item == null || item.stackTagCompound == null) return map;
if (item.stackTagCompound.hasKey(attributeTag)) {
NBTTagCompound magicMap = item.stackTagCompound.getCompoundTag(attributeTag);
Set<String> keys = magicMap.func_150296_c();
for (String key : keys) {
try {
int magicId = Integer.parseInt(key);
map.put(magicId, magicMap.getDouble(key));
} catch (NumberFormatException e) {
// Skip invalid key.
}
}
}
return map;
}
public static void writeMagicAttribute(ItemStack item, String attributeTag, int magicId, double value) {
if (item == null) return;
if (item.stackTagCompound == null)
item.stackTagCompound = new NBTTagCompound();
NBTTagCompound magicMap;
if (item.stackTagCompound.hasKey(attributeTag)) {
magicMap = item.stackTagCompound.getCompoundTag(attributeTag);
} else {
magicMap = new NBTTagCompound();
}
magicMap.setDouble(String.valueOf(magicId), value);
item.stackTagCompound.setTag(attributeTag, magicMap);
}
}
@@ -0,0 +1,29 @@
package noppes.npcs.attribute;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* CustomAttributeMap holds a set of attribute instances for an entity (or item).
*/
public class CustomAttributeMap {
private final Map<AttributeDefinition, IAttributeInstance> map = new HashMap<>();
public IAttributeInstance registerAttribute(AttributeDefinition attribute, double baseValue) {
if (map.containsKey(attribute)) {
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
}
IAttributeInstance instance = new ModifiableAttributeInstance(attribute, baseValue);
map.put(attribute, instance);
return instance;
}
public IAttributeInstance getAttributeInstance(AttributeDefinition attribute) {
return map.get(attribute);
}
public Collection<IAttributeInstance> getAllAttributes() {
return map.values();
}
}
@@ -0,0 +1,39 @@
package noppes.npcs.attribute;
import java.util.Random;
/**
* Calculates damage using cached (aggregated) offensive and defensive ratings from players.
* The formula here is simple: baseDamage = attacker.getOffense() - defender.getDefense(),
* then a critical chance is applied (if a random roll is below the attacker's crit chance,
* damage is doubled and a flat crit bonus is added).
*/
public class DamageCalculator {
private static final Random random = new Random();
/**
* Calculates damage given attacker and defender attribute trackers.
*/
public static double calculateDamage(PlayerAttributeTracker attacker, PlayerAttributeTracker defender) {
double offense = attacker.getOffense();
double defense = defender.getDefense();
double damage = offense - defense;
// Process critical hit chance from attacker's aggregated non-magic attributes.
double critChance = attacker.getAttributeValue(ModAttributes.CRITICAL_CHANCE_PERCENT);
double critBonus = attacker.getAttributeValue(ModAttributes.CRITICAL_DAMAGE_FLAT);
if (random.nextDouble() < critChance) {
damage = damage * 2 + critBonus;
}
return Math.max(damage, 0);
}
/**
* Optionally, calculates damage for a specific magic type.
*/
public static double calculateMagicDamage(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, int magicId) {
double offense = attacker.getOffense(magicId);
double defense = defender.getDefense(magicId);
return Math.max(offense - defense, 0);
}
}
@@ -0,0 +1,16 @@
package noppes.npcs.attribute;
import java.util.Collection;
/**
* IAttributeInstance represents an instance of an attribute (with a base value and applied modifiers).
*/
public interface IAttributeInstance {
AttributeDefinition getAttribute();
double getBaseValue();
void setBaseValue(double value);
void applyModifier(AttributeModifier modifier);
void removeModifier(AttributeModifier modifier);
Collection<AttributeModifier> getModifiers();
double getAttributeValue(); // Final computed value after modifiers
}
@@ -0,0 +1,30 @@
package noppes.npcs.attribute;
/**
* ModAttributes registers the core attributes (both non–magic and magic–based).
*/
public class ModAttributes {
public static final AttributeDefinition MAIN_ATTACK_FLAT;
public static final AttributeDefinition MAIN_ATTACK_PERCENT;
public static final AttributeDefinition HEALTH;
public static final AttributeDefinition CRITICAL_CHANCE_PERCENT;
public static final AttributeDefinition CRITICAL_DAMAGE_FLAT;
public static final AttributeDefinition MAGIC_DAMAGE_FLAT;
public static final AttributeDefinition MAGIC_DAMAGE_PERCENT;
public static final AttributeDefinition MAGIC_DEFENSE_FLAT;
public static final AttributeDefinition MAGIC_RESISTANCE_PERCENT;
static {
MAIN_ATTACK_FLAT = AttributeController.registerAttribute(AttributeKeys.MAIN_ATTACK_FLAT, "Main Attack Damage", AttributeValueType.FLAT);
MAIN_ATTACK_PERCENT = AttributeController.registerAttribute(AttributeKeys.MAIN_ATTACK_PERCENT, "Main Attack Damage (%)", AttributeValueType.PERCENT);
HEALTH = AttributeController.registerAttribute(AttributeKeys.HEALTH, "Health", AttributeValueType.FLAT);
CRITICAL_CHANCE_PERCENT = AttributeController.registerAttribute(AttributeKeys.CRITICAL_CHANCE_PERCENT, "Critical Chance (%)", AttributeValueType.PERCENT);
CRITICAL_DAMAGE_FLAT = AttributeController.registerAttribute(AttributeKeys.CRITICAL_DAMAGE_FLAT, "Critical Damage Bonus", AttributeValueType.FLAT);
MAGIC_DAMAGE_FLAT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DAMAGE_FLAT, "Magic Damage", AttributeValueType.MAGIC);
MAGIC_DAMAGE_PERCENT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DAMAGE_PERCENT, "Magic Damage (%)", AttributeValueType.MAGIC);
MAGIC_DEFENSE_FLAT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DEFENSE_FLAT, "Magic Defense", AttributeValueType.MAGIC);
MAGIC_RESISTANCE_PERCENT = AttributeController.registerAttribute(AttributeKeys.MAGIC_RESISTANCE_PERCENT, "Magic Resistance (%)", AttributeValueType.MAGIC);
}
}
@@ -0,0 +1,66 @@
package noppes.npcs.attribute;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class ModifiableAttributeInstance implements IAttributeInstance {
private final AttributeDefinition attribute;
private double baseValue;
private final Set<AttributeModifier> modifiers = new HashSet<>();
public ModifiableAttributeInstance(AttributeDefinition attribute, double baseValue) {
this.attribute = attribute;
this.baseValue = baseValue;
}
@Override
public AttributeDefinition getAttribute() {
return attribute;
}
@Override
public double getBaseValue() {
return baseValue;
}
@Override
public void setBaseValue(double value) {
this.baseValue = value;
}
@Override
public void applyModifier(AttributeModifier modifier) {
modifiers.add(modifier);
}
@Override
public void removeModifier(AttributeModifier modifier) {
modifiers.remove(modifier);
}
@Override
public Collection<AttributeModifier> getModifiers() {
return modifiers;
}
@Override
public double getAttributeValue() {
double finalValue = baseValue;
// Apply FLAT modifiers
for (AttributeModifier mod : modifiers) {
if (mod.getValueType() == AttributeValueType.FLAT) {
finalValue += mod.getAmount();
}
}
// Apply PERCENT modifiers additively.
double percentSum = 0.0;
for (AttributeModifier mod : modifiers) {
if (mod.getValueType() == AttributeValueType.PERCENT) {
percentSum += mod.getAmount();
}
}
finalValue *= (1 + percentSum);
return finalValue;
}
}
@@ -0,0 +1,31 @@
package noppes.npcs.attribute;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
/**
* PlayerAttributeManager maps player UUIDs to their attribute trackers.
*/
public class PlayerAttributeManager {
private static final Map<UUID, PlayerAttributeTracker> trackers = new HashMap<>();
public static PlayerAttributeTracker getTracker(UUID playerId) {
return trackers.computeIfAbsent(playerId, id -> new PlayerAttributeTracker(id));
}
public static void removeTracker(UUID playerId) {
trackers.remove(playerId);
}
/**
* Update all trackers (e.g. called every 10 ticks for all online players).
*/
public static void updateAllTrackers(Iterable<EntityPlayer> players) {
for (EntityPlayer player : players) {
PlayerAttributeTracker tracker = getTracker(player.getUniqueID());
tracker.updateIfChanged(player);
}
}
}
@@ -0,0 +1,202 @@
package noppes.npcs.attribute;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.Map.Entry;
/**
* Aggregates a player's attributes based on the attributes found on their held item and armor.
* Non–magic attributes are stored in a CustomAttributeMap (using string keys via AttributeController).
* Magic attributes (offense and defense) are aggregated as maps, keyed by magic type.
* This tracker uses a PlayerEquipmentTracker to keep track of the player's equipment,
* and recalculates only when the player's held item or armor changes.
*/
public class PlayerAttributeTracker {
private final UUID playerId;
private CustomAttributeMap aggregatedAttributes = new CustomAttributeMap();
// Aggregated magic offensive values:
private final Map<Integer, Double> aggregatedMagicDamageFlat = new HashMap<>();
private final Map<Integer, Double> aggregatedMagicDamagePercent = new HashMap<>();
// Aggregated magic defensive values:
private final Map<Integer, Double> aggregatedMagicDefenseFlat = new HashMap<>();
private final Map<Integer, Double> aggregatedMagicResistancePercent = new HashMap<>();
// Stores the last-known equipment.
private PlayerEquipmentTracker equipmentTracker = new PlayerEquipmentTracker();
public PlayerAttributeTracker(UUID playerId) {
this.playerId = playerId;
// Initialize equipmentTracker from a null player (will be updated on first tick).
recalcAttributes(null);
}
public CustomAttributeMap getAggregatedAttributes() {
return aggregatedAttributes;
}
/**
* Recalculates the aggregated attributes from the player's equipment.
* Non–magic attributes are read from each item's CNPCAttributes, and magic attributes
* are aggregated by summing values from their NBT maps.
*/
public void recalcAttributes(EntityPlayer player) {
aggregatedAttributes = new CustomAttributeMap();
// Reset magic aggregates.
aggregatedMagicDamageFlat.clear();
aggregatedMagicDamagePercent.clear();
aggregatedMagicDefenseFlat.clear();
aggregatedMagicResistancePercent.clear();
if (player != null) {
// Update equipmentTracker with the player's current equipment.
PlayerEquipmentTracker currentEquip = new PlayerEquipmentTracker();
currentEquip.updateFrom(player);
// Process held item (offense).
ItemStack held = currentEquip.heldItem;
if (held != null) {
// Process non-magic attributes.
for (Entry<String, Double> entry : CNPCItemAttributeHelper.readAttributes(held).entrySet()) {
String key = entry.getKey();
double value = entry.getValue();
AttributeDefinition def = AttributeController.getAttribute(key);
if (def != null) {
IAttributeInstance inst = aggregatedAttributes.getAttributeInstance(def);
if (inst == null) {
inst = aggregatedAttributes.registerAttribute(def, 0.0);
}
inst.setBaseValue(inst.getBaseValue() + value);
}
}
// Process magic offense.
Map<Integer, Double> magicFlat = CNPCItemAttributeHelper.readMagicAttributeMap(held, AttributeKeys.MAGIC_DAMAGE_FLAT);
for (Entry<Integer, Double> entry : magicFlat.entrySet()) {
int magicId = entry.getKey();
double value = entry.getValue();
aggregatedMagicDamageFlat.put(magicId, aggregatedMagicDamageFlat.getOrDefault(magicId, 0.0) + value);
}
Map<Integer, Double> magicPercent = CNPCItemAttributeHelper.readMagicAttributeMap(held, AttributeKeys.MAGIC_DAMAGE_PERCENT);
for (Entry<Integer, Double> entry : magicPercent.entrySet()) {
int magicId = entry.getKey();
double value = entry.getValue();
aggregatedMagicDamagePercent.put(magicId, aggregatedMagicDamagePercent.getOrDefault(magicId, 0.0) + value);
}
}
// Process armor (defense).
// Assuming armor order: 0: boots, 1: leggings, 2: chestplate, 3: helmet.
ItemStack[] armor = new ItemStack[] { currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet };
for (ItemStack piece : armor) {
if (piece != null) {
// Process non-magic attributes.
for (Entry<String, Double> entry : CNPCItemAttributeHelper.readAttributes(piece).entrySet()) {
String key = entry.getKey();
double value = entry.getValue();
AttributeDefinition def = AttributeController.getAttribute(key);
if (def != null) {
IAttributeInstance inst = aggregatedAttributes.getAttributeInstance(def);
if (inst == null) {
inst = aggregatedAttributes.registerAttribute(def, 0.0);
}
inst.setBaseValue(inst.getBaseValue() + value);
}
}
// Process magic defense.
Map<Integer, Double> magicDefFlat = CNPCItemAttributeHelper.readMagicAttributeMap(piece, AttributeKeys.MAGIC_DEFENSE_FLAT);
for (Entry<Integer, Double> entry : magicDefFlat.entrySet()) {
int magicId = entry.getKey();
double value = entry.getValue();
aggregatedMagicDefenseFlat.put(magicId, aggregatedMagicDefenseFlat.getOrDefault(magicId, 0.0) + value);
}
Map<Integer, Double> magicResist = CNPCItemAttributeHelper.readMagicAttributeMap(piece, AttributeKeys.MAGIC_RESISTANCE_PERCENT);
for (Entry<Integer, Double> entry : magicResist.entrySet()) {
int magicId = entry.getKey();
double value = entry.getValue();
aggregatedMagicResistancePercent.put(magicId, aggregatedMagicResistancePercent.getOrDefault(magicId, 0.0) + value);
}
}
}
// Update our stored equipment.
equipmentTracker = currentEquip;
}
}
/**
* Checks if the player's equipment has changed by comparing stored equipment with the current equipment.
* This should be called periodically (e.g., every 10 ticks).
*/
public void updateIfChanged(EntityPlayer player) {
PlayerEquipmentTracker currentEquip = new PlayerEquipmentTracker();
currentEquip.updateFrom(player);
if (!equipmentTracker.equals(player)) {
recalcAttributes(player);
}
}
/**
* Returns the aggregated non-magic value for a given attribute definition.
*/
public double getAttributeValue(AttributeDefinition def) {
IAttributeInstance inst = aggregatedAttributes.getAttributeInstance(def);
return inst != null ? inst.getAttributeValue() : 0.0;
}
/**
* Overall offense is calculated as:
* Non-magic offense (MAIN_ATTACK_FLAT*(1+MAIN_ATTACK_PERCENT))
* plus the sum over all magic offense: for each magic type, flat*(1+percent).
*/
public double getOffense() {
double nonMagic = 0.0;
AttributeDefinition atkFlat = AttributeController.getAttribute(AttributeKeys.MAIN_ATTACK_FLAT);
AttributeDefinition atkPercent = AttributeController.getAttribute(AttributeKeys.MAIN_ATTACK_PERCENT);
if (atkFlat != null && atkPercent != null) {
nonMagic = getAttributeValue(atkFlat) * (1 + getAttributeValue(atkPercent));
}
double magicOffense = 0.0;
for (Entry<Integer, Double> entry : aggregatedMagicDamageFlat.entrySet()) {
int magicId = entry.getKey();
double flat = entry.getValue();
double percent = aggregatedMagicDamagePercent.getOrDefault(magicId, 0.0);
magicOffense += flat * (1 + percent);
}
return nonMagic + magicOffense;
}
/**
* Returns offense for a specific magic type.
*/
public double getOffense(int magicId) {
double flat = aggregatedMagicDamageFlat.getOrDefault(magicId, 0.0);
double percent = aggregatedMagicDamagePercent.getOrDefault(magicId, 0.0);
return flat * (1 + percent);
}
/**
* Overall defense is calculated solely from magic defensive attributes.
* (HEALTH is managed separately.)
*/
public double getDefense() {
double magicDefense = 0.0;
for (Entry<Integer, Double> entry : aggregatedMagicDefenseFlat.entrySet()) {
int magicId = entry.getKey();
double flat = entry.getValue();
double percent = aggregatedMagicResistancePercent.getOrDefault(magicId, 0.0);
magicDefense += flat * (1 + percent);
}
return magicDefense;
}
/**
* Returns defense for a specific magic type.
*/
public double getDefense(int magicId) {
double flat = aggregatedMagicDefenseFlat.getOrDefault(magicId, 0.0);
double percent = aggregatedMagicResistancePercent.getOrDefault(magicId, 0.0);
return flat * (1 + percent);
}
}
@@ -0,0 +1,65 @@
package noppes.npcs.attribute;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class PlayerEquipmentTracker {
public ItemStack heldItem;
public ItemStack helmet;
public ItemStack chestplate;
public ItemStack leggings;
public ItemStack boots;
/**
* Updates the stored equipment based on the player's current held item and armor.
*/
public void updateFrom(EntityPlayer player) {
heldItem = copyIfNotNull(player.getHeldItem());
ItemStack[] armor = player.inventory.armorInventory;
// Armor inventory order: 0=boots, 1=leggings, 2=chestplate, 3=helmet.
boots = copyIfNotNull(armor[0]);
leggings = copyIfNotNull(armor[1]);
chestplate = copyIfNotNull(armor[2]);
helmet = copyIfNotNull(armor[3]);
}
/**
* Compares the stored equipment with the player's current equipment.
* Ignores changes like durability by comparing the item and the CNPCAttributes NBT only.
*/
public boolean equals(EntityPlayer player) {
if (player == null) return false;
if (!areItemStacksEquivalent(heldItem, player.getHeldItem())) return false;
ItemStack[] armor = player.inventory.armorInventory;
if (!areItemStacksEquivalent(boots, armor[0])) return false;
if (!areItemStacksEquivalent(leggings, armor[1])) return false;
if (!areItemStacksEquivalent(chestplate, armor[2])) return false;
if (!areItemStacksEquivalent(helmet, armor[3])) return false;
return true;
}
/**
* Returns a copy of the given ItemStack, or null if it is null.
*/
private ItemStack copyIfNotNull(ItemStack stack) {
return (stack == null) ? null : stack.copy();
}
/**
* Compares two ItemStacks for equivalence, ignoring durability differences.
* It checks if the items are the same and if the "CNPCAttributes" NBT compound is equal.
*/
private boolean areItemStacksEquivalent(ItemStack a, ItemStack b) {
if (a == b) return true;
if (a == null || b == null) return false;
if (a.getItem() != b.getItem()) return false;
NBTTagCompound tagA = a.stackTagCompound;
NBTTagCompound tagB = b.stackTagCompound;
String attrA = (tagA != null && tagA.hasKey(CNPCItemAttributeHelper.TAG_ROOT))
? tagA.getCompoundTag(CNPCItemAttributeHelper.TAG_ROOT).toString() : "";
String attrB = (tagB != null && tagB.hasKey(CNPCItemAttributeHelper.TAG_ROOT))
? tagB.getCompoundTag(CNPCItemAttributeHelper.TAG_ROOT).toString() : "";
return attrA.equals(attrB);
}
}
@@ -10,8 +10,8 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileLamp;
import noppes.npcs.blocks.tiles.TileVariant;
public class BlockLantern extends BlockLightable{
@@ -14,9 +14,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.blocks.tiles.TilePedestal;
import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
@@ -9,8 +9,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileShelf;
import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
@@ -23,7 +23,6 @@ import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.blocks.tiles.TileShortLamp;
import noppes.npcs.blocks.tiles.TileTallLamp;
import java.util.List;
@@ -12,8 +12,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileBanner;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileSign;
import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
@@ -16,8 +16,8 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileStool;
import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
@@ -1,13 +1,11 @@
package noppes.npcs.blocks;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileTable;
@@ -21,7 +21,6 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileBanner;
import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.blocks.tiles.TileTallLamp;
@@ -22,8 +22,8 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileTombstone;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.constants.EnumGuiType;
import java.util.List;
@@ -18,7 +18,6 @@ import net.minecraft.util.*;
import net.minecraft.world.World;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.blocks.tiles.TileColorable;
import noppes.npcs.blocks.tiles.TileCouchWool;
import noppes.npcs.blocks.tiles.TileWallBanner;
import java.util.List;
@@ -13,8 +13,8 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileNpcContainer;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.blocks.tiles.TileWeaponRack;
import java.util.List;
@@ -1,11 +1,8 @@
package noppes.npcs.blocks.tiles;
import net.minecraft.block.BlockColored;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.items.ItemNpcTool;
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
@@ -1,13 +1,15 @@
package noppes.npcs.client;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.OverlayQuestTracking;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.select.GuiTextureSelection;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.controllers.data.*;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.SkinOverlay;
import noppes.npcs.util.CacheHashMap;
import java.util.HashMap;
@@ -16,13 +18,16 @@ import java.util.UUID;
public class ClientCacheHandler {
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>((long) ConfigClient.CacheLife * 60 * 1000);
public static PlayerData playerData = new PlayerData();
public static OverlayQuestTracking questTrackingOverlay = null;
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
public static Party party;
public static boolean allowProfiles = true;
public static boolean allowParties = true;
public static ImageData getImageData(String directory) {
synchronized (imageDataCache) {
if (!imageDataCache.containsKey(directory)) {
@@ -49,7 +54,6 @@ public class ClientCacheHandler {
public static void clearCache() {
ClientCacheHandler.imageDataCache.clear();
ClientCacheHandler.questTrackingOverlay = null;
ClientCacheHandler.customOverlays.clear();
ClientCacheHandler.skinOverlays.clear();
ClientCacheHandler.playerAnimations.clear();
@@ -1,9 +1,7 @@
package noppes.npcs.client;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.entity.EntityClientPlayerMP;
@@ -17,13 +15,18 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.*;
import net.minecraftforge.event.entity.living.LivingEvent;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.gui.hud.ClientHudManager;
import noppes.npcs.client.gui.hud.CompassHudComponent;
import noppes.npcs.client.gui.hud.EnumHudComponent;
import noppes.npcs.client.gui.hud.QuestTrackingComponent;
import noppes.npcs.client.renderer.MarkRenderer;
import noppes.npcs.client.renderer.RenderCNPCPlayer;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.constants.MarkType;
import noppes.npcs.controllers.data.*;
import noppes.npcs.controllers.data.FramePart;
import noppes.npcs.controllers.data.MarkData;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
import java.lang.reflect.Field;
@@ -91,9 +94,16 @@ public class ClientEventHandler {
overlayCustom.renderGameOverlay(event.partialTicks);
}
if (ClientCacheHandler.questTrackingOverlay != null) {
ClientCacheHandler.questTrackingOverlay.renderGameOverlay(event.partialTicks);
if(ClientHudManager.getInstance().getHudComponents().isEmpty()){
ClientHudManager.getInstance().registerHud(EnumHudComponent.QuestTracker, new QuestTrackingComponent(Minecraft.getMinecraft()));
ClientHudManager.getInstance().registerHud(EnumHudComponent.QuestCompass, new CompassHudComponent(Minecraft.getMinecraft()));
}
ClientHudManager.getInstance().renderAllHUDs(event.partialTicks);
// if (ClientCacheHandler.questTrackingOverlay != null) {
// ClientCacheHandler.questTrackingOverlay.renderOverlay(event.partialTicks);
// }
}
}
@@ -21,7 +21,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemTool;
import net.minecraft.stats.Achievement;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ReportedException;
@@ -69,8 +68,8 @@ import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.*;
import noppes.npcs.entity.data.ModelData;
import noppes.npcs.entity.data.ModelPartData;
import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.items.ItemLinked;
import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.items.ItemScripted;
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabCustomNpc;
@@ -146,7 +145,7 @@ public class ClientProxy extends CommonProxy {
}
Minecraft mc = Minecraft.getMinecraft();
NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_L, "key.categories.customnpc");
NPCButton = new KeyBinding("NPC Inventory", Keyboard.KEY_N, "key.categories.customnpc");
ClientRegistry.registerKeyBinding(NPCButton);
mc.gameSettings.loadOptions();
@@ -534,9 +533,9 @@ public class ClientProxy extends CommonProxy {
@Override
public void registerItem(Item item) {
if (item instanceof ItemScripted || item instanceof ItemLinked) {
MinecraftForgeClient.registerItemRenderer(item, new CustomItemRenderer());
MinecraftForgeClient.registerItemRenderer(item, new ItemCustomRenderer());
} else if (item instanceof ItemNpcTool) {
MinecraftForgeClient.registerItemRenderer(item, new NpcItemToolRenderer());
MinecraftForgeClient.registerItemRenderer(item, new ItemToolRenderer());
}else {
MinecraftForgeClient.registerItemRenderer(item, new NpcItemRenderer());
}
@@ -598,7 +597,7 @@ public class ClientProxy extends CommonProxy {
}
public static class FontContainer {
private StringCache textFont = null;
public StringCache textFont = null;
public boolean useCustomFont = true;
private FontContainer(){
@@ -5,24 +5,32 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import kamkeel.npcs.addon.client.DBCClient;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
import kamkeel.npcs.network.packets.player.InputDevicePacket;
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.controllers.ScriptSoundController;
import noppes.npcs.client.gui.player.inventory.*;
import noppes.npcs.client.gui.hud.ClientHudManager;
import noppes.npcs.client.gui.hud.CompassHudComponent;
import noppes.npcs.client.gui.hud.EnumHudComponent;
import noppes.npcs.client.gui.hud.HudComponent;
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
import noppes.npcs.client.renderer.RenderNPCInterface;
import noppes.npcs.constants.EnumPlayerPacket;
import noppes.npcs.constants.MarkType;
import noppes.npcs.controllers.data.MarkData;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import java.util.ArrayList;
import static noppes.npcs.client.ClientEventHandler.renderCNPCPlayer;
@@ -79,6 +87,13 @@ public class ClientTickHandler{
prevHeight = mc.displayHeight;
PacketClient.sendClient(new ScreenSizePacket(mc.displayWidth,mc.displayHeight));
}
if(mc.theWorld == null)
return;
if(mc.theWorld.getTotalWorldTime() % 20 == 0) { // Update every second
updateCompassMarks();
}
}
@SubscribeEvent
@@ -94,23 +109,7 @@ public class ClientTickHandler{
if(ClientProxy.NPCButton.isPressed()){
Minecraft mc = Minecraft.getMinecraft();
if(mc.currentScreen == null){
switch (GuiCNPCInventory.activeTab){
case 0:
NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog());
break;
case 1:
NoppesUtil.openGUI(mc.thePlayer, new GuiParty());
break;
case 2:
NoppesUtil.openGUI(mc.thePlayer, new GuiFaction());
break;
case 3:
NoppesUtil.openGUI(mc.thePlayer, new GuiSettings());
break;
case 4:
NoppesUtil.openGUI(mc.thePlayer, DBCClient.Instance.inventoryGUI());
break;
}
InventoryTabCustomNpc.tabHelper();
}
else if(mc.currentScreen instanceof GuiCNPCInventory)
mc.setIngameFocus();
@@ -137,4 +136,50 @@ public class ClientTickHandler{
return false;
}
private final int SCAN_RANGE = 128;
private void updateCompassMarks() {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
// Update compass
HudComponent compass = ClientHudManager.getInstance()
.getHudComponents().get(EnumHudComponent.QuestCompass);
if(!compass.enabled || mc.thePlayer == null)
return;
ArrayList<CompassHudComponent.MarkTargetEntry> marks = new ArrayList<>();
// Scan entities in loaded chunks
for(Object entity : mc.theWorld.loadedEntityList) {
if(entity instanceof EntityNPCInterface) {
EntityNPCInterface npc = (EntityNPCInterface) entity;
if(npc.dimension != player.dimension)
continue;
// Check distance
if(player.getDistanceToEntity(npc) > SCAN_RANGE)
continue;
// Get marks
MarkData markData = MarkData.get(npc);
for(MarkData.Mark mark : markData.marks) {
if(mark.getType() != MarkType.NONE &&
mark.availability.isAvailable(player)) {
marks.add(new CompassHudComponent.MarkTargetEntry(
(int)npc.posX,
(int)npc.posZ,
mark.getType(),
mark.color
));
break; // Only show first valid mark per NPC
}
}
}
}
((CompassHudComponent) compass).updateMarkTargets(marks);
}
}
@@ -17,10 +17,7 @@ import net.minecraft.util.Util;
import noppes.npcs.CustomNpcs;
import noppes.npcs.client.gui.player.GuiDialogInteract;
import noppes.npcs.client.gui.player.GuiQuestCompletion;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.client.gui.util.IScrollGroup;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.Quest;
@@ -32,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
public class NoppesUtil {
@@ -258,4 +256,60 @@ public class NoppesUtil {
public static void isGUIOpen(boolean isGUIOpen) {
PacketClient.sendClient(new IsGuiOpenInform(isGUIOpen));
}
/**
* Handles the incoming large packet with full player data.
* The packet writes:
* - player name (String)
* - questCategories, questActive, questFinished (maps)
* - dialogCategories, dialogRead (maps)
* - transportCategories, transportLocations (maps)
* - bankData, factionData (maps)
*
* The existing PlayerDataController functions are used on the server side;
* here we simply update the active SubGuiPlayerDataNew if present.
*/
public static void handlePlayerData(ByteBuf data, EntityPlayer player) throws IOException {
String playerName = ByteBufUtils.readString(data);
Map<String, Integer> questCategories = readMap(data);
Map<String, Integer> questActive = readMap(data);
Map<String, Integer> questFinished = readMap(data);
Map<String, Integer> dialogCategories = readMap(data);
Map<String, Integer> dialogRead = readMap(data);
Map<String, Integer> transportCategories = readMap(data);
Map<String, Integer> transportLocations = readMap(data);
Map<String, Integer> bankData = readMap(data);
Map<String, Integer> factionData = readMap(data);
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if(gui == null)
return;
if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){
gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui();
}
if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){
gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui();
}
if (gui instanceof IPlayerDataInfo) {
IPlayerDataInfo info = (IPlayerDataInfo) gui;
info.setQuestData(questCategories, questActive, questFinished);
info.setDialogData(dialogCategories, dialogRead);
info.setTransportData(transportCategories, transportLocations);
info.setBankData(bankData);
info.setFactionData(factionData);
}
}
private static Map<String, Integer> readMap(ByteBuf data) {
int size = data.readInt();
Map<String, Integer> map = new HashMap<>();
for (int i = 0; i < size; i++) {
String key = ByteBufUtils.readString(data);
int value = data.readInt();
map.put(key, value);
}
return map;
}
}
@@ -4,7 +4,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.CustomNpcs;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.ServerTagMapController;
import noppes.npcs.controllers.data.TagMap;
import java.io.File;
@@ -1,7 +1,5 @@
package noppes.npcs.client.fx;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.client.Minecraft;
@@ -10,12 +8,12 @@ import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
import org.lwjgl.opengl.GL11;
public class EntityBigSmokeFX extends EntityFX
{
@@ -6,7 +6,6 @@ import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.client.gui.util.*;
public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
@@ -1,13 +1,5 @@
package noppes.npcs.client.gui;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import noppes.npcs.client.gui.util.GuiDiagram;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.Magic;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
@@ -15,8 +7,16 @@ import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.util.GuiDiagram;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.Magic;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class GuiMagicMap extends GuiDiagram {
private List<Magic> magics;
@@ -18,10 +18,8 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
import noppes.npcs.ServerEventsHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.containers.ContainerMerchantAdd;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@@ -4,11 +4,8 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashMap;
@@ -5,10 +5,8 @@ import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedGetPacket;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.Lines;
import noppes.npcs.entity.EntityNPCInterface;
@@ -5,13 +5,11 @@ import kamkeel.npcs.network.packets.request.transport.TransportCategoriesGetPack
import kamkeel.npcs.network.packets.request.transport.TransportCategorySavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCTransportCategoryEdit extends GuiNPCInterface
@@ -6,11 +6,9 @@ import kamkeel.npcs.network.packets.request.feather.DimensionTeleportPacket;
import kamkeel.npcs.network.packets.request.npc.RemoteDeletePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import java.util.HashMap;
import java.util.Vector;
@@ -11,11 +11,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.controllers.ClientTagMapController;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Tag;
import noppes.npcs.controllers.data.TagMap;
@@ -1,7 +1,6 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.request.clone.CloneAllTagsShortPacket;
import kamkeel.npcs.network.packets.request.clone.ClonePreSavePacket;
import kamkeel.npcs.network.packets.request.clone.CloneSavePacket;
@@ -14,11 +13,8 @@ import net.minecraft.entity.EntityList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.TagController;
import noppes.npcs.controllers.data.Tag;
import noppes.npcs.entity.EntityNPCInterface;
@@ -12,11 +12,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.gui.util.*;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
@@ -6,11 +6,9 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.client.controllers.ClientCloneController;
import noppes.npcs.client.gui.util.*;
import java.util.ArrayList;
import java.util.List;
@@ -7,12 +7,10 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.DataAI;
import noppes.npcs.NBTTags;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -6,7 +6,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -7,10 +7,8 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.entity.Entity;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -5,7 +5,6 @@ import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileWaypoint;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -10,15 +10,12 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.script.GuiNPCEventScripts;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.DataScript;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.*;
@@ -1,703 +0,0 @@
package noppes.npcs.client.gui;
import com.ibm.icu.text.ArabicShaping;
import com.ibm.icu.text.ArabicShapingException;
import com.ibm.icu.text.Bidi;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.controllers.data.Quest;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
public class OverlayQuestTracking extends Gui {
public Minecraft mc;
private ScaledResolution res = null;
public static int scaledWidth = 0;
public static int scaledHeight = 0;
int color = 0xFFFFFF;
float alpha = 1.0F;
private boolean randomStyle = false;
private boolean boldStyle = false;
private boolean italicStyle = false;
private boolean underlineStyle = false;
private boolean strikethroughStyle = false;
private boolean bidiFlag = false;
private boolean unicodeFlag = false;
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
private final FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
protected final ResourceLocation locationFontTexture = new ResourceLocation("textures/font/ascii.png");;
protected int[] charWidth = new int[256];
protected byte[] glyphWidth = new byte[65536];
private final int[] colorCode = new int[32];
private float red;
private float green;
private float blue;
private float posX;
private float posY;
private float renderOffsetY;
private final int overlayWidth = 120;
public ArrayList<String> trackedQuestLines = new ArrayList<>();
public ArrayList<String> categoryNameLines = new ArrayList<>();
public ArrayList<String> objectiveLines = new ArrayList<>();
public ArrayList<String> turnInText = new ArrayList<>();
public OverlayQuestTracking(Minecraft mc) {
this.mc = mc;
readFontTexture();
readGlyphSizes();
for (int i = 0; i < 32; ++i)
{
int j = (i >> 3 & 1) * 85;
int k = (i >> 2 & 1) * 170 + j;
int l = (i >> 1 & 1) * 170 + j;
int i1 = (i >> 0 & 1) * 170 + j;
if (i == 6)
{
k += 85;
}
if (Minecraft.getMinecraft().gameSettings.anaglyph)
{
int j1 = (k * 30 + l * 59 + i1 * 11) / 100;
int k1 = (k * 30 + l * 70) / 100;
int l1 = (k * 30 + i1 * 70) / 100;
k = j1;
l = k1;
i1 = l1;
}
if (i >= 16)
{
k /= 4;
l /= 4;
i1 /= 4;
}
this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255;
}
}
public void initOverlay() {
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
scaledWidth = res.getScaledWidth();
scaledHeight = res.getScaledHeight();
}
public void setOverlayData(NBTTagCompound compound) {
Quest trackedQuest = new Quest();
trackedQuest.readNBT(compound.getCompoundTag("Quest"));
trackedQuestLines = getLineList(trackedQuest.getName());
categoryNameLines = getLineList(compound.getString("CategoryName"));
NBTTagList nbtTagList = compound.getTagList("ObjectiveList",8);
for (int i = 0; i < nbtTagList.tagCount(); i++) {
String objective = nbtTagList.getStringTagAt(i);
String[] split = objective.split(":");
split = split[split.length-1].split("/");
boolean completed = false;
try {
if(split.length < 2)
throw new NumberFormatException("catch");
int killed = Integer.parseInt(split[0].trim());
int total = Integer.parseInt(split[1].trim());
if (killed/total == 1) {
completed = true;
}
} catch (NumberFormatException e) {
if (objective.endsWith("(Done)") || objective.endsWith("(read)") || (objective.endsWith("Found") && !objective.endsWith("Not Found"))) {
completed = true;
}
}
if (completed) {
objective = "&a&o&m" + objective;
} else {
objective = "&o" + objective;
}
objectiveLines.add(objective);
}
boolean instantComplete = compound.getBoolean("Instant");
if(instantComplete){
turnInText.add("Completed automatically");
}
else {
String npcName = compound.getString("TurnInNPC");
if (!npcName.isEmpty()) {
turnInText.add("Complete with " + npcName);
}
}
this.initOverlay();
}
public ArrayList<String> getLineList(String string) {
String[] split = string.split(" ");
ArrayList<String> lines = new ArrayList<>();
lines.add(split[0]);
for (int i = 1; i < split.length; i++) {
String s = split[i];
if (this.fontRenderer.getStringWidth(lines.get(lines.size() - 1) + " " + s) > 100) {
lines.add(s);
} else {
lines.set(lines.size() - 1, lines.get(lines.size() - 1) + " " + s);
}
}
return lines;
}
public void renderGameOverlay(float partialTicks){
res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
float overallScale = (float) ConfigClient.TrackingScale / 100;
scaledWidth = (int) (res.getScaledWidth());
scaledHeight = (int) (res.getScaledHeight());
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(ConfigClient.TrackingInfoAlignment%3*((float)(scaledWidth)/2), (float) (Math.floor((float)(ConfigClient.TrackingInfoAlignment/3))*((float)(scaledHeight)/2)),0.0F);
float offsetX = ConfigClient.TrackingInfoAlignment%3 == 0 ? 5 : -5;
float offsetY = ConfigClient.TrackingInfoAlignment < 3 ? 5 : 0;
offsetY = ConfigClient.TrackingInfoAlignment > 5 ? -5 : offsetY;
GL11.glTranslatef(ConfigClient.TrackingInfoX + offsetX, ConfigClient.TrackingInfoY + offsetY, 0.0F);
red = (color >> 16 & 255) / 255f;
green = (color >> 8 & 255) / 255f;
blue = (color & 255) / 255f;
float centerX = (float) -overlayWidth /2 * overallScale;
if (ConfigClient.TrackingInfoAlignment % 3 == 1) { // For Center alignment
centerX = 0;
} else {
centerX *= ConfigClient.TrackingInfoAlignment % 3 == 0 ? -1 : 1;
}
float questTitleTop;
this.renderOffsetY = -40 * overallScale;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(trackedQuestLines,1.2F * overallScale, false, true, 0);
GL11.glPopMatrix();
questTitleTop = this.renderOffsetY;
this.renderOffsetY -= 10 * overallScale;
GL11.glPushMatrix();
GL11.glTranslatef(centerX, 0.0F, 0.0F);
this.renderStringLines(categoryNameLines,0.85F * overallScale, false, false, 0);
GL11.glPopMatrix();
this.renderOffsetY = -10 * overallScale;
GL11.glPushMatrix();
this.renderStringLines(objectiveLines, 1F * overallScale, true, false, ConfigClient.TrackingInfoAlignment % 3 == 0 ? 1 : (ConfigClient.TrackingInfoAlignment % 3 == 2 ? 2 : 0));
GL11.glPopMatrix();
this.renderOffsetY += 10 * overallScale;
GL11.glPushMatrix();
this.renderStringLines(turnInText, 1F * overallScale, true, false, ConfigClient.TrackingInfoAlignment % 3 == 0 ? 1 : (ConfigClient.TrackingInfoAlignment % 3 == 2 ? 2 : 0));
GL11.glPopMatrix();
this.renderOffsetY = -20 * overallScale;
GL11.glPushMatrix();
if(overallScale < 0.6){
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFFFFFFFF);
} else if (overallScale < 0.8){
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFFA8A8A8);
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY + 1)), 0xFFFFFFFF);
} else {
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY), 0xFF777777);
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY + 1)), 0xFFA8A8A8);
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY + 2)), 0xFFFFFFFF);
}
GL11.glPopMatrix();
this.renderOffsetY = questTitleTop + 2;
GL11.glPushMatrix();
if(overallScale < 0.6){
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY - 2), 0xFFFFFFFF);
} else if (overallScale < 0.8){
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFFA8A8A8);
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY - 1), 0xFFFFFFFF);
} else {
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY)), 0xFF777777);
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) ((this.renderOffsetY -1)), 0xFFA8A8A8);
this.drawHorizontalLine((int) (centerX - (overlayWidth / 2 * overallScale)), (int) (centerX + (overlayWidth / 2 * overallScale)), (int) (this.renderOffsetY - 2), 0xFFFFFFFF);
}
GL11.glPopMatrix();
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
public void renderStringLines(ArrayList<String> lines, float scale, boolean downwards, boolean bold, int facing) {
for (int i = 0; i < lines.size(); i++) {
String s = lines.get(i);
if (!downwards) {
s = lines.get(lines.size()-1 - i);
}
int stringWidth = this.fontRenderer.getStringWidth(s.replace("&o",""));
if (s.startsWith("&a&o&m")) {
stringWidth = this.fontRenderer.getStringWidth(s.replace("&a&o&m",""));
}
float overallScale = (float) ConfigClient.TrackingScale / 100;
GL11.glPushMatrix();
switch (facing) {
case 0://center
GL11.glTranslatef(scale * (-stringWidth / 2.0F), this.renderOffsetY, 0.0F);
break;
case 1://left
GL11.glTranslatef(0, this.renderOffsetY, 0.0F);
break;
case 2://right
GL11.glTranslatef(scale * (-stringWidth), this.renderOffsetY, 0.0F);
break;
}
GL11.glScalef(scale, scale, scale);
this.drawString(s, 0, 0, this.color, true);
if (bold) {
GL11.glTranslatef(0.2F, 0.2F, 0.0F);
this.drawString(s, 0, 0, this.color, false);
}
this.renderOffsetY += (downwards ? 10 : -10) * overallScale;
GL11.glPopMatrix();
}
}
public int drawString(String p_85187_1_, int p_85187_2_, int p_85187_3_, int p_85187_4_, boolean p_85187_5_)
{
this.resetStyles();
int l;
if (p_85187_5_)
{
l = this.renderString(p_85187_1_, p_85187_2_ + 1, p_85187_3_ + 1, p_85187_4_, true);
l = Math.max(l, this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false));
}
else
{
l = this.renderString(p_85187_1_, p_85187_2_, p_85187_3_, p_85187_4_, false);
}
return l;
}
private void resetStyles()
{
this.randomStyle = false;
this.boldStyle = false;
this.italicStyle = false;
this.underlineStyle = false;
this.strikethroughStyle = false;
}
private int renderString(String p_78258_1_, int p_78258_2_, int p_78258_3_, int p_78258_4_, boolean p_78258_5_)
{
if (p_78258_1_ == null)
{
return 0;
}
else
{
if (this.bidiFlag)
{
p_78258_1_ = this.bidiReorder(p_78258_1_);
}
setColor(this.red, this.green, this.blue, this.alpha);
if (p_78258_5_) {
setColor(0,0,0,1.0F);
}
this.posX = (float)p_78258_2_;
this.posY = (float)p_78258_3_;
this.renderStringAtPos(p_78258_1_, p_78258_5_);
return (int)this.posX;
}
}
private void renderStringAtPos(String p_78255_1_, boolean p_78255_2_)
{
for (int i = 0; i < p_78255_1_.length(); ++i)
{
char c0 = p_78255_1_.charAt(i);
int j;
int k;
if (c0 == 38 && i + 1 < p_78255_1_.length())
{
j = "0123456789abcdefklmnor".indexOf(p_78255_1_.toLowerCase().charAt(i + 1));
if(j < 16){
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
if (j < 0 || j > 15)
{
j = 15;
}
if (p_78255_2_)
{
j += 16;
}
k = this.colorCode[j];
setColor((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha);
}
else if (j == 16)
{
this.randomStyle = true;
}
else if (j == 17)
{
this.boldStyle = true;
}
else if (j == 18)
{
this.strikethroughStyle = true;
}
else if (j == 19)
{
this.underlineStyle = true;
}
else if (j == 20)
{
this.italicStyle = true;
}
else if (j == 21)
{
this.randomStyle = false;
this.boldStyle = false;
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
}
++i;
}
else
{
j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0);
if (this.randomStyle && j != -1)
{
do
{
k = Minecraft.getMinecraft().fontRenderer.fontRandom.nextInt(this.charWidth.length);
}
while (this.charWidth[j] != this.charWidth[k]);
j = k;
}
float f1 = this.unicodeFlag ? 0.5F : 1.0F;
boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && p_78255_2_;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
float f = this.renderCharAtPos(j, c0, this.italicStyle);
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
if (this.boldStyle)
{
this.posX += f1;
if (flag1)
{
this.posX -= f1;
this.posY -= f1;
}
this.renderCharAtPos(j, c0, this.italicStyle);
this.posX -= f1;
if (flag1)
{
this.posX += f1;
this.posY += f1;
}
++f;
}
doDraw(f);
}
}
}
protected void doDraw(float f)
{
{
{
Tessellator tessellator;
if (this.strikethroughStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2)), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT / 2) - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
if (this.underlineStyle)
{
tessellator = Tessellator.instance;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
int l = this.underlineStyle ? -1 : 0;
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT), 0.0D);
tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 1.0F), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
this.posX += (float)((int)f);
}
}
}
private float renderCharAtPos(int p_78278_1_, char p_78278_2_, boolean p_78278_3_)
{
return p_78278_2_ == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(p_78278_2_) != -1 && !this.unicodeFlag ? this.renderDefaultChar(p_78278_1_, p_78278_3_) : this.renderUnicodeChar(p_78278_2_, p_78278_3_));
}
protected float renderDefaultChar(int p_78266_1_, boolean p_78266_2_)
{
float f = (float)(p_78266_1_ % 16 * 8);
float f1 = (float)(p_78266_1_ / 16 * 8);
float f2 = p_78266_2_ ? 1.0F : 0.0F;
bindTexture(this.locationFontTexture);
float f3 = (float)this.charWidth[p_78266_1_] - 0.01F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f2, this.posY, 0.0F);
GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F);
GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F);
GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (float)this.charWidth[p_78266_1_];
}
private ResourceLocation getUnicodePageLocation(int p_111271_1_)
{
if (unicodePageLocations[p_111271_1_] == null)
{
unicodePageLocations[p_111271_1_] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(p_111271_1_)}));
}
return unicodePageLocations[p_111271_1_];
}
private void loadGlyphTexture(int p_78257_1_)
{
bindTexture(this.getUnicodePageLocation(p_78257_1_));
}
/**
* Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files...
*/
protected float renderUnicodeChar(char p_78277_1_, boolean p_78277_2_)
{
if (this.glyphWidth[p_78277_1_] == 0)
{
return 0.0F;
}
else
{
int i = p_78277_1_ / 256;
this.loadGlyphTexture(i);
int j = this.glyphWidth[p_78277_1_] >>> 4;
int k = this.glyphWidth[p_78277_1_] & 15;
float f = (float)j;
float f1 = (float)(k + 1);
float f2 = (float)(p_78277_1_ % 16 * 16) + f;
float f3 = (float)((p_78277_1_ & 255) / 16 * 16);
float f4 = f1 - f - 0.02F;
float f5 = p_78277_2_ ? 1.0F : 0.0F;
GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f5, this.posY, 0.0F);
GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F);
GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F);
GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F);
GL11.glEnd();
return (f1 - f) / 2.0F + 1.0F;
}
}
protected void setColor(float r, float g, float b, float a)
{
GL11.glColor4f(r, g, b, a);
}
protected void bindTexture(ResourceLocation location)
{
Minecraft.getMinecraft().renderEngine.bindTexture(location);
}
private void readFontTexture()
{
BufferedImage bufferedimage;
try
{
bufferedimage = ImageIO.read(getResourceInputStream(this.locationFontTexture));
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
int i = bufferedimage.getWidth();
int j = bufferedimage.getHeight();
int[] aint = new int[i * j];
bufferedimage.getRGB(0, 0, i, j, aint, 0, i);
int k = j / 16;
int l = i / 16;
byte b0 = 1;
float f = 8.0F / (float)l;
int i1 = 0;
while (i1 < 256)
{
int j1 = i1 % 16;
int k1 = i1 / 16;
if (i1 == 32)
{
this.charWidth[i1] = 3 + b0;
}
int l1 = l - 1;
while (true)
{
if (l1 >= 0)
{
int i2 = j1 * l + l1;
boolean flag = true;
for (int j2 = 0; j2 < k && flag; ++j2)
{
int k2 = (k1 * l + j2) * i;
if ((aint[i2 + k2] >> 24 & 255) != 0)
{
flag = false;
}
}
if (flag)
{
--l1;
continue;
}
}
++l1;
this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0;
++i1;
break;
}
}
}
private void readGlyphSizes()
{
try
{
InputStream inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin"));
inputstream.read(this.glyphWidth);
}
catch (IOException ioexception)
{
throw new RuntimeException(ioexception);
}
}
protected InputStream getResourceInputStream(ResourceLocation location) throws IOException
{
return Minecraft.getMinecraft().getResourceManager().getResource(location).getInputStream();
}
private String bidiReorder(String p_147647_1_)
{
try
{
Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127);
bidi.setReorderingMode(0);
return bidi.writeReordered(2);
}
catch (ArabicShapingException arabicshapingexception)
{
return p_147647_1_;
}
}
}
@@ -1,9 +1,9 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsNpcGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -16,6 +16,8 @@ import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
import static noppes.npcs.client.gui.player.inventory.GuiCNPCInventory.specialIcons;
public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldListener {
private final GuiNPCManageEffects parent;
public CustomEffect effect;
@@ -128,10 +130,8 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi
func_152125_a(x, y, 0, 0, 1, 1, iconRenderSize, iconRenderSize, 1, 1);
}
GL11.glDisable(GL11.GL_DEPTH_TEST);
// TODO: FIX TEXTURE
// textureManager.bindTexture(new ResourceLocation(CustomNpcPlusDBC.ID + ":textures/gui/icons.png"));
// func_152125_a(x, y, 0, 240, 16, 16, iconRenderSize, iconRenderSize, 256, 256);
textureManager.bindTexture(specialIcons);
func_152125_a(x, y, 0, 224, 16, 16, iconRenderSize, iconRenderSize, 256, 256);
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
};
@@ -5,11 +5,9 @@ import kamkeel.npcs.network.packets.request.MailOpenSetupPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.player.GuiMailmanWrite;
import noppes.npcs.client.gui.select.GuiQuestSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.containers.ContainerMail;
import noppes.npcs.controllers.data.PlayerMail;
@@ -3,12 +3,10 @@ package noppes.npcs.client.gui;
import kamkeel.npcs.network.packets.request.faction.FactionGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumAvailabilityFactionType;
import noppes.npcs.constants.EnumDayTime;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.Faction;
@@ -3,11 +3,9 @@ package noppes.npcs.client.gui;
import kamkeel.npcs.network.packets.request.dialog.DialogGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.select.GuiDialogSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumAvailabilityDialog;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.Dialog;
@@ -3,11 +3,9 @@ package noppes.npcs.client.gui;
import kamkeel.npcs.network.packets.request.quest.QuestGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.select.GuiQuestSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumAvailabilityQuest;
import noppes.npcs.controllers.data.Availability;
import noppes.npcs.controllers.data.Quest;
@@ -4,7 +4,6 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.dialog.DialogSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.EntityUtil;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
@@ -12,7 +11,6 @@ import noppes.npcs.client.gui.player.GuiDialogInteract;
import noppes.npcs.client.gui.select.GuiQuestSelection;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.PlayerMail;
import noppes.npcs.entity.EntityDialogNpc;
@@ -3,11 +3,9 @@ package noppes.npcs.client.gui;
import kamkeel.npcs.network.packets.request.dialog.DialogGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.select.GuiDialogSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumOptionType;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogOption;
@@ -4,11 +4,9 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.dialog.DialogSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogImage;
@@ -3,9 +3,7 @@ package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.DimensionsGetPacket;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.SpawnData;
import java.util.*;
@@ -4,9 +4,7 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.FactionOptions;
import java.util.HashMap;
@@ -0,0 +1,65 @@
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumProfileSync;
import noppes.npcs.controllers.data.ProfileOptions;
public class SubGuiNpcProfileOptions extends SubGuiInterface
{
private final ProfileOptions options;
public SubGuiNpcProfileOptions(ProfileOptions options)
{
this.options = options;
setBackground("menubg.png");
xSize = 256;
ySize = 216;
closeOnEsc = true;
}
public void initGui()
{
super.initGui();
int y = 0;
//Allow party - T/F button
addButton(new GuiNpcButton(0, guiLeft + 130, guiTop + 10 + y, 60, 20,
new String[]{"gui.no", "gui.yes"}, options.enableOptions ? 1 : 0));
addLabel(new GuiNpcLabel(1, "profile.enableOptions", guiLeft + 10, guiTop + 17 + y));
if (options.enableOptions) {
y += 23;
addButton(new GuiNpcButton(5, guiLeft + 130, guiTop + 10 + y, 60, 20,
EnumProfileSync.values(), options.completeControl.ordinal()));
addLabel(new GuiNpcLabel(5, "profile.completion", guiLeft + 10, guiTop + 17 + y));
y += 23;
addButton(new GuiNpcButton(18, guiLeft + 130, guiTop + 10 + y, 60, 20,
EnumProfileSync.values(), options.cooldownControl.ordinal()));
addLabel(new GuiNpcLabel(18, "profile.cooldown", guiLeft + 10, guiTop + 17 + y));
}
addButton(new GuiNpcButton(66, guiLeft + 200, guiTop + 192, 50, 20, "gui.done"));
}
protected void actionPerformed(GuiButton guibutton)
{
int id = guibutton.id;
switch (id) {
case 0:
options.enableOptions = !options.enableOptions;
break;
case 5:
options.completeControl = EnumProfileSync.valueOf(guibutton.displayString);
break;
case 18:
options.cooldownControl = EnumProfileSync.valueOf(guibutton.displayString);
break;
case 66:
close();
break;
}
initGui();
}
}
@@ -5,7 +5,6 @@ import kamkeel.npcs.network.packets.request.quest.QuestOpenGuiPacket;
import kamkeel.npcs.network.packets.request.quest.QuestSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.global.GuiNPCManageQuest;
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeDialog;
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeKill;
@@ -13,7 +12,10 @@ import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeLocation;
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeManual;
import noppes.npcs.client.gui.select.GuiQuestSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.*;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.constants.EnumQuestCompletion;
import noppes.npcs.constants.EnumQuestRepeat;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.data.PlayerMail;
import noppes.npcs.controllers.data.Quest;
@@ -67,7 +69,10 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
addLabel(new GuiNpcLabel(17, "party.options", guiLeft + 180, guiTop + 135));
addButton(new GuiNpcButton(18, guiLeft + 303, guiTop + 130, 50, 20, "selectServer.edit"));
this.addButton(new GuiNpcButton(9, guiLeft + 7, guiTop + 102,90, 20, new String[]{"quest.npc","quest.instant"},quest.completion.ordinal()));
addLabel(new GuiNpcLabel(33, "quest.profile", guiLeft + 180, guiTop + 159));
addButton(new GuiNpcButton(33, guiLeft + 303, guiTop + 154, 50, 20, "selectServer.edit"));
this.addButton(new GuiNpcButton(9, guiLeft + 7, guiTop + 102,90, 20, new String[]{"quest.npc","quest.instant"},quest.completion.ordinal()));
if(quest.completerNpc.isEmpty() && npc != null)
quest.completerNpc = npc.display.name;
this.addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft + 104, guiTop + 102, 154, 20, quest.completerNpc));
@@ -83,9 +88,12 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
if(!quest.mail.subject.isEmpty())
getButton(13).setDisplayText(quest.mail.subject);
addLabel(new GuiNpcLabel(8, "quest.repeatable", guiLeft + 7, guiTop + 178 + 5));
this.addButton(new GuiNpcButton(8, guiLeft + 100, guiTop + 178,70, 20, new String[]{"gui.no","gui.yes","quest.mcdaily","quest.mcweekly","quest.rldaily","quest.rlweekly"}, quest.repeat.ordinal()));
addLabel(new GuiNpcLabel(8, "quest.repeatable", guiLeft + 7, guiTop + 178 + 5));
this.addButton(new GuiNpcButton(8, guiLeft + 100, guiTop + 178, 70, 20,
new String[]{"gui.no", "gui.yes", "quest.mcdaily", "quest.mcweekly", "quest.rldaily", "quest.rlweekly", "quest.mccustom", "quest.rlcustom"}, quest.repeat.ordinal()));
if(quest.repeat == EnumQuestRepeat.MCCUSTOM || quest.repeat == EnumQuestRepeat.RLCUSTOM) {
addButton(new GuiNpcButton(19, guiLeft + 175, guiTop + 178, 90, 20, "Set Cooldown"));
}
addButton(new GuiNpcButton(16, guiLeft + 303, guiTop + 192, 50, 20, "gui.done"));
if(!quest.mail.subject.isEmpty())
@@ -132,6 +140,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
if(button.id == 8)
{
quest.repeat = EnumQuestRepeat.values()[button.getValue()];
initGui();
}
if(button.id == 9)
{
@@ -159,14 +168,18 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
}
if(button.id == 15 && quest.id >= 0){
setSubGui(new GuiQuestSelection(quest.nextQuestid));
// questSelection = new GuiNPCQuestSelection(npc, getParent(), quest.nextQuestid);
// questSelection.listener = this;
// NoppesUtil.openGUI(player, questSelection);
}
if(button.id == 18)
{
setSubGui(new SubGuiNpcPartyOptions(quest.partyOptions));
}
if(button.id == 19) {
boolean isMCCustom = (quest.repeat == EnumQuestRepeat.MCCUSTOM);
setSubGui(new SubGuiNpcCooldownPicker(isMCCustom, quest.customCooldown));
}
if(button.id == 33){
setSubGui(new SubGuiNpcProfileOptions(quest.profileOptions));
}
if(button.id == 16){
close();
}
@@ -209,7 +222,13 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
else if(subgui instanceof SubGuiNpcCommand){
SubGuiNpcCommand sub = (SubGuiNpcCommand) subgui;
quest.command = sub.command;
}
initGui();
} else if(subgui instanceof SubGuiNpcCooldownPicker){
SubGuiNpcCooldownPicker cooldownGui = (SubGuiNpcCooldownPicker) subgui;
quest.customCooldown = cooldownGui.cooldownValue;
initGui();
}
else {
initGui();
}
File diff suppressed because it is too large. Load diff
@@ -5,9 +5,7 @@ import kamkeel.npcs.network.packets.request.linked.LinkedGetAllPacket;
import kamkeel.npcs.network.packets.request.linked.LinkedSetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -7,10 +7,8 @@ import kamkeel.npcs.network.packets.request.dialog.DialogNpcSetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.select.GuiDialogSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.DialogOption;
import noppes.npcs.entity.EntityNPCInterface;
@@ -6,10 +6,8 @@ import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashMap;
@@ -4,14 +4,12 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.GuiNPCLinesEdit;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCLinesMenu extends GuiNPCInterface2 {
@@ -1,14 +1,11 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedGetPacket;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedMarkDataPacket;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.MarkType;
import noppes.npcs.controllers.data.MarkData;
import noppes.npcs.entity.EntityNPCInterface;
@@ -6,12 +6,10 @@ import kamkeel.npcs.network.packets.request.transform.TransformLoadPacket;
import kamkeel.npcs.network.packets.request.transform.TransformSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.controllers.data.DataTransform;
import noppes.npcs.entity.EntityNPCInterface;
@@ -4,10 +4,8 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener, ISubGuiListener
@@ -1,9 +1,9 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsNpcGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -25,7 +25,6 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.api.gui.ICustomGuiComponent;
import noppes.npcs.client.gui.custom.components.*;
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
@@ -33,7 +32,6 @@ import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.scripted.gui.*;
import org.lwjgl.input.Keyboard;
@@ -7,10 +7,8 @@ import kamkeel.npcs.network.packets.request.bank.BankSavePacket;
import kamkeel.npcs.network.packets.request.bank.BanksGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.containers.ContainerManageBanks;
import noppes.npcs.controllers.data.Bank;
import noppes.npcs.entity.EntityNPCInterface;
@@ -7,12 +7,10 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiEditText;
import noppes.npcs.client.gui.SubGuiNpcDialog;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.DialogCategory;
import noppes.npcs.entity.EntityNPCInterface;
@@ -28,6 +28,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import static noppes.npcs.client.gui.player.inventory.GuiCNPCInventory.specialIcons;
public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScrollListener, IScrollData, IGuiData, ISubGuiListener, GuiYesNoCallback {
public GuiCustomScroll scrollEffects;
public HashMap<String, Integer> data = new HashMap<>();
@@ -170,10 +172,8 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
func_152125_a(x, y, 0, 0, 1, 1, iconRenderSize, iconRenderSize, 1, 1);
}
GL11.glDisable(GL11.GL_DEPTH_TEST);
// TODO: Fix ICONS
// textureManager.bindTexture(new ResourceLocation(CustomNpcPlusDBC.ID + ":textures/gui/icons.png"));
// func_152125_a(x, y, 0, 240, 16, 16, iconRenderSize, iconRenderSize, 256, 256);
textureManager.bindTexture(specialIcons);
func_152125_a(x, y, 0, 224, 16, 16, iconRenderSize, iconRenderSize, 256, 256);
GL11.glEnable(GL11.GL_DEPTH_TEST);
x += iconRenderSize + 3;
@@ -10,14 +10,11 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.SubGuiNpcFactionPoints;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Faction;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.*;
@@ -1,13 +1,9 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.effects.EffectRemovePacket;
import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
import kamkeel.npcs.network.packets.request.linked.*;
import kamkeel.npcs.network.packets.request.quest.QuestSavePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.client.renderer.OpenGlHelper;
@@ -24,11 +20,8 @@ import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiEditText;
import noppes.npcs.client.gui.item.SubGuiLinkedItem;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.CustomEffect;
import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Mouse;
@@ -26,7 +26,7 @@ public class GuiNPCManageMagic extends GuiNPCInterface2 {
}
@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
if (magicMap != null) {
magicMap.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
}
@@ -8,12 +8,10 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiEditText;
import noppes.npcs.client.gui.SubGuiNpcQuest;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestCategory;
import noppes.npcs.entity.EntityNPCInterface;
@@ -2,15 +2,13 @@ package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.tags.TagGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import kamkeel.npcs.network.packets.request.tags.TagRemovePacket;
import kamkeel.npcs.network.packets.request.tags.TagSavePacket;
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.Tag;
import noppes.npcs.entity.EntityNPCInterface;
@@ -6,7 +6,6 @@ import kamkeel.npcs.network.packets.request.transport.TransportCategoryRemovePac
import kamkeel.npcs.network.packets.request.transport.TransportRemovePacket;
import kamkeel.npcs.network.packets.request.transport.TransportsGetPacket;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.GuiNPCTransportCategoryEdit;
import noppes.npcs.client.gui.mainmenu.GuiNPCGlobalMainMenu;
@@ -14,7 +13,6 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNPCStringSlot;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashMap;
@@ -1,15 +1,15 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.playerdata.PlayerDataGetPacket;
import kamkeel.npcs.network.packets.request.playerdata.PlayerDataGetNamesPacket;
import kamkeel.npcs.network.packets.request.playerdata.PlayerDataMapRegenPacket;
import kamkeel.npcs.network.packets.request.playerdata.PlayerDataRemovePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.SubGuiPlayerData;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumPlayerData;
import noppes.npcs.entity.EntityNPCInterface;
@@ -18,167 +18,136 @@ import java.util.HashMap;
import java.util.List;
import java.util.Vector;
public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements IScrollData,ICustomScrollListener,GuiYesNoCallback
{
private GuiCustomScroll scroll;
private String selectedPlayer = null;
private String selected = null;
private HashMap<String,Integer> data = new HashMap<String,Integer>();
private EnumPlayerData selection = EnumPlayerData.Players;
private String search = "";
public class GuiNpcManagePlayerData extends GuiNPCInterface2 implements GuiYesNoCallback, IScrollData, ICustomScrollListener, ISubGuiListener {
public GuiNpcManagePlayerData(EntityNPCInterface npc)
{
super(npc);
PacketClient.sendClient(new PlayerDataGetPacket(selection, ""));
private GuiCustomScroll playerScroll;
private String selectedPlayer = null;
private HashMap<String, Integer> playerData = new HashMap<>();
private String search = "";
public GuiNpcManagePlayerData(EntityNPCInterface npcInterface) {
super(npcInterface);
// Request the complete list of players.
PacketClient.sendClient(new PlayerDataGetNamesPacket(EnumPlayerData.Players, ""));
}
public void initGui()
{
@Override
public void initGui() {
super.initGui();
scroll = new GuiCustomScroll(this,0, 0);
scroll.setSize(303, 175);
scroll.guiLeft = guiLeft + 4;
scroll.guiTop = guiTop + 16;
addScroll(scroll);
if (playerScroll == null) {
playerScroll = new GuiCustomScroll(this, 0, 0);
}
playerScroll.guiLeft = guiLeft + 4;
playerScroll.guiTop = guiTop + 16;
playerScroll.setSize(303, 175);
addScroll(playerScroll);
addLabel(new GuiNpcLabel(0,"All Players", guiLeft + 10, guiTop + 6));
addLabel(new GuiNpcLabel(0, StatCollector.translateToLocal("All Players"), guiLeft + 10, guiTop + 6));
this.addButton(new GuiNpcButton(0, guiLeft + 313, guiTop + 10,98, 20, "selectWorld.deleteButton"));
this.addButton(new GuiNpcButton(1, guiLeft + 313, guiTop + 32,98, 20, "Players"));
this.addButton(new GuiNpcButton(2, guiLeft + 313, guiTop + 54,98, 20, "Quest Data"));
this.addButton(new GuiNpcButton(3, guiLeft + 313, guiTop + 76,98, 20, "Dialog Data"));
this.addButton(new GuiNpcButton(4, guiLeft + 313, guiTop + 98,98, 20, "Transport Data"));
this.addButton(new GuiNpcButton(5, guiLeft + 313, guiTop + 120,98, 20, "Bank Data"));
this.addButton(new GuiNpcButton(6, guiLeft + 313, guiTop + 142,98, 20, "Faction Data"));
addButton(new GuiNpcButton(0, guiLeft + 313, guiTop + 10, 98, 20, "gui.remove"));
addButton(new GuiNpcButton(1, guiLeft + 313, guiTop + 32, 98, 20, "gui.view"));
addButton(new GuiNpcButton(2, guiLeft + 313, guiTop + 54, 98, 20, "gui.playerMap"));
this.addButton(new GuiNpcButton(7, guiLeft + 313, guiTop + 193,98, 20, "Regen PlayerMap"));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 303, 20, search));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 4, guiTop + 193, 303, 20, search));
getTextField(0).enabled = selection == EnumPlayerData.Players;
initButtons();
playerScroll.setList(getSearchList());
}
public void initButtons(){
getButton(1).setEnabled(selection != EnumPlayerData.Players);
getButton(2).setEnabled(selection != EnumPlayerData.Quest);
getButton(3).setEnabled(selection != EnumPlayerData.Dialog);
getButton(4).setEnabled(selection != EnumPlayerData.Transport);
getButton(5).setEnabled(selection != EnumPlayerData.Bank);
getButton(6).setEnabled(selection != EnumPlayerData.Factions);
if(selection == EnumPlayerData.Players)
getLabel(0).label = "All Players";
else
getLabel(0).label = "Selected player: " + selectedPlayer;
}
public void drawScreen(int i, int j, float f)
{
@Override
public void drawScreen(int i, int j, float f) {
super.drawScreen(i, j, f);
scroll.drawScreen(i, j, f);
playerScroll.drawScreen(i, j, f);
}
public void mouseClicked(int i, int j, int k)
{
super.mouseClicked(i, j, k);
if(k == 0 && scroll != null)
scroll.mouseClicked(i, j, k);
@Override
public void mouseClicked(int i, int j, int k) {;
super.mouseClicked(i, j, k);
if (k == 0 && playerScroll != null)
playerScroll.mouseClicked(i, j, k);
}
public void keyTyped(char c, int i)
{
super.keyTyped(c, i);
@Override
public void save() {}
if(search.equals(getTextField(0).getText()))
return;
search = getTextField(0).getText().toLowerCase();
scroll.setList(getSearchList());
}
private List<String> getSearchList(){
if(search.isEmpty())
return new ArrayList<String>(this.data.keySet());
List<String> list = new ArrayList<String>();
for(String name : data.keySet()){
if(name.toLowerCase().contains(search))
list.add(name);
}
return list;
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
String newText = getTextField(0).getText();
if (!search.equals(newText)) {
search = newText.toLowerCase();
playerScroll.setList(getSearchList());
}
}
protected void actionPerformed(GuiButton guibutton)
{
int id = guibutton.id;
if(id < 7){
GuiNpcTextField tf = getTextField(0);
if(tf != null){
tf.setText("");
}
search = "";
if(id == 0)
{
if(selected != null){
if(selection == EnumPlayerData.Players)
PacketClient.sendClient(new PlayerDataRemovePacket(selection, selectedPlayer, selected));
else
PacketClient.sendClient(new PlayerDataRemovePacket(selection, selectedPlayer, data.get(selected)));
data.clear();
}
selected = null;
}
if(id >= 1 && id <= 6)
{
if(selectedPlayer == null && id != 1)
return;
selection = EnumPlayerData.values()[id - 1];
initButtons();
scroll.clear();
data.clear();
PacketClient.sendClient(new PlayerDataGetPacket(selection, selectedPlayer));
selected = null;
}
}
if(id == 7){
displayGuiScreen(new GuiYesNo(this, "Warning", "Do not operate on PlayerData as its regenerating", 1));
}
private List<String> getSearchList() {
if (search.isEmpty())
return new ArrayList<>(playerData.keySet());
List<String> list = new ArrayList<>();
for (String name : playerData.keySet()) {
if (name.toLowerCase().contains(search))
list.add(name);
}
return list;
}
@Override
public void save() {
}
@Override
public void actionPerformed(GuiButton button) {
int id = button.id;
if (id == 0) {
if (selectedPlayer != null) {
displayGuiScreen(new GuiYesNo(this, selectedPlayer, StatCollector.translateToLocal("gui.deleteconfirm"), 0));
}
}
if (id == 1) {
if (selectedPlayer != null) {
setSubGui(new SubGuiPlayerData(selectedPlayer));
}
}
if (id == 2) {
displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.warning"), StatCollector.translateToLocal("gui.regenconfirm"), 1));
}
}
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data) {
this.data.putAll(data);
@Override
public void confirmClicked(boolean confirm, int id) {
if (confirm) {
if (id == 0) {
PacketClient.sendClient(new PlayerDataRemovePacket(EnumPlayerData.Players, selectedPlayer, null));
playerData.remove(selectedPlayer);
selectedPlayer = null;
playerScroll.setList(getSearchList());
}
if (id == 1) {
PacketClient.sendClient(new PlayerDataMapRegenPacket());
close();
}
} else {
displayGuiScreen(this);
}
}
scroll.setList(getSearchList());
// IScrollData interface.
@Override
public void setData(Vector<String> list, HashMap<String, Integer> data) {
playerData.clear();
playerData.putAll(data);
playerScroll.setList(getSearchList());
}
if(selection == EnumPlayerData.Players && selectedPlayer != null){
scroll.setSelected(selectedPlayer);
selected = selectedPlayer;
}
}
// ICustomScrollListener interface.
@Override
public void setSelected(String selected) {
selectedPlayer = selected;
}
@Override
public void setSelected(String selected) {
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
selectedPlayer = scroll.getSelected();
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
selected = guiCustomScroll.getSelected();
if(selection == EnumPlayerData.Players)
selectedPlayer = selected;
}
@Override
public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {}
@Override
public void confirmClicked(boolean confirm, int id){
if(confirm){
PacketClient.sendClient(new PlayerDataMapRegenPacket());
close();
}
else
displayGuiScreen(this);
}
public void subGuiClosed(SubGuiInterface subgui) {}
}
@@ -8,14 +8,12 @@ import kamkeel.npcs.network.packets.request.recipe.RecipesGetPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumGuiType;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.data.RecipeAnvil;
import noppes.npcs.controllers.data.RecipeCarpentry;
@@ -8,13 +8,11 @@ import kamkeel.npcs.network.packets.request.naturalspawns.NaturalSpawnSavePacket
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.GuiNpcMobSpawnerSelector;
import noppes.npcs.client.gui.SubGuiNpcBiomes;
import noppes.npcs.client.gui.SubGuiNpcDimensions;
import noppes.npcs.client.gui.SubGuiSpawningOptions;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.data.SpawnData;
import noppes.npcs.entity.EntityNPCInterface;
@@ -0,0 +1,36 @@
package noppes.npcs.client.gui.hud;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ClientHudManager {
private static ClientHudManager instance;
private HashMap<EnumHudComponent, HudComponent> hudComponents = new HashMap<>();
private ClientHudManager() {}
public static ClientHudManager getInstance() {
if(instance == null)
instance = new ClientHudManager();
return instance;
}
public void registerHud(EnumHudComponent enumHudComponent, HudComponent hud) {
hudComponents.put(enumHudComponent, hud);
}
public HashMap<EnumHudComponent, HudComponent> getHudComponents() {
return hudComponents;
}
/**
* Renders all enabled HUD components (normal mode).
*/
public void renderAllHUDs(float partialTicks) {
for (HudComponent hud : hudComponents.values()) {
if(hud.enabled)
hud.renderOnScreen(partialTicks);
}
}
}
@@ -0,0 +1,281 @@
package noppes.npcs.client.gui.hud;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.config.ConfigClient;
import noppes.npcs.constants.MarkType;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
public class CompassHudComponent extends HudComponent {
private final Minecraft mc;
private final List<MarkTargetEntry> markTargets = new ArrayList<>();
private final int BAR_HEIGHT = 20;
private final int BASE_ICON_SIZE = 8;
private final int MAX_ICON_SIZE = 16;
private final int SCALE_DISTANCE_MIN = 10;
private final int SCALE_DISTANCE_MAX = 40;
private static final int HANDLE_SIZE = 10;
private static final int WIDTH_BAR_SIZE = 6; // Width adjust bar width
private final int SCAN_RANGE = 128;
// Flag to indicate if the width bar is being dragged in editing mode.
public boolean resizingWidth = false;
public static class MarkTargetEntry {
public int x, z;
public int type;
public int color;
public MarkTargetEntry(int x, int z, int type, int color) {
this.x = x;
this.z = z;
this.type = type;
this.color = color;
}
}
public CompassHudComponent(Minecraft minecraft) {
mc = minecraft;
overlayWidth = 200;
overlayHeight = BAR_HEIGHT;
load();
}
@Override
public void loadData(NBTTagCompound compound) {
markTargets.clear();
NBTTagList list = compound.getTagList("MarkTargets", 10);
for(int i = 0; i < list.tagCount(); i++) {
NBTTagCompound entry = list.getCompoundTagAt(i);
markTargets.add(new MarkTargetEntry(
entry.getInteger("x"),
entry.getInteger("z"),
entry.getInteger("type"),
entry.getInteger("color")
));
}
hasData = !markTargets.isEmpty();
}
@Override
public void load() {
enabled = ConfigClient.CompassEnabled;
posX = ConfigClient.CompassOverlayX;
posY = ConfigClient.CompassOverlayY;
scale = ConfigClient.CompassOverlayScale;
overlayWidth = ConfigClient.CompassOverlayWidth;
}
@Override
public void save() {
ConfigClient.CompassEnabled = enabled;
ConfigClient.CompassEnabledProperty.set(ConfigClient.CompassEnabled);
ConfigClient.CompassOverlayX = posX;
ConfigClient.CompassOverlayXProperty.set(ConfigClient.CompassOverlayX);
ConfigClient.CompassOverlayY = posY;
ConfigClient.CompassOverlayYProperty.set(ConfigClient.CompassOverlayY);
ConfigClient.CompassOverlayScale = scale;
ConfigClient.CompassOverlayScaleProperty.set(ConfigClient.CompassOverlayScale);
ConfigClient.CompassOverlayWidth = overlayWidth;
ConfigClient.CompassOverlayWidthProperty.set(ConfigClient.CompassOverlayWidth);
if(ConfigClient.config.hasChanged())
ConfigClient.config.save();
}
@Override
public void renderOnScreen(float partialTicks) {
// If no mark data or in edit mode, skip normal rendering.
if (!hasData || isEditting) return;
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int actualX = (int)(posX / 100F * res.getScaledWidth());
int actualY = (int)(posY / 100F * res.getScaledHeight());
float effectiveScale = getEffectiveScale(res);
GL11.glPushMatrix();
GL11.glTranslatef(actualX, actualY, 0);
GL11.glScalef(effectiveScale, effectiveScale, effectiveScale);
// Draw background bar
drawRect(0, 0, overlayWidth, BAR_HEIGHT, 0x80000000);
// Render all marks
for(MarkTargetEntry mark : markTargets) {
renderMarkIcon(mark);
}
GL11.glPopMatrix();
}
private void renderMarkIcon(MarkTargetEntry mark) {
if (mc.thePlayer == null) return;
Float iconPos = calculateIconPosition(mark.x, mark.z);
if(iconPos == null) {
// Target is behind the player; don't render.
return;
}
int barWidth = overlayWidth;
float distance = (float) Math.sqrt(
Math.pow(mark.x - mc.thePlayer.posX, 2) +
Math.pow(mark.z - mc.thePlayer.posZ, 2)
);
int iconSize = calculateIconSize(distance);
int iconX = MathHelper.clamp_int((int)iconPos.floatValue(), iconSize/2, barWidth - iconSize/2);
int iconY = (BAR_HEIGHT - iconSize)/2;
ResourceLocation texture = getTextureForMark(mark.type);
if(texture != null) {
renderTextureIcon(iconX - iconSize/2, iconY, iconSize, texture, mark.color);
}
}
private ResourceLocation getTextureForMark(int type) {
switch(type) {
case MarkType.EXCLAMATION: return new ResourceLocation("customnpcs", "textures/marks/exclamation.png");
case MarkType.QUESTION: return new ResourceLocation("customnpcs", "textures/marks/question.png");
case MarkType.POINTER: return new ResourceLocation("customnpcs", "textures/marks/pointer.png");
case MarkType.CROSS: return new ResourceLocation("customnpcs", "textures/marks/cross.png");
case MarkType.SKULL: return new ResourceLocation("customnpcs", "textures/marks/skull.png");
case MarkType.STAR: return new ResourceLocation("customnpcs", "textures/marks/star.png");
default: return null;
}
}
private void renderTextureIcon(int x, int y, int size, ResourceLocation texture, int color) {
float red = (color >> 16 & 255) / 255.0F;
float green = (color >> 8 & 255) / 255.0F;
float blue = (color & 255) / 255.0F;
GL11.glPushMatrix();
GL11.glColor4f(red, green, blue, 1);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.getTextureManager().bindTexture(texture);
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + size, 0, 0, 1);
tessellator.addVertexWithUV(x + size, y + size, 0, 1, 1);
tessellator.addVertexWithUV(x + size, y, 0, 1, 0);
tessellator.addVertexWithUV(x, y, 0, 0, 0);
tessellator.draw();
GL11.glColor4f(1, 1, 1, 1);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
private Float calculateIconPosition(double targetX, double targetZ) {
double dx = targetX - mc.thePlayer.posX;
double dz = targetZ - mc.thePlayer.posZ;
double angleToTarget = Math.toDegrees(Math.atan2(dz, dx));
double adjustedPlayerYaw = mc.thePlayer.rotationYaw + 90;
double relativeAngle = angleToTarget - adjustedPlayerYaw;
while(relativeAngle < -180) relativeAngle += 360;
while(relativeAngle > 180) relativeAngle -= 360;
// Only render if the target is within 90° to either side (180° front)
if (Math.abs(relativeAngle) > 90) {
return null;
}
// Map -90..90 to 0..overlayWidth so that 0 becomes the left edge and 90 the right edge.
return (float)(overlayWidth / 2.0 + (relativeAngle / 90.0) * (overlayWidth / 2.0));
}
private int calculateIconSize(float distance) {
if(distance <= SCALE_DISTANCE_MIN) return MAX_ICON_SIZE;
if(distance >= SCALE_DISTANCE_MAX) return BASE_ICON_SIZE;
float t = (distance - SCALE_DISTANCE_MIN) /
(SCALE_DISTANCE_MAX - SCALE_DISTANCE_MIN);
return (int)(MAX_ICON_SIZE - (MAX_ICON_SIZE - BASE_ICON_SIZE) * t);
}
@Override
public void renderEditing() {
isEditting = true;
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int actualX = (int)(posX / 100F * res.getScaledWidth());
int actualY = (int)(posY / 100F * res.getScaledHeight());
float effectiveScale = getEffectiveScale(res);
GL11.glPushMatrix();
GL11.glTranslatef(actualX, actualY, 0);
GL11.glScalef(effectiveScale, effectiveScale, effectiveScale);
// Draw background bar and border.
drawRect(0, 0, overlayWidth, overlayHeight, 0x80000000);
drawRectOutline(0, 0, overlayWidth, overlayHeight, 0xFF00FF00);
// Resize handle (bottom-right for scale)
drawRect(overlayWidth - HANDLE_SIZE, overlayHeight - HANDLE_SIZE,
overlayWidth, overlayHeight, 0xFFCCCCCC);
// Width adjust bar on right side (centered vertically)
int margin = 5;
int barX = overlayWidth + margin;
int barY = (overlayHeight - BAR_HEIGHT) / 2;
drawRect(barX, barY, barX + WIDTH_BAR_SIZE, barY + BAR_HEIGHT, 0xFF888888);
// Demo marks for preview.
renderDemoIcon(overlayWidth * 0.25f, MarkType.EXCLAMATION, 0xFF00FF00);
renderDemoIcon(overlayWidth * 0.75f, MarkType.QUESTION, 0xFFFF0000);
GL11.glPopMatrix();
}
private void renderDemoIcon(float position, int type, int color) {
float pulse = (System.currentTimeMillis() % 1000) / 1000f;
int size = (int)(BASE_ICON_SIZE + (MAX_ICON_SIZE - BASE_ICON_SIZE) * pulse);
ResourceLocation texture = getTextureForMark(type);
if(texture != null) {
GL11.glPushMatrix();
GL11.glTranslatef(position - size/2, (BAR_HEIGHT - size)/2, 0);
renderTextureIcon(0, 0, size, texture, color);
GL11.glPopMatrix();
}
}
/**
* Updates the mark targets directly.
* (This method assumes external code (CNPC+ mark data) supplies the new marks
* without having to loop through all loaded entities.)
*/
public void updateMarkTargets(List<MarkTargetEntry> newMarks) {
markTargets.clear();
markTargets.addAll(newMarks);
hasData = !markTargets.isEmpty();
}
// Helper drawing methods
private void drawRect(int left, int top, int right, int bottom, int color) {
net.minecraft.client.gui.Gui.drawRect(left, top, right, bottom, color);
}
private void drawRectOutline(int left, int top, int right, int bottom, int color) {
drawHorizontalLine(left, right, top, color);
drawHorizontalLine(left, right, bottom - 1, color);
net.minecraft.client.gui.Gui.drawRect(left, top, left + 1, bottom, color);
net.minecraft.client.gui.Gui.drawRect(right - 1, top, right, bottom, color);
}
private void drawHorizontalLine(int left, int right, int y, int color) {
net.minecraft.client.gui.Gui.drawRect(left, y, right, y + 1, color);
}
}
@@ -0,0 +1,6 @@
package noppes.npcs.client.gui.hud;
public enum EnumHudComponent {
QuestTracker,
QuestCompass
}
@@ -0,0 +1,248 @@
package noppes.npcs.client.gui.hud;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.util.List;
import java.util.ArrayList;
public class GuiHudEditor extends GuiScreen {
private GuiScreen parent;
// Currently selected HUD component for moving/resizing.
private HudComponent selectedComponent;
private int dragOffsetX, dragOffsetY;
private boolean dragging = false;
private boolean resizing = false;
// For general scaling resize.
private int initialScale, initialMouseX, initialMouseY;
// For Compass width adjustment.
private boolean resizingWidth = false;
private int initialOverlayWidth, initialWidthMouseX;
private final int HANDLE_SIZE = 10;
private final int RESET_POSITION_ID = 100;
public GuiHudEditor(GuiScreen parent) {
this.parent = parent;
// For example, default to QuestTracker if available.
selectedComponent = ClientHudManager.getInstance().getHudComponents().get(EnumHudComponent.QuestTracker);
}
@Override
public void initGui() {
buttonList.clear();
// Global "Save and Close" button always visible.
buttonList.add(new GuiButton(0, width / 2 - 60, height - 45, 120, 20, "Save and Close"));
updateCustomButtons();
}
/**
* Updates the custom buttons shown on screen.
* Removes all buttons except the global Save button (id 0)
* then adds the selected component's custom buttons plus a Reset Position button.
* Buttons are now arranged in two columns.
*/
private void updateCustomButtons() {
// Remove any buttons that are not the global Save (id 0)
for (int i = buttonList.size() - 1; i >= 0; i--) {
GuiButton btn = (GuiButton) buttonList.get(i);
if (btn.id != 0) {
buttonList.remove(i);
}
}
if (selectedComponent != null) {
List<GuiButton> customButtons = new ArrayList<>();
selectedComponent.addEditorButtons(customButtons);
// Arrange buttons in 2 columns.
int spacingX = 10;
int spacingY = 5;
int buttonWidth = 120; // assuming uniform width
int startXLeft = width / 2 - buttonWidth - spacingX/2;
int startXRight = width / 2 + spacingX/2;
int rowHeight = 0;
int numButtons = customButtons.size();
for (int i = 0; i < numButtons; i += 2) {
// If two buttons in this row.
if (i + 1 < numButtons) {
GuiButton btnLeft = customButtons.get(i);
GuiButton btnRight = customButtons.get(i+1);
btnLeft.xPosition = startXLeft;
btnRight.xPosition = startXRight;
// Determine row y based on button height.
int rowY = height - 70 - rowHeight;
btnLeft.yPosition = rowY;
btnRight.yPosition = rowY;
rowHeight += btnLeft.height + spacingY;
buttonList.add(btnLeft);
buttonList.add(btnRight);
} else {
// One button: center it.
GuiButton btn = customButtons.get(i);
btn.xPosition = width / 2 - buttonWidth / 2;
btn.yPosition = height - 70 - rowHeight;
buttonList.add(btn);
rowHeight += btn.height + spacingY;
}
}
// Always add the Reset Position button below the custom buttons.
GuiButton resetPos = new GuiButton(RESET_POSITION_ID, width / 2 - buttonWidth / 2, height - 70 - rowHeight, buttonWidth, 20, "Reset Position");
buttonList.add(resetPos);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawDefaultBackground();
// Render each HUD in editing mode.
for (HudComponent hud : ClientHudManager.getInstance().getHudComponents().values()) {
hud.renderEditing();
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
// Iterate over HUD components to check for selection.
// First, check for Compass width adjust hitbox if the mouse is near a CompassHudComponent.
for (HudComponent hud : ClientHudManager.getInstance().getHudComponents().values()) {
if (!(hud instanceof CompassHudComponent))
continue;
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
float effectiveScale = hud.getEffectiveScale(res);
int actualX = (int)(hud.posX / 100F * res.getScaledWidth());
int actualY = (int)(hud.posY / 100F * res.getScaledHeight());
// Even if the mouse is outside the hud bounds, we want to check for the floating adjust bar.
int margin = 5;
int barWidth = 6; // same as WIDTH_BAR_SIZE
// The adjust bar is drawn to the right of the component.
int barX = actualX + (int)(hud.overlayWidth * effectiveScale) + margin;
int barY = actualY + (int)(((hud.overlayHeight - 20) / 2.0F) * effectiveScale); // 20 = BAR_HEIGHT
int barHeight = (int)(20 * effectiveScale);
if (mouseX >= barX && mouseX <= barX + barWidth &&
mouseY >= barY && mouseY <= barY + barHeight) {
resizingWidth = true;
selectedComponent = hud;
initialOverlayWidth = hud.overlayWidth;
initialWidthMouseX = mouseX;
updateCustomButtons();
return;
}
}
// Next, proceed with the normal hit detection for dragging/resizing of the HUD components.
for (HudComponent hud : ClientHudManager.getInstance().getHudComponents().values()) {
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
float effectiveScale = hud.getEffectiveScale(res);
int actualX = (int)(hud.posX / 100F * res.getScaledWidth());
int actualY = (int)(hud.posY / 100F * res.getScaledHeight());
int absWidth = (int)(hud.overlayWidth * effectiveScale);
int absHeight = (int)(hud.overlayHeight * effectiveScale);
if (mouseX >= actualX && mouseX <= actualX + absWidth &&
mouseY >= actualY && mouseY <= actualY + absHeight) {
// Check if clicking on the resize handle (bottom-right).
if (mouseX >= actualX + absWidth - HANDLE_SIZE && mouseY >= actualY + absHeight - HANDLE_SIZE) {
resizing = true;
selectedComponent = hud;
initialScale = hud.scale;
initialMouseX = mouseX;
initialMouseY = mouseY;
updateCustomButtons();
return;
} else {
dragging = true;
selectedComponent = hud;
dragOffsetX = mouseX - actualX;
dragOffsetY = mouseY - actualY;
updateCustomButtons();
return;
}
}
}
super.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
dragging = false;
resizing = false;
resizingWidth = false;
super.mouseMovedOrUp(mouseX, mouseY, state);
}
@Override
public void updateScreen() {
if (selectedComponent != null) {
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int scaledWidth = res.getScaledWidth();
int scaledHeight = res.getScaledHeight();
float effectiveScale = selectedComponent.getEffectiveScale(res);
if (dragging) {
int newX = Mouse.getX() * width / mc.displayWidth - dragOffsetX;
int newY = scaledHeight - (Mouse.getY() * scaledHeight / mc.displayHeight) - dragOffsetY;
if (newX < 0) newX = 0;
if (newY < 0) newY = 0;
if (newX + (int)(selectedComponent.overlayWidth * effectiveScale) > scaledWidth)
newX = scaledWidth - (int)(selectedComponent.overlayWidth * effectiveScale);
if (newY + (int)(selectedComponent.overlayHeight * effectiveScale) > scaledHeight)
newY = scaledHeight - (int)(selectedComponent.overlayHeight * effectiveScale);
selectedComponent.posX = (int)(100F * newX / scaledWidth);
selectedComponent.posY = (int)(100F * newY / scaledHeight);
}
if (resizing) {
int currentMouseX = Mouse.getX() * width / mc.displayWidth;
int deltaX = currentMouseX - initialMouseX;
selectedComponent.scale = initialScale + deltaX; // 1 pixel = 1% change.
if (selectedComponent.scale < 50) selectedComponent.scale = 50;
if (selectedComponent.scale > 300) selectedComponent.scale = 300;
}
if (resizingWidth && (selectedComponent instanceof CompassHudComponent)) {
int currentMouseX = Mouse.getX() * width / mc.displayWidth;
int delta = currentMouseX - initialWidthMouseX;
selectedComponent.overlayWidth = initialOverlayWidth + delta;
if (selectedComponent.overlayWidth < 50) selectedComponent.overlayWidth = 50;
if (selectedComponent.overlayWidth > 500) selectedComponent.overlayWidth = 500;
}
}
super.updateScreen();
}
@Override
protected void actionPerformed(GuiButton button) {
if (button.id == 0) {
close();
} else if (button.id == RESET_POSITION_ID) {
// Reset position for selected HUD.
if (selectedComponent != null) {
selectedComponent.posX = 50;
selectedComponent.posY = 50;
updateCustomButtons();
}
} else {
// Dispatch other button actions to the selected component.
if (selectedComponent != null) {
selectedComponent.onEditorButtonPressed(button);
updateCustomButtons();
}
}
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (keyCode == 1) {
close();
}
}
public void close() {
for (HudComponent hud : ClientHudManager.getInstance().getHudComponents().values()) {
hud.isEditting = false;
hud.save();
}
mc.displayGuiScreen(parent);
}
}
@@ -0,0 +1,70 @@
package noppes.npcs.client.gui.hud;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.nbt.NBTTagCompound;
import java.util.List;
public abstract class HudComponent {
// Stored as percentages (0-100) of the current screen resolution.
protected int posX = 50, posY = 50, scale = 100, textAlign = 0;
public boolean enabled = true;
public boolean hasData = false;
public boolean isEditting = false;
public int overlayWidth = 200, overlayHeight = 120;
/**
* Loads custom HUD data from an NBT compound.
*/
public abstract void loadData(NBTTagCompound compound);
/**
* Loads HUD settings from the config.
*/
public abstract void load();
/**
* Saves HUD settings to the config.
*/
public abstract void save();
/**
* Renders the HUD as it appears during normal gameplay.
*/
public abstract void renderOnScreen(float partialTicks);
/**
* Renders the HUD in edit mode (with handles, borders, dummy data, etc.).
*/
public abstract void renderEditing();
/**
* Allows the component to add its own editor buttons.
* The default implementation adds a toggle button for enabling/disabling the component.
*/
public void addEditorButtons(List<GuiButton> buttonList) {
// Toggle enabled/disabled button (id 999 reserved for toggle)
String label = enabled ? "Enabled" : "Disabled";
buttonList.add(new GuiButton(999, 0, 0, 120, 20, label));
}
/**
* Handles editor button actions specific to this HUD component.
* The default implementation toggles the enabled state if button id is 999.
*/
public void onEditorButtonPressed(GuiButton button) {
if(button.id == 999){
enabled = !enabled;
button.displayString = enabled ? "Enabled" : "Disabled";
}
}
/**
* Computes the effective scale factor for rendering and hitbox calculations.
* Uses the current resolution (with 1920 as the base width).
*/
public float getEffectiveScale(ScaledResolution res) {
return (scale / 100.0F) * (res.getScaledWidth() / 1920.0F);
}
}
@@ -0,0 +1,280 @@
package noppes.npcs.client.gui.hud;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.config.ConfigClient;
import org.lwjgl.opengl.GL11;
import noppes.npcs.controllers.data.Quest;
import java.util.ArrayList;
import java.util.List;
public class QuestTrackingComponent extends HudComponent {
private Minecraft mc;
private ArrayList<String> questTitleLines = new ArrayList<>();
private ArrayList<String> questCategoryLines = new ArrayList<>();
private ArrayList<String> objectiveLines = new ArrayList<>();
private ArrayList<String> turnInLines = new ArrayList<>();
public QuestTrackingComponent(Minecraft mc) {
this.mc = mc;
load();
}
/**
* Sets quest data similar to the original OverlayQuestTracking.
*/
public void setQuestData(Quest quest, String category, List<String> objectives, String turnIn) {
questTitleLines = splitLines(convertColorCodes(quest.getName()), overlayWidth - 10);
questCategoryLines = splitLines(convertColorCodes(category), overlayWidth - 10);
objectiveLines.clear();
for (String obj : objectives) {
objectiveLines.add(convertColorCodes(obj));
}
turnInLines.clear();
if (turnIn != null && !turnIn.isEmpty()) {
turnInLines.add(convertColorCodes(turnIn));
}
}
/**
* Loads overlay data from an NBT compound.
*/
public void setOverlayData(NBTTagCompound compound) {
Quest quest = new Quest();
quest.readNBT(compound.getCompoundTag("Quest"));
String category = compound.getString("CategoryName");
ArrayList<String> objectives = new ArrayList<>();
NBTTagList objectiveList = compound.getTagList("ObjectiveList", 8);
for (int i = 0; i < objectiveList.tagCount(); i++) {
String objective = objectiveList.getStringTagAt(i);
objectives.add(objective);
}
String turnIn = "";
boolean instantComplete = compound.getBoolean("Instant");
if (instantComplete) {
turnIn = "Completed automatically";
} else {
String npcName = compound.getString("TurnInNPC");
if (!npcName.isEmpty()) {
turnIn = "Complete with " + npcName;
}
}
setQuestData(quest, category, objectives, turnIn);
hasData = true;
}
@Override
public void loadData(NBTTagCompound compound) {
setOverlayData(compound);
}
@Override
public void load() {
posX = ConfigClient.QuestOverlayX;
posY = ConfigClient.QuestOverlayY;
scale = ConfigClient.QuestOverlayScale;
textAlign = ConfigClient.QuestOverlayTextAlign;
}
@Override
public void save() {
ConfigClient.QuestOverlayX = posX;
ConfigClient.QuestOverlayXProperty.set(ConfigClient.QuestOverlayX);
ConfigClient.QuestOverlayY = posY;
ConfigClient.QuestOverlayYProperty.set(ConfigClient.QuestOverlayY);
ConfigClient.QuestOverlayScale = scale;
ConfigClient.QuestOverlayScaleProperty.set(ConfigClient.QuestOverlayScale);
ConfigClient.QuestOverlayTextAlign = textAlign;
ConfigClient.QuestOverlayTextAlignProperty.set(ConfigClient.QuestOverlayTextAlign);
if (ConfigClient.config.hasChanged()) {
ConfigClient.config.save();
}
}
@Override
public void renderOnScreen(float partialTicks) {
if (!hasData || isEditting)
return;
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int actualX = (int)(posX / 100F * res.getScaledWidth());
int actualY = (int)(posY / 100F * res.getScaledHeight());
float effectiveScale = getEffectiveScale(res);
GL11.glPushMatrix();
GL11.glTranslatef(actualX, actualY, 0);
GL11.glScalef(effectiveScale, effectiveScale, effectiveScale);
// Draw background (semi-transparent).
drawRect(0, 0, overlayWidth, overlayHeight, 0x40000000);
int currentY = 5;
currentY = renderTextBlock(questTitleLines, currentY, textAlign, 0xFFFFFF);
drawDecorativeLine(currentY - 1);
currentY += 8;
currentY = renderTextBlock(questCategoryLines, currentY, textAlign, 0xCCCCCC);
drawDecorativeLine(currentY - 1);
currentY += 8;
currentY = renderTextBlock(objectiveLines, currentY, textAlign, 0xAAAAAA);
if (!turnInLines.isEmpty()) {
drawDecorativeLine(currentY - 1);
currentY += 8;
}
renderTextBlock(turnInLines, currentY, textAlign, 0xAAAAAA);
GL11.glPopMatrix();
}
@Override
public void renderEditing() {
isEditting = true;
ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int actualX = (int)(posX / 100F * res.getScaledWidth());
int actualY = (int)(posY / 100F * res.getScaledHeight());
float effectiveScale = getEffectiveScale(res);
GL11.glPushMatrix();
GL11.glTranslatef(actualX, actualY, 0);
GL11.glScalef(effectiveScale, effectiveScale, effectiveScale);
// Draw editing background, border, and resize handle.
drawRect(0, 0, overlayWidth, overlayHeight, 0x40FFFFFF);
drawRectOutline(0, 0, overlayWidth, overlayHeight, 0xFFAAAAAA);
drawRect(overlayWidth - 10, overlayHeight - 10, overlayWidth, overlayHeight, 0xFFCCCCCC);
int currentY = 5;
currentY = renderDemoTextBlock(new String[] { "Dummy Quest Title" }, currentY, textAlign, 0xFFFFFF);
drawDecorativeLine(currentY - 1);
currentY += 8;
currentY = renderDemoTextBlock(new String[] { "Dummy Category" }, currentY, textAlign, 0xCCCCCC);
drawDecorativeLine(currentY - 1);
currentY += 8;
currentY = renderDemoTextBlock(new String[] { "Objective: Kill 10 mobs", "Objective: Collect 5 items" }, currentY, textAlign, 0xAAAAAA);
drawDecorativeLine(currentY - 1);
currentY += 8;
renderDemoTextBlock(new String[] { "Turn in with NPC" }, currentY, textAlign, 0xAAAAAA);
GL11.glPopMatrix();
}
@Override
public void addEditorButtons(List<GuiButton> buttonList) {
// First add the default toggle button.
super.addEditorButtons(buttonList);
// Then add other custom buttons.
buttonList.add(new GuiButton(1, 100, 0, 120, 20, getAlignText()));
buttonList.add(new GuiButton(3, 100, 0, 120, 20, "Reset to Center"));
}
@Override
public void onEditorButtonPressed(GuiButton button) {
if (button.id == 1) { // Cycle alignment.
textAlign = (textAlign + 1) % 3;
button.displayString = getAlignText();
} else if (button.id == 3) { // Reset to center.
posX = 50;
posY = 50;
} else {
super.onEditorButtonPressed(button);
}
}
private String getAlignText() {
switch (textAlign) {
case 0: return "Align: Left";
case 1: return "Align: Center";
case 2: return "Align: Right";
default: return "Align: Unknown";
}
}
// ---------- Helper rendering methods -----------
private int renderTextBlock(List<String> lines, int startY, int align, int color) {
int y = startY;
FontRenderer font = mc.fontRenderer;
for (String line : lines) {
int strWidth = font.getStringWidth(line);
int xOffset = (align == 1) ? (overlayWidth - strWidth) / 2
: (align == 2) ? overlayWidth - strWidth - 5 : 5;
font.drawStringWithShadow(line, xOffset, y, color);
y += font.FONT_HEIGHT + 4;
}
return y;
}
private int renderDemoTextBlock(String[] lines, int startY, int align, int color) {
int y = startY;
FontRenderer font = mc.fontRenderer;
for (String line : lines) {
int strWidth = font.getStringWidth(line);
int xOffset = (align == 1) ? (overlayWidth - strWidth) / 2
: (align == 2) ? overlayWidth - strWidth - 5 : 5;
font.drawStringWithShadow(line, xOffset, y, color);
y += font.FONT_HEIGHT + 4;
}
return y;
}
private void drawDecorativeLine(int y) {
drawHorizontalLine(5, overlayWidth - 5, y, 0xFF777777);
drawHorizontalLine(5, overlayWidth - 5, y + 1, 0xFFA8A8A8);
drawHorizontalLine(5, overlayWidth - 5, y + 2, 0xFFFFFFFF);
}
// Simple wrappers for drawing.
private void drawRect(int left, int top, int right, int bottom, int color) {
net.minecraft.client.gui.Gui.drawRect(left, top, right, bottom, color);
}
private void drawHorizontalLine(int left, int right, int y, int color) {
net.minecraft.client.gui.Gui.drawRect(left, y, right, y + 1, color);
}
private void drawRectOutline(int left, int top, int right, int bottom, int color) {
drawHorizontalLine(left, right, top, color);
drawHorizontalLine(left, right, bottom - 1, color);
net.minecraft.client.gui.Gui.drawRect(left, top, left + 1, bottom, color);
net.minecraft.client.gui.Gui.drawRect(right - 1, top, right, bottom, color);
}
private String convertColorCodes(String text) {
return text.replaceAll("&([0-9a-fk-or])", "§$1");
}
private ArrayList<String> splitLines(String text, int maxWidth) {
ArrayList<String> lines = new ArrayList<>();
String[] words = text.split(" ");
StringBuilder current = new StringBuilder();
FontRenderer font = mc.fontRenderer;
for (String word : words) {
String test = current.length() == 0 ? word : current.toString() + " " + word;
if (font.getStringWidth(test) > maxWidth) {
if (current.length() > 0) {
lines.add(current.toString());
current = new StringBuilder(word);
} else {
lines.add(word);
}
} else {
if (current.length() > 0)
current.append(" ").append(word);
else
current.append(word);
}
}
if (current.length() > 0)
lines.add(current.toString());
return lines;
}
}
@@ -2,25 +2,20 @@ package noppes.npcs.client.gui.item;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.linked.LinkedItemSavePacket;
import kamkeel.npcs.network.packets.request.linked.LinkedNPCAddPacket;
import kamkeel.npcs.util.ColorUtil;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.SubGuiEditText;
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
import noppes.npcs.client.gui.script.GuiScriptLinkedItem;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.util.ValueUtil;
import org.lwjgl.opengl.GL11;
public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListener, GuiYesNoCallback, ISubGuiListener {
Loaded 100 of 305 files, more files were not shown because too many files have changed in this diff. Show more