Jump to content

[SOLVED] is there a way to get stack.stackSize in 1.11 ?


Recommended Posts

Posted

I need to know how many items of one type I got in a stack but seems stackSize is no longer public or it has changed for 1.11 ? My code logic depends on counting the amount of items of one type.

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Posted

Nope :(

 

I just had a look and it seems stackSize got made private .

 

The only possible way to get it now is just as part of toString()

 

Is this intentional or an accident? Will we ever have a getter for stackSize ?

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Posted
ItemStack#func_190916_E

returns the stack size if the stack is valid (see

ItemStack#func_190926_b

, which returns

true

if the stack is invalid/empty) or 0 if it's not.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 11/17/2016 at 1:25 AM, Choonster said:

ItemStack#func_190916_E

returns the stack size if the stack is valid (see

ItemStack#func_190926_b

, which returns

true

if the stack is invalid/empty) or 0 if it's not.

 

This isn't working for me, and I have no code errors (and I went back through and changed the entities accordingly to 1.11) (I can share src if need be):

 

  Reveal hidden contents

 

Posted
  On 11/17/2016 at 1:28 AM, gurujive said:

  Quote

ItemStack#func_190916_E

returns the stack size if the stack is valid (see

ItemStack#func_190926_b

, which returns

true

if the stack is invalid/empty) or 0 if it's not.

 

This isn't working for me, and I have no code errors (and I went back through and changed the entities accordingly to 1.11) (I can share src if need be):

 

  Reveal hidden contents

 

 

What exactly isn't working?

 

Forge hasn't yet added the ability to register entities in 1.11, so it's unlikely that any modded entity will work.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 11/17/2016 at 1:47 AM, Choonster said:

  Quote

  Quote

ItemStack#func_190916_E

returns the stack size if the stack is valid (see

ItemStack#func_190926_b

, which returns

true

if the stack is invalid/empty) or 0 if it's not.

 

This isn't working for me, and I have no code errors (and I went back through and changed the entities accordingly to 1.11) (I can share src if need be):

 

  Reveal hidden contents

 

 

What exactly isn't working?

 

Forge hasn't yet added the ability to register entities in 1.11, so it's unlikely that any modded entity will work.

 

With the changes when you right click it wont render the entity, but the entity will act as an entity and does exist. The item will drop and is visible in hand. So that sounds about right, I do believe.

width=233 height=253

tzIrzEf.jpg?1 [/img]

Posted

Thanks Choonster I am testing this right now. It appears to be correct.

 

First boot of 1.11

Ob3jnZf.png

 

:D

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Posted

Wait so that means func_190916_E returns 0 if the stack is invalid? ie it uses the _b one to check if stack is valid and if the _b returns 0 it will also return 0 which is now AIR . Seems Mojang is trying to get rid of null for some reason.

 

So I am wondering if I can now use _E for null check AND stack size AT THE SAME TIME

 

no longer need to use stack != null && stack.func_190916_E > 10

just saying if func_190916_E > 10 is automatically valid ie not null?

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Posted

Yes,

ItemStack

s are no loner allowed to be

null

, the default value is now

ItemStack#field_190927_a

(the empty/invalid

ItemStack

).

ItemStack#func_190916_E

checks the validity of the

ItemStack

for you, so you don't have to check it yourself.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 11/17/2016 at 3:31 AM, Choonster said:

Yes,

ItemStack

s are no loner allowed to be

null

, the default value is now

ItemStack#field_190927_a

(the empty/invalid

ItemStack

).

ItemStack#func_190916_E

checks the validity of the

ItemStack

for you, so you don't have to check it yourself.

 

but it was so beautiful....

if (!playerIn.capabilities.isCreativeMode)

        {

            --itemStackIn.stackSize;

        }

Posted

Thanks Choonster !

 

  On 11/17/2016 at 3:37 AM, gurujive said:

 

but it was so beautiful....

if (!playerIn.capabilities.isCreativeMode)

        {

            --itemStackIn.stackSize;

        }

 

nah dude but you can still -- tho

func_190918_g(1)

 

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Posted
  On 11/17/2016 at 3:37 AM, gurujive said:

  Quote

Yes,

ItemStack

s are no loner allowed to be

null

, the default value is now

ItemStack#field_190927_a

(the empty/invalid

ItemStack

).

ItemStack#func_190916_E

checks the validity of the

ItemStack

for you, so you don't have to check it yourself.

 

but it was so beautiful....

if (!playerIn.capabilities.isCreativeMode)

        {

            --itemStackIn.stackSize;

        }

 

ItemStack#func_190918_g

decrements the stack size by the specified amount.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 11/17/2016 at 3:37 AM, gurujive said:

  Quote

Yes,

ItemStack

s are no loner allowed to be

null

, the default value is now

ItemStack#field_190927_a

(the empty/invalid

ItemStack

).

ItemStack#func_190916_E

checks the validity of the

ItemStack

for you, so you don't have to check it yourself.

 

but it was so beautiful....

if (!playerIn.capabilities.isCreativeMode)

        {

            --itemStackIn.stackSize;

        }

ItemStack#func_190918_g(

amount

)

will remove amount from the stacksize.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

this is unintentional but pretty sure you can add to stack size  like

 

func_190918_g(-1) by using the decrement function hahaha

 

mojang probably made 2 functions add and sub but you only really need one to change the amount :D anyway back 2 coding.

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Posted
  On 11/17/2016 at 3:25 PM, diesieben07 said:

  Quote

this is unintentional but pretty sure you can add to stack size  like

 

func_190918_g(-1) by using the decrement function hahaha

 

mojang probably made 2 functions add and sub but you only really need one to change the amount :D anyway back 2 coding.

Yes, the decrement method is actually just an alias that uses the increment method. This is just for aesthetics, because stack.increment(-1) looks weird.

 

When did you get 26,000 somethin' posts? I'm pretty certain that takes about 20 years. (There's no way)

 

Edit:

ok, so about 4 years..

Posted
  On 11/17/2016 at 6:37 PM, gurujive said:

When did you get 26,000 somethin' posts? I'm pretty certain that takes about 20 years. (There's no way)

 

16.4 posts per day is not that many, especially for a moderator.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • inicie un mundo donde instale Croptopia y Farmer's Delight, entonces instale el addon Croptopia Delight pero no funciona. es la version 1.18.2
    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
  • Topics

×
×
  • Create New...

Important Information

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