titan stuff

I HATE YOU SNAKE.
This commit is contained in:
Cheese 2015-11-28 15:57:07 +11:00
parent f55b6761a8
commit 0871663498
5 changed files with 83 additions and 34 deletions

View File

@ -443,6 +443,11 @@ public class UtilAlg
public static EulerAngle vectorToEuler(Vector vector)
{
return new EulerAngle(Math.toRadians(GetPitch(vector)), Math.toRadians(GetYaw(vector)), 0);
//JUST MAKE SURE THE ARMOR STAND ISNT ROTATED.
return new EulerAngle(
Math.toRadians(UtilAlg.GetPitch(vector)),
Math.toRadians(UtilAlg.GetYaw(vector)),
0);
}
}

View File

@ -46,7 +46,9 @@ public class MorphTitan extends MorphGadget
{
super(manager, "Elder Guardian Morph", new String[]
{
C.cWhite + "From deep withinsdngsg",
C.cWhite + "From the depths of the sea, the",
C.cWhite + "Elder Guardian posseses powers",
C.cWhite + "more amazing than any seen before!",
" ",
C.cRed + "Unlocked with Titan Rank",
},
@ -208,9 +210,9 @@ public class MorphTitan extends MorphGadget
@EventHandler
public void titanOwner(PlayerJoinEvent event)
{
// if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN))
// {
// Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
// }
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}
}
}

View File

@ -10,7 +10,10 @@ import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -115,12 +118,22 @@ public class MountTitan extends Mount<MountTitanData>
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.LOWEST)
public void target(EntityDamageEvent event)
{
for (MountTitanData data : _active.values())
{
if (data.ownsEntity(event.getEntity()))
event.setCancelled(true);
}
}
@EventHandler
public void titanOwner(PlayerJoinEvent event)
{
// if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN))
// {
// Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
// }
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.TITAN))
{
Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName());
}
}
}

View File

@ -5,7 +5,9 @@ package mineplex.core.mount.types;
import java.util.ArrayList;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Location;
import org.bukkit.Material;
@ -15,6 +17,7 @@ import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
public class MountTitanData
@ -29,24 +32,32 @@ public class MountTitanData
{
_owner = player.getName();
Location loc = player.getLocation();
loc.setPitch(0);
loc.setYaw(0);
//Nodes
_nodes = new ArrayList<ArmorStand>();
for (int i=0 ; i<30 ; i++)
{
ArmorStand node = player.getWorld().spawn(player.getLocation(), ArmorStand.class);
ArmorStand node = loc.getWorld().spawn(loc, ArmorStand.class);
node.setVisible(false);
node.setGravity(false);
node.setGhost(true);
node.setHelmet(new ItemStack(Material.REDSTONE_BLOCK));
node.setHelmet(new ItemStack(Material.NETHERRACK));
UtilEnt.setFakeHead(node, true);
_nodes.add(node);
}
//Head
_head = player.getWorld().spawn(player.getLocation(), MagmaCube.class);
_head = player.getWorld().spawn(loc, MagmaCube.class);
_head.setSize(2);
UtilEnt.ghost(_head, true, false);
_head.setCustomName(player.getName() + "'s " + name);
}
@ -61,7 +72,7 @@ public class MountTitanData
{
//Head
if (_head.getPassenger() != null)
_head.setVelocity(_head.getPassenger().getLocation().getDirection().add(new Vector(0,0.2,0)));
_head.setVelocity(_head.getPassenger().getLocation().getDirection().multiply(0.5).add(new Vector(0,0.2,0)));
Location infront = _head.getLocation().add(0, -1.5, 0);
@ -70,16 +81,26 @@ public class MountTitanData
{
ArmorStand node = _nodes.get(i);
Location old = node.getLocation();
infront.setPitch(node.getLocation().getPitch());
infront.setYaw(node.getLocation().getYaw());
//Move
if (i == 0)
node.teleport(infront);
else if (UtilMath.offset(node.getLocation(), infront) > 0.5)
node.teleport(infront.add(UtilAlg.getTrajectory(infront, node.getLocation()).multiply(0.5)));
infront = node.getLocation();
else if (UtilMath.offset(node.getLocation(), infront) > 0.6)
node.teleport(infront.add(UtilAlg.getTrajectory(infront, node.getLocation()).multiply(0.6)));
//Rotation
node.setHeadPose(UtilAlg.vectorToEuler(UtilAlg.getTrajectory(infront, node.getLocation())));
Vector vector = UtilAlg.getTrajectory(old, node.getLocation());
node.setHeadPose(new EulerAngle(
Math.toRadians(UtilAlg.GetPitch(vector)),
Math.toRadians(UtilAlg.GetYaw(vector)),
0));
infront = node.getLocation();
}
@ -95,6 +116,9 @@ public class MountTitanData
else
infront = _head.getLocation().add(0, -1.5, 0);
infront.setPitch(node.getLocation().getPitch());
infront.setYaw(node.getLocation().getYaw());
node.teleport(infront);
}
}
@ -114,4 +138,9 @@ public class MountTitanData
{
return _owner.equals(player.getName());
}
public boolean ownsEntity(Entity ent)
{
return (_head.equals(ent) || _nodes.contains(ent));
}
}

View File

@ -167,8 +167,8 @@ public class PetManager extends MiniClientPlugin<PetClient>
if (rank.has(Rank.TITAN))
{
// if (!Get(p).GetPets().containsKey(EntityType.SKELETON))
// Get(p).GetPets().put(EntityType.SKELETON, "Guardian");
if (!Get(p).GetPets().containsKey(EntityType.SKELETON))
Get(p).GetPets().put(EntityType.SKELETON, "Guardian");
}
}