Jump to content

New Item SMP mod. How do I manage item IDs?


meathelix

Recommended Posts

I'm working on a mod that adds a few new items to the game. It works fine in single player. It works fine in SMP when I run it from the eclipse IDE. I got it to run fine with builds of Minecraft over the network as well, but there was a problem.

 

I initially assumed that if I set the item IDs to 0-3, that Forge or ModLoader or something would remap them to whatever they needed to be. I was going off of some tutorials I cobbled together, and they all assumed that indexing for their examples. When I got the mod to work, I could craft the new items in SMP but 2 of the items replaced the iron pickaxe and shovel. I didn't check for what the others replaced.

 

I went back to the drawing board and assumed I needed to set the index higher to a spot that wasn't taken by preexisting items. I tried 247-250, 400-403, and 146-149, but all of these resulted in "Internal exception: java.IOException: Received string length is less than zero! Weird string!"

 

After some forum digging, it appears that this can happen when item IDs conflict, so I'm trying to figure out how to manage this correctly. I'm sure there's a disconnect in the way I'm copying the source code from the client to the server as well as the way I'm indexing the items.

 

I'm also intentionally not getting into config files at this point because it's just a local mod for the people in my office. If there's an easy explanation as to how to incorporate those, and that would help solve the problem I'm up for trying it out, as I plan on researching that before I release this thing into the wild anyway.

 

mod server source:

 

package net.minecraft.src;

import net.minecraft.src.Lenses.*;
import net.minecraft.src.forge.*;

public class mod_Lenses extends NetworkMod 

{
public static final Item itemLens = (new ItemLens(146)).setIconIndex(0).setItemName("itemLens");
public static final Item itemTelescope = (new ItemTelescope(147)).setIconIndex(1).setItemName("itemTelescope");

public static final Item itemDiamondLens = (new ItemDiamondLens(148)).setIconIndex(2).setItemName("itemDiamondLens");
public static final Item itemDiamondTelescope = (new ItemDiamondTelescope(149)).setIconIndex(3).setItemName("itemDiamondTelescope");


public String getVersion() 
{

	return "0.0.0.0";
}


public void load() 
{
	//MinecraftForgeClient.preloadTexture("/Lenses/items.png");
        //MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
        
        ModLoader.addName(itemLens, "Glass Lens");
        ModLoader.addName(itemTelescope, "Telescope");
        ModLoader.addName(itemDiamondLens, "Diamond Lens");
        ModLoader.addName(itemDiamondTelescope, "Diamond Telescope");
        this.addrecipes();        
}

private void addrecipes()
{
	ModLoader.addRecipe(new ItemStack(itemLens, 1), new Object[] 
			{	"_X_", 
				"X_X", 
				"_X_",
				'X', Block.glass  });	
	ModLoader.addRecipe(new ItemStack(itemTelescope, 1), new Object[] 
			{	"_X_", 
				"#*#", 
				"_X_",
				'X', itemLens,
				'#', Item.leather,
				'*',Item.ingotIron});
	ModLoader.addRecipe(new ItemStack(itemDiamondLens, 1), new Object[] 
			{	"_X_", 
				"X_X", 
				"_X_",
				'X', Item.diamond  });	
	ModLoader.addRecipe(new ItemStack(itemDiamondTelescope, 1), new Object[] 
			{	"_X_", 
				"#*#", 
				"_X_",
				'X', itemDiamondLens,
				'#', Item.leather,
				'*',Item.ingotGold});
}

	@Override
	public boolean clientSideRequired()
	{
	        return true;
	}

	@Override
	public boolean serverSideRequired()
	{
	        return false;
	}
}

 

 

 

client mod source:

 

package net.minecraft.src;

import net.minecraft.src.Lenses.*;
import net.minecraft.src.forge.*;

public class mod_Lenses extends NetworkMod 

{
public static final Item itemLens = (new ItemLens(146)).setIconIndex(0).setItemName("itemLens");
public static final Item itemTelescope = (new ItemTelescope(147)).setIconIndex(1).setItemName("itemTelescope");

public static final Item itemDiamondLens = (new ItemDiamondLens(148)).setIconIndex(2).setItemName("itemDiamondLens");
public static final Item itemDiamondTelescope = (new ItemDiamondTelescope(149)).setIconIndex(3).setItemName("itemDiamondTelescope");


public String getVersion() 
{

	return "0.0.0.0";
}


public void load() 
{
	MinecraftForgeClient.preloadTexture("/Lenses/items.png");
        //MinecraftForgeClient.preloadTexture("/CamelMod/CamelOre/gui/items.png");
        
        ModLoader.addName(itemLens, "Glass Lens");
        ModLoader.addName(itemTelescope, "Telescope");
        ModLoader.addName(itemDiamondLens, "Diamond Lens");
        ModLoader.addName(itemDiamondTelescope, "Diamond Telescope");
        this.addrecipes();        
}

private void addrecipes()
{
	ModLoader.addRecipe(new ItemStack(itemLens, 1), new Object[] 
			{	"_X_", 
				"X_X", 
				"_X_",
				'X', Block.glass  });	
	ModLoader.addRecipe(new ItemStack(itemTelescope, 1), new Object[] 
			{	"_X_", 
				"#*#", 
				"_X_",
				'X', itemLens,
				'#', Item.leather,
				'*',Item.ingotIron});
	ModLoader.addRecipe(new ItemStack(itemDiamondLens, 1), new Object[] 
			{	"_X_", 
				"X_X", 
				"_X_",
				'X', Item.diamond  });	
	ModLoader.addRecipe(new ItemStack(itemDiamondTelescope, 1), new Object[] 
			{	"_X_", 
				"#*#", 
				"_X_",
				'X', itemDiamondLens,
				'#', Item.leather,
				'*',Item.ingotGold});
}

}

 

