mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Fix Magic Crashes
This commit is contained in:
1 parent
180d257024
commit
06a8317860
4 files changed
+50
-4
No files matched your search
@@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.api.handler.IMagicHandler;
|
||||
import noppes.npcs.controllers.data.Magic;
|
||||
import noppes.npcs.controllers.data.MagicAssociation;
|
||||
import noppes.npcs.controllers.data.MagicCycle;
|
||||
@@ -17,7 +18,7 @@ import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class MagicController {
|
||||
public class MagicController implements IMagicHandler {
|
||||
public HashMap<Integer, Magic> magics = new HashMap<>();
|
||||
public HashMap<Integer, Magic> magicSync = new HashMap<>();
|
||||
|
||||
@@ -37,10 +38,12 @@ public class MagicController {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Magic getMagic(int magicId) {
|
||||
return magics.get(magicId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagicCycle getCycle(int cycleID) {
|
||||
return cycles.get(cycleID);
|
||||
}
|
||||
@@ -322,6 +325,7 @@ public class MagicController {
|
||||
/**
|
||||
* Associates a magic with a category along with its per-category ordering data.
|
||||
*/
|
||||
@Override
|
||||
public void addMagicToCycle(int magicId, int cycleId, int index, int priority) {
|
||||
MagicCycle cat = cycles.get(cycleId);
|
||||
if (cat == null)
|
||||
@@ -340,6 +344,7 @@ public class MagicController {
|
||||
saveCycle(cat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMagicFromCycle(int magicId, int cycleId) {
|
||||
MagicCycle cat = cycles.get(cycleId);
|
||||
if (cat == null) return;
|
||||
|
||||
@@ -117,14 +117,17 @@ public class Magic implements IMagic {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
MagicController.getInstance().saveMagic(this);
|
||||
}
|
||||
@@ -157,4 +160,21 @@ public class Magic implements IMagic {
|
||||
public Map<Integer, Float> getInteractions() {
|
||||
return this.interactions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasInteraction(int magicID) {
|
||||
return interactions.containsKey(magicID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInteraction(int magicID, float value) {
|
||||
interactions.put(magicID, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInteraction(int magicID, float value) {
|
||||
if(hasInteraction(magicID))
|
||||
return interactions.get(magicID);
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.api.handler.data.IMagicCycle;
|
||||
import noppes.npcs.constants.EnumDiagramLayout;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -10,15 +11,14 @@ import java.util.HashMap;
|
||||
* Holds category information for magic.
|
||||
* Each category can have many magic associations.
|
||||
*/
|
||||
public class MagicCycle {
|
||||
public class MagicCycle implements IMagicCycle {
|
||||
public int id = -1;
|
||||
public String name = "";
|
||||
public String displayName = "";
|
||||
public EnumDiagramLayout layout = EnumDiagramLayout.CIRCULAR;
|
||||
public HashMap<Integer, MagicAssociation> associations = new HashMap<>();
|
||||
|
||||
public MagicCycle() {
|
||||
}
|
||||
public MagicCycle(){}
|
||||
|
||||
public void readNBT(NBTTagCompound compound) {
|
||||
id = compound.getInteger("ID");
|
||||
@@ -53,22 +53,27 @@ public class MagicCycle {
|
||||
compound.setTag("Associations", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
@@ -77,10 +82,22 @@ public class MagicCycle {
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutType() {
|
||||
return layout.ordinal();
|
||||
}
|
||||
|
||||
public void setLayout(EnumDiagramLayout layout) {
|
||||
this.layout = layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLayoutType(int layout) {
|
||||
if(layout < 0 || layout > EnumDiagramLayout.values().length - 1)
|
||||
return;
|
||||
this.layout = EnumDiagramLayout.values()[layout];
|
||||
}
|
||||
|
||||
public HashMap<Integer, MagicAssociation> getAssociations() {
|
||||
return associations;
|
||||
}
|
||||
|
||||
@@ -253,6 +253,10 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return CustomEffectController.Instance;
|
||||
}
|
||||
|
||||
public IMagicHandler getMagicHandler() {
|
||||
return MagicController.getInstance();
|
||||
}
|
||||
|
||||
public IPartyHandler getPartyHandler() {
|
||||
return PartyController.Instance();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user