Fixed UtilEnt.isGrounded for non-player entities.

Updated UtilEnt.isGrounded(Entity) to only apply custom handling of
players. Non-player entities now uses the default .isOnGround() check.
Implemented to fix entities like minecart which applies custom
is-on-ground checks.
This commit is contained in:
xGamingDudex 2015-10-09 14:42:38 +02:00
parent 99fd88473b
commit ba171f95c6
2 changed files with 17 additions and 15 deletions

View File

@ -496,6 +496,11 @@ public class UtilEnt
public static boolean isGrounded(Entity ent) public static boolean isGrounded(Entity ent)
{ {
if(!(ent instanceof Player)) {
return ent.isOnGround();
}
AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox; AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox;
Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c); Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c);
Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f); Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f);

View File

@ -1,8 +1,19 @@
package mineplex.core.mount.types; package mineplex.core.mount.types;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
@ -11,17 +22,6 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftMinecart;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.vehicle.VehicleDamageEvent;
public class MountCart extends Mount<Minecart> public class MountCart extends Mount<Minecart>
{ {
public MountCart(MountManager manager) public MountCart(MountManager manager)
@ -110,12 +110,9 @@ public class MountCart extends Mount<Minecart>
if (cart.getPassenger() == null) if (cart.getPassenger() == null)
continue; continue;
if (!((CraftMinecart) cart).getHandle().onGround) if (!UtilEnt.isGrounded(cart))
continue; continue;
// if (!UtilEnt.isGrounded(cart))
// continue;
if (!(cart.getPassenger() instanceof Player)) if (!(cart.getPassenger() instanceof Player))
continue; continue;