Jump to content

[1.7.10] Ticking memory connection when opening GUI after changing NBT data


Recommended Posts

Posted

Hi,

 

I have a GUI which opens upon rightclicking a custom item. Basically you can add and remove players to/from the item, and in order to save the players I'm using the ItemStack's NBTTagCompound via player.getCurrentEquippedItem().getTagCompound().

Whenever the NBT data gets changed and the GUI is closed and quickly reopened, I get a serverside crash:

 

 

---- Minecraft Crash Report ----

// Why is it breaking :(

 

Time: 08.09.16 17:04

Description: Ticking memory connection

 

java.lang.NullPointerException: Ticking memory connection

at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:657)

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:657)

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

 

-- Ticking connection --

Details:

Connection: net.minecraft.network.NetworkManager@6acb4ade

Stacktrace:

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Windows 10 (amd64) version 10.0

Java Version: 1.8.0_101, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 330923008 bytes (315 MB) / 653262848 bytes (623 MB) up to 1900019712 bytes (1812 MB)

JVM Flags: 0 total;

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94

FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 5 mods loaded, 5 mods active

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)

UCHIJAAAA Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar)

UCHIJAAAA examplemod{1.0} [Example Mod] (bin)

UCHIJAAAA modid{v0.1} [Mod Name] (bin)

GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.

Profiler Position: N/A (disabled)

Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Player Count: 1 / 8; [EntityPlayerMP['bl4ckscor3'/244, l='New World', x=217,26, y=66,00, z=258,89]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

 

 

This is the method from the item's class where the GUI is opened from:

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{ 
    if(!par2World.isRemote)
    {
         if(!par1ItemStack.hasTagCompound())
   	{
   		par1ItemStack.stackTagCompound = new NBTTagCompound();
       	        ClientUtils.syncItemNBT(par1ItemStack);
}
    	
    	if(aBoolean)
            par3EntityPlayer.openGui(Main.instance, guiToOpen, par2World, (int) par3EntityPlayer.posX, (int) par3EntityPlayer.posY, (int) par3EntityPlayer.posZ); 
    }
    	
    return par1ItemStack;
}

 

This is ClientUtils.syncItemNBT():

@SideOnly(Side.CLIENT)
public static void syncItemNBT(ItemStack item)
{
    Main.network.sendToServer(new PacketSUpdateNBTTag(item));
}

 

The Packet:

public class PacketSUpdateNBTTag implements IMessage
{
private NBTTagCompound stack;
private String itemName;

public PacketSUpdateNBTTag(ItemStack par1ItemStack)
{
	if(par1ItemStack != null && par1ItemStack.hasTagCompound())
	{
		this.stack = par1ItemStack.stackTagCompound;
		this.itemName = par1ItemStack.getUnlocalizedName();
	}
}

public void fromBytes(ByteBuf buf)
{
	this.stack = ByteBufUtils.readTag(buf);
	this.itemName = ByteBufUtils.readUTF8String(buf);
}

public void toBytes(ByteBuf buf)
{
	ByteBufUtils.writeTag(buf, this.stack);
	ByteBufUtils.writeUTF8String(buf, this.itemName);
}

public static class Handler extends PacketHelper implements IMessageHandler<PacketSUpdateNBTTag, IMessage>
{
	public IMessage onMessage(PacketSUpdateNBTTag message, MessageContext context)
	{
		if(context.getServerHandler().playerEntity.getCurrentEquippedItem() != null && context.getServerHandler().playerEntity.getCurrentEquippedItem().getItem().getUnlocalizedName().matches(message.itemName))
			context.getServerHandler().playerEntity.getCurrentEquippedItem().stackTagCompound = message.stack;	
		return null;
	}
}
}

 

What causes this crash and how can I fix it?

Thanks in advance for any help!

↑↑↑↑↑↑↑↑↑↑ Click it please? :3 ↑↑↑↑↑↑↑↑↑↑

Posted

Update to at least 1.8.9 or at best to 1.10.2, 1.7.10 is not supported anymore on this forum!

Posted

1.7.10 is not supported here.

 

That said, why are you using the stack's item's unlocalized name to insure that you're setting the correct stack's NBT?  There is only one possibility: the item that the player is holding is the item the player is holding.

 

One of the things you need to do, though, is provide a zero-argument constructor to your IMessage class (how else would the server create one?) second, don't put the IMessageHandler inside the IMessage class.  Create two sparate class files: it's possible you've goofed something up in doing it this way.  Third, you probably should send more generic messages than trying to send the NBT data.  This is rife for letting the client dictate rules rather than client asking the server "can I do this thing?" and the server handling the rules.

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.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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