Jump to content

Recommended Posts

Posted

I don't even know what's causing this one. It happens whenever I right click an item that I created.

 

Note: It works perfectly the first two times I use it but on the third one it crashes. Also this only seems to pertain to the Skin type.

 

Error

14:22:29] [server thread/FATAL] [FML]: Exception caught executing FutureTask: java.util.concurrent.ExecutionException: java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.7.0_79]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.7.0_79]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:715) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:727) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171) [integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.7.0_79]
Caused by: java.lang.NullPointerException
at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:398) ~[itemInWorldManager.class:?]
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:607) ~[NetHandlerPlayServer.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:67) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:114) ~[C08PacketPlayerBlockPlacement.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:24) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.7.0_79]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.7.0_79]
at net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:714) ~[FMLCommonHandler.class:?]

 

Item Class

@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn){
	if (!worldIn.isRemote){
		if(!playerIn.capabilities.isCreativeMode){
			if(PackManager.crackPack(playerIn, type)){
				itemStackIn.stackSize --;
				return null;
			}else{
				playerIn.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You are out of inventory space!"));
			}
		}else{
			playerIn.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must be in survival mode to use this!"));
		}
	}
	return itemStackIn;
}

 

More code that might be helpful.

/**
 * Opens a trail pack for the player.
 * @param player
 */
public static boolean crackPack(EntityPlayer player, EnumPackType type){
	if(!player.worldObj.isRemote){
		switch(type){
		default:
			logger.error("Invalid pack type for type " + type + "!");
			return false;
		case Trail:
			if(player.inventory.hasItem(ItemManager.trailPack)){
				Trail trail = TrailManager.getRandomTrail();

				ItemStack is = new ItemStack(ItemManager.openedTrailPack, 1);
				NBTTagCompound tag = new NBTTagCompound();
				is.setTagCompound(tag);
				tag.setString("Type", EnumPackType.Trail.toString());
				tag.setString("Trail", trail.getName());
				is.setStackDisplayName("" + EnumAppRarity.getColorFromTrail(trail) + trail.getRarity() + EnumChatFormatting.AQUA + " Trail Pack");

				if(player.inventory.addItemStackToInventory(is)){
					player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have cracked a " + EnumAppRarity.getColorFromTrail(trail) + trail.getRarity() + EnumChatFormatting.AQUA + " Trail of " + EnumAppRarity.getColorFromTrail(trail) + trail.getName() + "!"));
					if(trail.getRarity() == EnumAppRarity.Mythic){
						PacketManager.sendPacketToAll(new PacketChatMessage(EnumChatFormatting.GOLD + player.getName() + " just cracked a " + EnumAppRarity.getColorFromTrail(trail) + trail.getRarity() + EnumChatFormatting.GOLD + " Trail of " + EnumAppRarity.getColorFromTrail(trail) + trail.getName() + "!"));
					}
					return true;
				}else{
					return false;
				}
			}
			break;
		case Skin:
			if(player.inventory.hasItem(ItemManager.skinPack)){
				Skin skin = SkinManager.getRandomSkin();

				ItemStack is = new ItemStack(ItemManager.openedSkinPack, 1);
				NBTTagCompound tag = new NBTTagCompound();
				is.setTagCompound(tag);
				tag.setString("Type", EnumPackType.Skin.toString());
				tag.setString("Skin", skin.getName());
				is.setStackDisplayName("" + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getRarity() + EnumChatFormatting.AQUA + " Skin Pack");

				if(player.inventory.addItemStackToInventory(is)){
					player.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "You have cracked a " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getRarity() + EnumChatFormatting.AQUA + " Skin of " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getName() + "!"));
					if(skin.getRarity() == EnumAppRarity.Mythic){
						PacketManager.sendPacketToAll(new PacketChatMessage(EnumChatFormatting.GOLD + player.getName() + " just cracked a " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getRarity() + EnumChatFormatting.GOLD + " Skin of " + EnumAppRarity.getColorFromRarity(skin.getRarity()) + skin.getName() + "!"));
					}
					return true;
				}else{
					return false;
				}
			}
			break;
		}

	}
	return false;
}

