Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.1 - 1.12.2] An already working method suddenly stop working out of nowhere
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Gess1t

[1.12.1 - 1.12.2] An already working method suddenly stop working out of nowhere

By Gess1t, September 10 in Modder Support

  • Start new topic
  • Prev
  • 1
  • 2
  • 3
  • 4
  • Next
  • Page 1 of 4  

Recommended Posts

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10 (edited)

forge recommended (1.12.1 - 14.22.1.2478)

 

so one of my 2 methods that check the inventory and send the message suddenly stopped working completely without editing it, copy pasting code from a known working method doesn't fix it, redoing the method does not fix it,  create the method under another name doesn't work, logs show nothing, it's just forge shenanigans at this point for me.

 

the method : 

 

@SubscribeEvent
	public static void PckUpItm(EntityItemPickupEvent event) {
		System.out.println("output1");
     	int g = 0;
		for(int e=0; e < 37; e++) {
			if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(e).isEmpty() && Minecraft.getMinecraft()
					.player.inventory.getStackInSlot(e).getCount() == Minecraft.getMinecraft().player.inventory.getStackInSlot(e).getMaxStackSize()) {
				g++;
              	System.out.println("output2");
				if(g > 35) {
					Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full"));
					System.out.println("output3");
                  	return;
					}
					
				}
				
			}				

		}

so i've added 3 output to console

the "output1" appear,

the "output2" appear 35 times? it should appear 36 times so wtf.

the "output3" does not appear at all obviously.

 

EDIT: last time i tried it, i started the game, and it was working, so i just closed the game, and i closed eclipse.

and when i came back to test it today, it wasn't working anymore

EDIT2: Added System.out.println(g) instead, it doesn't go higher than 35, even when editing the value to e < 38

Even More EDIT cause why not: it worked for one try, and now, value don't go higher than 35 when the other method goes to 36 flawlessly

Edited September 10 by Gess1t

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10
  • Why on earth are you using 1.12.1? Update to 1.12.2.
  • You are reaching across logical sides.

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10 (edited)
6 minutes ago, diesieben07 said:
  • Why on earth are you using 1.12.1? Update to 1.12.2.
  • You are reaching across logical sides.

i'm using 1.12.1 cause it's also compatible with 1.12.2

So i'm reaching across logicals sides now? why not before? like when the code was working flawlessly? even on servers!

Edited September 10 by Gess1t

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10
4 minutes ago, Gess1t said:

So i'm reaching across logicals sides now? why not before?

If you were doing the same thing before then you were already reaching across logical sides.

 

4 minutes ago, Gess1t said:

like when the code was working flawlessly? even on servers!

It wasn't. You just got lucky. And no, this code will never run on a server. The class Minecraft is not present on a server and your code will immediately crash with a NoClassDefFoundError.

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10
6 minutes ago, Gess1t said:

i'm using 1.12.1 cause it's also compatible with 1.12.2

So...? That does not justify using 1.12.1. 1.12.2 is a bug-fix update for 1.12.1. The only "advantage" you have from using 1.12.1 is more bugs. Use 1.12.2.

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10
2 minutes ago, diesieben07 said:

If you were doing the same thing before then you were already reaching across logical sides.

 

It wasn't. You just got lucky. And no, this code will never run on a server. The class Minecraft is not present on a server and your code will immediately crash with a NoClassDefFoundError.

so i need to learn how to use packets now just because it refuse to work?

even hypixel accepted it

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10

Okay so.

Please clarify what you mean by "on a server".


Is this a client-only mod?

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10 (edited)
6 minutes ago, diesieben07 said:

Okay so.

Please clarify what you mean by "on a server".


Is this a client-only mod?

mostly, but i learned you can't make all things client side.

tried it while farming sugar canes on skyblock servers, worked flawlessly.

