Jump to content

[1.7.10] [UNSOLVED] Slots & NBT


BinaryCPG

Recommended Posts

I have 2 Problems:

1) I've got two methods to interact with the slots in my TileEntity:

 

 

public void importMoneyFromInput(EntityPlayer player)
    {
        double val = 0;
        ItemStack input = atmSlots[0];
        if ( input != null )
        {
            if ( input.getItem() instanceof ItemNote )
            {
                val = ((ItemNote) input.getItem()).getValue()*input.stackSize;
            }
            else if ( input.getItem() instanceof ItemCoin )
            {
                val = ((ItemCoin) input.getItem()).getValue()*input.stackSize;
            }
        }

        double lastVal = player.getEntityData().getDouble("bankBalance");
        player.getEntityData().setDouble("bankBalance", val + lastVal);

        atmSlots[0] = null;
        this.onInventoryChanged = true;
    }

    public void exportMoneyFromBuffer (ATMHelper helper, EntityPlayer player)
    {
        helper.updateOutput();

        atmSlots[2] = (ModMoneyHelper.createFullBriefcase(toPutOut_is)).copy();

        double oldVal = player.getEntityData().getDouble("bankBalance");
        double remove = helper.getValueOutput();

        player.getEntityData().setDouble("bankBalance", oldVal-remove);

        helper.reset();
        this.onInventoryChanged = true;
    }

 

(

    this.onInventoryChnaged = true causes this.markDirty()

)

 

 

 

 

The Methods work, but the items in the input-slot don't disappear correctly &

the items in the output-slot don't appear correctly.

 

What did i forgot?

 

2)

I am using the EntityPlayer.getEntityData() to get an double:

 

 

this.bankBalance = player.getEntityData().getDouble("bankBalance");

 

 

& later to set it:

 

 

this.player.getEntityData().setDouble("bankBalance", this.bankBalance);

 

 

It works as long as i don't reload the world. On re-log the var "bankBalance" is 0.

is this because of the development environment (like i can't take screenshots) or did i

miss something?

The TileEntitys are Going to kill us all and take over the entire (Minecraft) world!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.