Posted

I think the error is caused by returning null from

Item#onItemRightClick

.

ItemInWorldManager#tryUseItem

expects a non-null

ItemStack

to be returned, even if its

stackSize

is 0 (which it explicitly checks for).

 

Oddly enough, it does check if the returned

ItemStack

is null; but only after checking that the returned

ItemStack

is equal to the original

ItemStack

(which can't possibly be null at that point).

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
  On 8/21/2015 at 7:44 PM, Choonster said:

I think the error is caused by returning null from

Item#onItemRightClick

.

ItemInWorldManager#tryUseItem

expects a non-null

ItemStack

to be returned, even if its

stackSize

is 0 (which it explicitly checks for).

 

Oddly enough, it does check if the returned

ItemStack

is null; but only after checking that the returned

ItemStack

is equal to the original

ItemStack

(which can't possibly be null at that point).

 

If I don't return null then for whatever ungodly reason is it starts to give me negative item stack sizes.

 

EDIT: Just for testing purposes I made it return the itemstack regardless but the error is still happening.

EDIT EDIT: Well I take back my last edit, I see your reasoning so I made it return the itemstack and now it crashes without any errors.

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Start by following the docs to get a workspace setup: https://docs.minecraftforge.net/en/latest/gettingstarted/ Then poke around some of the tutorials, https://www.mcjty.eu/docs/1.20/ used to be the goto, but not sure if there are any updates for regular forge or not, but if you've brushed up on Java, it will be enough to get you started. Poke around the Minecraft and Forge sources to see how things are done. Read the FAQ for information on how to post code/logs when you run into issues. Share as much info on issues you have as possible. Use github to host projects, chances of someone helping are higher when they can actually see all your code and/or build it themselves. And finally, keep it on the forums, don't direct message people with questions, most people do not provide personal support like that. Also keep in mind forums posts are not always immediately answered, if you're looking for a quicker response, you can always try the Minecraft Forge discord server.
    • Hello, I have a Forge Minecraft sever (I host it at g-portal.com) which has always worked fine and I had no problems, but today it doesn't wanna work anymore. Today I started the server and the status said online, but after a few seconds it said this: "Start failed". And then out of nowhere it restarted itself and the same thing happened again and again and now it's in an infinite loop where it just keeps failing and then restarts. Here's the download link for the server logs: https://www.mediafire.com/file/sq30dgoonjevib1/2025-07-06-1.log/file Does anyone know how to fix this? If yes I would really appreciate help. Best wishes, Gabs1107
    • I'm experiencing a critical issue on a dedicated Arch Linux server running the latest Forge for Minecraft 1.20.1. When a player exits a Nether portal (not enters, and not via /tp) or teleports into the End via portal, the server completely freezes for 1–10 minutes. During this time, all commands are unresponsive, and the game world essentially locks up. This is with watchdog disabled. Environment: OS: Arch Linux (latest packages) Java: OpenJDK 17 (up to date) Forge Version: Latest 1.20.1 (tested multiple versions from the past ~3 months) Mods: None (issue occurs on a clean install) Server Type: Proxmox VM with: 4 virtual cores 64 GB RAM (63 GB allocated via -Xmx and -Xms flags) Observed Behavior: Observed Behavior: The server freezes for 1–10 minutes when: Exiting a Nether portal (entering does not trigger the issue) Entering or exiting the End using a portal Teleporting using commands (e.g., /tp) works only for the Nether; teleporting to the End via command also causes a freeze The issue occurs anywhere in the world, not tied to specific coordinates or builds During the freeze: The server becomes completely unresponsive to all commands and player actions No crash reports, no errors, and no warnings are logged CPU usage remains under 50%, and RAM usage stays around 6–14 GB After 1–10 minutes, the server recovers automatically and resumes normal operation
  • Topics

×
×
  • Create New...

Important Information

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