Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bbw2.moneyMod.items;
- import com.bbw2.moneyMod.MoneyMod;
- import com.bbw2.moneyMod.handler.MyPacket;
- import com.bbw2.moneyMod.holders.BankAccount;
- import com.bbw2.moneyMod.reference.NBTTags;
- import com.bbw2.moneyMod.utility.LogHelper;
- import cpw.mods.fml.client.config.GuiConfigEntries;
- import cpw.mods.fml.common.registry.EntityRegistry;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.nbt.NBTTagString;
- import net.minecraft.network.Packet;
- import net.minecraft.util.ChatComponentStyle;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.world.World;
- import java.util.ArrayDeque;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.UUID;
- /**
- * Created on 9/30/2015.
- */
- public class ItemCard extends ItemMT {
- public ItemCard(){
- super();
- this.setUnlocalizedName("creditCard");
- }
- @Override
- public void onUpdate(ItemStack stack, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) {
- /*NBTTagCompound tag = stack.stackTagCompound;
- if (tag == null) tag = new NBTTagCompound();
- NBTTagCompound ownerTag = tag.getCompoundTag("ownerID");
- long ownerIDLeast = ownerTag.getLong("UUID_least");
- long ownerIDMost = ownerTag.getLong("UUID_most");
- if (ownerIDLeast == 0L || ownerIDMost == 0L){
- if (entity instanceof EntityPlayer){
- UUID id = entity.getPersistentID();
- ownerIDLeast = id.getLeastSignificantBits();
- ownerIDMost = id.getMostSignificantBits();
- ownerTag.setLong("UUID_least",ownerIDLeast);
- ownerTag.setLong("UUID_most", ownerIDMost);
- tag.setTag("ownerID", ownerTag);
- stack.stackTagCompound = tag;
- }
- }*/
- }
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) {
- NBTTagCompound tag = stack.stackTagCompound;
- if (tag != null) {
- if (tag.hasKey(NBTTags.Card.ACCOUNTS_TAG)) {
- NBTTagCompound accountTag = tag.getCompoundTag(NBTTags.Card.ACCOUNTS_TAG);
- BankAccount account = BankAccount.fromNBT(accountTag, null);
- if (account!=null) {
- if (account.getPlayer() != null) list.add("Owner: " + ((account.getPlayer()==player) ? EnumChatFormatting.GREEN : EnumChatFormatting.DARK_RED) + account.getPlayer().getDisplayName());
- else list.add("Owner: " + EnumChatFormatting.DARK_RED + account.getId());
- if (account.getBank()!=null) list.add("Bank: " + EnumChatFormatting.GREEN + account.getBank().getName());
- else list.add("Bank: " + EnumChatFormatting.DARK_RED + "Bankrupt");
- list.add(String.format("Credit: %s\u20a9%.3f",
- ((account.getCredit() > 0) ? EnumChatFormatting.GREEN :
- ((account.getCredit() < 0) ? EnumChatFormatting.DARK_RED :
- EnumChatFormatting.YELLOW)),
- account.getCredit()));
- } else {
- LogHelper.warn("Account not found.");
- NBTTagCompound ownerTag = accountTag.getCompoundTag(NBTTags.Card.UUID_OWNER_TAG);
- long ownerIDLeast = ownerTag.getLong(NBTTags.Card.UUID_LEAST_TAG);
- long ownerIDMost = ownerTag.getLong(NBTTags.Card.UUID_MOST_TAG);
- UUID id = new UUID(ownerIDMost, ownerIDLeast);
- list.add("Owner: " + EnumChatFormatting.DARK_RED + id);
- }
- }
- list.add(tag.toString());
- }
- }
- private String[] tagToViewable(NBTTagCompound tag){
- String tagString = tag.toString();
- char[] charArray = tagString.toCharArray();
- String line = "";
- ArrayList<String> lines = new ArrayList<String>();
- for (int i = 0; i < charArray.length; i++) {
- char current = charArray[i];
- line += current;
- if ("{,}".indexOf(current) > 0){
- lines.add(line);
- line = "";
- }
- }
- return null;
- }
- @Override
- public String getItemStackDisplayName(ItemStack stack) {
- NBTTagCompound tag = stack.stackTagCompound;
- if (tag != null){
- if (tag.hasKey(NBTTags.Card.ACCOUNTS_TAG)){
- NBTTagCompound accountTag = tag.getCompoundTag(NBTTags.Card.ACCOUNTS_TAG);
- BankAccount account = BankAccount.fromNBT(accountTag,null);
- if (account!=null&&account.getBank()!=null) {
- return account.getBank().getName() + " " + super.getItemStackDisplayName(stack);
- }
- }
- }
- return super.getItemStackDisplayName(stack);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment