Making a island

Discussion in 'Spigot Plugin Development' started by nayongbin108, Aug 12, 2018.

  1. So I want to make an island for a plugin (Skyblock) but I don't know how I am able to do that with code. I tried making a schematic then loading it to a location but that is not working. Sure I can use ASkyblock but I want to make it my own. Any ideas on completing this task?
     
  2. What server version?
    With the world edit API? So what exactly didn't work out?
    Show us your sourcecode.
     
  3. 1.12.2
    I deleted it but I tried so imports with it and it never made sense
     
  4. Get an Island pos1 & pos2 (like WEdit)
    And do : For each number in x, z, y, copy block from area1, and put it to area 2

    Code (Text):
    int minX1 = -10;//------------------------------------------------------IslandToCOpy
            int minY1 = 130;
            int minZ1 = -10;

            int maxX1 = 10;
            int maxY1 = 170;
            int maxZ1 = 10;//-------------------------------------------------------IleACopier

            int centerX = xIle * 500 + 250;//---------------------------------------Island
            int centerY = 50;
            int centerZ = zIle * 500 + 250;//---------------------------------------Ile

            World world2 = Bukkit.getWorld("Spawn");

            for (int x1 = minX1; x1 <= maxX1; x1++)
            {
                for (int y1 = minY1; y1 <= maxY1; y1++)
                {
                    for (int z1 = minZ1; z1 <= maxZ1; z1++)
                    {
                        Block block = world2.getBlockAt(x1, y1, z1);
                        if (block.getType() != Material.AIR)
                        {
                            Block blockDest = world2.getBlockAt(centerX + block.getX(), centerY + block.getY() - 142, centerZ + block.getZ());
                            blockDest.setType(block.getType());
                            if (block.getType() == Material.CHEST)
                            {
                                Chest chest = (Chest) block.getState();
                                Inventory inv = chest.getInventory();

                                Chest chestDest = (Chest) blockDest.getState();
                                Inventory invDest = chestDest.getInventory();

                                invDest.setStorageContents(inv.getStorageContents());
                            }
                            else if (block.getType() == Material.STEP)
                            {
                                blockDest.setData((byte) 11);
                            }
                            else if (block.getType() == Material.COBBLESTONE_STAIRS)
                            {
                                blockDest.setData(block.getData());
                            }
                        }
                    }
                }
            }
        }
     
    This code is just an example, this code is ugly
     
  5. Your missing a chestDest.update() call so your chests will be empty but other then that I can't see any obvious issues.
    Are your sure the source cords are correct and your not just copying air?

    If you are doing it based off user selected rather then hard coded values like in your example above you will need to find the min/max of the user provided cords otherwise one of your for loops might exit immediately because effectively the min and max are the wrong way around.
     
  6. Full code work, pleas read better
    if (block.getType() != Material.AIR)
    Inventory invDest = chestDest.getInventory();
    invDest.setStorageContents(inv.getStorageContents());

    SetStorage don't need of an Invetory update

    all of what you say is OK in code and work
    It was just for giving idea, I don't like the way I show

    How do you wan't to do to copy and past an island with Player var xDDD we care, else if you paste it on PlayerLocation I don't see, but useless, using a coord make same thing

    And it can't break the loop until EACH block between X et xMax, y et yMax etc...
     
    #6 Ohwnead, Aug 13, 2018
    Last edited: Aug 13, 2018

Share This Page