Implement lockable pitches
This commit is contained in:
parent
ef92d7ab62
commit
77adc83720
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user