Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So I was trying to create a battery of sorts that will automatically recharge any item that I specify that is in the players inventory. When I load my world with this item already in my inventory I get this Error: AL lib: (EE) alc_cleanup: 1 device not closed. Here is the onUpdate() function in my item class (Everything else is working as intended):

@Override
public void onUpdate(ItemStack batteryStack, World world, Entity entity, int par4, boolean par5)
{
	EntityPlayer player = (EntityPlayer)entity;
	if(!world.isRemote)
	{
		for(int i = 0; i < 104; i++)
		{
			ItemStack itemStack = player.inventory.getStackInSlot(i);
			if(Commons.isChargeable(itemStack.getItem()) && itemStack.getItemDamage() > 0)
			{
				itemStack.setItemDamage(itemStack.getItemDamage() - 1);
				batteryStack.setItemDamage(batteryStack.getItemDamage() + 1);
			}
		}
	}
}

It is kinda hard to charge anything or get if it is chargeable at all if it happens to be null for instance  ;)

If my post helped you, please press that "Thank You"-button to show your appreciation.

 

Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding!

 

Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.

  • Author

.............-facepalm-. Thank you. I'll fix that tomorrow morning. I'm obviously too tired right now.

.............-facepalm-. Thank you. I'll fix that tomorrow morning. I'm obviously too tired right now.

 

Don't forget to hit that "Thank you"-button :)

 

Oh and also change the thread title to have tag [sOLVED]

If my post helped you, please press that "Thank You"-button to show your appreciation.

 

Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding!

 

Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.

Where did you get the magic number 104 from?

Where did you get the batteryStack from?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

Where did you get the magic number 104 from?

Where did you get the batteryStack from?

103 is the head slot which is less than 104.... batteryStack is defined in the parameters for my onUpdate function....

 

Anyways, I null checked and I still get the same crash with the same error. Here is the new code:

@Override
public void onUpdate(ItemStack batteryStack, World world, Entity entity, int par4, boolean par5)
{
	EntityPlayer player = (EntityPlayer)entity;
	if(!world.isRemote)
	{
		for(int i = 0; i < 104; i++)
		{
			ItemStack itemStack = player.inventory.getStackInSlot(i);
			if(itemStack != null)
			{
				if(Commons.isChargeable(itemStack.getItem()) && itemStack.getItemDamage() > 0)
				{
					itemStack.setItemDamage(itemStack.getItemDamage() - 1);
					batteryStack.setItemDamage(batteryStack.getItemDamage() + 1);
				}
			}
		}
	}
}

 

Please post the stacktrace of the crash. We can't do much with "AL lib: (EE) alc_cleanup: 1 " considering that happens WHENEVER the game crashes.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

  • Author

Please post the stacktrace of the crash. We can't do much with "AL lib: (EE) alc_cleanup: 1 " considering that happens WHENEVER the game crashes.

That will not be necessary. I found out that checking for slots 36 - 99, which do not exist, crashes the game. LOL

And Minecraft also doesn't seem to like checking for slots 100 - 103, which are supposed to be the armor slots, either.

  • Author

This code seems to work fine:

@Override
public void onUpdate(ItemStack batteryStack, World world, Entity entity, int par4, boolean par5)
{
	EntityPlayer player = (EntityPlayer)entity;
	if(!world.isRemote)
	{
		for(int i = 0; i < 36; i++)
		{
			ItemStack itemStack = player.inventory.getStackInSlot(i);
			if(itemStack != null)
			{
				if(Commons.isChargeable(itemStack.getItem()) && itemStack.getItemDamage() > 0)
				{
					itemStack.setItemDamage(itemStack.getItemDamage() - 1);
					batteryStack.setItemDamage(batteryStack.getItemDamage() + 1);
				}
			}
		}
	}
}

 

Oh and by the way... im new to the forums, how do I put the [solved] tag?

Oh and by the way... im new to the forums, how do I put the [solved] tag?

Go to the OP, click edit, and put [solved] before the title.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.