From 77adc83720e65cd3f786d623715f71aa032d3fcf Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 30 Apr 2018 16:42:16 +0100 Subject: [PATCH] Implement lockable pitches --- .../core/disguise/DisguiseManager.java | 33 ++++++++++++++++++- .../core/disguise/disguises/DisguiseBase.java | 14 ++++++++ .../games/hideseek/forms/CreatureForm.java | 1 + .../kits/SneakyAssassinKit.java | 4 ++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index a7879fdb0..6a5e4fd54 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -1,5 +1,6 @@ package mineplex.core.disguise; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -21,6 +22,10 @@ import net.minecraft.server.v1_8_R3.EnumDirection; import net.minecraft.server.v1_8_R3.MinecraftServer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutBed; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntity; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutEntityLook; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; @@ -31,6 +36,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_8_R3.PacketPlayOutVehicleMove; import net.minecraft.server.v1_8_R3.WorldServer; import net.minecraft.server.v1_8_R3.WorldSettings; @@ -58,6 +64,7 @@ import mineplex.core.MiniPlugin; import mineplex.core.PlayerSelector; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilLambda; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -112,7 +119,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler PacketPlayOutSpawnEntityLiving.class, PacketPlayOutUpdateAttributes.class, PacketPlayOutEntityEquipment.class, - PacketPlayOutEntityVelocity.class + PacketPlayOutEntityVelocity.class, + PacketPlayOutEntityLook.class, + PacketPlayOutRelEntityMove.class, + PacketPlayOutRelEntityMoveLook.class, + PacketPlayOutEntityTeleport.class ); createBedChunk(); @@ -484,6 +495,26 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler packetInfo.setCancelled(true); } } + else if (packet instanceof PacketPlayOutEntity) + { + PacketPlayOutEntity entityPacket = (PacketPlayOutEntity) packet; + DisguiseBase latestDisguise = getActiveDisguise(entityPacket.a); + + if (latestDisguise != null && latestDisguise.isPitchLocked()) + { + entityPacket.f = 0; + } + } + else if (packet instanceof PacketPlayOutEntityTeleport) + { + PacketPlayOutEntityTeleport teleportPacket = (PacketPlayOutEntityTeleport) packet; + DisguiseBase latestDisguise = getActiveDisguise(teleportPacket.a); + + if (latestDisguise != null && latestDisguise.isPitchLocked()) + { + teleportPacket.f = 0; + } + } } private void handlePacket(Packet packet, PacketVerifier verifier) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java index e6e02767b..536486d32 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/disguises/DisguiseBase.java @@ -31,6 +31,10 @@ public abstract class DisguiseBase * Whether the disguised entity should be entirely hidden from a player if that player does not receive the disguise */ private boolean _hideIfNotDisguised = false; + /** + * Whether the entity should have it's pitch locked at 0, prevents ESP being used. + */ + private boolean _lockPitch; protected boolean _spawnedIn = false; @@ -143,6 +147,16 @@ public abstract class DisguiseBase getEntity().world.makeSound(getEntity(), _soundDisguise.getHurtSound(), _soundDisguise.getVolume(), _soundDisguise.getPitch()); } + public void setLockPitch(boolean lockPitch) + { + _lockPitch = lockPitch; + } + + public boolean isPitchLocked() + { + return _lockPitch; + } + public Entity getEntity() { return _entity.get(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java index 1ea337549..2458d2ea0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/hideseek/forms/CreatureForm.java @@ -42,6 +42,7 @@ public class CreatureForm extends Form else if (_type == EntityType.PIG) {_disguise = new DisguisePig(Player); icon = Material.PORK;} _disguise.setSoundDisguise(new DisguiseCat(Player)); + _disguise.setLockPitch(true); Host.Manager.GetDisguise().disguise(_disguise); ((CraftEntity)Player).getHandle().getDataWatcher().watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/kits/SneakyAssassinKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/kits/SneakyAssassinKit.java index d138c0f31..e5da8181d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/kits/SneakyAssassinKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/sneakyassassins/kits/SneakyAssassinKit.java @@ -47,7 +47,9 @@ public abstract class SneakyAssassinKit extends Kit @Override public void GiveItems(Player player) { - Manager.GetDisguise().disguise(new DisguiseVillager(player)); + DisguiseVillager disguise = new DisguiseVillager(player); + disguise.setLockPitch(true); + Manager.GetDisguise().disguise(disguise); player.getInventory().addItem(PLAYER_ITEMS); player.getInventory().setArmorContents(PLAYER_ARMOR);