mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 00:39:40 +00:00
Rename Namespace to kamkeel.npcs
This commit is contained in:
1 parent
19c31b985d
commit
5d41f5b939
128 files changed
+406
-440
No files matched your search
@@ -0,0 +1,57 @@
|
||||
package kamkeel.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class Profile {
|
||||
|
||||
public EntityPlayer player;
|
||||
public int currentID;
|
||||
public HashMap<Integer, Slot> slots = new HashMap<>();
|
||||
|
||||
public Profile(EntityPlayer player, NBTTagCompound compound){
|
||||
this.player = player;
|
||||
if(compound.hasKey("CurrentID")){
|
||||
this.currentID = compound.getInteger("CurrentID");
|
||||
} else {
|
||||
this.currentID = 1;
|
||||
}
|
||||
|
||||
if (compound.hasKey("Slots")) {
|
||||
// Load Slots
|
||||
NBTTagCompound slotsCompound = compound.getCompoundTag("Slots");
|
||||
for (String key : (Set<String>) slotsCompound.func_150296_c()) {
|
||||
int slotID = Integer.parseInt(key);
|
||||
NBTTagCompound slotNBT = slotsCompound.getCompoundTag(key);
|
||||
Slot slot = Slot.fromNBT(slotID, slotNBT);
|
||||
slots.put(slotID, slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT() {
|
||||
NBTTagCompound fullCompound = new NBTTagCompound();
|
||||
|
||||
if(this.player != null)
|
||||
fullCompound.setString("Name", player.getCommandSenderName());
|
||||
fullCompound.setInteger("CurrentID", currentID);
|
||||
|
||||
if(!slots.isEmpty()){
|
||||
NBTTagCompound slotsCompound = new NBTTagCompound();
|
||||
for (HashMap.Entry<Integer, Slot> entry : slots.entrySet()) {
|
||||
int id = entry.getKey();
|
||||
Slot slot = entry.getValue();
|
||||
slot.setId(id);
|
||||
|
||||
NBTTagCompound slotTag = slot.toNBT();
|
||||
slotsCompound.setTag(String.valueOf(id), slotTag);
|
||||
}
|
||||
|
||||
fullCompound.setTag("Slots", slotsCompound);
|
||||
}
|
||||
return fullCompound;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user