use of net.minecraft.server.v1_12_R1.EntityArmorStand in project VehiclesPlus2.0 by legofreak107.
the class Helicopter method Helicopter.
public static void Helicopter(PacketPlayInSteerVehicle ppisv, Player p) {
ArmorStand a2 = (ArmorStand) p.getVehicle();
Seat s = plugin.seatInfo.get(a2);
ArmorStand a = (ArmorStand) s.parent;
Vehicle v = plugin.vehicleInfo.get(a);
float forward = ppisv.b();
float side = ppisv.a();
boolean space = ppisv.c();
/*if(!Main.flyspeedlr.containsKey(p)){
Main.flyspeedlr.put(p, (float) 0);
}
if (!space && forward > 0 && Main.flyspeedlr.get(p) > 1.2){ //Forward[W]
if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) < 1.5){
Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) + 0.05));
a.setHeadPose(new EulerAngle(Math.toRadians(Main.flyspeed.get(p) * 30),0,0));
}else if(!Main.flyspeed.containsKey(p)){
Main.flyspeed.put(p, (float) 0);
}
if(Main.flyspeed.get(p) < 1){
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
}else{
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
}
}else if(forward == 0){
if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) > 0){
Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) - 0.01));
}else if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) < 0){
Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) + 0.01));
}
if(Main.flyspeed.get(p) < 0.6 && Main.flyspeed.get(p) > -0.6){
a.setHeadPose(new EulerAngle(0,0,0));
}else{
a.setHeadPose(new EulerAngle(Math.toRadians(Main.flyspeed.get(p) * 30),0,0));
}
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(Main.flyspeed.get(p)).getX(), Main.flyspeedlr.get(p) -1.3, a.getLocation().getDirection().multiply(Main.flyspeed.get(p)).getZ()));
}else if(!space && forward < 0 && Main.flyspeedlr.get(p) > 1.2){
if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) > -1.5){
Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) - 0.05));
a.setHeadPose(new EulerAngle(Math.toRadians(Main.flyspeed.get(p) * 30),0,0));
}else if(!Main.flyspeed.containsKey(p)){
Main.flyspeed.put(p, (float) 0);
}
if(Main.flyspeed.get(p) < -1){
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
}else{
a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
}
}
if (side > 0){ //Side[A]
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
} else if (side < 0){ //Side[D]
EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
}
if(space && forward > 0){
if(Main.flyspeedlr.containsKey(p) && Main.flyspeedlr.get(p) < 1.5){
Main.flyspeedlr.put(p, (float) (Main.flyspeedlr.get(p) + 0.01));
a.setVelocity(new Vector(0, Main.flyspeedlr.get(p)-1.2, 0));
}else if(!Main.flyspeedlr.containsKey(p)){
Main.flyspeedlr.put(p, (float) 0);
}
}
if(space && forward < 0){
if(Main.flyspeedlr.containsKey(p) && Main.flyspeedlr.get(p) > 0){
Main.flyspeedlr.put(p, (float) (Main.flyspeedlr.get(p) - 0.01));
a.setVelocity(new Vector(0, Main.flyspeedlr.get(p)-1.2, 0));
}else if(!Main.flyspeedlr.containsKey(p)){
Main.flyspeedlr.put(p, (float) 0);
}
}*/
}
use of net.minecraft.server.v1_12_R1.EntityArmorStand in project MyPet by xXKeyleXx.
the class ControlTarget method shouldStart.
@Override
public boolean shouldStart() {
if (controlPathfinderGoal == null) {
if (petEntity.getPathfinder().hasGoal("Control")) {
controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
}
}
if (controlPathfinderGoal == null) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
}
for (EntityLiving entityLiving : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
if (entityLiving instanceof EntityPlayer) {
Player targetPlayer = (Player) entityLiving.getBukkitEntity();
if (myPet.getOwner().equals(targetPlayer)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
continue;
}
} else if (entityLiving instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
continue;
} else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
continue;
}
}
} else if (entityLiving instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
continue;
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
continue;
}
if (behaviorSkill != null) {
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (entityLiving instanceof EntityTameableAnimal) {
continue;
} else if (entityLiving instanceof EntityMyPet) {
continue;
} else if (entityLiving instanceof EntityPlayer) {
continue;
}
}
}
controlPathfinderGoal.stopControl();
this.target = entityLiving;
return true;
}
}
}
return false;
}
use of net.minecraft.server.v1_12_R1.EntityArmorStand in project MyPet by xXKeyleXx.
the class OwnerHurtByTarget method shouldStart.
@Override
public boolean shouldStart() {
if (!petEntity.canMove()) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
this.lastDamager = owner.getLastDamager();
if (this.lastDamager == null || !lastDamager.isAlive()) {
return false;
}
if (lastDamager instanceof EntityArmorStand) {
return false;
}
if (lastDamager == petEntity) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
if (owner == lastDamager) {
return false;
}
Player targetPlayer = (Player) lastDamager.getBukkitEntity();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
return false;
}
} else if (lastDamager instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
return false;
}
} else if (lastDamager instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
return false;
}
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
return false;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
return false;
}
if (lastDamager instanceof EntityMyPet) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
return false;
}
}
}
return true;
}
use of net.minecraft.server.v1_12_R1.EntityArmorStand in project MyPet by xXKeyleXx.
the class OwnerHurtByTarget method shouldStart.
@Override
public boolean shouldStart() {
if (!petEntity.canMove()) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
this.lastDamager = owner.getLastDamager();
if (this.lastDamager == null || !lastDamager.isAlive()) {
return false;
}
if (lastDamager instanceof EntityArmorStand) {
return false;
}
if (lastDamager == petEntity) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
if (owner == lastDamager) {
return false;
}
Player targetPlayer = (Player) lastDamager.getBukkitEntity();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
return false;
}
} else if (lastDamager instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
return false;
}
} else if (lastDamager instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
return false;
}
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
return false;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
return false;
}
if (lastDamager instanceof EntityMyPet) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
return false;
}
}
}
return true;
}
use of net.minecraft.server.v1_12_R1.EntityArmorStand in project MyPet by xXKeyleXx.
the class OwnerHurtByTarget method shouldStart.
@Override
public boolean shouldStart() {
if (!petEntity.canMove()) {
return false;
}
if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
return false;
}
this.lastDamager = owner.getLastDamager();
if (this.lastDamager == null || !lastDamager.isAlive()) {
return false;
}
if (lastDamager instanceof EntityArmorStand) {
return false;
}
if (lastDamager == petEntity) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
if (owner == lastDamager) {
return false;
}
Player targetPlayer = (Player) lastDamager.getBukkitEntity();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
return false;
}
} else if (lastDamager instanceof EntityMyPet) {
MyPet targetMyPet = ((EntityMyPet) lastDamager).getMyPet();
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
return false;
}
} else if (lastDamager instanceof EntityTameableAnimal) {
EntityTameableAnimal tameable = (EntityTameableAnimal) lastDamager;
if (tameable.isTamed() && tameable.getOwner() != null) {
Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
if (myPet.getOwner().equals(tameableOwner)) {
return false;
}
}
}
if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), lastDamager.getBukkitEntity())) {
return false;
}
Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
if (behaviorSkill != null && behaviorSkill.isActive()) {
if (behaviorSkill.getBehavior() == BehaviorMode.Friendly) {
return false;
}
if (behaviorSkill.getBehavior() == BehaviorMode.Raid) {
if (lastDamager instanceof EntityTameableAnimal && ((EntityTameableAnimal) lastDamager).isTamed()) {
return false;
}
if (lastDamager instanceof EntityMyPet) {
return false;
}
if (lastDamager instanceof EntityPlayer) {
return false;
}
}
}
return true;
}
Aggregations