Jump to content

[1.7.2] onUpdate Method Not Being Called for Custom Item


Malkuthe

Recommended Posts

Hi! I'm having a bit of an issue, and were it, frankly, a more mundane one, I would have crashlogs to post, however, I do not. The game isn't crashing. onUpdate is simply not working. I thought it may have been the functionality I put into the code, however, even with just

System.out.println("onUpdate is now working!")

the console is not printing anything despite me having the item in my inventory.

 

This is the item itself: ItemConsumingRage.

 

This is the class it extends: SAAItemEmpowered.

 

And this is the class that the class the item extends extends, which in turn extends Item... did that make any sense? SAAItem

 

A thing to note is that an item that extends SAAItem alone seems to be working just fine. Another thing to note is that the onCreated method for ItemConsumingRage -is- being called, so I have no idea what the heck is going on.

 

Anyone have any ideas?

Link to comment
Share on other sites

Dude!

 

Waste no more time!    Get thee hence to debugging school posthaste!

 

I guess you're using Eclipse? 

 

http://www.vogella.com/tutorials/EclipseDebugging/article.html

or

http://agile.csc.ncsu.edu/SEMaterials/tutorials/eclipse-debugger/

or many many more

 

Seriously, it's really straightforward to learn and once you've tried it you'll wonder how on earth you ever managed without them.  Step through your code line by line to see where it's going, look at the variables and see what happens to them at each step.  In this case, it will let you find out in 2 minutes flat what happens when the vanilla code gets to your item and tries to call onUpdate for it.

 

-TGG

 

 

Link to comment
Share on other sites

Grey,

I've used that type of debugging in VBA and other applications and loved it.  I had 'assumed' incorrectly that with how we were running the testing environment for Eclpise that thye wouldn't work here.

 

what happens to the server or client when the other hits one of these breaks in the testing envioronment?

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

@Delpi

 

Not sure about Eclipse - I use IntelliJ - but when I set a breakpoint on a line in my code or in the vanilla source, it runs to that line and stops exactly like you'd expect.  IntelliJ gives the option of pausing all threads or just the one with the breakpoint, so you can choose what you want it to do (normally I suspend both threads, but doing client or server only also works).

 

-TGG

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

    • How to fix file server-1.20.1-20230612.114412-srg.jar  
    • Just a few months ago I was creating my own plugin for Minecraft 1.20.2 spigot that did the same thing, but the skins were not saved, if you can understand this code that I made a long time ago it may help you.   //This is a class method private static String APIRequest(String value, String url, String toSearch) { try { URL api = new URL(url + value); HttpURLConnection connection = (HttpURLConnection) api.openConnection(); connection.setRequestMethod("GET"); int responseCode = connection.getResponseCode(); if (responseCode == HttpURLConnection.HTTP_OK) { BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuilder response = new StringBuilder(); for (String responseChar; (responseChar = reader.readLine()) != null; ) response.append(responseChar); reader.close(); JSONObject responseObject = new JSONObject(response.toString()); if (!toSearch.equals("id")) return responseObject .getJSONArray("properties") .getJSONObject(0) .getString("value"); else return responseObject.getString("id"); } else { AntiGianka.ConsoleMessage(ChatColor.RED, String.format( "Could not get %s. Response code: %s", ((toSearch.equals("id")) ? "UUID" : "texture"), responseCode )); } } catch (MalformedURLException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } catch (IOException error) { AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while attempting to connect to the URL. Error: " + error); } return ""; } //other class method private void SkinGetter() { String uuid; String textureCoded; if ((uuid = APIRequest(args[0], "https://api.mojang.com/users/profiles/minecraft/", "id")).isEmpty() || (textureCoded = APIRequest(uuid, "https://sessionserver.mojang.com/session/minecraft/profile/", "value")).isEmpty() ) sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); else SkinSetter(textureCoded); } //other more private void SkinSetter(String textureCoded) { JSONObject profile = new JSONObject(new String(Base64.getDecoder().decode(textureCoded))); try { URL textureUrl = new URL(profile.getJSONObject("textures"). getJSONObject("SKIN"). getString("url")); if (sender instanceof Player && args.length == 1) { PlayerTextures playerTextures = ((Player) sender).getPlayerProfile().getTextures(); playerTextures.setSkin(textureUrl); ((Player) sender).getPlayerProfile().setTextures(playerTextures); if (((Player) sender).getPlayerProfile().getTextures().getSkin() != null) sender.sendMessage(((Player) sender).getPlayerProfile().getTextures().getSkin().toString()); else sender.sendMessage("Null"); sender.sendMessage("Skin changed successfully.a"); } else { } AntiGianka.ConsoleMessage(ChatColor.GREEN, "Skin command executed successfully."); } catch (MalformedURLException error) { sender.sendMessage(ChatColor.RED + String.format( "An error has occurred while trying to obtain the %s player skin, please check if the name %s is spelled correctly or try again later.", args[0], args[0] ) ); AntiGianka.ConsoleMessage(ChatColor.RED, "An error occurred while trying to access the URL. Error: " + error); } }  
    • Use /locate structure The chat should show all available structures as suggestion For the Ancient City it is /locate structure ancient_city
    • So does it work without this mod? Did you test it with other builds?
  • Topics

×
×
  • Create New...

Important Information

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