Git Product home page Git Product logo

Comments (4)

FindZach avatar FindZach commented on June 19, 2024

Update the issue was coming from the

BotHooks#draw(MainBufferProvider, Graphics, x, y) method

Commented out the draw method inside of the method above

        // Draw the image onto the game canvas
        //graphics.drawImage(image, 0, 0, bot.getCanvas());

from osrsbot.

FindZach avatar FindZach commented on June 19, 2024

**Unofficial Fix - Works for me

Replace your BotHooks#draw method with mine**

    @Override
    public void draw(MainBufferProvider mainBufferProvider, Graphics graphics, int x, int y) {
        try {


            //Preferably initialize the value of bot with the current bot on screen
           // IE Application.getBot or similar manner.



            if (graphics == null) {
                return;
            }
            // We only want do do this once because this would MASSIVELY affect performance.


            /*
            if (SUPERCLASS_MAP.get(SUPERCLASS_MAP.keySet().iterator().next()) == null) {

                for (Method method : this.getClass().getSuperclass().getDeclaredMethods()) {
                    Iterator itr = SUPERCLASS_MAP.keySet().iterator();
                    while (itr.hasNext()) {
                        String name = (String) itr.next();
                        if (method.getName().equals(name)) {
                            method.setAccessible(true);
                            SUPERCLASS_MAP.replace(name, null, method);
                        }
                    }
                }
                for (Field field : this.getClass().getSuperclass().getDeclaredFields()) {
                    Iterator itr = SUPERCLASS_MAP.keySet().iterator();
                    while (itr.hasNext()) {
                        String name = (String) itr.next();
                        if (field.getName().equals(name)) {
                            field.setAccessible(true);
                            SUPERCLASS_MAP.replace(name, null, field);
                        }
                    }
                }
            }*/

            //We then simply invoke the method as needed here. It should perform similar to how it does in RuneLite
            //final Graphics2D graphics2d = (Graphics2D) ((Method) SUPERCLASS_MAP.get(GETGRAPHICS)).invoke(this,
             //       mainBufferProvider);

            Image image = mainBufferProvider.getImage();
            // finalImage is backed by the client buffer which will change soon. make a copy
            // so that callbacks can safely use it later from threads.
            drawManager.processDrawComplete(() -> copy(image));

            final Graphics2D g2d = (Graphics2D) bot.getCanvas().getGraphics(bot, mainBufferProvider);

            // Draw the image onto the game canvas
            //graphics.drawImage(image, 0, 0, bot.getCanvas());

            g2d.drawImage(image, 0, 0, bot.getCanvas());


        } catch (Exception e) {
            e.printStackTrace();
            //log.warn("Bot hooks failed to paint properly");
        }
    }

from osrsbot.

GigiaJ avatar GigiaJ commented on June 19, 2024

Looks good, I'll check in a bit to make sure it works properly. Basically what happens on
final Graphics2D g2d = (Graphics2D) bot.getCanvas().getGraphics(bot, mainBufferProvider);
is that it allows the bot canvas to be passed the MainBufferProvider for use in getBufferGraphics
It simply allows overlay from the bot to be painted onto the canvas and stores the buffer on the variable back. (Might be unnecessary, but a good bit of the code is just an inefficient port.)

Not sure what could've caused it to have any issues.

from osrsbot.

GigiaJ avatar GigiaJ commented on June 19, 2024

Been a bit, but I just got around to checking after porting a completely different code base to use with this.

Seems your change causes the bot to fail to display at all.

from osrsbot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.