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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm using Modrinth as a launcher for a forge modpack on 1.20.1, and can't diagnose the issue on the crash log myself. Have tried repairing the Minecraft instillation as well as removing a few mods that have been problematic for me in the past to no avail. Crash log is below, if any further information is necessary let me know. Thank you! https://paste.ee/p/k6xnS
    • Hey folks. I am working on a custom "Mecha" entity (extended from LivingEntity) that the player builds up from blocks that should get modular stats depending on the used blocks. e.g. depending on what will be used for the legs, the entity will have a different jump strength. However, something unexpected is happening when trying to override a few of LivingEntity's functions and using my new own "Mecha" specific fields: instead of their actual instance-specific value, the default value is used (0f for a float, null for an object...) This is especially strange as when executing with the same entity from a point in the code specific to the mecha entity, the correct value is used. Here are some code snippets to better illustrate what I mean: /* The main Mecha class, cut down for brevity */ public class Mecha extends LivingEntity { protected float jumpMultiplier; //somewhere later during the code when spawning the entity, jumpMultiplier is set to something like 1.5f //changing the access to public didn't help @Override //Overridden from LivingEntity, this function is only used in the jumpFromGround() function, used in the aiStep() function, used in the LivingEntity tick() function protected float getJumpPower() { //something is wrong with this function //for some reason I can't correctly access the fields and methods from the instanciated entity when I am in one of those overridden protected functions. this is very annoying LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 0f return this.jumpMultiplier * super.getJumpPower(); } //The code above does not operate properly. Written as is, the entity will not jump, and adding debug logs shows that when executing the code, the value of this.jumpMultiplier is 0f //in contrast, it will be the correct value when done here: @Override public void tick() { super.tick(); //inherited LivingEntity logic //Custom logic LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 1.5f } } My actual code is slightly different, as the jumpMuliplier is stored in another object (so I am calling "this.legModule.getJumpPower()" instead of the float), but even using a simple float exactly like in the code above didn't help. When running my usual code, the object I try to use is found to be null instead, leading to a crash from a nullPointerException. Here is the stacktrace of said crash: The full code can be viewed here. I have found a workaround in the case of jump strength, but have already found the same problem for another parameter I want to do, and I do not understand why the code is behaving as such, and I would very much like to be able to override those methods as intended - they seemed to work just fine like that for vanilla mobs... Any clues as to what may be happening here?
    • Please delete post. Had not noticed the newest edition for 1.20.6 which resolves the issue.
    • https://paste.ee/p/GTgAV Here's my debug log, I'm on 1.18.2 with forge 40.2.4 and I just want to get it to work!! I cant find any mod names in the error part and I would like some help from the pros!! I have 203 mods at the moment.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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