Help with the Spout API

Discussion in 'Plugin Development' started by MuisYa, Aug 20, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    MuisYa

    I really need some help with the Spout API,
    Spout is a very good plugin, which im really interested in. But i just cant get it figured out, if there is a developer who could give me some info. Not very much, im very pleased!
    Feel free to add me on skype! Just reply and ill pm my name :D

    Thanks Muis!
     
  2. Offline

    iKrazy

    What do you want to know about it?
     
  3. Offline

    MuisYa

    @iKrazy
    Well, i viewed the Spout javadocs.
    But how is a "Achievement get" thingie called in Spout language :3
    How do i make a new HUD with buttons which perform commands?

    Thanks for the fast response! D:
     
  4. Offline

    iKrazy

  5. Offline

    MuisYa

    @iKrazy
    For the HUD? Andd eeeehm, how should i tell Eclipse to call the widget? :3
     
  6. Offline

    iKrazy

    This is all taken from http://forums.bukkit.org/threads/me...ms-and-blocks-w-spout-1060.32271/#post-598512 btw.

    Well you'd have to have a keylistener, so not in your main class, but in your "KeyListener" class

    Code:
    public class Sp_KeyListener extends InputListener {
    
        private YOUR_PLUGINNAME plugin;
    
        public Sp_KeyListener(YOUR_PLUGINNAME plugin) {
            this.plugin = plugin;
        }
    
        public void onKeyPressedEvent(KeyPressedEvent event) {
     
            if (event.getKey() == Keyboard.KEY_ESCAPE) {
                event.getPlayer().getMainScreen().closePopup();
            }
    Then your if statement,

    Code:
    ScreenType screentype = event.getScreenType();
                if ((screentype != null)
                        && ((screentype == ScreenType.GAME_SCREEN)
                                || (screentype == ScreenType.PLAYER_INVENTORY)
                                || (screentype == ScreenType.DISPENSER_INVENTORY)
                                || (screentype == ScreenType.FURNACE_INVENTORY)
                                || (screentype == ScreenType.WORKBENCH_INVENTORY) || (screentype == ScreenType.CUSTOM_SCREEN))) {
    
                    SpoutPlayer player = event.getPlayer();
                    InGameHUD hudscreen = player.getMainScreen();
                    //System.out.println("hudscreen: " + hudscreen);
    
                    GenericPopup popscreen = new GenericPopup();
                    popscreen.setVisible(true);
     
                    popscreen.attachWidget(plugin, new GenericButton()
                    .setText("EXIT")
                    .setWidth(60).setHeight(10)
                    .setX(334).setY(5));
     
                    popscreen.attachWidget(plugin, new GenericButton()
                    .setText(amountdrop)
                    .setWidth(60).setHeight(10)
                    .setX(35).setY(5));
    Then you have to have a "ButtonListener" class

    Code:
    public class Sp_ButtonListener extends ScreenListener {
    
        private Spitems plugin;
    
        public Sp_ButtonListener(Spitems plugin) {
            this.plugin = plugin;
        }
    
        @Override
        public void onButtonClick(ButtonClickEvent event) {
    
            String tooltip_text = event.getButton().getTooltip();
            SpoutPlayer evt_player = event.getPlayer();
    
            if (event.getButton().isDirty()){
                return;
            }
     
            if (event.getButton().getText().equals("EXIT")) {
    
                event.getPlayer().getMainScreen().closePopup();
    
                return;
            }    
    My advice is just do what I did and try to learn how to use it from his, http://forums.bukkit.org/threads/me...ms-and-blocks-w-spout-1060.32271/#post-598512, the source is in the jar.
     
  7. Offline

    MuisYa

    I cant get one thing fixed, when i press the button p i now got a message, how do i fix it so the HUD will popup?
    @iKrazy
    Thanks alot btw!

    Also if i type in the chat and say "Poo" the HUD will popup.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  8. Offline

    iKrazy

    I'm guessing your key is P, and when you type "Poo" it is listening for that P. So do an if statement on if chat pulled up or something, I can't look at the classes right now but I'll look at them in a bit!

    Did you try adding a Key Binding?

    Code:
    void addKeyBinding(Keyboard, KEY_P, YOURPLUGIN)
    Another option would be binding it to a key that doesn't have a use in chat, such as F12 or one of the function keys.

    Code:
    public class Sp_KeyListener extends InputListener {
    
        private YOURPLUGIN plugin;
    
        public Sp_KeyListener(YOURPLUGIN plugin) {
            this.plugin = plugin;
        }
    
        public void onKeyPressedEvent(KeyPressedEvent event) {
    
            if (event.getKey() == Keyboard.KEY_F12) {
                event.getPlayer().getMainScreen().closePopup();
            }
     
  9. Offline

    iPixeli

    *curious bukkit noob sticks around to see what I might learn*
     
  10. Offline

    MuisYa

    Hahaha, @iPixeli i started that way to!
     
  11. Offline

    RogerWaters

    Hallo,
    I have a problem with the spoutAPI. I write on a addon that allows custom block forms.
    But everytime i create a new instance of GenericBlockDesign the server does anything i do not know.

    Code:
            //3 Points per triangle
            int points = mesh.triangles.length * 3;
    
            float[][] xPos = new float[1][points];
            float[][] yPos = new float[1][points];
            float[][] zPos = new float[1][points];
    
            float[][] xTex = new float[1][points];
            float[][] yTex = new float[1][points];
           //...Some conversion from mesh triangles to the coords
    
            //And here the server takes 100% CPU usage and seems to freeze until doing nothing at all also after hours
    
            new GenericBlockDesign(mesh.min().x, mesh.min().y, mesh.min().z, mesh.max().x, mesh.max().y, mesh.max().z, textureURL, texturePlugin, xPos, yPos, zPos, xTex, yTex, 0);
    
    Using Spout 642

    I have also looked at scource from spoutcraft the ctor does only store the parameters in the object. Here is the code I found:

    Code:
        public GenericBlockDesign(float lowXBound, float lowYBound, float lowZBound, float highXBound, float highYBound, float highZBound, String textureURL, Plugin texturePlugin, float[][] xPos, float[][] yPos, float[][] zPos, float[][] textXPos, float[][] textYPos, int renderPass) {
            this.lowXBound = lowXBound;
            this.lowYBound = lowYBound;
            this.lowZBound = lowZBound;
            this.highXBound = highXBound;
            this.highYBound = highYBound;
            this.highZBound = highZBound;
            this.textureURL = textureURL;
            this.texturePlugin = texturePlugin.getDescription().getName();
            this.xPos = xPos;
            this.yPos = yPos;
            this.zPos = zPos;
            this.textXPos = textXPos;
            this.textYPos = textYPos;
            this.renderPass = renderPass;
        }
    
    I hope someone can help.

    Greetings
    RogerWaters
     
Thread Status:
Not open for further replies.

Share This Page