Solved Nether void no fall (PLEASE HELP)

Discussion in 'Spigot Plugin Development' started by MaxJacobsYT123, Jun 7, 2017.

  1. Hello! I am trying to make a plugin that makes it so that a player can not fall out of the void in the nether, and only in the nether. When they reach 32 blocks under the world, I want it to teleport them to the top of the nether, and make them invincible while the fall. The plugin is not working and I do not know why, but I am hoping someone else does. Thank you so much in advance!

    Code:
    Code (Text):
    package com.randamonium.netherfall;

    import java.util.ArrayList;
    import java.util.UUID;

    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Netherfall extends JavaPlugin implements Listener {
       
        ArrayList<UUID> noDeath = new ArrayList<UUID>();
       
        @EventHandler
        public void onEntityDamage(EntityDamageEvent e) {
            if (noDeath.contains(e.getEntity().getUniqueId())) {
                e.setCancelled(true);
            }
        }
       
        @EventHandler
        public void onNetherFall(PlayerMoveEvent e) {
            if (!(e.getPlayer().getWorld().equals("world_nether"))) return;
            if (e.getPlayer().getLocation().getY() <= -33) {
                e.getPlayer().teleport(new Location(e.getPlayer().getWorld(), e.getPlayer().getLocation().getX(), 100, e.getPlayer().getLocation().getZ()));
                noDeath.add(e.getPlayer().getUniqueId());
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
                    public void run() {
                        noDeath.remove(e.getPlayer().getUniqueId());
                    }
                }, 14400);
            }
        }
       
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
       
    }
    there is no error in console either.
     
  2. It should work, try to debug your code.
     
  3. On player move check if Y < -32 and in nether environment type. If they are teleport them to y 256 (or wherever) and give them -256 fall distance to to make them invincible to fall damage until they reach the next ground level.
     
  4. Instead if listening to the MoveEvent, why not listen to the EntityDamageEvent, check if player, check if cause is void > Check if in NetherWorld > Teleport > Profit.
     
  5. I couldn't do that because I don't want them to take damage. They take damage after 64 blocks down, which is why I only want them to go 32 blocks down
     
  6. Code (Text):
    public void onVoidFall(PlayerMoveEvent event) {
        if (event.getTo().getY() > -32) {
            return; // not below -32 Y
        }

        if (event.getTo().getWorld().getEnvironment() != Environment.NETHER) {
            return; // not in nether
        }

        event.getTo().setY(100); // teleport player up

        event.getPlayer().setFallDistance(-256); // make player immune to falling until they touch ground again.
    }
    That's literally it.
     
    • Optimistic Optimistic x 1
  7. Thank you so much!