Sort of adjust the antlers for 1.8 clients
This commit is contained in:
parent
87f35fecca
commit
504418ca6e
@ -2,6 +2,11 @@ package mineplex.core.gadget.gadgets.outfit.reindeer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -10,13 +15,18 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class OutfitReindeerAntlers extends OutfitReindeer
|
||||
public class OutfitReindeerAntlers extends OutfitReindeer implements IPacketHandler
|
||||
{
|
||||
|
||||
private static final ItemStack HELMET = new ItemStack(Material.DEAD_BUSH);
|
||||
@ -30,6 +40,8 @@ public class OutfitReindeerAntlers extends OutfitReindeer
|
||||
super(manager, "Antlers", ArmorSlot.HELMET, Material.DEAD_BUSH, (byte) 0);
|
||||
|
||||
_antlers = new HashMap<>();
|
||||
|
||||
manager.getPacketManager().addPacketHandler(this, PacketPlayOutEntityTeleport.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,4 +106,51 @@ public class OutfitReindeerAntlers extends OutfitReindeer
|
||||
|
||||
_antlers.forEach((player, pair) -> updateRotation(player, pair.getLeft(), pair.getRight()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
Player player = packetInfo.getPlayer();
|
||||
|
||||
if (UtilPlayer.is1_9(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PacketPlayOutEntityTeleport packet = (PacketPlayOutEntityTeleport) packetInfo.getPacket();
|
||||
int id = packet.a;
|
||||
|
||||
for (Entry<Player, Pair<ArmorStand, ArmorStand>> entry : _antlers.entrySet())
|
||||
{
|
||||
Player other = entry.getKey();
|
||||
Pair<ArmorStand, ArmorStand> pair = entry.getValue();
|
||||
ArmorStand left = pair.getLeft();
|
||||
ArmorStand right = pair.getRight();
|
||||
boolean isLeft = left.getEntityId() == id;
|
||||
PacketPlayOutRelEntityMove
|
||||
if (isLeft || right.getEntityId() == id)
|
||||
{
|
||||
Location location = isLeft ? left.getLocation() : right.getLocation();
|
||||
Location otherLocation = other.getLocation();
|
||||
otherLocation.setPitch(0);
|
||||
Vector direction = otherLocation.getDirection();
|
||||
Vector offset;
|
||||
|
||||
if (isLeft)
|
||||
{
|
||||
offset = UtilAlg.getRight(direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = UtilAlg.getLeft(direction);
|
||||
}
|
||||
|
||||
location.add(offset.multiply(0.4));
|
||||
|
||||
packet.b = MathHelper.floor(location.getX() * 32);
|
||||
packet.d = MathHelper.floor(location.getZ() * 32);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user