EDIT: i also had potentially found a way to add minecraft: IDs as exception for the check (for the nether star and the head cause backpacks and the menu aren't stackable items), but deleted it in the process of trying to fix it, will have to re-write all that later.

Edited September 10 by Gess1t

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10

Okay, if this is intended to be client-only then you still need to first check if you are actually on the logical client using World#isRemote. You can get the World from the EntityPlayer in the event.

 

Is your inventory actually full in these tests? Have you used the debugger?

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10 (edited)
14 minutes ago, diesieben07 said:

Okay, if this is intended to be client-only then you still need to first check if you are actually on the logical client using World#isRemote. You can get the World from the EntityPlayer in the event.

 

Is your inventory actually full in these tests? Have you used the debugger?

EDIT cause i'm retarded : if(Minecraft.getMinecraft().world.isRemote)

 

yup, in solo, worked with 64 in each of 36 inv slots, and same in multiplayer ans hypixel when i had the exception, didn't used any debugger.

Edited September 10 by Gess1t

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10
6 minutes ago, Gess1t said:

EDIT cause i'm retarded : if(Minecraft.getMinecraft().world.isRemote)

No! This is completely and utterly pointless.

 

Again: Have you used the debugger?

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10 (edited)
15 minutes ago, diesieben07 said:

No! This is completely and utterly pointless.

 

Again: Have you used the debugger?

then it is if(Minecraft.getMinecraft().player.world.isRemote)

EDIT: well nope, no need to tell me

 

and again, as i said in my previous message, no i didn't, cause i didn't needed one yet.

i guess now you ask that, that i need one?

Edited September 10 by Gess1t

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 10
1 minute ago, Gess1t said:

then it is if(Minecraft.getMinecraft().player.world.isRemote)

Still makes no sense. Minecraft#world (Or Minecraft#player.world) is always the (logical) client world. isRemote will always be true. But at this point you do not know if you are even running on the logical client. You might be in single player with the event being fired on the logical server. And, boom, there is you reaching across logical sides (accessing logical client stuff from logical server).

 

Again:

25 minutes ago, diesieben07 said:

You can get the World from the EntityPlayer in the event. 

 

3 minutes ago, Gess1t said:

and again, as i said in my previous message, no i didn't, cause i didn't needed one yet

It's about time then.

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted September 10
3 minutes ago, Gess1t said:

then it is if(Minecraft.getMinecraft().player.world.isRemote)

No.

 

25 minutes ago, diesieben07 said:

You can get the World from the EntityPlayer in the event.

 

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 10 (edited)
29 minutes ago, diesieben07 said:

Still makes no sense. Minecraft#world (Or Minecraft#player.world) is always the (logical) client world. isRemote will always be true. But at this point you do not know if you are even running on the logical client. You might be in single player with the event being fired on the logical server. And, boom, there is you reaching across logical sides (accessing logical client stuff from logical server).

 

Again:

 

It's about time then.

my last try for today : event.getEntityPlayer().world.isRemote

there is world, but i can't find World

Edited September 10 by Gess1t

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted September 10
16 minutes ago, Gess1t said:

my last try for today : event.getEntityPlayer().world.isRemote

This is correct.

 

16 minutes ago, Gess1t said:

World

This refers to the objects type name. While world refers to the field name.

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 13

tried to use the eclipse's debugger; bug it crash the game so... nope

added the line of code as an if statement like you told me, but as far as i know, this line of code alone won't help right?

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted September 13
1 hour ago, Gess1t said:

bug it crash the game so... nope

The debugger itself won't crash the game. So some code is crashing the game or one of the threads is suspended. And you will need to un-suspend it.

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 13 (edited)
32 minutes ago, Animefan8888 said:

The debugger itself won't crash the game. So some code is crashing the game or one of the threads is suspended. And you will need to un-suspend it.

should had edited it, it freeze and crash the game on the ms the game windows show up,

 

Edited September 13 by Gess1t

Share this post


Link to post
Share on other sites

Animefan8888    677

Animefan8888

Animefan8888    677

  • Reality Controller
  • Animefan8888
  • Forge Modder
  • 677
  • 5746 posts
Posted September 13
2 hours ago, Gess1t said:

should had edited it, it freeze and crash the game on the ms the game windows show up,

I have a theory but since I dont have the crash log I'm not sure. But I think the problem is that the ClientTickEvent is called before the player is created. Thus you need to check if it is not null before you do the is remote check.

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 14 (edited)
10 hours ago, Animefan8888 said:

I have a theory but since I dont have the crash log I'm not sure. But I think the problem is that the ClientTickEvent is called before the player is created. Thus you need to check if it is not null before you do the is remote check.

anyway, it started working again, i guess things want to work whenever they want, like my method for example, it worked for like 30 min and stopped working again after relaunching.

Still don't know how to fix it nothing special at all in the logs, when compared with other logs.

 

another edit cause why not: i wonder if the issue is forge or minecraft itself at this point, all this make no sense to me and probably you, am i right?

Edited September 14 by Gess1t

Share this post


Link to post
Share on other sites

4sterism    0

4sterism

4sterism    0

  • Tree Puncher
  • 4sterism
  • Members
  • 0
  • 31 posts
Posted September 14

Thats bc the code is not robust. It doesnt work in all possible situations.

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 15 (edited)

so, is there any way to fix this issue? just adding event.getEntityPlayer().world.isRemote didn't helped in any way as far as i know and tested, on server and single player, i'm repeating myself i know.

 i've seen that the using Minecraft.getMinecraft() is client-side code or something like that. what should i use then?

Edited September 15 by Gess1t

Share this post


Link to post
Share on other sites

Gess1t    0

Gess1t

Gess1t    0

  • Stone Miner
  • Gess1t
  • Members
  • 0
  • 65 posts
Posted September 16 (edited)

i was wandering i could build the mod with one method, and then another mod with the other one, will i still reach across logical sides?

or it's just something else, like i need to send packets?

Edited September 16 by Gess1t

Share this post


Link to post
Share on other sites

diesieben07    6687

diesieben07

diesieben07    6687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6687
  • 45711 posts
Posted September 16

Please show your current code and I will tell you if it is correct or not.

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • 3
  • 4
  • Next
  • Page 1 of 4  
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Ronaldi2001
      Adding burn time to a block

      By Ronaldi2001 · Posted 40 minutes ago

      Im trying to figure out how to add burn time to a block, I can add It to an item no problem but I can't figure it out for a block. I tried looking through the Minecraft code for what they do with a coal block but I can't find where they do it.
    • NoMercyPro
      Forge 1.12.2 Launcher Crash

      By NoMercyPro · Posted 42 minutes ago

      Oh, I'm so sorry! I didn't know 9minecraft.net was a repost site. I won't use it anymore and I thank you for your help. A lot of people (including me) would be lost without you.
    • DavidM
      Forge server kicking players randomly, sometimes unable to join

      By DavidM · Posted 49 minutes ago

      Please post the server log of when someone got kicked.
    • DavidM
      pointing to MCP folder instead of MDK ???

      By DavidM · Posted 52 minutes ago

      No need to mess with MCP. Simply download the 1.14 mdk and copy the src from 1.12 to 1.14. Then fix all the mapping changes and other changes with your IDE.
    • DaemonUmbra
      pointing to MCP folder instead of MDK ???

      By DaemonUmbra · Posted 53 minutes ago

      At this time I have to say McJty's tutorial is the least bad. If you have an MCP folder you're doing something wrong because MCP is not longer really a thing
  • Topics

    • Ronaldi2001
      0
      Adding burn time to a block

      By Ronaldi2001
      Started 41 minutes ago

    • NoMercyPro
      3
      Forge 1.12.2 Launcher Crash

      By NoMercyPro
      Started 21 hours ago

    • Kull
      1
      Forge server kicking players randomly, sometimes unable to join

      By Kull
      Started 17 hours ago

    • JMAS
      8
      pointing to MCP folder instead of MDK ???

      By JMAS
      Started 3 hours ago

    • Professional Derp
      0
      Server frequently crashes

      By Professional Derp
      Started 1 hour ago

  • Who's Online (See full list)

    • geekles
    • A-Game
    • nugycal
    • Arcratist
    • bandofbros20
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.1 - 1.12.2] An already working method suddenly stop working out of nowhere
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community