1.14.4 Is there a way to get nether fortress bounding box?

Discussion in 'Spigot Plugin Development' started by NoKi_Le_Previam, Mar 23, 2020.

  1. Hello hello !

    I'm trying to get nether fortress bounding boxes using spigot api.

    I searched on google but I haven't find how to do.

    Is it possible?

    I'm able to locate a nether fortress but nothing else.

    Any idea?

    Thanks :)

    PS : I'm trying to create a plugin that show wither_skeleton spawning area. (Yeah, mods already exist. But I want it as plugin)
     
    #1 NoKi_Le_Previam, Mar 23, 2020
    Last edited: Mar 23, 2020
  2. You can do this with NMS I don't know exactly how but it's possible
     
  3. I found this <redacted> it's possible with this a(String s, int i, int j, int k) or this a(Class oclass, String s) but I don't know witch one
     
    #3 CokeJoke, Mar 23, 2020
    Last edited by a moderator: Mar 24, 2020
  4. Or if you're using 1.14 or above then this could work w.a(structureType, somePosition, 100, true); 100 is the range
     
  5. Sorry but it seems my skills doesn't allow me to understand your purpose :/

    Can you explain me ? I read that NMS is not a good way for plugins. What about that?
     
  6. Yes, but you can't do it without using nms, iirc.
     
  7. This seems doesn't exist :/

    Here is what a did : (Allman code style)

    Code (Java):
    package be.noki_senpai.WitherSkeletonSpawnArea.cmd;

    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.StructureType;
    import org.bukkit.World;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class wssa implements CommandExecutor
    {
        public wssa()
        {

        }

        @Override
        public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args)
        {
            // Check if sender is a player
            if(sender instanceof Player)
            {
                // Cast sender to player
                Player player = (Player) sender;

                // Check is player is in nether
                if(!(player.getWorld().getEnvironment() == World.Environment.NETHER))
                {
                    player.sendMessage(ChatColor.RED + "You're not in nether.");
                    return true;
                }

                // Get the nether
                World nether = player.getWorld();

                // Get location of the nearest Nether Fortress
                Location fortress = nether.locateNearestStructure(player.getLocation(), StructureType.NETHER_FORTRESS, 100, false);

                // If no fortress found nearby then deny command
                if(fortress == null)
                {
                    player.sendMessage(ChatColor.RED + "No nearby fortress.");
                    return true;
                }

                //??????
                net.minecraft.server.v1_14_R1.World test = (net.minecraft.server.v1_14_R1.World) nether;
                test.a(StructureType.NETHER_FORTRESS, 2.0,2.0,2.0, 100, true);
                //??????
            }
            else
            {
                sender.sendMessage(ChatColor.RED + "This command can only be used by players.");
            }
            return true;
        }
    }
    Edit: 2 hours I'm searching in "net.minecraft.server.v1_14_R1" classes ... Is there a specialist here? xD
     
    #7 NoKi_Le_Previam, Mar 23, 2020
    Last edited: Mar 24, 2020
  8. You can get a handle to the NMS-world using
    Code (Text):
    ((CraftWorld) world).getHandle();
     
  9. Thanks ! But ... Then ... ? ^^" I have no idea what I'm doing. I'm really lost Y-Y

    Here changes :


    Code (Java):
    package be.noki_senpai.WitherSkeletonSpawnArea.cmd;

    import net.minecraft.server.v1_14_R1.BlockPosition;
    import net.minecraft.server.v1_14_R1.ChunkGenerator;
    import net.minecraft.server.v1_14_R1.MinecraftKey;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.StructureType;
    import org.bukkit.World;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
    import org.bukkit.entity.Player;

    public class wssa implements CommandExecutor
    {
        public wssa()
        {

        }

        @Override
        public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args)
        {
            // Check if sender is a player
            if(sender instanceof Player)
            {
                // Cast sender to player
                Player player = (Player) sender;

                // Check is player is in nether
                if(!(player.getWorld().getEnvironment() == World.Environment.NETHER))
                {
                    player.sendMessage(ChatColor.RED + "You're not in nether.");
                    return true;
                }

                // Get the nether
                World nether = player.getWorld();

                // Get location of the nearest Nether Fortress
                Location fortress = nether.locateNearestStructure(player.getLocation(), StructureType.NETHER_FORTRESS, 100, false);

                // If no fortress found nearby then deny command
                if(fortress == null)
                {
                    player.sendMessage(ChatColor.RED + "No nearby fortress.");
                    return true;
                }

                //??????
                //??????
                BlockPosition blockPosition = ((CraftWorld) nether).getHandle().a(StructureType.NETHER_FORTRESS.getName(), new BlockPosition(2.0,2.0,2.0), 100, true);
                //??????
                //??????
            }
            else
            {
                sender.sendMessage(ChatColor.RED + "This command can only be used by players.");
            }
            return true;
        }
    }
     
     
  10. Choco

    Moderator

    For future reference, that code should not be publicly available. Yes, it's there, though it should be taken down as it's infringing on Mojang's copyright. Try not to refer to it if possible. Not to mention that it's 6 years out of date for Minecraft 1.7.10 and is of no use to any version after the fact.
     
  11. SCP-5217: CraftBukkit
     
    • Funny Funny x 1
  12. #12 NoKi_Le_Previam, Mar 24, 2020
    Last edited: Mar 24, 2020