From 0e6146d5c9543b5cab7ea82373c997c5d962ff6d Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Wed, 11 Nov 2015 04:32:56 -0600 Subject: [PATCH 1/4] Added expire to Stacker throw. --- .../Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 2f8a774d4..2ac87ef75 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -226,7 +226,7 @@ public class StackerManager extends MiniPlugin implements IThrown UtilAction.velocity(throwee, thrower.getLocation().getDirection(), 1.8, false, 0, 0.3, 2, false); - _projectileManager.AddThrow(throwee, thrower, this, -1, true, false, true, false, 0.5f); + _projectileManager.AddThrow(throwee, thrower, this, 4000, true, false, true, false, 0.5f); //Portal Delay Manager.SetPortalDelay(thrower); From 27ef2c0bbb2dd3f2ace17167e5ebb62385b5c8f2 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Wed, 11 Nov 2015 04:36:10 -0600 Subject: [PATCH 2/4] Fixed UtilEnt.Leash method. --- .../src/mineplex/core/common/util/UtilEnt.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 e0f96dc9f..8587871ee 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 @@ -78,10 +78,13 @@ public class UtilEnt public static void Leash(LivingEntity leashed, Entity holder, boolean pull, boolean breakable) { - leashed.setPullWhileLeashed(pull); - leashed.setShouldBreakLeash(breakable); - leashed.setLeashHolder(holder); + + if (!(((CraftLivingEntity)leashed).getHandle() instanceof EntityInsentient)) + return; + + ((EntityInsentient)((CraftLivingEntity)leashed).getHandle()).setPullWhileLeashed(pull); + ((EntityInsentient)((CraftLivingEntity)leashed).getHandle()).setShouldBreakLeash(breakable); } public static void addLookAtPlayerAI(Entity entity, float dist) From b915131407645697630b8a7ff60228b1327dbb03 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 12 Nov 2015 04:26:55 +1300 Subject: [PATCH 3/4] Fix some armorstands and interaction bugs --- .../src/mineplex/core/CustomTagFix.java | 10 +-- .../mineplex/core/PacketsInteractionFix.java | 89 +++++++------------ 2 files changed, 36 insertions(+), 63 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 73138c191..9d03f8f82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -22,6 +22,7 @@ import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; +import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; @@ -55,15 +56,12 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook private NautHashMap _exemptTimeMap = new NautHashMap(); private NautHashMap> _doubleStrike = new NautHashMap>(); - private PacketHandler _packetHandler; public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler) { super("Custom Tag Fix", plugin); - _packetHandler = packetHandler; - - packetHandler.addPacketHandler(this, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, + packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, PacketPlayInUseEntity.class); @@ -353,10 +351,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); newPacket.a = entry.getKey(); - newPacket.action = usePacket.action; - newPacket.c = usePacket.c; + newPacket.action = EnumEntityUseAction.INTERACT; - if (_packetHandler.handlePacket(owner, newPacket)) { ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java b/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java index a5f302e97..227cba9bb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/PacketsInteractionFix.java @@ -5,11 +5,15 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import net.minecraft.server.v1_8_R3.EntityPlayer; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.MovingObjectPosition; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; -import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_8_R3.Vec3D; +import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; @@ -18,9 +22,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerAnimationType; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -33,8 +34,6 @@ import mineplex.core.updater.event.UpdateEvent; public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler { private HashMap> _armorStands = new HashMap>(); - private HashSet _leftClicked = new HashSet(); - private int _lastTick; public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler) { @@ -44,42 +43,9 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler PacketPlayInUseEntity.class); } - private void checkLeftClicks() - { - if (MinecraftServer.currentTick == _lastTick) - { - return; - } - - _lastTick = MinecraftServer.currentTick; - _leftClicked.clear(); - } - - //@EventHandler - public void onArmAnimation(PlayerAnimationEvent event) - { - if (event.getAnimationType() != PlayerAnimationType.ARM_SWING) - { - return; - } - - checkLeftClicks(); - - Player player = event.getPlayer(); - - if (_leftClicked.remove(player)) - { - return; - } - - CraftEventFactory.callPlayerInteractEvent(((CraftPlayer) player).getHandle(), Action.LEFT_CLICK_AIR, - ((CraftPlayer) player).getHandle().inventory.getItemInHand()); - } - @EventHandler public void onQuit(PlayerQuitEvent event) { - _leftClicked.remove(event.getPlayer().getName()); _armorStands.remove(event.getPlayer().getName()); } @@ -91,8 +57,6 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler return; } - checkLeftClicks(); - Iterator itel = _armorStands.keySet().iterator(); while (itel.hasNext()) @@ -110,19 +74,6 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler } } - //@EventHandler - public void onPlayerInteract(PlayerInteractEvent event) - { - if (!event.getAction().name().contains("LEFT")) - { - return; - } - - checkLeftClicks(); - - _leftClicked.add(event.getPlayer()); - } - @Override public void handle(PacketInfo packetInfo) { @@ -166,12 +117,38 @@ public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler { PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket(); - if (!list.contains(packet.a)) + if (packet.action == EnumEntityUseAction.ATTACK) { + EntityPlayer nmsPlayer = ((CraftPlayer) packetInfo.getPlayer()).getHandle(); + + float f1 = nmsPlayer.pitch; + float f2 = nmsPlayer.yaw; + double d0 = nmsPlayer.locX; + double d1 = nmsPlayer.locY + nmsPlayer.getHeadHeight(); + double d2 = nmsPlayer.locZ; + Vec3D vec3d = new Vec3D(d0, d1, d2); + + float f3 = MathHelper.cos(-f2 * 0.01745329F - 3.141593F); + float f4 = MathHelper.sin(-f2 * 0.01745329F - 3.141593F); + float f5 = -MathHelper.cos(-f1 * 0.01745329F); + float f6 = MathHelper.sin(-f1 * 0.01745329F); + float f7 = f4 * f5; + float f8 = f3 * f5; + nmsPlayer.playerInteractManager.getGameMode(); + double d3 = nmsPlayer.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE ? 5 : 4.5; + Vec3D vec3d1 = vec3d.add(f7 * d3, f6 * d3, f8 * d3); + MovingObjectPosition movingobjectposition = nmsPlayer.world.rayTrace(vec3d, vec3d1, false); + + if (movingobjectposition != null && movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK) + { + CraftEventFactory.callPlayerInteractEvent(nmsPlayer, Action.LEFT_CLICK_AIR, + nmsPlayer.inventory.getItemInHand()); + } + return; } - if (packet.action == EnumEntityUseAction.ATTACK) + if (!list.contains(packet.a)) { return; } From 25f299b4904688642916351e92845ee2bde1d0ad Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 12 Nov 2015 14:34:12 +1300 Subject: [PATCH 4/4] Fix interact types --- Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 9d03f8f82..df327ad09 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -351,7 +351,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); newPacket.a = entry.getKey(); - newPacket.action = EnumEntityUseAction.INTERACT; + newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK + : EnumEntityUseAction.INTERACT; { ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);