ImageWings - Create particle wings from images

Discussion in 'WIP and Development Status' started by I Al Istannen, Nov 5, 2016.

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

    I Al Istannen

    Hey,

    I am currently developing a small plugin which is able to take an image (and some metadata) and convert that to wings in Minecraft.
    How it works is described on the github page here, so I will just show an image and my problem here ;)
    You should be able to make your own wings with reading the readme and maybe a bit of the source :D


    Example picture
    This is just a very basic conversion from one of the first images found online. I scaled it down a bit and let the plugin do it's thing.
    You can make much cooler wings with it. Trust me, I made some ;)

    [​IMG]


    Problem
    I have no clue how the user should interact with the plugin. Currently it just replays the loaded wings 20 times after the plugin gets loaded for all players, but that obviously doesn't quite cut it.
    I do not know a nice way to allow this to be customizable and easy to use for the players and the server owner, so I would absolutely love your suggestions.


    Other
    Feel encouraged to also provide some pull requests or to offer any other help if you want. I know it is far from perfect, and probably far from efficient too ;)


    @timtower I guess for once this is the right forum, right? And sorry for the random tag here.
     
    bwfcwalshy and timtower like this.
  2. Offline

    ShaneCraftDev

    @I Al Istannen

    For customization, you can make it so your plugin comes with an easy-to-use command which spawns an amorstand or fakeplayer with a wing from one of the selected images in the designated folder for the wings, e.g.:
    The server owner has a folder of images for the wings, with the image names being wings(1 through 10).
    A player or server admin can execute: /wings test wings1
    This would spawn a test subject, with the wings of the image file "wings1"(.png) for the player, to make it customizable, you could allow the command to take in additional arguments for the offset as described in the .wingmeta file format. If the users is pleased with the outcome, the user can export this configuration to that file, with either rightclicking or add an additional argument flag, e.g.:
    /wings test wings1 {xOffset:50, yOffset:50} export

    Maybe you can also change the parameters as described in the configuration file with interacting with the spawned test subject entity using different items. Right clicking with a stick would move the xOffset in the positive direction and Shift right clicking would make it move in the negative direction.

    These are just a few ideas I had for "user friendly" configuration.
     
  3. @I Al Istannen What about like on Hypixel where when you stay still for a few second you get the wings, means you don't need to try and make them stay with the player and it's still an easy way to trigger a VERY nice effect.

    Well done on this! It's very nice!
     
  4. Offline

    I Al Istannen

    @ShaneCraftDev @bwfcwalshy
    Thank you both so much!

    I think the dummy approach ShaneCraft provided is an excellent idea to correctly configure it without messing with the file, I will certainly implement it!
    EDIT: Hmm. That would require a new parsing of the image every time a change is made. I will see how the performance of that is tomorrow :)

    @bwfcwalshy
    Yea, that will probably look cool. I will try to make it this way ;)

    Now I just need to figure out the rotation of the players body... :p

    Thanks to you two for the ideas, they are very much appreciated :)
     
    Last edited: Nov 5, 2016
  5. Offline

    I Al Istannen

    @ShaneCraftDev

    Added Edit command to spawn the interactive editor
    Command usage:
    [​IMG]

    Editor ingame:
    Gif: http://i.imgur.com/TOBuODX.mp4
    (Yes, sorry for the quality. I wanted to keep the file size down and I am not well versed in that...)
    [​IMG]
     
    cococow123 likes this.
  6. Offline

    ShaneCraftDev

    @I Al Istannen

    That is really cool, I had something like that in mind when I suggested this. I like the usage of the tipped arrows. I am also a bit curious, does it update the configuration file for every change made to the wings, or does an export have to be issued? And does it update existing wing 'carriers'? I can imagine that this could be abused if a random player (no permission?) toys with the configuration of a wing.

    I could answer these questions for my self, but I am not familiar with Kotlin at all. Some of the source code (looking at the enum States in the ArmorStandEditor class) looks gibberish to me :p. Although the language looks a lot like TypeScript, which I am very familiar with.
     
  7. Offline

    I Al Istannen

    @ShaneCraftDev
    It actually doesn't use tipped arrows :/ Sorry :(
    You just need to have an item in hand for Bukkit to register right click (or click a block), which is why I filled my hotbar.

    Scrolling in it changes the property being edited.
    Left click makes it smaller, right bigger and shifting makes the steps finer.

    The changes are just for the displayed wing. It keeps a copy of the Configuration used in memory, as well as the original image.
    Then, when you modify it, it re-parses the whole image to update things like granularity.
    At least it is in the ram, so it isn't that slow and doesn't require disk IO.

    When you stop the editing, there are two ways:
    "/imageWings edit discard" and "/imageWings edit save"
    If you choose save, the new configuration will be written to disk and any new parsing of the configuration will make the changes appear.
    Currently there is no way for a player to display it to himself, so I haven't dealt with updating the others yet.

    The permissions are handled by the command system in PcCore, they are defined in the config and parsed here for the edit command:
    Code:
    # +--------------------------------+
    # |                                |
    # |           PERMISISONS          |
    # |                                |
    # +--------------------------------+
    
    # Here are all permissions of that plugin listed. You can change them here, if you want:
    permissions:
      commands:
        help: "imagewings.help"
        main: "imagewings.main"
        edit: "imagewings.edit"
    So you should be able to prevent players from screwing up the config files.

    You will need to create (or copy) a default file however, for the editor to work.

    The enum isn't quite what you would call "clean code" probably xD
    It just creates a BiConsumer, taking a PlayerInteractEvent and a DummyEditor and does something with them, returning nothing. This is so I can change the action on interact in the enum and don't need a big switch statement.

    Thanks for the feedback, appreciate it!

    @bwfcwalshy
    Now I just need to make the player actually be able to equip them xD
    I will see how I am able to fit this ;)
     
    cococow123 likes this.
  8. Offline

    I Al Istannen

    @ShaneCraftDev @bwfcwalshy
    Tagging you because reasons ;)

    I released a version, which may not be totally buggy. If you drop the two jars in your plugins folder and the other two files in a folder called "images" in the "plugins/ImageWings" folder, you should have an example wing.

    And I finally managed to get the wings to align to the players body rotation, NOT the direction he is looking at.
    This is achieved using some NMS on a field, whose name changes between versions. I fetched the names for 1.7 to 1.10 from MCP-Mappings and fed them to a file called "mappings.yml".
    You can adjust them if needed in the future. For now I am excited if it will work at all on another computer :p

    Here is the link to the github release.

    I would be very grateful if anybody could have a short look at it and say:
    1. If it works at all
    2. Any suggestions they may have :)

    Thank you and have a nice day!
     
  9. @I Al Istannen Jeez... People can always rely on you to put a lot of work in :D

    I will test this out when possible and give feedback, good idea on the mappings.yml my only concern would be people who would try to modify it to work in the future without knowledge of Bukkit and NMS. This would probably end in them complaining it no longer works and will usually blame the developer (You)
     
    cococow123 likes this.
  10. Offline

    I Al Istannen

    @bwfcwalshy
    Sometimes I have productive phases :D

    Thank you so much for trying to test it out :)!

    Yea, but the mapping.yml also allows server owners to fix it on their own (if they know how) as you mentioned.

    I desperately hope that a header like this will throw all others off :/
    Code:
    # DO NOT MODIFY IF YOU DO NOT KNOW WHAT YOU ARE DOING!
    But if I learned one thing from /r/TalesFromTechSupport, it is that user blame who they can find (excempt themselves)... :p
     
  11. Offline

    ShaneCraftDev

    @I Al Istannen
    Hey, I've just tested it out for MC 1.10.2. It's a cool plugin for sure. But you can't do any small details because the particles in this game are so big or have an animation. Water/Lava drips are really cool for details, but they drip after x ticks...
    I have tried to create a player cape (yes, I am That good with Photoshop):
    [​IMG]
    A problem in the last picture, explained later in the post.

    Was it by design that the particles will be displayed for the player once he/she stops moving after a couple of ticks? Maybe you can add a change for that in a configuration file, to make it spawn even when you are walking. Also it would be cool if the particles didn't 'die'. e.g. kept spawning. Now the particles disappear for a brief moment. I saw there was a delay property in your config file when I browser the source, but where does one find the config file for your plugin? -Or am I obligated to create my own?

    You also might want to add a reload command, when toying directly with the yaml files in a file editor, it would be nice to see the changes you've made without reloading all the other plugins. I plopped your plugin in a plugins folder for my experimental developments, it's becoming slightly annoying to keep reloading all of them.

    Some bugs or minor complaints:
    I found out that the displayed image is mirrored in game. When editing, it's hard to tell what the back of the armor stand is. When the armor stand is spawned, it faces the player. You possibly could fix this by giving it a helmet or player head, maybe the head of the player who is currently editing. Some of the particles 'shift' (see last image of the gif). They spawn and shift to an other location, I am not sure why that is. I haven't had any problems with that when I use particles. And there are more particles, could be cool if you were able to integrate those as well. I remember there is a way to get green colored [redstone]dust particles. Dust particles are somewhat the only particles that do not animate, e.g. rise up or drop down. They are pretty much stable at all times.

    This problem is very minor, though, occasionally the particles do not rotate properly with the player. It occurs when the player walks backwards:
    [​IMG]

    My last 2 advises:
    1) You should add a message when the player starts editing the wings that he/she can scroll through their hotbar to select a tool to edit a specific detail about the wing.
    2) Add an auto complete for selecting wings to edit, you already have access to the all the details of the wing when you load the plugin for the fist time. I wasn't sure what to use as name argument, it turns out it is looking for the file name instead of the wing name.

    For the cape, I wanted to use smoke particles, but they float upwards in your plugin. You can make particles non directional when spawned. My second choice was the SUSPENDED_DEPTH particle, but that one shifts locations. Now I have used dripping particles. But as the name suggests, this particle drips and they also shift but they're more dense, so you can actually see the creeper face in the cape.
     
    Last edited: Nov 11, 2016
    I Al Istannen likes this.
  12. Offline

    I Al Istannen

    @ShaneCraftDev
    THANKS!
    That is more detailed feedback than I have dreamed of ;)

    I have made a small list for me, which hopefully covers all you have mentioned. I will update this post as I work on them:

    TO-DO:
    • Spawn when moving - Yes, that is intentional. I will make a config option.
    • saveDefaultConfig() - I have a config, it just never generates...
    • reload command - That will unequip the wings for all players, but I guess that is wanted
      It will keep the wings equipped, if they exist after the reload.
    • image is mirrored (temp work around is setting the x/y scale to something negative. This flips over the image)
    • Set the helmet of the armorstand to show direction it is facing
    • particles shift after being spawned
      I have NO idea. Based on the code, Drip shouldn't move. It does however.
      No matter what params I input, it keeps happening. I am beginning to think this is not fixable.
      The best I could come up with is adding 0.1 to all axes. This aligns it somewhat.
    • particles are off when looking behind
      Not reproducable. I can't turn with just my head and for the rest it works.
    • colored particles! - That is a great idea, I will have a look at how to nicely do this
      Okay, I added coloured REDSTONE, SPELL_MOB, SPELL_MOB_AMBIENT, NOTE as well as ITEM_CRACK, BLOCK_CRACK and BLOCK_DUST
      Code:
        # As this would be too easy, there is something more!
        # Some particles take extra data. These are "BLOCK_CRACK, BLOCK_DUST, ITEM_CRACK, REDSTONE, SPELL_MOB, SPELL_MOB_AMBIENT and NOTE"
        # The first three just have " as <MATERIAL>:<DURABILITY>" behind the particle.
        #   You can find the materials here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
        #     Example: "20,20,20 to 20,20,20 is BLOCK_CRACK as OBSIDIAN:0" will be obsidian cracking
        # The next 3 have " with rgb <red>,<green>,<blue>" behind the particle
        #     Example: "20,20,20 to 20,20,20 is REDSTONE with rgb 255,255,255" will be a white Redstone dust
        # The NOTE particle has " with note index <index>" behind the particle. Each note has a number, and that is how often you need to hit the note block
        #     Example: "20,20,20 to 20,20,20 is NOTE with note index 5" will be a magenta-ish note
      Here is a note cheat sheet.

    • block crack and stuff - Additional data for particles (e.g. Block crack IRON)
      See above
    • rotation sometimes not updating - I do not think I can fix this :/
    • message when editing starts explaining scrolling
    • auto complete for wings - This needs to read the entire directory and list the files. But that should be quite fast. It is made this way, so you can edit non-indexed wings
      The name of the file they are loaded from is now stored too.
    • smoke flies upwards? - Impossible. In the client render code for smoke:
      this.motionY += 0.004D;
      So they WILL go upwards, no matter what I do. Sorry :/

    Again, thank you so much for the testing! I really appreciate it, and wouldn't have thought somebody would but so much effort in this plugin!

    If I can help you with something in the future, feel free to ask ;)
     
    Last edited: Nov 12, 2016
    cococow123 likes this.
  13. Offline

    ShaneCraftDev

    @I Al Istannen
    Maybe I didn't explain the 'shifting' part good enough. Its very easy to reproduce to see what I actually mean. Create a wing, or alter the wing image from the example, with just a flat, filled square/rectangle with 1 color. In your yaml file, map the used color to one of the following particles:
    • SUSPENDED_DEPTH
    • SUSPENDED
    • DRIP_WATER
    • DRIP_LAVA
    There might be more, but I do not know the rest from the top of my head.

    All of the above have the 'shifting' quirk. Just load and equip the wing, and try to stand still, looking into various different directions (mind to turn the actual body). You can see it spawn and slightly, but noticeably, change locations by x pixels (meaning 1 pixel is the equivalent of 1/16th of a block). You can see it in the gif I've posted in the previous post. When I turn around, the same cape with the same configuration is now located inside my player's body.

    For the auto completion, when you load the plugin, the console logs a message saying 'x wings are loaded'. I assume you check and validate(I changed an integer value to a double/float, and the wing was not loade the files when the plugin is being enabled, thus granting you access to the file names. It wouldn't have to be reading the directory for wing files every time the command is issued.

    For the smoke particles motion, the Mineplex plugin has player particles animations, for one of the animations it used both the normal and the large smoke particles and they were staying in the same location without it flying upwards. I come from Minecraft modding, where it's pretty easy to alter particles, as they are entities (at least till 1.8, I thought they changed it lately). I might have been confusing my self with MCP and Bukkit.
     
    I Al Istannen likes this.
  14. Offline

    I Al Istannen

    @ShaneCraftDev
    I see what you mean with shifting now. I will have a look at it, thanks!
    If not all do it, that is another fun thing to look into :D

    That looking back changes the offset shouldn't be possible, I will re-check my math :p


    While that would work in the auto-completion, it wouldn't allow you to tab complete all wings (newly added files).
    But I guess that is better than nothing, I will see how I can nicely add that :)
    EDIT: Added that. It just lists the known wings, and indexes the file name when loading (as you suggested).


    The smoke is odd. I don't believe there is a server side way to toggle the floating, so you may have confused the two. Would be cool if there was a way though ;)
    Yea, they changed the particles being entities in 1.9 or something. A core mod can still easily change them, I do not know enough (hint, nearly nothing) about modding, so I have no idea if you can change that using forge or something.

    Have a nice day!

    EDIT:
    I have released an update here.
    I do hope I haven't introduced new bugs...
     
    Last edited: Nov 12, 2016
  15. Offline

    ShaneCraftDev

    @I Al Istannen
    You've got that list done pretty quickly here. Everything seems to be working fine, except I think that you've introduced a new bug. This problem might have already been present in the first release, but I've only noticed that behavior when walking backwards.

    [​IMG]
    In the images of this gif, you can clearly see that the wings are not properly rotated. This only happens when you initially activate the selected wings and have not rotated the body of the player yet before the initial wing display task has run. The initial rotation seems to be off. When I rotate the body of the player, the next display of the wings are properly aligned. So the previous bug, where the wings did not properly rotate when looking in a certain direction, seems to be fixed. The last slide of the gif shows the default example wings, to show that it is not an error in the 'cape' wings. Keep in mind that I am running a version of Minecraft for 1.10.2, maybe you're running a different one, where this does not happen.
     
  16. Offline

    I Al Istannen

    @ShaneCraftDev
    Hmm. That bug was there before too, I think.
    It sometimes occurs when you walk (==> Lose your wings) and then gain them again, or when you first equip them.
    The funny thing is though, that NOTHING code wise changes between that.
    The renderedYawOffset just doesn't seem to be accurate, which makes no sense, considering it is directly pulled from the NMS player.
    I am at my wit's end here :/

    I have absolutely no idea why that happens.

    I will dig a bit into the NMS code to see where it is set, but I doubt I can do much :/
    Yea, it is set in onUpdate, which I guess is called when the entity ticks.

    EDIT:
    I thought about adding gif support, but that introduces a few problems.
    • How would you do the editor? Does it edit all images or just a frame?
    • Gifs have a "delay" property. Do you respect that?
      If yes, do you have a master timer for the whole wing or a timer for every player?
    • Reading the gif. Java has a bug in ImageIO (buffer overflows, causing IndexOutOfBounds) for a few years, rendering me unable to read higher compressed gifs. I would need to use a library/util class for that, as I do not feel like reimplementing the gif image specification from the binary data upwards
    • The question whether it is feasible to add it
    • Does it even make sense?
    I am not sure how to answer these, I will look at them tomorrow ;)
     
    Last edited: Nov 14, 2016
  17. Offline

    I Al Istannen

    @bwfcwalshy @ShaneCraftDev and everybody else
    I pushed a new update, which is hopefully good enough to released :)

    The main change is that it now supports Animated wings in gif format. Not optimized gifs (Java's ImageIO has a bug...), but normal gifs.

    The rotation error is nothing I could resolve, even with looking at how the clients handle it. The body rotation of a player seems to sometimes even differ when viewed from different clients...

    [​IMG]

    I also added two example wings, (I just realized you can not delete them. Whoops.) which show a static and an animated wing, to quickly let you experience how it looks like.

    Here is the link to the github release, which might be worth reading.

    If you see a bugs or have a suggestion, feel free to share them here or by creating a issue on github :)


    Merry christmas and have a nice day :)
     
    skiithaw and timtower like this.
Thread Status:
Not open for further replies.

Share This Page