Link to comment
Share on other sites

Forge does not do ID resolution, whatever tutorial you used was wrong or you misunderstood it.

You need to pick ids that are not in use. Hence why configurations and initializing your items properly is a good idea.

http://www.minecraftwiki.net/wiki/Data_values#Item_IDs

Remember to add 256 to your id to get the id on that chart.

As for the exception, show a proper stack trace and we could prolly help.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

So, ignoring the exception for a second, using the IDs 146-149 should have worked, right?

 

Also, the bug only occurs when I run with the standalone game, so I can't get a stack trace. Running it from the IDE and the MCP batch files works perfectly, much to my dismay.  :(

Link to comment
Share on other sites

Learn to run the normal game from the command line, if its truly an error you can always get a stack trace.

And yes, those ids are unused in vanilla, but may be used by other mods.

So ya, get a stacktrace, or we cant do anything.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Ok, here you go.

 

Dump from client:

 

 

C:\Users\rwilson\AppData\Roaming\.minecraft\bin>java -Xmx2048m -Xms2048m -jar mi

necraftBasic.jar

27 achievements

182 recipes

Setting user: meathelix, 4866673626411892980

LWJGL Version: 2.4.2

Jun 26, 2012 3:29:34 PM cpw.mods.fml.common.FMLCommonHandler beginLoading

INFO: Attempting early MinecraftForge initialization

Jun 26, 2012 3:29:34 PM cpw.mods.fml.common.FMLCommonHandler beginLoading

INFO: Completed early MinecraftForge initialization

2012-06-26 15:29:34 [iNFO] Forge Mod Loader version 2.2.48.135 for Minecraft 1.2

.5 loading

2012-06-26 15:29:34 [iNFO] Loading mods from C:\Users\rwilson\AppData\Roaming\.m

inecraft\mods

2012-06-26 15:29:34 [iNFO] Forge Mod Loader has loaded 2 mods

CONFLICT @ 0

CONFLICT @ 1

CONFLICT @ 2

CONFLICT @ 3

WARNING: Found unknown Windows version: Windows 7

Attempting to use default windows plug-in.

Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin

Failed to initialize device Wacom Virtual Hid Driver because of: java.io.IOExcep

tion: Failed to acquire device (8007001e)

MinecraftForge v3.3.7.135 Initialized

2012-06-26 15:29:35 [iNFO] MinecraftForge v3.3.7.135 Initialized

2012-06-26 15:29:35 [iNFO] Forge Mod Loader load complete, 2 mods loaded

 

Starting up SoundSystem...

Initializing LWJGL OpenAL

    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.or

g)

OpenAL initialized.

 

Connecting to 127.0.0.1, 25565

java.io.IOException: Received string length is less than zero! Weird string!

        at abs.a(SourceFile:200)

        at amg.a(SourceFile:16)

        at abs.a(SourceFile:155)

        at lg.e(NetworkManager.java:227)

        at lg.c(NetworkManager.java:389)

        at rl.run(SourceFile:76)

 

 

Dump from server:

 

 

2012-06-26 15:30:07 [iNFO] meathelix [/127.0.0.1:54293] logged in with entity id 400 at (-34.34375, 75.0, 118.09375)

2012-06-26 15:30:07 [iNFO] meathelix joined with: [MinecraftForge 3.3.7.135, Lenses 0.0.0.0]

2012-06-26 15:30:08 [iNFO] meathelix lost connection: disconnect.endOfStream

 

Link to comment
Share on other sites

Interesting the issue is that you are running into a kick message, with a blank message... or so it would seem.

And what version of Forge are you using ojn the client?

And why are you not using 152?

Any chance I could get you to run a packet logger. {Google if you don't know how}

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

I'm using 135 on both. It was just the recommended version I came across when I was setting things up at the end of last week.

 

I'm going to try migrating to 152 or 153 and see if that changes anything.

 

Also, what logging program do you recommend? The search results come up with several random ones, and I don't know which one is the best to use.

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.