From ba171f95c6062d0e3bd7d30fa0b6fb639b617e82 Mon Sep 17 00:00:00 2001 From: xGamingDudex Date: Fri, 9 Oct 2015 14:42:38 +0200 Subject: [PATCH 1/3] 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. --- .../mineplex/core/common/util/UtilEnt.java | 5 ++++ .../mineplex/core/mount/types/MountCart.java | 27 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index 1cc2d5416..4f24d9a57 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -496,6 +496,11 @@ public class UtilEnt public static boolean isGrounded(Entity ent) { + + if(!(ent instanceof Player)) { + return ent.isOnGround(); + } + 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_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java index af5e1db39..1802add2f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java @@ -1,8 +1,19 @@ 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.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.mount.Mount; @@ -11,17 +22,6 @@ import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; 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 { public MountCart(MountManager manager) @@ -110,12 +110,9 @@ public class MountCart extends Mount if (cart.getPassenger() == null) continue; - if (!((CraftMinecart) cart).getHandle().onGround) + if (!UtilEnt.isGrounded(cart)) continue; -// if (!UtilEnt.isGrounded(cart)) -// continue; - if (!(cart.getPassenger() instanceof Player)) continue; From 84fde1c08780f2c40ba27e9225915d44c19d4862 Mon Sep 17 00:00:00 2001 From: xGamingDudex Date: Wed, 25 Nov 2015 16:42:32 +0100 Subject: [PATCH 2/3] Fixed double jump and entity ground tool. Fixed isGrounded so that it doesn't return false positives when too close to a wall. Added 500ms recharge to double jump, preventing instant recharge allowing players to jump twice before having to touch the ground again. --- .../src/mineplex/core/common/util/UtilEnt.java | 6 +++--- .../src/mineplex/hub/modules/JumpManager.java | 11 +++++++++-- .../game/arcade/kit/perks/PerkDoubleJump.java | 5 +++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index cd63f9f77..3913574f7 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -537,9 +537,9 @@ public class UtilEnt return ent.isOnGround(); } - AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox(); - 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); + AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox().shrink(0.05, 0, 0.05); + Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.05, box.c); + Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.05, box.f); for(Block b : UtilBlock.getInBoundingBox(bottom_corner_1, bottom_corner_2)){ if(UtilBlock.solid(b)) return true; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java index e86d2e3c6..fb2c0090e 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/JumpManager.java @@ -1,5 +1,6 @@ package mineplex.hub.modules; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.block.BlockFace; @@ -18,6 +19,7 @@ import mineplex.core.disguise.disguises.DisguiseBat; import mineplex.core.disguise.disguises.DisguiseChicken; import mineplex.core.disguise.disguises.DisguiseEnderman; import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.hub.HubManager; @@ -66,6 +68,8 @@ public class JumpManager extends MiniPlugin //Sound player.playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0); + + Recharge.Instance.useForce(player, "Double Jump", 500); } @EventHandler @@ -94,8 +98,11 @@ public class JumpManager extends MiniPlugin if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) { - player.setAllowFlight(true); - player.setFlying(false); + if(!player.getAllowFlight() && Recharge.Instance.usable(player, "Double Jump")) + { + player.setAllowFlight(true); + player.setFlying(false); + } } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java index 018522154..7ca633d75 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDoubleJump.java @@ -101,6 +101,8 @@ public class PerkDoubleJump extends Perk Recharge.Instance.setDisplayForce(player, GetName(), true); } } + + Recharge.Instance.useForce(player, "Double Jump", 500); } @EventHandler @@ -119,6 +121,9 @@ public class PerkDoubleJump extends Perk if (_recharge > 0 && !Recharge.Instance.usable(player, GetName())) continue; + + if (!Recharge.Instance.usable(player, "Double Jump")) + continue; if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) player.setAllowFlight(true); From 24f8a985459d2e91b25bbe7400934bc2d833780d Mon Sep 17 00:00:00 2001 From: xGamingDudex Date: Sat, 28 Nov 2015 02:22:41 +0100 Subject: [PATCH 3/3] Added titan particle trail. --- .../core/common/util/UtilParticle.java | 26 ++++-- .../core/gadget/gadgets/ParticleTitan.java | 80 ++++++++++++++++++- 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index ec6587bcf..ab455015c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -1,14 +1,12 @@ package mineplex.core.common.util; -import java.lang.reflect.Field; - -import mineplex.core.common.util.UtilParticle.ViewDist; -import net.minecraft.server.v1_8_R3.EnumParticle; -import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import net.minecraft.server.v1_8_R3.EnumParticle; +import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles; public class UtilParticle { @@ -243,6 +241,22 @@ public class UtilParticle return packet; } + public static void PlayParticleToAll(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist) + { + PlayParticle(type, location, (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), speed, count, dist, UtilServer.getPlayers()); + } + + public static void PlayParticle(ParticleType type, Location location, Vector offset, float speed, int count, ViewDist dist, Player... players) + { + PlayParticle(type, location, (float) offset.getX(), (float) offset.getY(), (float) offset.getZ(), speed, count, dist, players); + } + + public static void PlayParticleToAll(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, + float speed, int count, ViewDist dist) + { + PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, UtilServer.getPlayers()); + } + public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, ViewDist dist, Player... players) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleTitan.java index e9f3c8022..a8f515735 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleTitan.java @@ -1,13 +1,25 @@ package mineplex.core.gadget.gadgets; +import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; -import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class ParticleTitan extends ParticleGadget { + + private int _tick; + public ParticleTitan(GadgetManager manager) { super(manager, "Titanic Particle", new String[] @@ -16,7 +28,71 @@ public class ParticleTitan extends ParticleGadget " ", C.cRed + "Unlocked with Titan Rank", }, - -1, +// Price for debuging purposes + 10, Material.INK_SACK, (byte)8); } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + _tick++; + _tick = _tick%620; + + for(Player player : GetActive()) + { + if (!shouldDisplay(player)) continue; + + double total = 3; + double step = (1/total)*Math.PI*2; + double offset1 = (step/20)*_tick%20; + double offset2 = (step/31)*_tick%31; + + double r = 3; + boolean redstone = false; + + if(Manager.isMoving(player)) r = 0.5; + + for(int i = 0; i < total; i++) + { + double rad = step*i + offset1; + + double x = Math.sin(rad); + double y = 0; + double z = Math.cos(rad); + + + Vector v = new Vector(x,y,z).normalize(); + v.multiply(r); + Location loc = player.getLocation(); + loc.add(0, 0.1, 0); + + loc.add(v); + + + if(redstone) UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL); + v.multiply(-1); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL); + + rad = -(step*i + offset2); + x = Math.sin(rad); + z = Math.cos(rad); + + v = new Vector(x,y,z).normalize(); + v.multiply(r); + loc = player.getLocation(); + loc.add(0, 0.1, 0); + + loc.add(v); + + if(redstone) UtilParticle.PlayParticleToAll(ParticleType.RED_DUST, loc, 1, 0, 0, 1, 0, ViewDist.NORMAL); + v.multiply(-1); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, loc, v, 0.05f, 0, ViewDist.NORMAL); + } + } + } }