mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-22 12:59:46 +00:00
Initial commit
This commit is contained in:
commit
e37de23340
41 files changed
+2123
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package baubles.common.lib;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
|
||||
public class PlayerHandler {
|
||||
private HashMap<String,InventoryBaubles> playerBaubles = new HashMap<String,InventoryBaubles>();
|
||||
|
||||
public InventoryBaubles getPlayerBaubles(EntityPlayer player) {
|
||||
if (!playerBaubles.containsKey(player.getCommandSenderName())) {
|
||||
InventoryBaubles inventory = new InventoryBaubles(player);
|
||||
playerBaubles.put(player.getCommandSenderName(), inventory);
|
||||
}
|
||||
return playerBaubles.get(player.getCommandSenderName());
|
||||
}
|
||||
|
||||
public void setPlayerBaubles(EntityPlayer player, InventoryBaubles inventory) {
|
||||
playerBaubles.put(player.getCommandSenderName(), inventory);
|
||||
}
|
||||
|
||||
public void updatePlayerBaubles(EntityPlayer player) {
|
||||
InventoryBaubles inventory = getPlayerBaubles(player);
|
||||
inventory.saveNBT(player);
|
||||
}
|
||||
|
||||
public void loadPlayerBaubles(EntityPlayer player) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if (!data.hasKey("Baubles")) {
|
||||
data.setTag("Baubles", new NBTTagCompound());
|
||||
}
|
||||
InventoryBaubles inventory = new InventoryBaubles(player);
|
||||
inventory.readNBT(player);
|
||||
playerBaubles.put(player.getCommandSenderName(), inventory);
|
||||
updatePlayerBaubles(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user