Posted May 6, 201510 yr 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); } } } }
May 6, 201510 yr 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.
May 6, 201510 yr Author .............-facepalm-. Thank you. I'll fix that tomorrow morning. I'm obviously too tired right now.
May 6, 201510 yr .............-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.
May 6, 201510 yr 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/
May 6, 201510 yr 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); } } } } }
May 7, 201510 yr 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.
May 7, 201510 yr 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.
May 7, 201510 yr 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?
May 7, 201510 yr 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.