Jump to content

[1.7.10] Ticking memory connection NBT Error


MrNegaBlox

Recommended Posts

So I am trying to make an item that saves coordinates when you right click. I think it might have to do with packets, but I am not sure.  When I right click on the ground, I get a crash:

---- Minecraft Crash Report ----
// Why is it breaking 

Time: 8/24/15 9:21 AM
Description: Ticking memory connection

java.lang.NullPointerException: Ticking memory connection
at io.github.mrnegablox.tecmod.item.GPS.onItemUse(GPS.java:36)
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:507)
at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:142)
at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:422)
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
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 io.github.mrnegablox.tecmod.item.GPS.onItemUse(GPS.java:36)
at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:507)
at net.minecraft.item.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:142)
at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:422)
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
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@79c04bb1
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 7 (amd64) version 6.1
Java Version: 1.7.0_75, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 268821320 bytes (256 MB) / 444596224 bytes (424 MB) up to 954728448 bytes (910 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: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 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.1448-1.7.10.jar) 
UCHIJAAAA	Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) 
UCHIJAAAA	Tec2Mod_NegaBlox{0.1.0} [Tec Mod 2] (bin) 
UCHIJAAAA	examplemod{1.0} [Example Mod] (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['LoztInSpace'/247, l='Test', x=-559.12, y=4.00, z=-197.03]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'fml,forge'

 

Here is the code:

 

Main Class:

package io.github.mrnegablox.tecmod;

import io.github.mrnegablox.tecmod.item.ModItems;
import net.minecraft.entity.EntityTracker;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;

@Mod(modid = Tec2Mod.MODID, name = Tec2Mod.MODNAME, version = Tec2Mod.VERSION)
public class Tec2Mod {

    public static final String MODID = "Tec2Mod_NegaBlox";
    public static final String MODNAME = "Tec Mod 2";
    public static final String VERSION = "0.1.0";
        
    @SidedProxy(clientSide = "io.github.mrnegablox.tecmod.ClientProxy", serverSide = "io.github.mrnegablox.tecmod.ServerProxy")
    public static CommonProxy proxy;
    
    //public static SimpleNetworkWrapper network;
    
    @Instance
    public static Tec2Mod instance = new Tec2Mod();
        
     
    @EventHandler
    public void preInit(FMLPreInitializationEvent e) {
    	//network = NetworkRegistry.INSTANCE.newSimpleChannel("TecTalk");
        //network.registerMessage(MyMessage.Handler.class, MyMessage.class, 0, Side.SERVER);
    	ModItems.init();
    }
        
    @EventHandler
    public void init(FMLInitializationEvent e) {

    }
        
    @EventHandler
    public void postInit(FMLPostInitializationEvent e) {
                
    }
}

 

The Problem Item:

package io.github.mrnegablox.tecmod.item;



import io.github.mrnegablox.tecmod.Tec2Mod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;

public class GPS extends Item {

public double savedTargetX = 0;
public double savedTargetY = 0;
public double savedTargetZ = 0;

public NBTTagCompound compound;

public GPS() {
	setMaxStackSize(1);
}

@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player,
		World world, int x, int y, int z, int l, float f, float f1, float f2) {
	if(world.isRemote)
		return true;
    	player.addChatComponentMessage(new ChatComponentText("Target saved"));
    	savedTargetX = x + 0.5;
    	savedTargetY = y;
    	savedTargetZ = z + 0.5;
    	compound = itemstack.getTagCompound();
    	compound.setDouble("TargetX", savedTargetX);
    	compound.setDouble("TargetY", savedTargetY);
    	compound.setDouble("TargetZ", savedTargetZ);
    	itemstack.stackTagCompound = compound;
    	player.addChatComponentMessage(new ChatComponentText("X       - " + savedTargetX));
//    	entityplayer.addChatMessage("Y       - " + savedTargetY);
    	player.addChatComponentMessage(new ChatComponentText("Z       - " + savedTargetZ));
//    	entityplayer.addChatMessage("BlockID - " + world.getBlockId(i, j, k));
    	
    	
        return true;
}

@Override
public void onCreated(ItemStack item, World world,
	EntityPlayer player) {
item.stackTagCompound = new NBTTagCompound();


}

}

 

If it is packets, what do I send? a packet that tells Forge that NBT is being edited?

 

BONUS:

I have been trying to figure out how packets work. I have seen things like diesieben's tutorial. But how would I update a server on something like an entities location?

Link to comment
Share on other sites

Does that code really show up in your IDE without a ton of errors reported? 

 

Things to do:

- Go read up on NBTTagCompound.  Search for some tutorials

- Delete all the variables you defined for your item.  They won't work the way you want them to. If you want variables specific to an itemstack in the world, you have to store the variables values in the itemstack NBT Data and then pull them out each time you want to use them.  You can't store in the Item class.  there is only one of those and its not unique for your itemstack in the world.

- 'compound = itemstack.getTagCompound();' is probably giving error.  You need to test if there is a tagcompound first and there probably isn't.  If there isn't add one first.

- 'itemstack.stackTagCompound = compound;' is not how you write the data back. 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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