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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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    6679

diesieben07

diesieben07    6679

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6679
  • 45656 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

    • BattleDash
      Get all players connected to a bungee server

      By BattleDash · Posted 41 minutes ago

      Hello all, I'm trying to make a mod that can tell you all the players on a bungee server you're connected to, I've never worked with Forge before and this API is very abstract to me compared to plugin development which is what I normally do. Does anyone know how I would go about getting a list of Player Entities of every player on the network you're connected to?
    • Draco18s
      Trouble getting contents of a Chest

      By Draco18s · Posted 1 hour ago

      It isn't merged, so it won't work yet.
    • saxon564
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564 · Posted 2 hours ago

      Does anyone else have any thoughts as to what might be causing this issue?
    • diesieben07
      [1.12.2] How can I close GUI in Forge?

      By diesieben07 · Posted 2 hours ago

      You cannot call Minecraft methods from a separate thread. You need to wait a tick using ClientTickEvent.
    • bismuth210
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210 · Posted 2 hours ago

      I'm creating a custom gamemode using forge in which players get teleported around regularly. I've run into a problem when I do the following:   I spawn a firework rocket near a player I teleport the player to a different location I wait a couple of seconds (or minutes) I teleport the player back to the same location as in step 1. Doing this will show the firework spawned in step 1 in step 4, despite significant time having passed in 3. This video shows what I mean:   I suspect the reason for why this happens is because once I teleport the player somewhere else, the chunk with the firework is no longer loaded and doesn't get updated.   Is there a simple way for me to simply "get rid" of all active fireworks shortly before teleporting players so that this doesn't occur? Or do I really have to forcibly keep all chunks loaded? To be more clear: I don't want to disable fireworks all together, but I don't want remnants of old fireworks showing up when I teleport players. "Killing" all firework rockets when I teleport a player would work fine, but I don't know if/how I can do that.   I've tried using /kill @e[type=!player] But that doesn't work for firework rockets apparently.
  • Topics

    • BattleDash
      0
      Get all players connected to a bungee server

      By BattleDash
      Started 41 minutes ago

    • MattNL
      5
      Trouble getting contents of a Chest

      By MattNL
      Started 12 hours ago

    • saxon564
      12
      [1.14.4] [UNSOLVED] Server Thread Freezes After Entity Explodes

      By saxon564
      Started Friday at 05:11 AM

    • Filip4223
      5
      [1.12.2] How can I close GUI in Forge?

      By Filip4223
      Started 3 hours ago

    • bismuth210
      0
      [1.12.2] Killing fireworks in unloaded chunks

      By bismuth210
      Started 2 hours ago

  • Who's Online (See full list)

    • EfrenB
    • Redstoneguy129
    • DragonITA
    • salvestrom
    • MrMarioMaster34
    • Pyre540
    • MattNL
    • no namezzzz
    • Draco18s
    • Simon_kungen
    • LouieDep
    • diesieben07
    • largeDachshund
  • 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