Used packets to spectate the rotation bat.
This commit is contained in:
parent
4fdd42c599
commit
0a20a04903
@ -41,7 +41,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
public class Evolution extends SoloGame
|
||||
{
|
||||
@ -52,9 +51,7 @@ public class Evolution extends SoloGame
|
||||
private NautHashMap<String, EvoToken> _tokens = new NautHashMap<String, EvoToken>();
|
||||
|
||||
private ArrayList<Location> _evoPlatforms = new ArrayList<Location>();
|
||||
|
||||
private ArrayList<String> _except = new ArrayList<String>();
|
||||
|
||||
|
||||
public Evolution(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Evolution,
|
||||
@ -121,11 +118,6 @@ public class Evolution extends SoloGame
|
||||
return _evolve;
|
||||
}
|
||||
|
||||
public void addDismountException(Player player)
|
||||
{
|
||||
_except.add(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ParseData()
|
||||
{
|
||||
@ -258,30 +250,7 @@ public class Evolution extends SoloGame
|
||||
if (_evolve.isEvolving(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEvolveDismount(VehicleExitEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.getExited() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getExited();
|
||||
|
||||
if (!_evolve.isEvolving(player))
|
||||
return;
|
||||
|
||||
if (!_except.contains(player.getName()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
_except.remove(player.getName());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void startEvolve(EvolutionBeginEvent event)
|
||||
{
|
||||
|
@ -13,19 +13,20 @@ import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.packethandler.PacketPlayOutCamera;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import nautilus.game.arcade.game.games.evolution.EvoKit;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionBeginEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionEndEvent;
|
||||
import nautilus.game.arcade.game.games.evolution.events.EvolutionPostEvolveEvent;
|
||||
import net.minecraft.server.v1_7_R4.Entity;
|
||||
import net.minecraft.server.v1_7_R4.EntityBat;
|
||||
import net.minecraft.server.v1_7_R4.EntityBlaze;
|
||||
import net.minecraft.server.v1_7_R4.EntityChicken;
|
||||
import net.minecraft.server.v1_7_R4.EntityCreeper;
|
||||
import net.minecraft.server.v1_7_R4.EntityEnderman;
|
||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||
import net.minecraft.server.v1_7_R4.EntityIronGolem;
|
||||
import net.minecraft.server.v1_7_R4.EntityPlayer;
|
||||
import net.minecraft.server.v1_7_R4.EntitySkeleton;
|
||||
import net.minecraft.server.v1_7_R4.EntitySlime;
|
||||
import net.minecraft.server.v1_7_R4.EntitySnowman;
|
||||
@ -41,6 +42,7 @@ import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftBat;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -88,25 +90,10 @@ public class EvolveData
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionBeginEvent(_player));
|
||||
|
||||
teleport(true);
|
||||
|
||||
setupPlayer();
|
||||
}
|
||||
|
||||
// private void setupLocs()
|
||||
// {
|
||||
// for (double i = 0 ; i < 50.0 ; i+= .03)
|
||||
// {
|
||||
// Location loc = _manager.getLocation().clone().add(Math.cos(i) * _radius, 3.0, Math.sin(i) * _radius);
|
||||
//
|
||||
// Vector pyRef = UtilAlg.getTrajectory(loc, _manager.getLocation());
|
||||
//
|
||||
// loc.setPitch(UtilAlg.GetPitch(pyRef));
|
||||
// loc.setYaw(UtilAlg.GetYaw(pyRef));
|
||||
//
|
||||
// _rotateLocs.add(loc);
|
||||
// }
|
||||
//
|
||||
// _rotateIterator = _rotateLocs.iterator();
|
||||
// }
|
||||
|
||||
private void setupBat()
|
||||
{
|
||||
_manager.Host.CreatureAllowOverride = true;
|
||||
@ -122,6 +109,13 @@ public class EvolveData
|
||||
_bat = bat;
|
||||
}
|
||||
|
||||
private void setupPlayer()
|
||||
{
|
||||
//Spectate
|
||||
PacketPlayOutCamera packet = new PacketPlayOutCamera(_bat);
|
||||
UtilPlayer.sendPacket(_player, packet);
|
||||
}
|
||||
|
||||
//Boolean completed
|
||||
public boolean tick()
|
||||
{
|
||||
@ -174,17 +168,20 @@ public class EvolveData
|
||||
return false;
|
||||
|
||||
despawn(_eTo);
|
||||
|
||||
_player.leaveVehicle();
|
||||
_manager.Host.addDismountException(_player);
|
||||
|
||||
UtilAction.velocity(_player, 0.0, 0.0, 0.0, false);
|
||||
|
||||
_player.setVelocity(new Vector());
|
||||
//Stop spectating
|
||||
PacketPlayOutCamera packet = new PacketPlayOutCamera(_player);
|
||||
UtilPlayer.sendPacket(_player, packet);
|
||||
|
||||
_bat.remove();
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new EvolutionPostEvolveEvent(_player));
|
||||
|
||||
_manager.Host.Manager.GetCondition().GetActiveCondition(_player, ConditionType.CLOAK).Expire();
|
||||
_manager.Host.Manager.GetCondition().Clean(_player);
|
||||
|
||||
_to.ApplyKit(_player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -216,35 +213,25 @@ public class EvolveData
|
||||
0.4, false, 0, 0.0, 1, true);
|
||||
}
|
||||
|
||||
if (_bat.isEmpty() || _bat.getPassenger() != _player)
|
||||
{
|
||||
_bat.setPassenger(_player);
|
||||
((CraftPlayer) _player).getHandle().setSneaking(false);
|
||||
}
|
||||
EntityBat eB = ((CraftBat) _bat).getHandle();
|
||||
|
||||
EntityPlayer eP = ((CraftPlayer) _player).getHandle();
|
||||
|
||||
Vector to = UtilAlg.getTrajectory(_player.getEyeLocation(), _manager.getLocation());
|
||||
Vector to = UtilAlg.getTrajectory(_bat.getEyeLocation(), _manager.getLocation());
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
float pitch = ;
|
||||
float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory(_player.getEyeLocation(), _manager.getLocation()));
|
||||
float pitch = UtilAlg.GetPitch(to);
|
||||
float yaw = UtilAlg.GetYaw(to);
|
||||
|
||||
eP.lastYaw = yaw;
|
||||
eP.yaw = yaw;
|
||||
eB.lastYaw = yaw;
|
||||
eB.yaw = yaw;
|
||||
|
||||
eP.lastPitch = pitch;
|
||||
eP.pitch = pitch;
|
||||
eB.lastPitch = pitch;
|
||||
eB.pitch = pitch;
|
||||
|
||||
Method method = Entity.class.getDeclaredMethod("b", float.class, float.class);
|
||||
method.setAccessible(true);
|
||||
method.invoke(eP, yaw, pitch);
|
||||
method.invoke(eB, yaw, pitch);
|
||||
method.setAccessible(false);
|
||||
|
||||
eP.aO = eP.yaw;
|
||||
eP.aM = eP.yaw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user