1.16.5 block setType Dragon Egg not working properly

Discussion in 'Spigot Plugin Development' started by Navio, Jul 2, 2021.

Thread Status:
Not open for further replies.
  1. Hi, I have a problem with
    Generally I can spawn the egg, but when I try to spawn It above ( at 30y ) my block of grass on 29y, egg spawns on 29y where the grass was, not on 30y above grass.

    When I'm next to the spawn place and egg start spawning it lands normally on grass, but if I'm not the egg spawns in grass.

    My code for now:

    Code (Java):

    Location location = new Location(world, locVector.getX(), 256, locVector.getZ());
    placeBlockBelowLoc(location, Material.matchMaterial("DRAGON_EGG"));

    public static void placeBlockBelowLoc(Location loc, Material material) {
            Location locBelow = loc.subtract(0, 1, 0);
            if(locBelow.getBlock().getType() == Material.AIR) {
                placeBlockBelowLoc(locBelow, material);
    External: I use Material.matchMaterial("DRAGON_EGG") becouse I use API 13 version, on minecraft 1.8.9. Do you have better way of it?

  2. You are currently setting a non-air block to the dragon egg. I assume you want it to be above that. Simply add 1 to y coordinate of locBelow and then set the dragon egg. You can also use the getRelative() method if you want. You can also simply use a while loop instead of recursion. Also if you choose to use recursion I think you should add a return inside the if statement after calling the method.
    • Agree Agree x 1
Thread Status:
Not open for further replies.