Jump to content

Recommended Posts

Posted
2 hours ago, diesieben07 said:
  • Please, for the love of god, remove all that log spam. Nobody cares that your mod has now received it's preInit event, especially not at INFO level. Your main mod class contains more logging statements than anything else, for crying out loud.
  • Please remove your own (broken!) version checker. Forge already has one, use it.
  • You do not register your gui handler on the server. You must register it on both sides.
  • In general, why is all your code in the proxies? The proxies are for things that are specific to one physical side. Common code goes in your main mod class (or other classes if needed for organization).

Ok, I clean my code and added GuiHandler in both sides, but it doesn't work! :|

  • Like 1
Posted
1 hour ago, diesieben07 said:

Define "doesn't work". Is your gui handler called?

Yes, here is code where it called:

@Override
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
			EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) {
		if (!worldIn.isRemote) {
			playerIn.openGui(ModCore.instance, GuiHandler.BLOCKBREAKER, worldIn, pos.getX(), pos.getY(), pos.getZ());
		}
		return true;
	}

 

  • Like 1
Posted
3 minutes ago, IvanSteklow said:

Yes, here is code where it called:

 

I believe diesieben07 meant "Is it actually called at runtime"? Set a breakpoint in each of the GuiHandler methods and try to open your GUI, are the breakpoints hit?

 

In the code on GitHub, GuiHandler#getClientGuiElement always returns null. It should return a new GuiBlockBreaker instance when the ID matches.

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 (edited)
30 minutes ago, Choonster said:

 

I believe diesieben07 meant "Is it actually called at runtime"? Set a breakpoint in each of the GuiHandler methods and try to open your GUI, are the breakpoints hit?

 

In the code on GitHub, GuiHandler#getClientGuiElement always returns null. It should return a new GuiBlockBreaker instance when the ID matches.

So, thank you, but now I got new problem... In this piece of code:

if (sync == 0)
PacketHandler.INSTANCE.sendToServer(new PacketGetWorker(this.te.getPos(), this.mc.player.getAdjustedHorizontalFacing(), "ivansteklow.vanillaex.client.gui.GuiBlockBreaker", "cooldown", "maxCooldown"));

There is an error:

Description: Rendering screen

java.lang.NullPointerException: Rendering screen
	at ivansteklow.vanillaex.client.gui.GuiBlockBreaker.drawGuiContainerForegroundLayer(GuiBlockBreaker.java:77)

What's wrong, why NullPointerException?

It's full error:

Spoiler

[Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering screen
	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1191) ~[EntityRenderer.class:?]
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1140) ~[Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:407) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NullPointerException
	at ivansteklow.vanillaex.client.gui.GuiBlockBreaker.drawGuiContainerForegroundLayer(GuiBlockBreaker.java:77) ~[GuiBlockBreaker.class:?]
	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:136) ~[GuiContainer.class:?]
	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:382) ~[ForgeHooksClient.class:?]
	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1164) ~[EntityRenderer.class:?]
	... 15 more

 

 

Edited by IvanSteklow
  • Like 1
Posted
4 hours ago, diesieben07 said:

Set a breakpoint on that line and check what is null.

It's crashes on this block of code:

public static SimpleNetworkWrapper INSTANCE;

This is all class:

Spoiler

package ivansteklow.vanillaex.network;

import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;

public class PacketHandler {

	public static SimpleNetworkWrapper INSTANCE;

	private static int ID = 0;

	private static int nextID() {
		return ID++;
	}

	public static void registerMessages(String channelName) {
		INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(channelName);

		INSTANCE.registerMessage(PacketGetWorker.Handler.class, PacketGetWorker.class, nextID(), Side.SERVER);

		INSTANCE.registerMessage(PacketReturnWorker.Handler.class, PacketReturnWorker.class, nextID(), Side.CLIENT);
	}

}

But I don't know what is it...

 

  • Like 1
Posted
On 16.06.2017 at 3:09 PM, Choonster said:

 

I believe diesieben07 meant "Is it actually called at runtime"? Set a breakpoint in each of the GuiHandler methods and try to open your GUI, are the breakpoints hit?

 

In the code on GitHub, GuiHandler#getClientGuiElement always returns null. It should return a new GuiBlockBreaker instance when the ID matches.

 

21 hours ago, diesieben07 said:

You never call registerMessages from anywhere.

Thank you for all!

  • Like 1

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.