More Core Class Conversion

This commit is contained in:
Kam committed 2026-03-13 16:59:00 -04:00
1 parent 27a9e4c808
commit 79b63efa19
36 files changed
+420 -102

No files matched your search

@@ -1,9 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
public enum AbilityPhase {
IDLE, // Not executing
WINDUP, // Charging up (telegraph visible)
ACTIVE, // Executing (damage happens)
DAZED, // Stunned after interrupt during WINDUP (cannot attack)
BURST_DELAY // Waiting between burst repetitions (free movement/rotation)
}
@@ -1,71 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines anchor points for ability charging effects.
* Determines where the charging visual (orb, disc, etc.) appears relative to the entity.
*/
public enum AnchorPoint {
FRONT("Front"), // In front of entity face (default)
CENTER("Center"), // Entity center
RIGHT_HAND("Right Hand"), // Right arm/hand position
LEFT_HAND("Left Hand"), // Left arm/hand position
ABOVE_HEAD("Above Head"), // Above the entity
CHEST("Chest"), // Chest level, centered
EYE("Eye"); // Eye level, centered
private final String displayName;
AnchorPoint(String displayName) {
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
/**
* Get AnchorPoint from ordinal value.
* Returns FRONT if ordinal is out of bounds.
*/
public static AnchorPoint fromOrdinal(int ordinal) {
AnchorPoint[] vals = values();
if (ordinal < 0 || ordinal >= vals.length) {
return FRONT;
}
return vals[ordinal];
}
/**
* Get all display names for GUI dropdowns.
*/
public static String[] getDisplayNames() {
AnchorPoint[] values = values();
String[] names = new String[values.length];
for (int i = 0; i < values.length; i++) {
names[i] = values[i].displayName;
}
return names;
}
@Override
public String toString() {
switch (this) {
case FRONT:
return "ability.anchor.front";
case CENTER:
return "ability.anchor.center";
case RIGHT_HAND:
return "ability.anchor.rightHand";
case LEFT_HAND:
return "ability.anchor.leftHand";
case ABOVE_HEAD:
return "ability.anchor.aboveHead";
case CHEST:
return "ability.anchor.chest";
case EYE:
return "ability.anchor.eye";
default:
return name();
}
}
}
@@ -1,32 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Shared hit behavior for energy projectiles.
*/
public enum HitType {
SINGLE,
PIERCE,
MULTI;
public static HitType fromOrdinal(int ordinal) {
HitType[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return SINGLE;
}
@Override
public String toString() {
switch (this) {
case SINGLE:
return "ability.hitType.single";
case PIERCE:
return "ability.hitType.pierce";
case MULTI:
return "ability.hitType.multi";
default:
return name();
}
}
}
@@ -1,66 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines when a caster is invulnerable while an ability is executing.
*/
public enum InvulnerableMode {
NONE,
WINDUP,
ACTIVE,
BOTH;
public boolean invulnerableDuringWindup() {
return this == WINDUP || this == BOTH;
}
public boolean invulnerableDuringActive() {
return this == ACTIVE || this == BOTH;
}
/**
* Treat BURST_DELAY as windup-like for interruption/damage immunity checks.
*/
public boolean isInvulnerableInPhase(AbilityPhase phase) {
if (phase == null) return false;
switch (phase) {
case WINDUP:
case BURST_DELAY:
return invulnerableDuringWindup();
case ACTIVE:
return invulnerableDuringActive();
default:
return false;
}
}
public String getDisplayKey() {
switch (this) {
case WINDUP:
return "ability.invulnerable.windup";
case ACTIVE:
return "ability.invulnerable.active";
case BOTH:
return "ability.invulnerable.both";
case NONE:
default:
return "ability.invulnerable.none";
}
}
public static String[] getDisplayKeys() {
return new String[]{
"ability.invulnerable.none",
"ability.invulnerable.windup",
"ability.invulnerable.active",
"ability.invulnerable.both"
};
}
public static InvulnerableMode fromOrdinal(int ordinal) {
InvulnerableMode[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return NONE;
}
}
@@ -1,83 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines when an ability locks NPC movement and rotation.
*/
public enum LockMode {
/**
* No movement lock - NPC can move freely during both phases.
*/
NO,
/**
* Lock movement during WINDUP phase only.
* NPC can move during ACTIVE phase.
*/
WINDUP,
/**
* Lock movement during ACTIVE phase only.
* NPC can move during WINDUP phase.
*/
ACTIVE,
/**
* Lock movement during both WINDUP and ACTIVE phases.
*/
WINDUP_AND_ACTIVE;
/**
* Check if movement should be locked during WINDUP phase.
*/
public boolean locksWindup() {
return this == WINDUP || this == WINDUP_AND_ACTIVE;
}
/**
* Check if movement should be locked during ACTIVE phase.
*/
public boolean locksActive() {
return this == ACTIVE || this == WINDUP_AND_ACTIVE;
}
/**
* Get display name for GUI.
*/
public String getDisplayKey() {
switch (this) {
case NO:
return "gui.no";
case WINDUP:
return "ability.lockMove.windup";
case ACTIVE:
return "ability.lockMove.active";
case WINDUP_AND_ACTIVE:
return "ability.lockMove.both";
default:
return "gui.no";
}
}
/**
* Get all display keys for GUI dropdown.
*/
public static String[] getDisplayKeys() {
return new String[]{
"gui.no",
"ability.lockMove.windup",
"ability.lockMove.active",
"ability.lockMove.both"
};
}
/**
* Get LockMode from ordinal, with fallback to WINDUP.
*/
public static LockMode fromOrdinal(int ordinal) {
LockMode[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return WINDUP;
}
}
@@ -1,53 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines what happens to NPC rotation during ability phases.
* Used with a LockMode to control WHEN it applies.
*/
public enum RotationMode {
/**
* NPC rotates normally via AI look helper.
*/
FREE,
/**
* Freeze rotation at the moment the phase starts.
* NPC stays facing the direction it was looking when the phase began.
*/
LOCKED,
/**
* Force NPC to continuously face its target (hit scan).
* Overrides AI look helper every tick for precise aiming.
*/
TRACK;
public String getDisplayKey() {
switch (this) {
case FREE:
return "ability.rotation.free";
case LOCKED:
return "ability.rotation.locked";
case TRACK:
return "ability.rotation.track";
default:
return "ability.rotation.free";
}
}
public static String[] getDisplayKeys() {
return new String[]{
"ability.rotation.free",
"ability.rotation.locked",
"ability.rotation.track"
};
}
public static RotationMode fromOrdinal(int ordinal) {
RotationMode[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return FREE;
}
}
@@ -1,32 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Filter for determining which entities an ability should affect in AOE mode.
*/
public enum TargetFilter {
ALLIES,
ENEMIES,
ALL;
@Override
public String toString() {
switch (this) {
case ALLIES:
return "ability.targetFilter.allies";
case ENEMIES:
return "ability.targetFilter.enemies";
case ALL:
return "ability.targetFilter.all";
default:
return name();
}
}
public static TargetFilter fromString(String name) {
try {
return valueOf(name);
} catch (Exception e) {
return ALLIES;
}
}
}
@@ -1,42 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines how an ability selects its target(s).
*/
public enum TargetingMode {
/**
* Target the current aggro target
*/
AGGRO_TARGET,
/**
* Target self (for buffs, heals, guards)
*/
SELF,
/**
* AOE centered on self
*/
AOE_SELF,
/**
* AOE centered on target
*/
AOE_TARGET;
@Override
public String toString() {
switch (this) {
case AGGRO_TARGET:
return "ability.target.aggro_target";
case SELF:
return "ability.target.self";
case AOE_SELF:
return "ability.target.aoe_self";
case AOE_TARGET:
return "ability.target.aoe_target";
default:
return name();
}
}
}
@@ -1,27 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines which entity types can use an ability.
*/
public enum UserType {
NPC_ONLY,
PLAYER_ONLY,
BOTH,
NONE;
public boolean allowsNpc() {
return this == NPC_ONLY || this == BOTH;
}
public boolean allowsPlayer() {
return this == PLAYER_ONLY || this == BOTH;
}
public static UserType fromOrdinal(int ordinal) {
UserType[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return BOTH;
}
}
@@ -1,57 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
import noppes.npcs.api.handler.data.IAttributeDefinition;
public class AttributeDefinition implements IAttributeDefinition {
private final String key;
private String translationKey;// e.g., "main_attack_flat"
private final String displayName; // Human‑readable name
private final char colorCode;
private final AttributeValueType attributeValueType;
private final AttributeSection section;
public AttributeDefinition(String key, String displayName, char colorCode, AttributeValueType attributeValueType, AttributeSection section) {
this.key = key;
this.translationKey = "rpgcore:attribute." + key;
this.displayName = displayName;
this.attributeValueType = attributeValueType;
this.section = section;
this.colorCode = colorCode;
}
public String getKey() {
return key;
}
public String getDisplayName() {
return displayName;
}
public String getTranslationKey() {
return translationKey;
}
public void setTranslationKey(String translationKey) {
this.translationKey = translationKey;
}
public AttributeValueType getValueType() {
return attributeValueType;
}
public AttributeSection getSection() {
return section;
}
public char getColorCode() {
return colorCode;
}
public enum AttributeSection {
BASE,
MODIFIER,
STATS,
INFO,
EXTRA
}
}
@@ -1,7 +0,0 @@
package kamkeel.npcs.controllers.data.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 float)
}
@@ -1,24 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
import noppes.npcs.api.handler.data.ICustomAttribute;
public class PlayerAttribute implements ICustomAttribute {
private final AttributeDefinition attribute;
public float value;
public PlayerAttribute(AttributeDefinition attribute, float value) {
this.attribute = attribute;
this.value = value;
}
@Override
public AttributeDefinition getAttribute() {
return attribute;
}
@Override
public float getValue() {
return value;
}
}
@@ -1,24 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
import java.util.HashMap;
import java.util.Map;
/**
* CustomAttributeMap holds a set of attribute instances for an entity (or item).
*/
public class PlayerAttributeMap {
public final Map<AttributeDefinition, PlayerAttribute> map = new HashMap<>();
public PlayerAttribute registerAttribute(AttributeDefinition attribute, float baseValue) {
if (map.containsKey(attribute)) {
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
}
PlayerAttribute instance = new PlayerAttribute(attribute, baseValue);
map.put(attribute, instance);
return instance;
}
public PlayerAttribute getAttributeInstance(AttributeDefinition attribute) {
return map.get(attribute);
}
}
@@ -1,7 +0,0 @@
package kamkeel.npcs.controllers.data.profile;
public enum EnumProfileOperation {
SUCCESS,
ERROR,
LOCKED
}
@@ -1,62 +0,0 @@
package kamkeel.npcs.controllers.data.profile;
import net.minecraft.nbt.NBTTagCompound;
public class ProfileInfoEntry {
private String label;
private String result;
private int labelColor;
private int resultColor;
public ProfileInfoEntry() {
}
public ProfileInfoEntry(String label, int labelColor, String result, int resultColor) {
this.label = label;
this.result = result;
this.labelColor = labelColor;
this.resultColor = resultColor;
}
public ProfileInfoEntry(String label, int labelColor, int result, int resultColor) {
this(label, labelColor, String.valueOf(result), resultColor);
}
public ProfileInfoEntry(String label, String result) {
this(label, 0xFFFFFF, result, 0xFFFFFF);
}
public NBTTagCompound writeToNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("Label", label);
tag.setInteger("LabelColor", labelColor);
tag.setString("Result", result);
tag.setInteger("ResultColor", resultColor);
return tag;
}
public static ProfileInfoEntry readFromNBT(NBTTagCompound tag) {
return new ProfileInfoEntry(
tag.getString("Label"),
tag.getInteger("LabelColor"),
tag.getString("Result"),
tag.getInteger("ResultColor")
);
}
public String getLabel() {
return label;
}
public String getResult() {
return result;
}
public int getLabelColor() {
return labelColor;
}
public int getResultColor() {
return resultColor;
}
}
@@ -1,41 +0,0 @@
package kamkeel.npcs.controllers.data.telegraph;
/**
* Types of telegraph shapes for visual attack warnings.
*/
public enum TelegraphType {
/**
* Filled circle (uses radius)
*/
CIRCLE,
/**
* Donut shape (uses radius and innerRadius)
*/
RING,
/**
* Rectangle (uses length, width)
*/
LINE,
/**
* Fan/wedge shape (uses length, angle)
*/
CONE,
/**
* Single point indicator
*/
POINT,
/**
* Filled square (uses radius as half-size)
*/
SQUARE,
/**
* No telegraph
*/
NONE
}
@@ -7,6 +7,7 @@ import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
import kamkeel.npcs.network.AbstractPacket;
import noppes.npcs.wrapper.nbt.MC1710NBTCompound;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
@@ -72,7 +73,7 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
slotCompound.setInteger("ID", slot.getId());
List<ProfileInfoEntry> profileInfo = ProfileController.Instance.getProfileInfo(player, slot.getId());
for (ProfileInfoEntry profileInfoEntry : profileInfo) {
infoList.appendTag(profileInfoEntry.writeToNBT());
infoList.appendTag(((MC1710NBTCompound) profileInfoEntry.writeToNBT()).getMCTag());
}
slotCompound.setTag("INFO", infoList);
slotList.appendTag(slotCompound);
@@ -98,7 +99,7 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
List<ProfileInfoEntry> infoEntries = new ArrayList<>();
for (int j = 0; j < infoList.tagCount(); j++) {
NBTTagCompound infoTag = infoList.getCompoundTagAt(j);
infoEntries.add(ProfileInfoEntry.readFromNBT(infoTag)); // Convert back to InfoEntry
infoEntries.add(ProfileInfoEntry.readFromNBT(new MC1710NBTCompound(infoTag))); // Convert back to InfoEntry
}
slotInfoMap.put(slotId, infoEntries);
@@ -1,97 +0,0 @@
package kamkeel.npcs.util;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* Utility helpers for filename-safe ability/chained names.
* Allowed characters are letters, digits, underscore, and dash.
*/
public final class FileNameHelper {
private static final Set<String> WINDOWS_RESERVED_NAMES = new HashSet<String>(Arrays.asList(
"CON", "PRN", "AUX", "NUL",
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
));
private FileNameHelper() {
}
/**
* Sanitize a name to a filename-safe identifier.
* Whitespace becomes underscores; unsupported chars are removed.
*/
public static String sanitizeName(String input, String fallback) {
String sanitized = sanitizeInternal(input);
if (sanitized.isEmpty()) {
sanitized = sanitizeInternal(fallback);
}
if (sanitized.isEmpty()) {
sanitized = "Ability";
}
if (isReservedWindowsName(sanitized)) {
sanitized = "_" + sanitized;
}
return sanitized;
}
/**
* Sanitize textfield input without forcing a fallback.
*/
public static String sanitizeTextInput(String input) {
return sanitizeInternal(input);
}
/**
* Quick check for compatibility with sanitized identifier rules.
*/
public static boolean isFileNameCompatible(String value) {
if (value == null || value.isEmpty()) return false;
if (isReservedWindowsName(value)) return false;
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!Character.isLetterOrDigit(c) && c != '_' && c != '-') {
return false;
}
}
return true;
}
/**
* Human-readable fallback display text for sanitized names.
*/
public static String toDisplayName(String value) {
if (value == null || value.isEmpty()) return "";
return value.replace('_', ' ');
}
private static String sanitizeInternal(String raw) {
if (raw == null) return "";
String trimmed = raw.trim();
if (trimmed.isEmpty()) return "";
StringBuilder out = new StringBuilder(trimmed.length());
for (int i = 0; i < trimmed.length(); i++) {
char c = trimmed.charAt(i);
if (Character.isLetterOrDigit(c)) {
out.append(c);
} else if (c == '_' || c == '-') {
out.append(c);
} else if (Character.isWhitespace(c)) {
if (out.length() == 0) continue;
char last = out.charAt(out.length() - 1);
if (last == '_') continue;
out.append('_');
}
}
return out.toString();
}
private static boolean isReservedWindowsName(String value) {
return WINDOWS_RESERVED_NAMES.contains(value.toUpperCase());
}
}
@@ -1,40 +0,0 @@
package kamkeel.npcs.util;
import java.util.ArrayList;
import java.util.List;
public class TextSplitter {
public static List<String> splitText(String input, int maxSegmentLength) {
List<String> result = new ArrayList<>();
while (input.length() > maxSegmentLength) {
int spaceIndex = input.lastIndexOf(" ", maxSegmentLength);
if (spaceIndex == -1) {
// No space found within the maxSegmentLength, so split at the exact length.
result.add(input.substring(0, maxSegmentLength));
input = input.substring(maxSegmentLength);
} else {
// Split at the last space within maxSegmentLength.
result.add(input.substring(0, spaceIndex));
input = input.substring(spaceIndex + 1); // Skip the space.
}
}
if (!input.isEmpty()) {
result.add(input);
}
return result;
}
public static void main(String[] args) {
String longText = "This is a very long string that needs to be split into multiple lines based on a maximum line length of 30 characters.";
int maxLineLength = 30;
List<String> lines = splitText(longText, maxLineLength);
for (String line : lines) {
System.out.println(line);
}
}
}
@@ -165,6 +165,7 @@ public class ClientEventHandler {
}
ClientEventHandler.renderer = event.renderer;
ClientEventHandler.partialRenderTick = Minecraft.getMinecraft().timer.renderPartialTicks;
FramePart.renderPartialTick = ClientEventHandler.partialRenderTick;
this.setOriginalPlayerParts(event.entity);
}
@@ -195,7 +195,8 @@ public class GuiAnimationDirectory extends GuiDirectoryCategorized {
data.animation.loop = 0;
if (!animation.frames.isEmpty()) {
Frame firstFrame = new Frame();
firstFrame.parent = data.animation;
firstFrame.parentSpeed = data.animation.speed;
firstFrame.parentSmooth = data.animation.smooth;
firstFrame.readFromNBT(animation.frames.get(0).writeToNBT());
data.animation.addFrame(firstFrame);
}
@@ -113,14 +113,15 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
for (Frame frame : animation.frames) {
frame.parent = animation;
frame.parentSpeed = animation.speed;
frame.parentSmooth = animation.smooth;
if (!frame.isCustomized()) {
frame.speed = animation.speed;
frame.smooth = animation.smooth;
}
for (Map.Entry<EnumAnimationPart, FramePart> entry : frame.frameParts.entrySet()) {
FramePart part = entry.getValue();
part.parent = animation;
part.paused = animation.paused;
if (!part.isCustomized()) {
part.speed = frame.speed;
part.smooth = frame.smooth;
@@ -675,7 +676,8 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
case 47:
if (copiedFrame != null) {
Frame frame = new Frame(10);
frame.parent = this.animation;
frame.parentSpeed = this.animation.speed;
frame.parentSmooth = this.animation.smooth;
frame.readFromNBT(copiedFrame.writeToNBT());
this.addFrame(frame);
this.initGui();
@@ -116,7 +116,8 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
if (this.animation.frames.size() > 0) {
Frame firstFrame = new Frame();
firstFrame.parent = data.animation;
firstFrame.parentSpeed = data.animation.speed;
firstFrame.parentSmooth = data.animation.smooth;
firstFrame.readFromNBT(this.animation.frames.get(0).writeToNBT());
data.animation.addFrame(firstFrame);
}
@@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.EventHooks;
import noppes.npcs.wrapper.nbt.MC1710NBTCompound;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.api.handler.data.IAnimationData;
import noppes.npcs.api.handler.data.IFrame;
@@ -223,8 +224,9 @@ public class Animation implements IAnimation {
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
Frame frame = new Frame();
frame.parent = this;
frame.readFromNBT(item);
frame.parentSpeed = this.speed;
frame.parentSmooth = this.smooth;
frame.readFromNBT(new MC1710NBTCompound(item));
frames.add(frame);
}
this.frames = frames;
@@ -247,7 +249,7 @@ public class Animation implements IAnimation {
NBTTagList list = new NBTTagList();
for (Frame frame : frames) {
NBTTagCompound item = frame.writeToNBT();
NBTTagCompound item = ((MC1710NBTCompound) frame.writeToNBT()).getMCTag();
list.appendTag(item);
}
compound.setTag("Frames", list);
@@ -2,6 +2,7 @@ package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.wrapper.nbt.MC1710NBTCompound;
/**
* A read-only animation loaded from mod assets.
@@ -78,8 +79,9 @@ public class BuiltInAnimation extends Animation {
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
Frame frame = new Frame();
frame.parent = this;
frame.readFromNBT(item);
frame.parentSpeed = this.speed;
frame.parentSmooth = this.smooth;
frame.readFromNBT(new MC1710NBTCompound(item));
frames.add(frame);
}
@@ -1,197 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.api.handler.data.IFrame;
import noppes.npcs.api.handler.data.IFramePart;
import noppes.npcs.constants.EnumAnimationPart;
import java.util.HashMap;
import java.util.Map;
public class Frame implements IFrame {
public Animation parent;
public HashMap<EnumAnimationPart, FramePart> frameParts = new HashMap<>();
public int duration = 0;
boolean customized = false;
public float speed = 1.0F;
public byte smooth = 0;
private int colorMarker = 0xFFFFFF;
private String comment = "";
public Frame() {
}
public Frame(int duration) {
this.duration = duration;
}
public Frame(int duration, float speed, byte smooth) {
this.duration = duration;
this.speed = speed;
this.smooth = smooth;
this.customized = true;
}
public HashMap<EnumAnimationPart, FramePart> getFrameMap() {
return frameParts;
}
public IFramePart[] getParts() {
return frameParts.values().toArray(new IFramePart[0]);
}
public IFrame addPart(IFramePart partConfig) {
this.frameParts.put(((FramePart) partConfig).getPart(), (FramePart) partConfig);
return this;
}
public IFrame removePart(String partName) {
try {
this.frameParts.remove(EnumAnimationPart.valueOf(partName));
} catch (IllegalArgumentException ignored) {
}
return this;
}
public IFrame removePart(int partId) {
for (EnumAnimationPart part : EnumAnimationPart.values()) {
this.frameParts.remove(part);
}
return this;
}
public IFrame clearParts() {
frameParts.clear();
return this;
}
public int getDuration() {
return duration;
}
public IFrame setDuration(int duration) {
this.duration = duration;
return this;
}
public boolean isCustomized() {
return customized;
}
public IFrame setCustomized(boolean customized) {
this.customized = customized;
return this;
}
public float getSpeed() {
return speed;
}
public IFrame setSpeed(float speed) {
this.speed = speed;
return this;
}
public byte smoothType() {
return smooth;
}
public IFrame setSmooth(byte smooth) {
this.smooth = smooth;
return this;
}
public int getColorMarker() {
return this.colorMarker;
}
public void setColorMarker(int color) {
this.colorMarker = color;
}
public String getComment() {
return this.comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public void readFromNBT(NBTTagCompound compound) {
duration = compound.getInteger("Duration");
if (compound.hasKey("ColorMarker")) {
this.setColorMarker(compound.getInteger("ColorMarker"));
}
if (compound.hasKey("Comment")) {
this.comment = compound.getString("Comment");
}
// Customized = TRUE if Speed or Smooth Exist
if (compound.hasKey("Speed")) {
customized = true;
speed = compound.getFloat("Speed");
}
if (compound.hasKey("Smooth")) {
customized = true;
smooth = compound.getByte("Smooth");
}
if (!customized && parent != null) {
this.speed = parent.speed;
this.smooth = parent.smooth;
}
HashMap<EnumAnimationPart, FramePart> frameParts = new HashMap<>();
NBTTagList list = compound.getTagList("FrameParts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
FramePart framePart = new FramePart();
framePart.readFromNBT(item);
if (!framePart.customized) {
framePart.smooth = this.smooth;
framePart.speed = this.speed;
}
frameParts.put(framePart.part, framePart);
}
this.frameParts = frameParts;
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("Duration", duration);
compound.setInteger("ColorMarker", this.colorMarker);
compound.setString("Comment", this.comment);
if (customized) {
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
}
NBTTagList list = new NBTTagList();
for (FramePart framePart : frameParts.values()) {
NBTTagCompound item = framePart.writeToNBT();
list.appendTag(item);
}
compound.setTag("FrameParts", list);
return compound;
}
public Frame copy() {
Frame frame = new Frame(this.duration);
HashMap<EnumAnimationPart, FramePart> frameParts = this.frameParts;
for (Map.Entry<EnumAnimationPart, FramePart> entry : frameParts.entrySet()) {
frame.frameParts.put(entry.getKey(), entry.getValue().copy());
}
frame.parent = this.parent;
frame.duration = this.duration;
frame.customized = this.customized;
frame.speed = this.speed;
frame.smooth = this.smooth;
frame.colorMarker = this.colorMarker;
return frame;
}
}
@@ -1,241 +0,0 @@
package noppes.npcs.controllers.data;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.data.IFramePart;
import noppes.npcs.client.ClientEventHandler;
import noppes.npcs.constants.EnumAnimationPart;
public class FramePart implements IFramePart {
public Animation parent;
public EnumAnimationPart part;
public float[] rotation = {0, 0, 0};
public float[] pivot = {0, 0, 0};
boolean customized = false;
public float speed = 1.0F;
//0 - Interpolated, 1 - Linear, 2 - None
public byte smooth = 0;
//Client-sided fields (unsaved)
public float[] prevRotations = {0, 0, 0};
public float[] prevPivots = {0, 0, 0};
public float partialRotationTick;
public float partialPivotTick;
public FramePart() {
}
public FramePart(EnumAnimationPart part) {
this.part = part;
}
public EnumAnimationPart getPart() {
return part;
}
public String getName() {
return part.name();
}
public int getPartId() {
return part.ordinal();
}
public void setPart(EnumAnimationPart part) {
this.part = part;
}
public IFramePart setPart(String name) {
try {
this.setPart(EnumAnimationPart.valueOf(name));
} catch (IllegalArgumentException ignored) {
}
return this;
}
public IFramePart setPart(int partId) {
for (EnumAnimationPart enumPart : EnumAnimationPart.values()) {
if (enumPart.ordinal() == partId) {
this.setPart(enumPart);
break;
}
}
return this;
}
public float[] getRotations() {
return rotation;
}
public IFramePart setRotations(float[] rotation) {
this.rotation = rotation;
return this;
}
public float[] getPivots() {
return pivot;
}
public IFramePart setPivots(float[] pivot) {
this.pivot = pivot;
return this;
}
public boolean isCustomized() {
return customized;
}
public IFramePart setCustomized(boolean customized) {
this.customized = customized;
return this;
}
public float getSpeed() {
return speed;
}
public IFramePart setSpeed(float speed) {
this.speed = speed;
return this;
}
public byte isSmooth() {
return smooth;
}
public IFramePart setSmooth(byte smooth) {
this.smooth = smooth;
return this;
}
public void readFromNBT(NBTTagCompound compound) {
part = EnumAnimationPart.valueOf(compound.getString("Part"));
for (int i = 0; i < 3; i++) {
rotation[i] = compound.getFloat("Rotation" + i);
}
for (int i = 0; i < 3; i++) {
pivot[i] = compound.getFloat("Pivot" + i);
}
// Customized = TRUE if Speed or Smooth Exist
if (compound.hasKey("Speed")) {
customized = true;
speed = compound.getFloat("Speed");
}
if (compound.hasKey("Smooth")) {
customized = true;
smooth = compound.getByte("Smooth");
}
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Part", part.toString());
for (int i = 0; i < 3; i++) {
compound.setFloat("Rotation" + i, rotation[i]);
}
for (int i = 0; i < 3; i++) {
compound.setFloat("Pivot" + i, pivot[i]);
}
if (customized) {
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
}
return compound;
}
public FramePart copy() {
FramePart part = new FramePart(this.part);
part.rotation = new float[]{this.rotation[0], this.rotation[1], this.rotation[2]};
part.pivot = new float[]{this.pivot[0], this.pivot[1], this.pivot[2]};
part.customized = this.customized;
part.speed = this.speed;
part.smooth = this.smooth;
return part;
}
@SideOnly(Side.CLIENT)
public void interpolateAngles() {
if (parent != null && parent.paused)
return;
float pi = (float) Math.PI / 180;
if (this.smooth == 2) {
this.prevRotations[0] = this.rotation[0] * pi;
this.prevRotations[1] = this.rotation[1] * pi;
this.prevRotations[2] = this.rotation[2] * pi;
} else if (this.partialRotationTick != ClientEventHandler.partialRenderTick) {
this.partialRotationTick = ClientEventHandler.partialRenderTick;
if (this.smooth == 0) {
this.prevRotations[0] = (this.rotation[0] * pi - this.prevRotations[0]) * Math.abs(this.speed) / 10f + this.prevRotations[0];
this.prevRotations[1] = (this.rotation[1] * pi - this.prevRotations[1]) * Math.abs(this.speed) / 10f + this.prevRotations[1];
this.prevRotations[2] = (this.rotation[2] * pi - this.prevRotations[2]) * Math.abs(this.speed) / 10f + this.prevRotations[2];
} else {
int directionX = Float.compare(this.rotation[0] * pi, this.prevRotations[0]);
this.prevRotations[0] += directionX * this.speed / 10f;
this.prevRotations[0] = directionX == 1 ?
Math.min(this.rotation[0] * pi, this.prevRotations[0]) : Math.max(this.rotation[0] * pi, this.prevRotations[0]);
int directionY = Float.compare(this.rotation[1] * pi, this.prevRotations[1]);
this.prevRotations[1] += directionY * this.speed / 10f;
this.prevRotations[1] = directionY == 1 ?
Math.min(this.rotation[1] * pi, this.prevRotations[1]) : Math.max(this.rotation[1] * pi, this.prevRotations[1]);
int directionZ = Float.compare(this.rotation[2] * pi, this.prevRotations[2]);
this.prevRotations[2] += directionZ * this.speed / 10f;
this.prevRotations[2] = directionZ == 1 ?
Math.min(this.rotation[2] * pi, this.prevRotations[2]) : Math.max(this.rotation[2] * pi, this.prevRotations[2]);
}
}
}
@SideOnly(Side.CLIENT)
public void interpolateOffset() {
if (parent != null && parent.paused)
return;
if (this.smooth == 2) {
this.prevPivots[0] = this.pivot[0];
this.prevPivots[1] = this.pivot[1];
this.prevPivots[2] = this.pivot[2];
} else if (this.partialPivotTick != ClientEventHandler.partialRenderTick) {
this.partialPivotTick = ClientEventHandler.partialRenderTick;
if (this.smooth == 0) {
this.prevPivots[0] = (this.pivot[0] - this.prevPivots[0]) * Math.abs(this.speed) / 10f + this.prevPivots[0];
this.prevPivots[1] = (this.pivot[1] - this.prevPivots[1]) * Math.abs(this.speed) / 10f + this.prevPivots[1];
this.prevPivots[2] = (this.pivot[2] - this.prevPivots[2]) * Math.abs(this.speed) / 10f + this.prevPivots[2];
} else {
int directionX = Float.compare(this.pivot[0], this.prevPivots[0]);
this.prevPivots[0] += directionX * this.speed / 10f;
this.prevPivots[0] = directionX == 1 ?
Math.min(this.pivot[0], this.prevPivots[0]) : Math.max(this.pivot[0], this.prevPivots[0]);
int directionY = Float.compare(this.pivot[1], this.prevPivots[1]);
this.prevPivots[1] += directionY * this.speed / 10f;
this.prevPivots[1] = directionY == 1 ?
Math.min(this.pivot[1], this.prevPivots[1]) : Math.max(this.pivot[1], this.prevPivots[1]);
int directionZ = Float.compare(this.pivot[2], this.prevPivots[2]);
this.prevPivots[2] += directionZ * this.speed / 10f;
this.prevPivots[2] = directionZ == 1 ?
Math.min(this.pivot[2], this.prevPivots[2]) : Math.max(this.pivot[2], this.prevPivots[2]);
}
}
}
@SideOnly(Side.CLIENT)
public void jumpToCurrentFrame() {
this.partialRotationTick = ClientEventHandler.partialRenderTick;
this.partialPivotTick = ClientEventHandler.partialRenderTick;
this.prevPivots[0] = this.pivot[0];
this.prevPivots[1] = this.pivot[1];
this.prevPivots[2] = this.pivot[2];
float pi = (float) Math.PI / 180;
this.prevRotations[0] = this.rotation[0] * pi;
this.prevRotations[1] = this.rotation[1] * pi;
this.prevRotations[2] = this.rotation[2] * pi;
}
}
@@ -49,10 +49,10 @@ import java.util.HashSet;
import java.util.UUID;
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public PlayerDialogData dialogData = new PlayerDialogData(this);
public PlayerDialogData dialogData = new PlayerDialogData();
public PlayerBankData bankData = new PlayerBankData(this);
public PlayerQuestData questData = new PlayerQuestData(this);
public PlayerTransportData transportData = new PlayerTransportData(this);
public PlayerTransportData transportData = new PlayerTransportData();
public PlayerFactionData factionData = new PlayerFactionData(this);
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData(this);
public PlayerMailData mailData = new PlayerMailData(this);
@@ -141,10 +141,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
}
public void setNBT(NBTTagCompound data) {
dialogData.loadNBTData(data);
dialogData.loadNBTData(new MC1710NBTCompound(data));
bankData.loadNBTData(data);
questData.loadNBTData(data);
transportData.loadNBTData(data);
transportData.loadNBTData(new MC1710NBTCompound(data));
factionData.loadNBTData(data);
itemgiverData.loadNBTData(data);
mailData.loadNBTData(data);
@@ -186,10 +186,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
uuid = player.getPersistentID().toString();
}
NBTTagCompound compound = new NBTTagCompound();
dialogData.saveNBTData(compound);
dialogData.saveNBTData(new MC1710NBTCompound(compound));
bankData.saveNBTData(compound);
questData.saveNBTData(compound);
transportData.saveNBTData(compound);
transportData.saveNBTData(new MC1710NBTCompound(compound));
factionData.saveNBTData(compound);
itemgiverData.saveNBTData(compound);
mailData.saveNBTData(compound);
@@ -219,14 +219,14 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public NBTTagCompound getSyncNBT() {
NBTTagCompound compound = new NBTTagCompound();
dialogData.saveNBTData(compound);
dialogData.saveNBTData(new MC1710NBTCompound(compound));
questData.saveNBTData(compound);
factionData.saveNBTData(compound);
return compound;
}
public void setSyncNBT(NBTTagCompound data) {
dialogData.loadNBTData(data);
dialogData.loadNBTData(new MC1710NBTCompound(data));
questData.loadNBTData(data);
factionData.loadNBTData(data);
}
@@ -247,10 +247,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
uuid = player.getPersistentID().toString();
}
NBTTagCompound compound = new NBTTagCompound();
dialogData.saveNBTData(compound);
dialogData.saveNBTData(new MC1710NBTCompound(compound));
bankData.saveNBTData(compound);
questData.saveNBTData(compound);
transportData.saveNBTData(compound);
transportData.saveNBTData(new MC1710NBTCompound(compound));
factionData.saveNBTData(compound);
mailData.saveNBTData(compound);
tradeData.writeToNBT(compound);
@@ -263,10 +263,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
}
public void setSyncNBTFull(NBTTagCompound data) {
dialogData.loadNBTData(data);
dialogData.loadNBTData(new MC1710NBTCompound(data));
bankData.loadNBTData(data);
questData.loadNBTData(data);
transportData.loadNBTData(data);
transportData.loadNBTData(new MC1710NBTCompound(data));
factionData.loadNBTData(data);
mailData.loadNBTData(data);
tradeData.readFromNBT(data);
@@ -1,55 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.api.handler.IPlayerDialogData;
import java.util.HashSet;
public class PlayerDialogData implements IPlayerDialogData {
private final PlayerData parent;
public HashSet<Integer> dialogsRead = new HashSet<Integer>();
public PlayerDialogData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashSet<Integer> dialogsRead = new HashSet<Integer>();
if (compound == null)
return;
NBTTagList list = compound.getTagList("DialogData", 10);
if (list == null) {
return;
}
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
dialogsRead.add(nbttagcompound.getInteger("Dialog"));
}
this.dialogsRead = dialogsRead;
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for (int dia : dialogsRead) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Dialog", dia);
list.appendTag(nbttagcompound);
}
compound.setTag("DialogData", list);
}
public boolean hasReadDialog(int id) {
return dialogsRead.contains(id);
}
public void readDialog(int id) {
dialogsRead.add(id);
}
public void unreadDialog(int id) {
dialogsRead.remove(id);
}
}
@@ -1,76 +0,0 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.api.handler.IPlayerTransportData;
import noppes.npcs.api.handler.data.ITransportLocation;
import noppes.npcs.controllers.TransportController;
import java.util.ArrayList;
import java.util.HashSet;
public class PlayerTransportData implements IPlayerTransportData {
private final PlayerData parent;
public HashSet<Integer> transports = new HashSet<Integer>();
public PlayerTransportData(PlayerData parent) {
this.parent = parent;
}
public void loadNBTData(NBTTagCompound compound) {
HashSet<Integer> dialogsRead = new HashSet<Integer>();
if (compound == null)
return;
NBTTagList list = compound.getTagList("TransportData", 10);
if (list == null) {
return;
}
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
dialogsRead.add(nbttagcompound.getInteger("Transport"));
}
this.transports = dialogsRead;
}
public void saveNBTData(NBTTagCompound compound) {
NBTTagList list = new NBTTagList();
for (int dia : transports) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Transport", dia);
list.appendTag(nbttagcompound);
}
compound.setTag("TransportData", list);
}
public boolean hasTransport(int id) {
return transports.contains(id);
}
public void addTransport(int id) {
transports.add(id);
}
public void addTransport(ITransportLocation location) {
transports.add(location.getId());
}
public ITransportLocation getTransport(int id) {
return TransportController.getInstance().getTransport(id);
}
public ITransportLocation[] getTransports() {
ArrayList<ITransportLocation> list = new ArrayList<>();
for (int id : transports) {
ITransportLocation location = TransportController.getInstance().getTransport(id);
list.add(location);
}
return list.toArray(new ITransportLocation[0]);
}
public void removeTransport(int id) {
transports.remove(id);
}
}