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

    • i was playing a custom modpack and i cant open the world anymore.  here are the logs :  [15:28:31] [Server thread/ERROR]:Encountered an unexpected exception net.minecraftforge.fml.config.ConfigFileTypeHandler$ConfigLoadingException: Failed loading config file jei-server.toml of type SERVER for modid jei at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:47) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at net.minecraftforge.fml.config.ConfigTracker.openConfig(ConfigTracker.java:60) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at net.minecraftforge.fml.config.ConfigTracker.lambda$loadConfigs$1(ConfigTracker.java:50) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at java.util.Collections$SynchronizedCollection.forEach(Collections.java:2131) ~[?:?] at net.minecraftforge.fml.config.ConfigTracker.loadConfigs(ConfigTracker.java:50) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] at net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(ServerLifecycleHooks.java:96) ~[forge-1.20.1-47.4.0-universal.jar%23309!/:?] at net.minecraft.client.server.IntegratedServer.m_7038_(IntegratedServer.java:62) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:634) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at java.lang.Thread.run(Thread.java:840) ~[?:?] Caused by: com.electronwill.nightconfig.core.io.ParsingException: Not enough data available at com.electronwill.nightconfig.core.io.ParsingException.notEnoughData(ParsingException.java:22) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.ReaderInput.directReadChar(ReaderInput.java:36) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.AbstractInput.readChar(AbstractInput.java:49) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.AbstractInput.readCharsUntil(AbstractInput.java:123) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.toml.TableParser.parseKey(TableParser.java:166) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:145) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) ~[toml-3.6.4.jar%2394!/:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.file.WriteSyncFileConfig.load(WriteSyncFileConfig.java:73) ~[core-3.6.4.jar%2393!/:?] at com.electronwill.nightconfig.core.file.AutosaveCommentedFileConfig.load(AutosaveCommentedFileConfig.java:85) ~[core-3.6.4.jar%2393!/:?] at net.minecraftforge.fml.config.ConfigFileTypeHandler.lambda$reader$1(ConfigFileTypeHandler.java:43) ~[fmlcore-1.20.1-47.4.0.jar%23305!/:?] ... 10 more [15:28:31] [Server thread/FATAL]:Preparing crash report with UUID 2a3982ea-90f2-492d-85e7-f1cb63906dcb [15:28:31] [Server thread/ERROR]:This crash report has been saved to: C:\Users\gueri\curseforge\minecraft\Instances\modpack je sais pas\crash-reports\crash-2025-05-29_15.28.31-server.txt [15:28:31] [Server thread/INFO]:Stopping server [15:28:31] [Server thread/INFO]:Saving players [15:28:31] [Server thread/INFO]:Saving worlds [15:28:31] [Server thread/ERROR]:Exception stopping the server java.lang.NullPointerException: Cannot invoke "net.minecraft.server.level.ServerLevel.m_6857_()" because "serverlevel2" is null at net.minecraft.server.MinecraftServer.m_129885_(MinecraftServer.java:513) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_7041_(MinecraftServer.java:584) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.client.server.IntegratedServer.m_7041_(IntegratedServer.java:187) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:689) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[client-1.20.1-20230612.114412-srg.jar%23304!/:?] at java.lang.Thread.run(Thread.java:840) ~[?:?]
    • Add the crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here  
    • I recently updated my mods for prominence 2 and instead of opening like usual it just crashes. I already disable any incompatible mods and I don't know what to do. If anyone could help that would be nice. Thanks Latest log:https://mclo.gs/jsuIlZX
    • I dont know how I can elaborate more, just every time I try to create a new instance where its forge, its 1.20.1 and the forge version is 47.4.1 it doesnt work. Im really confused because it works for my friend he even showed it to me. This is on modrinth btw
  • Topics

×
×
  • Create New...

Important Information

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