Solved How to make the animated blue "world border" wall

Discussion in 'Plugin Development' started by plisov, Mar 27, 2017.

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

    plisov

    I have been trying to create this animated wall that is in vanilla Minecraft however I don't know where to begin? Is it a block? If so what is the name of it? It looks something like this. I am trying to make it so that there can be multiple of these in 1 world.
    2017-03-27_21.32.30.png
     
  2. Offline

    Zombie_Striker

    @plisov
    Its not a block. It is actually its own object called "WorldBoarder". And no, you can't have multiple of these per world. What exactly would you use these for?
     
  3. Offline

    plisov

    I know a Skyblock server that uses these as barriers for islands. People are allowed to upgrade their borders to to make them bigger. Many people play on the same world. The reason I know that is because when I visit someone else's island that's on the same server, the game doesn't cut to that quick dirt loading screen. It automatically teleports me to their island. However when I go to spawn, it has that loading screen and I notice there are totally different people on that server. So these are two different servers. They have more servers. If I go to someone's island that isn't on my world it also shows the dirt loading screen. Every person has this type of border around their island.
     
  4. Offline

    Zombie_Striker

    @plisov
    Either each player has their own world, or they are sending packets to each individual player so they register their own worldboarder. If it is the packets, they are using:
    http://wiki.vg/Protocol#World_Border
     
  5. Offline

    plisov

    Ahhh. That makes sense. They are most likely using packets. However I am not too familiar packets. I did find this piece of code however. But I don't quite understand how this is supposed to work.
    Code:
    protected void sendWorldBorderPacket(Player player, int warningBlocks) {
            EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
            WorldBorder playerWorldBorder = nmsPlayer.world.getWorldBorder();
            PacketPlayOutWorldBorder worldBorder = new PacketPlayOutWorldBorder(playerWorldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS);
            try {
                Field field = worldBorder.getClass().getDeclaredField("i");
                field.setAccessible(true);
                field.setInt(worldBorder, warningBlocks);
                field.setAccessible(!field.isAccessible());
            } catch (Exception e) {
                e.printStackTrace();
            }
            nmsPlayer.playerConnection.sendPacket(worldBorder);
        }
     
    Last edited: Mar 28, 2017
  6. Offline

    Zombie_Striker

    @plisov
    Because I do not know which version of MC you are running, I cannot say which fields you need to modify. I would recommend loop through all the fields and try to match their value/ classtype to those in the link.
     
  7. Offline

    plisov

    I'm going to be using the latest version of Minecraft everytime I make my plugins. I've put this code into my class and I've edited it. However I don't know how to set the radius of how big to show the border. I log in to the server and it isn't there. I do also call it.
     
  8. Offline

    Zombie_Striker

    @plisov
    I just remembered that you can use protocol lib. Using it, you can use its wrappers to easily create the world boarder:
    Code:
    WrapperPlayServerWorldBoarder packet = new WrapperPlayServerWorldBoarder();
    packet.setAction(3);//creating the world boarder
    packet.setX(CENTER X);
    packet.setZ(CENTER Z);
    ....
    
    packet.sendPacket(player);
    
     
  9. Offline

    plisov

    That isn't working. It says That WrapperPlayerServerWorldBorder Or WrapperPlayerServerWorldBoarder isn't a class. Says I must create it. I have ProtocolLib in my Buildpath
     
  10. Offline

    Zombie_Striker

  11. Offline

    plisov

    Ah. Okay that works. However now .setAction(), .setX and .setZ are red. I look to see what packet has and it doesn't have anything but a few things like a(), b(), equals(), etc.

    POST EDIT: Looking at the link right now. I'll see what I can do.

    I found this
    Code:
                    PacketPlayOutWorldBorder border = new PacketPlayOutWorldBorder(PacketPlayOutWorldBorder.Action.INITIALIZE);
                    border.setX(Bukkit.getWorld("SkyRealms").getSpawnLocation().getX());
                    border.setZ(Bukkit.getWorld("SkyRealms").getSpawnLocation().getZ());
                    border.setRadius(20 / 2);
                    border.setSpeed(1L);
                    border.setPortalBoundary(10);
                    border.setWarningTime(20);
                    border.setWarningBlocks(2);
    However all the things after border. are red. They don't exist. Also Action is red. No imports.
    @Zombie_Striker
     
    Last edited: Mar 28, 2017
  12. Online

    timtower Administrator Administrator Moderator

    @plisov It is NMS, obfuscated, names don't make sense.
    If you google the class then you see all fields it has.

    The class that is used there is listed in one of the top posts on the page.
     
  13. Offline

    plisov

    @timtower @Zombie_Striker I'm not understanding something. How am I able to use it if it is obfuscated? I'm looking at this, hopefully this is what I should be looking at. Is there a class anywhere out there that I could put into my project that is not obfuscated?

    Current code
    Code:
                    PacketPlayOutWorldBorder border = new PacketPlayOutWorldBorder(null, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE);
                    border.setX(Bukkit.getWorld("SkyRealms").getSpawnLocation().getX());
                    border.setX(Bukkit.getWorld("SkyRealms").getSpawnLocation().getX());
                    border.setZ(Bukkit.getWorld("SkyRealms").getSpawnLocation().getZ());
                    border.setRadius(20 / 2);
                    border.setSpeed(1L);
                    border.setPortalBoundary(10);
                    border.setWarningTime(20);
                    border.setWarningBlocks(2);
     
  14. Online

    timtower Administrator Administrator Moderator

    @plisov Obfuscated is annoying to use, and that is the nicest thing about it.
    I don't think that anybody made a per player world border already that uses this, so that would be a no (feel free to prove me wrong)
    The thing you linked is a wrapper for 1.7.4, might work after fixing the imports, might not work.
     
  15. Offline

    plisov

    Here is an example. I play on a server that has exactly what I'm talking about. Look in the chat when I type as I explain more in detail.

    Video

    POST EDIT:
    This may clear a few things up. I'm trying to actually set the world border, I'm only trying to get the effect of it. Meaning you can still build behind that "border" / effect. What I'm trying to figure out is how to draw that effect around a set coordinate * a set radius.

    @timtower @Zombie_Striker
     
    Last edited: Mar 28, 2017
  16. Offline

    plisov

Thread Status:
Not open for further replies.

Share This Page