Better Reorganization

This commit is contained in:
Kam committed 2025-02-27 15:54:42 -05:00
1 parent a328a635d7
commit da0489296e
38 files changed
+151 -144

No files matched your search

@@ -1,9 +1,13 @@
package noppes.npcs.attribute;
package kamkeel.npcs;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
/**
* ModAttributes registers the core attributes (both non–magic and magic–based).
*/
public class ModAttributes {
public class CustomAttributes {
public static final String HEALTH_KEY = "health";
public static final String MAIN_ATTACK_KEY = "main_attack";
public static final String MAIN_ATTACK_BOOST_KEY = "main_attack_boost";
@@ -31,7 +35,7 @@ public class ModAttributes {
public static AttributeDefinition MAGIC_DEFENSE;
public static AttributeDefinition MAGIC_RESISTANCE;
public ModAttributes(){
public CustomAttributes(){
HEALTH = AttributeController.registerAttribute(HEALTH_KEY, "Health", 'c', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE);
MAIN_ATTACK = AttributeController.registerAttribute(MAIN_ATTACK_KEY, "Main Attack Damage", '4', AttributeValueType.FLAT, AttributeDefinition.AttributeSection.BASE);
@@ -10,10 +10,10 @@ import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.attribute.AttributeController;
import noppes.npcs.attribute.AttributeDefinition;
import noppes.npcs.attribute.AttributeValueType;
import noppes.npcs.attribute.ItemAttributeHelper;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
import kamkeel.npcs.util.AttributeItemUtil;
import noppes.npcs.controllers.MagicController;
import static kamkeel.npcs.util.ColorUtil.sendError;
@@ -126,7 +126,7 @@ public class AttributeCommand extends CommandKamkeelBase {
return;
}
ItemAttributeHelper.writeMagicAttribute(held, attrKey, magicId, value);
AttributeItemUtil.writeMagicAttribute(held, attrKey, magicId, value);
sendResult(sender, "Applied magic attribute " + attrKey + " with magicID " + magicId + " and value " + value + " to held item.");
} else {
if(args.length < 2){
@@ -140,7 +140,7 @@ public class AttributeCommand extends CommandKamkeelBase {
sendError(sender, "Invalid number format for value.");
return;
}
ItemAttributeHelper.applyAttribute(held, attrKey, value);
AttributeItemUtil.applyAttribute(held, attrKey, value);
sendResult(sender, "Applied attribute " + attrKey + " with value " + value + " to held item.");
}
}
@@ -187,10 +187,10 @@ public class AttributeCommand extends CommandKamkeelBase {
return;
}
ItemAttributeHelper.removeMagicAttribute(held, attrKey, magicId);
AttributeItemUtil.removeMagicAttribute(held, attrKey, magicId);
sendResult(sender, "Removed magic attribute " + attrKey + " (magicID " + magicId + ") from held item.");
} else {
ItemAttributeHelper.removeAttribute(held, attrKey);
AttributeItemUtil.removeAttribute(held, attrKey);
sendResult(sender, "Removed attribute " + attrKey + " from held item.");
}
}
@@ -6,8 +6,8 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.attribute.AttributeController;
import noppes.npcs.attribute.AttributeDefinition;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.scripted.CustomNPCsException;
@@ -1,10 +1,10 @@
package kamkeel.npcs.command.profile;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.EnumProfileOperation;
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
import noppes.npcs.api.handler.data.ISlot;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
@@ -1,8 +1,8 @@
package kamkeel.npcs.command.profile;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.EnumProfileOperation;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,8 +1,8 @@
package kamkeel.npcs.command.profile;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.EnumProfileOperation;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -2,7 +2,7 @@ package kamkeel.npcs.command.profile;
import kamkeel.npcs.controllers.ProfileController;
import noppes.npcs.api.handler.data.ISlot;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.profile.Profile;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,8 +1,8 @@
package kamkeel.npcs.command.profile;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.EnumProfileOperation;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -1,7 +1,10 @@
package noppes.npcs.attribute;
package kamkeel.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.attribute.player.PlayerAttributeTracker;
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
import kamkeel.npcs.CustomAttributes;
import kamkeel.npcs.controllers.data.attribute.tracker.PlayerAttributeTracker;
import java.util.Collection;
import java.util.HashMap;
@@ -15,7 +18,7 @@ import java.util.UUID;
public class AttributeController {
public AttributeController Instance;
public ModAttributes attributes;
public CustomAttributes attributes;
// Tracking Player Attributes
private static final Map<UUID, PlayerAttributeTracker> trackers = new HashMap<>();
@@ -25,7 +28,7 @@ public class AttributeController {
this.Instance = this;
definitions.clear();
trackers.clear();
attributes = new ModAttributes();
attributes = new CustomAttributes();
}
@@ -1,6 +1,6 @@
package kamkeel.npcs.controllers;
import kamkeel.npcs.controllers.data.*;
import kamkeel.npcs.controllers.data.profile.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -596,8 +596,8 @@ public class ProfileController implements IProfileHandler {
}
}
public List<InfoEntry> getProfileInfo(EntityPlayer player, int slotId) {
List<InfoEntry> infoList = new ArrayList<>();
public List<ProfileInfoEntry> getProfileInfo(EntityPlayer player, int slotId) {
List<ProfileInfoEntry> infoList = new ArrayList<>();
Profile profile = getProfile(player);
if (profile == null)
return infoList;
@@ -607,7 +607,7 @@ public class ProfileController implements IProfileHandler {
if (slotId == profile.getCurrentSlotId()) {
for (IProfileData pd : dataList) {
NBTTagCompound currentNBT = pd.getCurrentNBT(player);
List<InfoEntry> subInfo = pd.getInfo(player, currentNBT);
List<ProfileInfoEntry> subInfo = pd.getInfo(player, currentNBT);
infoList.addAll(subInfo);
}
} else {
@@ -617,7 +617,7 @@ public class ProfileController implements IProfileHandler {
for (IProfileData pd : dataList) {
if (slot.getComponents().containsKey(pd.getTagName())) {
NBTTagCompound sub = slot.getComponentData(pd.getTagName());
List<InfoEntry> subInfo = pd.getInfo(player, sub);
List<ProfileInfoEntry> subInfo = pd.getInfo(player, sub);
infoList.addAll(subInfo);
}
}
@@ -1,4 +1,4 @@
package noppes.npcs.attribute;
package kamkeel.npcs.controllers.data.attribute;
public class AttributeDefinition {
private final String key; // e.g., "main_attack_flat"
@@ -1,4 +1,4 @@
package noppes.npcs.attribute;
package kamkeel.npcs.controllers.data.attribute;
public enum AttributeValueType {
FLAT, // e.g., +10 Health or +3 Damage
@@ -1,4 +1,4 @@
package noppes.npcs.attribute;
package kamkeel.npcs.controllers.data.attribute;
/**
* IAttributeInstance represents an instance of an attribute (with a base value and applied modifiers).
@@ -1,9 +1,6 @@
package noppes.npcs.attribute.player;
package kamkeel.npcs.controllers.data.attribute;
import noppes.npcs.attribute.AttributeDefinition;
import noppes.npcs.attribute.ICustomAttribute;
public class PlayerAttribute implements ICustomAttribute {
private final AttributeDefinition attribute;
private float baseValue;
@@ -1,7 +1,4 @@
package noppes.npcs.attribute.player;
import noppes.npcs.attribute.AttributeDefinition;
import noppes.npcs.attribute.ICustomAttribute;
package kamkeel.npcs.controllers.data.attribute;
import java.util.Collection;
import java.util.HashMap;
@@ -1,16 +1,22 @@
package noppes.npcs.attribute.player;
package kamkeel.npcs.controllers.data.attribute.tracker;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.Map.Entry;
import kamkeel.npcs.CustomAttributes;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
import kamkeel.npcs.controllers.data.attribute.ICustomAttribute;
import kamkeel.npcs.controllers.data.attribute.PlayerAttributeMap;
import kamkeel.npcs.util.AttributeAttackUtil;
import kamkeel.npcs.util.AttributeItemUtil;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import noppes.npcs.attribute.*;
public class PlayerAttributeTracker {
@@ -56,7 +62,7 @@ public class PlayerAttributeTracker {
ItemStack[] equipment = new ItemStack[] { currentEquip.heldItem, currentEquip.boots, currentEquip.leggings, currentEquip.chestplate, currentEquip.helmet };
for (ItemStack piece : equipment) {
if (piece != null) {
for (Entry<String, Float> entry : ItemAttributeHelper.readAttributes(piece).entrySet()) {
for (Entry<String, Float> entry : AttributeItemUtil.readAttributes(piece).entrySet()) {
String key = entry.getKey();
float value = entry.getValue();
AttributeDefinition def = AttributeController.getAttribute(key);
@@ -71,13 +77,13 @@ public class PlayerAttributeTracker {
// Process Magic
// OFFENSIVE MAGIC
Map<Integer, Float> magicFlat = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_DAMAGE_KEY);
Map<Integer, Float> magicFlat = AttributeItemUtil.readMagicAttributeMap(piece, CustomAttributes.MAGIC_DAMAGE_KEY);
for (Entry<Integer, Float> entry : magicFlat.entrySet()) {
int magicId = entry.getKey();
float value = entry.getValue();
magicDamage.put(magicId, magicDamage.getOrDefault(magicId, 0.0f) + value);
}
Map<Integer, Float> magicPercent = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_BOOST_KEY);
Map<Integer, Float> magicPercent = AttributeItemUtil.readMagicAttributeMap(piece, CustomAttributes.MAGIC_BOOST_KEY);
for (Entry<Integer, Float> entry : magicPercent.entrySet()) {
int magicId = entry.getKey();
float value = entry.getValue();
@@ -85,13 +91,13 @@ public class PlayerAttributeTracker {
}
// DEFENSIVE MAGIC
Map<Integer, Float> magicDefFlat = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_DEFENSE_KEY);
Map<Integer, Float> magicDefFlat = AttributeItemUtil.readMagicAttributeMap(piece, CustomAttributes.MAGIC_DEFENSE_KEY);
for (Entry<Integer, Float> entry : magicDefFlat.entrySet()) {
int magicId = entry.getKey();
float value = entry.getValue();
magicDefense.put(magicId, magicDefense.getOrDefault(magicId, 0.0f) + value);
}
Map<Integer, Float> magicResist = ItemAttributeHelper.readMagicAttributeMap(piece, ModAttributes.MAGIC_RESISTANCE_KEY);
Map<Integer, Float> magicResist = AttributeItemUtil.readMagicAttributeMap(piece, CustomAttributes.MAGIC_RESISTANCE_KEY);
for (Entry<Integer, Float> entry : magicResist.entrySet()) {
int magicId = entry.getKey();
float value = entry.getValue();
@@ -100,8 +106,8 @@ public class PlayerAttributeTracker {
}
}
equipmentTracker = currentEquip;
maximumOutput = AttributeAttackHelper.calculateMaximumOutput(this);
extraHealth = getAttributeValue(ModAttributes.HEALTH);
maximumOutput = AttributeAttackUtil.calculateMaximumOutput(this);
extraHealth = getAttributeValue(CustomAttributes.HEALTH);
updatePlayerMaxHealth(player);
}
@@ -1,9 +1,9 @@
package noppes.npcs.attribute.player;
package kamkeel.npcs.controllers.data.attribute.tracker;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.attribute.ItemAttributeHelper;
import kamkeel.npcs.util.AttributeItemUtil;
public class PlayerEquipmentTracker {
public ItemStack heldItem;
@@ -57,10 +57,10 @@ public class PlayerEquipmentTracker {
if (a.getItem() != b.getItem()) return false;
NBTTagCompound tagA = a.stackTagCompound;
NBTTagCompound tagB = b.stackTagCompound;
String attrA = (tagA != null && tagA.hasKey(ItemAttributeHelper.RPGItemAttributes))
? tagA.getCompoundTag(ItemAttributeHelper.RPGItemAttributes).toString() : "";
String attrB = (tagB != null && tagB.hasKey(ItemAttributeHelper.RPGItemAttributes))
? tagB.getCompoundTag(ItemAttributeHelper.RPGItemAttributes).toString() : "";
String attrA = (tagA != null && tagA.hasKey(AttributeItemUtil.RPGItemAttributes))
? tagA.getCompoundTag(AttributeItemUtil.RPGItemAttributes).toString() : "";
String attrB = (tagB != null && tagB.hasKey(AttributeItemUtil.RPGItemAttributes))
? tagB.getCompoundTag(AttributeItemUtil.RPGItemAttributes).toString() : "";
return attrA.equals(attrB);
}
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
import kamkeel.npcs.controllers.SyncController;
import net.minecraft.entity.player.EntityPlayer;
@@ -58,15 +58,15 @@ public class CNPCData implements IProfileData {
}
@Override
public List<InfoEntry> getInfo(EntityPlayer player, NBTTagCompound compound) {
public List<ProfileInfoEntry> getInfo(EntityPlayer player, NBTTagCompound compound) {
PlayerData playerData = new PlayerData();
playerData.player = player;
playerData.setNBT(compound);
List<InfoEntry> info = new ArrayList<>();
info.add(new InfoEntry("profile.info.quest.finished", 0x60fa57, playerData.questData.finishedQuests.size(), 0xFFFFFF));
info.add(new InfoEntry("profile.info.quest.active", 0xf75336, playerData.questData.activeQuests.size(), 0xFFFFFF));
info.add(new InfoEntry("profile.info.dialog.read", 0x47acf5, playerData.dialogData.dialogsRead.size(), 0xFFFFFF));
List<ProfileInfoEntry> info = new ArrayList<>();
info.add(new ProfileInfoEntry("profile.info.quest.finished", 0x60fa57, playerData.questData.finishedQuests.size(), 0xFFFFFF));
info.add(new ProfileInfoEntry("profile.info.quest.active", 0xf75336, playerData.questData.activeQuests.size(), 0xFFFFFF));
info.add(new ProfileInfoEntry("profile.info.dialog.read", 0x47acf5, playerData.dialogData.dialogsRead.size(), 0xFFFFFF));
return info;
}
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
public enum EnumProfileOperation {
SUCCESS,
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@@ -48,5 +48,5 @@ public interface IProfileData {
* @param compound The NBT data from the slot under this profile data's tag.
* @return A list of InfoEntry with information
*/
public List<InfoEntry> getInfo(EntityPlayer player, NBTTagCompound compound);
public List<ProfileInfoEntry> getInfo(EntityPlayer player, NBTTagCompound compound);
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@@ -1,27 +1,27 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
import net.minecraft.nbt.NBTTagCompound;
public class InfoEntry {
public class ProfileInfoEntry {
private String label;
private String result;
private int labelColor;
private int resultColor;
public InfoEntry() {}
public ProfileInfoEntry() {}
public InfoEntry(String label, int labelColor, String result, int resultColor) {
public ProfileInfoEntry(String label, int labelColor, String result, int resultColor) {
this.label = label;
this.result = result;
this.labelColor = labelColor;
this.resultColor = resultColor;
}
public InfoEntry(String label, int labelColor, int result, int resultColor) {
public ProfileInfoEntry(String label, int labelColor, int result, int resultColor) {
this(label, labelColor, String.valueOf(result), resultColor);
}
public InfoEntry(String label, String result) {
public ProfileInfoEntry(String label, String result) {
this(label, 0xFFFFFF, result, 0xFFFFFF);
}
@@ -34,8 +34,8 @@ public class InfoEntry {
return tag;
}
public static InfoEntry readFromNBT(NBTTagCompound tag) {
return new InfoEntry(
public static ProfileInfoEntry readFromNBT(NBTTagCompound tag) {
return new ProfileInfoEntry(
tag.getString("Label"),
tag.getInteger("LabelColor"),
tag.getString("Result"),
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
public class ProfileOperation {
private final EnumProfileOperation result;
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data;
package kamkeel.npcs.controllers.data.profile;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.ISlot;
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
@@ -4,8 +4,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
@@ -5,8 +5,8 @@ import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.ProfileController;
import noppes.npcs.api.handler.data.ISlot;
import kamkeel.npcs.controllers.data.InfoEntry;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
@@ -64,9 +64,9 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
NBTTagCompound slotCompound = new NBTTagCompound();
NBTTagList infoList = new NBTTagList();
slotCompound.setInteger("ID", slot.getId());
List<InfoEntry> profileInfo = ProfileController.Instance.getProfileInfo(player, slot.getId());
for(InfoEntry infoEntry : profileInfo){
infoList.appendTag(infoEntry.writeToNBT());
List<ProfileInfoEntry> profileInfo = ProfileController.Instance.getProfileInfo(player, slot.getId());
for(ProfileInfoEntry profileInfoEntry : profileInfo){
infoList.appendTag(profileInfoEntry.writeToNBT());
}
slotCompound.setTag("INFO", infoList);
slotList.appendTag(slotCompound);
@@ -76,8 +76,8 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
public static HashMap<Integer, List<InfoEntry>> readProfileInfo(NBTTagCompound compound) {
HashMap<Integer, List<InfoEntry>> slotInfoMap = new HashMap<>();
public static HashMap<Integer, List<ProfileInfoEntry>> readProfileInfo(NBTTagCompound compound) {
HashMap<Integer, List<ProfileInfoEntry>> slotInfoMap = new HashMap<>();
if (!compound.getBoolean("PROFILE_INFO")) return slotInfoMap;
@@ -89,10 +89,10 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
int slotId = slotCompound.getInteger("ID");
NBTTagList infoList = slotCompound.getTagList("INFO", Constants.NBT.TAG_COMPOUND);
List<InfoEntry> infoEntries = new ArrayList<>();
List<ProfileInfoEntry> infoEntries = new ArrayList<>();
for (int j = 0; j < infoList.tagCount(); j++) {
NBTTagCompound infoTag = infoList.getCompoundTagAt(j);
infoEntries.add(InfoEntry.readFromNBT(infoTag)); // Convert back to InfoEntry
infoEntries.add(ProfileInfoEntry.readFromNBT(infoTag)); // Convert back to InfoEntry
}
slotInfoMap.put(slotId, infoEntries);
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.ProfileOperation;
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
@@ -4,7 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
@@ -1,16 +1,17 @@
package noppes.npcs.attribute;
package kamkeel.npcs.util;
import kamkeel.npcs.CustomAttributes;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.attribute.player.PlayerAttributeTracker;
import kamkeel.npcs.controllers.data.attribute.tracker.PlayerAttributeTracker;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.Map;
import java.util.Random;
import static noppes.npcs.attribute.AttributeController.getTracker;
import static kamkeel.npcs.controllers.AttributeController.getTracker;
public class AttributeAttackHelper {
public class AttributeAttackUtil {
private static final Random random = new Random();
public static float calculateDamagePlayer(EntityPlayer attacker, EntityPlayer defender, float base){
@@ -20,13 +21,13 @@ public class AttributeAttackHelper {
public static float calculateDamagePlayer(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, float baseDamage) {
// Calculate physical damage
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
float mainBoost = attacker.getAttributeValue(ModAttributes.MAIN_BOOST) + 1;
float mainAttack = attacker.getAttributeValue(CustomAttributes.MAIN_ATTACK);
float mainBoost = attacker.getAttributeValue(CustomAttributes.MAIN_BOOST) + 1;
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
// Calculate neutral damage
float neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
float neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
float neutralDamage = attacker.getAttributeValue(CustomAttributes.NEUTRAL_ATTACK);
float neutralBoost = attacker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST) + 1;
float neutralTotal = neutralDamage * neutralBoost;
// Calculate magic damage
@@ -53,8 +54,8 @@ public class AttributeAttackHelper {
float totalDamage = physicalDamage + neutralTotal + magicTotal;
// Critical hit: if critical, float damage and add bonus
float criticalChance = attacker.getAttributeValue(ModAttributes.CRITICAL_CHANCE);
float criticalBonus = attacker.getAttributeValue(ModAttributes.CRITICAL_DAMAGE);
float criticalChance = attacker.getAttributeValue(CustomAttributes.CRITICAL_CHANCE);
float criticalBonus = attacker.getAttributeValue(CustomAttributes.CRITICAL_DAMAGE);
if (random.nextFloat() < (criticalChance / 100)) {
totalDamage = (totalDamage * 2) + criticalBonus;
}
@@ -65,13 +66,13 @@ public class AttributeAttackHelper {
public static float calculateDamageNPC(PlayerAttributeTracker attacker, EntityNPCInterface defender, float baseDamage) {
// Calculate physical damage
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
float mainBoost = attacker.getAttributeValue(ModAttributes.MAIN_BOOST) + 1;
float mainAttack = attacker.getAttributeValue(CustomAttributes.MAIN_ATTACK);
float mainBoost = attacker.getAttributeValue(CustomAttributes.MAIN_BOOST) + 1;
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
// Calculate neutral damage
float neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
float neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
float neutralDamage = attacker.getAttributeValue(CustomAttributes.NEUTRAL_ATTACK);
float neutralBoost = attacker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST) + 1;
float neutralTotal = neutralDamage * neutralBoost;
// Calculate magic damage
@@ -117,8 +118,8 @@ public class AttributeAttackHelper {
*/
public static float calculateMaximumOutput(PlayerAttributeTracker attacker) {
// Neutral damage remains unchanged.
float neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
float neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
float neutralDamage = attacker.getAttributeValue(CustomAttributes.NEUTRAL_ATTACK);
float neutralBoost = attacker.getAttributeValue(CustomAttributes.NEUTRAL_BOOST) + 1;
float neutralTotal = neutralDamage * neutralBoost;
// For magic damage, we ignore any defensive values.
@@ -145,8 +146,8 @@ public class AttributeAttackHelper {
public static float calculateOutgoing(EntityPlayer entityPlayer, float baseDamage) {
PlayerAttributeTracker attacker = getTracker(entityPlayer);
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
float mainBoost = attacker.getAttributeValue(ModAttributes.MAIN_BOOST) + 1;
float mainAttack = attacker.getAttributeValue(CustomAttributes.MAIN_ATTACK);
float mainBoost = attacker.getAttributeValue(CustomAttributes.MAIN_BOOST) + 1;
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
return attacker.maximumOutput + physicalDamage;
}
@@ -1,12 +1,15 @@
package noppes.npcs.attribute;
package kamkeel.npcs.util;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import kamkeel.npcs.controllers.AttributeController;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import kamkeel.npcs.controllers.data.attribute.AttributeDefinition;
import kamkeel.npcs.controllers.data.attribute.AttributeValueType;
import kamkeel.npcs.CustomAttributes;
import noppes.npcs.client.ClientProxy;
import noppes.npcs.controllers.MagicController;
import noppes.npcs.controllers.data.Magic;
@@ -14,15 +17,12 @@ import org.lwjgl.input.Keyboard;
import java.util.*;
import static noppes.npcs.attribute.AttributeDefinition.AttributeSection.INFO;
import static noppes.npcs.attribute.AttributeDefinition.AttributeSection.MODIFIER;
/**
* 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 ItemAttributeHelper {
public class AttributeItemUtil {
public static final String RPGItemAttributes = "RPGCoreAttributes";
/**
@@ -161,8 +161,8 @@ public class ItemAttributeHelper {
while (iter.hasNext()) {
String key = iter.next();
// Skip magic attribute keys; they are handled separately.
if(key.equals(ModAttributes.MAGIC_DAMAGE_KEY) || key.equals(ModAttributes.MAGIC_BOOST_KEY)
|| key.equals(ModAttributes.MAGIC_DEFENSE_KEY) || key.equals(ModAttributes.MAGIC_RESISTANCE_KEY)) {
if(key.equals(CustomAttributes.MAGIC_DAMAGE_KEY) || key.equals(CustomAttributes.MAGIC_BOOST_KEY)
|| key.equals(CustomAttributes.MAGIC_DEFENSE_KEY) || key.equals(CustomAttributes.MAGIC_RESISTANCE_KEY)) {
continue;
}
Float value = attrTag.getFloat(key);
@@ -212,10 +212,10 @@ public class ItemAttributeHelper {
private static void processMagicAttributes(NBTTagCompound compound, List<String> baseList, List<String> modifierList,
List<String> infoList, List<String> extraList) {
String[] magicKeys = {
ModAttributes.MAGIC_DAMAGE_KEY,
ModAttributes.MAGIC_BOOST_KEY,
ModAttributes.MAGIC_DEFENSE_KEY,
ModAttributes.MAGIC_RESISTANCE_KEY
CustomAttributes.MAGIC_DAMAGE_KEY,
CustomAttributes.MAGIC_BOOST_KEY,
CustomAttributes.MAGIC_DEFENSE_KEY,
CustomAttributes.MAGIC_RESISTANCE_KEY
};
for (String magicKey : magicKeys) {
if (compound.hasKey(magicKey)) {
@@ -260,9 +260,9 @@ public class ItemAttributeHelper {
@SideOnly(Side.CLIENT)
private static String getMagicAppendix(String type){
switch(type){
case ModAttributes.MAGIC_DEFENSE_KEY:
case CustomAttributes.MAGIC_DEFENSE_KEY:
return StatCollector.translateToLocal("rpgcore:attribute.defense");
case ModAttributes.MAGIC_RESISTANCE_KEY:
case CustomAttributes.MAGIC_RESISTANCE_KEY:
return StatCollector.translateToLocal("rpgcore:attribute.resistance");
default:
return StatCollector.translateToLocal("rpgcore:attribute.damage");
+2 -2
View File
@@ -13,7 +13,7 @@ import kamkeel.npcs.addon.AddonManager;
import kamkeel.npcs.command.CommandKamkeel;
import kamkeel.npcs.command.profile.CommandProfile;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.CNPCData;
import kamkeel.npcs.controllers.data.profile.CNPCData;
import kamkeel.npcs.developer.Developer;
import kamkeel.npcs.network.PacketHandler;
import net.minecraft.block.Block;
@@ -27,7 +27,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.MinecraftForge;
import nikedemos.markovnames.generators.*;
import noppes.npcs.attribute.AttributeController;
import kamkeel.npcs.controllers.AttributeController;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.LoadConfiguration;
@@ -23,9 +23,8 @@ 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.AttributeController;
import noppes.npcs.attribute.AttributeAttackHelper;
import noppes.npcs.attribute.player.PlayerAttributeTracker;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.util.AttributeAttackUtil;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.CustomEffectController;
@@ -478,7 +477,7 @@ public class ScriptPlayerEventHandler {
if(event.source.getEntity() instanceof EntityPlayer) {
float attackAmount = event.ammount;
if(ConfigMain.AttributesEnabled)
attackAmount = AttributeAttackHelper.calculateOutgoing((EntityPlayer) event.source.getEntity(), event.ammount);
attackAmount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) event.source.getEntity(), event.ammount);
noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, attackAmount, event.source);
cancel = cancel || EventHooks.onPlayerAttack(handler, pevent1);
@@ -500,9 +499,9 @@ public class ScriptPlayerEventHandler {
// Player to Player Interaction
if(ConfigMain.AttributesEnabled){
if(event.entityLiving instanceof EntityPlayer && source instanceof EntityPlayer){
event.ammount = AttributeAttackHelper.calculateDamagePlayer((EntityPlayer) event.entityLiving, (EntityPlayer) source, event.ammount);
event.ammount = AttributeAttackUtil.calculateDamagePlayer((EntityPlayer) event.entityLiving, (EntityPlayer) source, event.ammount);
} else if (!(event.entityLiving instanceof EntityNPCInterface) && source instanceof EntityPlayer){
event.ammount = AttributeAttackHelper.calculateOutgoing((EntityPlayer) event.entityLiving, event.ammount);
event.ammount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) event.entityLiving, event.ammount);
}
}
@@ -1,9 +1,9 @@
package noppes.npcs.client.gui.player.inventory;
import noppes.npcs.api.handler.data.ISlot;
import kamkeel.npcs.controllers.data.InfoEntry;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.Slot;
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.controllers.data.profile.Slot;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.profile.*;
import net.minecraft.client.gui.GuiButton;
@@ -36,7 +36,7 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC
private String rename;
private Profile profile;
private Slot slot;
private HashMap<Integer, List<InfoEntry>> slotInfoMap = new HashMap<>();
private HashMap<Integer, List<ProfileInfoEntry>> slotInfoMap = new HashMap<>();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/yyyy HH:mm");
private int scrollY = 0; // Vertical scrolling position
@@ -182,8 +182,8 @@ public class GuiProfiles extends GuiCNPCInventory implements ISubGuiListener, IC
}
if (slotInfoMap.containsKey(slot.getId())) {
List<InfoEntry> infoEntries = slotInfoMap.get(slot.getId());
for (InfoEntry entry : infoEntries) {
List<ProfileInfoEntry> infoEntries = slotInfoMap.get(slot.getId());
for (ProfileInfoEntry entry : infoEntries) {
label = StatCollector.translateToLocal(entry.getLabel());
result = StatCollector.translateToLocal(entry.getResult());
labelColor = entry.getLabelColor();
@@ -2,7 +2,7 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.addon.DBCAddon;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.network.packets.data.AchievementPacket;
import kamkeel.npcs.network.packets.data.ChatAlertPacket;
import kamkeel.npcs.network.packets.request.party.PartyInvitePacket;
@@ -2,7 +2,7 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.controllers.ProfileController;
import noppes.npcs.api.handler.data.ISlot;
import kamkeel.npcs.controllers.data.Profile;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.network.packets.data.QuestCompletionPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -3,7 +3,7 @@ package noppes.npcs.mixin;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.attribute.ItemAttributeHelper;
import kamkeel.npcs.util.AttributeItemUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import static noppes.npcs.attribute.ItemAttributeHelper.RPGItemAttributes;
import static kamkeel.npcs.util.AttributeItemUtil.RPGItemAttributes;
@Mixin(ItemStack.class)
public abstract class MixinItemStack {
@@ -29,7 +29,7 @@ public abstract class MixinItemStack {
public void getAttributeTooltip(EntityPlayer player, boolean advanced, CallbackInfoReturnable<List<String>> cir) {
List<String> tooltip = cir.getReturnValue();
if (hasTagCompound() && getTagCompound().hasKey(RPGItemAttributes)) {
cir.setReturnValue(ItemAttributeHelper.getToolTip(tooltip, getTagCompound()));
cir.setReturnValue(AttributeItemUtil.getToolTip(tooltip, getTagCompound()));
}
}
}