Added armor show/hide for insentient disguises.
This commit is contained in:
parent
97405f6cfa
commit
9121d429c2
@ -1,8 +1,10 @@
|
||||
package mineplex.core.disguise;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.server.v1_6_R2.ChunkAddEntityEvent;
|
||||
@ -16,6 +18,7 @@ import net.minecraft.server.v1_6_R2.Packet31RelEntityMove;
|
||||
import net.minecraft.server.v1_6_R2.Packet33RelEntityMoveLook;
|
||||
import net.minecraft.server.v1_6_R2.Packet34EntityTeleport;
|
||||
import net.minecraft.server.v1_6_R2.Packet40EntityMetadata;
|
||||
import net.minecraft.server.v1_6_R2.Packet5EntityEquipment;
|
||||
import net.minecraft.server.v1_6_R2.Packet62NamedSoundEffect;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -35,6 +38,7 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||
import mineplex.core.disguise.disguises.DisguiseInsentient;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.packethandler.IPacketRunnable;
|
||||
import mineplex.core.packethandler.PacketArrayList;
|
||||
@ -142,6 +146,19 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
|
||||
entityPlayer.playerConnection.sendPacket(new Packet29DestroyEntity(disguise.GetEntityId()));
|
||||
}
|
||||
|
||||
List<Packet> tempArmor = new ArrayList<Packet>();
|
||||
|
||||
if (disguise instanceof DisguiseInsentient && disguise.GetEntity() instanceof LivingEntity)
|
||||
{
|
||||
if (((DisguiseInsentient)disguise).armorVisible())
|
||||
{
|
||||
for (Packet armorPacket : ((DisguiseInsentient)disguise).getArmorPackets())
|
||||
tempArmor.add(armorPacket);
|
||||
}
|
||||
}
|
||||
|
||||
final List<Packet> armorPackets = tempArmor;
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@ -153,6 +170,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
|
||||
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
|
||||
entityPlayer.playerConnection.sendPacket(disguise.GetSpawnPacket());
|
||||
|
||||
for (Packet packet : armorPackets)
|
||||
{
|
||||
entityPlayer.playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -206,7 +228,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
|
||||
@EventHandler
|
||||
public void TeleportDisguises(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
@ -261,6 +283,18 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (packet instanceof Packet5EntityEquipment)
|
||||
{
|
||||
int entityId = ((Packet5EntityEquipment)packet).a;
|
||||
|
||||
if (_spawnPacketMap.containsKey(entityId) && _spawnPacketMap.get(entityId) instanceof DisguiseInsentient)
|
||||
{
|
||||
if (!((DisguiseInsentient)_spawnPacketMap.get(entityId)).armorVisible() && ((Packet5EntityEquipment)packet).b != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (packet instanceof Packet28EntityVelocity)
|
||||
{
|
||||
Packet28EntityVelocity velocityPacket = (Packet28EntityVelocity)packet;
|
||||
@ -271,6 +305,10 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable
|
||||
if (velocityPacket.c > 0)
|
||||
_goingUp.add(velocityPacket.a);
|
||||
}
|
||||
else if (velocityPacket.b == 0 && velocityPacket.c == 0 && velocityPacket.d == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (_spawnPacketMap.containsKey(velocityPacket.a))
|
||||
{
|
||||
return false;
|
||||
|
@ -1,7 +1,15 @@
|
||||
package mineplex.core.disguise.disguises;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_6_R2.Packet;
|
||||
import net.minecraft.server.v1_6_R2.Packet5EntityEquipment;
|
||||
|
||||
public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
private boolean _showArmor;
|
||||
|
||||
public DisguiseInsentient(org.bukkit.entity.Entity entity)
|
||||
{
|
||||
super(entity);
|
||||
@ -29,4 +37,37 @@ public abstract class DisguiseInsentient extends DisguiseLiving
|
||||
{
|
||||
return DataWatcher.getByte(11) == 1;
|
||||
}
|
||||
|
||||
public boolean armorVisible()
|
||||
{
|
||||
return _showArmor;
|
||||
}
|
||||
|
||||
public void showArmor()
|
||||
{
|
||||
_showArmor = true;
|
||||
}
|
||||
|
||||
public void hideArmor()
|
||||
{
|
||||
_showArmor = false;
|
||||
}
|
||||
|
||||
public List<Packet> getArmorPackets()
|
||||
{
|
||||
List<Packet5EntityEquipment> p5 = new ArrayList<Packet5EntityEquipment>();
|
||||
net.minecraft.server.v1_6_R2.ItemStack[] armorContents = Entity.getEquipment();
|
||||
|
||||
for (short i=0; i < armorContents.length; i++)
|
||||
{
|
||||
net.minecraft.server.v1_6_R2.ItemStack armorSlot = armorContents[i];
|
||||
|
||||
if (armorSlot != null)
|
||||
{
|
||||
p5.add(new Packet5EntityEquipment(Entity.id, i, armorSlot));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user