Search in sources :

Example 16 with EntityArmorStand

use of net.minecraft.server.v1_16_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 = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            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() == BehaviorState.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;
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_8_R1.EntityPlayer) Player(org.bukkit.entity.Player) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R1.EntityLiving) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R1.entity.EntityMyPet) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityPlayer(net.minecraft.server.v1_8_R1.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_8_R1.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_8_R1.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 17 with EntityArmorStand

use of net.minecraft.server.v1_16_R1.EntityArmorStand in project MyPet by xXKeyleXx.

the class MeleeAttack method shouldStart.

@Override
public boolean shouldStart() {
    if (myPet.getDamage() <= 0) {
        return false;
    }
    if (!this.petEntity.hasTarget()) {
        return false;
    }
    EntityLiving targetEntity = ((CraftLivingEntity) this.petEntity.getTarget()).getHandle();
    if (targetEntity instanceof EntityArmorStand) {
        return false;
    }
    if (petEntity.getMyPet().getRangedDamage() > 0 && this.petEntity.f(targetEntity.locX, targetEntity.getBoundingBox().b, targetEntity.locZ) >= 20) {
        return false;
    }
    this.targetEntity = targetEntity;
    return true;
}
Also used : EntityLiving(net.minecraft.server.v1_8_R2.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_8_R2.entity.CraftLivingEntity) EntityArmorStand(net.minecraft.server.v1_8_R2.EntityArmorStand)

Example 18 with EntityArmorStand

use of net.minecraft.server.v1_16_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 = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            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() == BehaviorState.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;
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_9_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R1.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_9_R1.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_9_R1.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_9_R1.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_9_R1.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_9_R1.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 19 with EntityArmorStand

use of net.minecraft.server.v1_16_R1.EntityArmorStand in project VehiclesPlus2.0 by legofreak107.

the class Main method onEnable.

@Override
public void onEnable() {
    ChunkUnload cu = new ChunkUnload(this);
    EntityDamage ed = new EntityDamage(this);
    EntityDismount edi = new EntityDismount(this);
    InventoryClick ic = new InventoryClick(this);
    InventoryClose icl = new InventoryClose(this, ic);
    PlayerDropItem pdi = new PlayerDropItem(this);
    PlayerInteract pi = new PlayerInteract(this);
    PlayerInteractAtEntity piae = new PlayerInteractAtEntity(this);
    PlayerJoin pj = new PlayerJoin(this);
    PlayerQuit pq = new PlayerQuit(this);
    SignChange sc = new SignChange(this);
    VehicleExit ve = new VehicleExit(this);
    Bukkit.getPluginManager().registerEvents(cu, this);
    Bukkit.getPluginManager().registerEvents(ed, this);
    Bukkit.getPluginManager().registerEvents(edi, this);
    Bukkit.getPluginManager().registerEvents(ic, this);
    Bukkit.getPluginManager().registerEvents(icl, this);
    Bukkit.getPluginManager().registerEvents(pdi, this);
    Bukkit.getPluginManager().registerEvents(pi, this);
    Bukkit.getPluginManager().registerEvents(piae, this);
    Bukkit.getPluginManager().registerEvents(pj, this);
    Bukkit.getPluginManager().registerEvents(pq, this);
    Bukkit.getPluginManager().registerEvents(sc, this);
    Bukkit.getPluginManager().registerEvents(ve, this);
    if (getCustomSettingsConfig().contains("Garage.maxCarsSpawnedPerPlayer")) {
        maxCars = getCustomSettingsConfig().getInt("Garage.maxCarsSpawnedPerPlayer");
    } else {
        getCustomSettingsConfig().set("Garage.maxCarsSpawnedPerPlayer", 3);
        saveCustomSettingsConfig();
    }
    if (getCustomSettingsConfig().contains("Items.upgrades")) {
        repairMenuItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.repairMenuItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.repairMenuItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.repairMenuItem.unbreakable"));
        upgradeMenuItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.upgradeMenuItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.upgradeMenuItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.upgradeMenuItem.unbreakable"));
        engineUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.engineUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.engineUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.engineUpgradeItem.unbreakable"));
        steeringUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.steeringUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.steeringUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.steeringUpgradeItem.unbreakable"));
        gearboxUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.gearboxUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.gearboxUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.gearboxUpgradeItem.unbreakable"));
        fuelUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.fuelUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.fuelUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.fuelUpgradeItem.unbreakable"));
        engineRepairItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.engineRepairItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.engineRepairItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.engineRepairItem.unbreakable"));
        wheelRepairItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.wheelRepairItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.wheelRepairItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.wheelRepairItem.unbreakable"));
    } else {
        getCustomSettingsConfig().set("Items.upgrades.repairMenuItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.repairMenuItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.repairMenuItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.upgradeMenuItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.upgradeMenuItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.upgradeMenuItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.engineUpgradeItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.engineUpgradeItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.engineUpgradeItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.steeringUpgradeItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.steeringUpgradeItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.steeringUpgradeItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.gearboxUpgradeItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.gearboxUpgradeItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.gearboxUpgradeItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.fuelUpgradeItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.fuelUpgradeItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.fuelUpgradeItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.engineRepairItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.engineRepairItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.engineRepairItem.unbreakable", false);
        getCustomSettingsConfig().set("Items.upgrades.wheelRepairItem.id", 1);
        getCustomSettingsConfig().set("Items.upgrades.wheelRepairItem.data", 0);
        getCustomSettingsConfig().set("Items.upgrades.wheelRepairItem.unbreakable", false);
        repairMenuItem = new ItemStack(Material.STONE, 1);
        upgradeMenuItem = new ItemStack(Material.STONE, 1);
        engineUpgradeItem = new ItemStack(Material.STONE, 1);
        steeringUpgradeItem = new ItemStack(Material.STONE, 1);
        gearboxUpgradeItem = new ItemStack(Material.STONE, 1);
        fuelUpgradeItem = new ItemStack(Material.STONE, 1);
        engineRepairItem = new ItemStack(Material.STONE, 1);
        wheelRepairItem = new ItemStack(Material.STONE, 1);
        saveCustomSettingsConfig();
    }
    Bukkit.getPluginManager().registerEvents(this, this);
    if (!setupEconomy()) {
        this.getLogger().severe("Disabled due to no Vault dependency found!");
        Bukkit.getPluginManager().disablePlugin(this);
        return;
    }
    ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
    Bike.plugin = this;
    Plane.plugin = this;
    Car.plugin = this;
    Helicopter.plugin = this;
    Boat.plugin = this;
    sal.plugin = this;
    enable();
    protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.LOWEST, PacketType.Play.Client.STEER_VEHICLE) {

        @Override
        public void onPacketReceiving(PacketEvent event) {
            if (event.getPacketType().equals(PacketType.Play.Client.STEER_VEHICLE)) {
                PacketPlayInSteerVehicle ppisv = (PacketPlayInSteerVehicle) event.getPacket().getHandle();
                for (Seat s2 : seatInfo.values()) {
                    ArmorStand vp = s2.parent;
                    Location locvp = vp.getLocation().clone();
                    Location fbvp = locvp.add(locvp.getDirection().setY(0).normalize().multiply(s2.offset.getX()));
                    float zvp = (float) (fbvp.getZ() + (s2.offset.getZ() * Math.sin(Math.toRadians(fbvp.getYaw() + 90 * 0))));
                    float xvp = (float) (fbvp.getX() + (s2.offset.getZ() * Math.cos(Math.toRadians(fbvp.getYaw() + 90 * 0))));
                    Vehicle v = vehicleInfo.get(vp);
                    EntityArmorStand seat = ((CraftArmorStand) s2.seat).getHandle();
                    seat.setLocation(xvp, vp.getLocation().getY() + s2.offset.getY(), zvp, fbvp.getYaw(), fbvp.getPitch());
                    EntityArmorStand s3 = ((CraftArmorStand) v.skinHolder).getHandle();
                    s3.setLocation(vp.getLocation().getX(), vp.getLocation().getY(), vp.getLocation().getZ(), fbvp.getYaw(), fbvp.getPitch());
                }
                Player p = event.getPlayer();
                if (p.getVehicle() instanceof ArmorStand) {
                    ArmorStand a = (ArmorStand) p.getVehicle();
                    if (seatInfo.containsKey(a)) {
                        Seat s = seatInfo.get(a);
                        if (s.steer) {
                            ArmorStand a2 = s.parent;
                            Vehicle v = vehicleInfo.get(a2);
                            if (v.type == VehicleType.CAR) {
                                Car.Car(ppisv, p);
                            } else if (v.type == VehicleType.PLANE) {
                                Plane.Plane(ppisv, p);
                            } else if (v.type == VehicleType.BIKE) {
                                Bike.Bike(ppisv, p);
                            } else if (v.type == VehicleType.HELICOPTER) {
                                Helicopter.Helicopter(ppisv, p);
                            } else if (v.type == VehicleType.BOAT) {
                                Boat.Boat(ppisv, p);
                            }
                        }
                    }
                }
            }
        }
    });
    Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {

        public void run() {
            for (Vehicle v : vehicleInfo.values()) {
                if (v.type == VehicleType.CAR) {
                    for (Seat s : v.seats) {
                        for (Entity e : s.seat.getPassengers()) {
                            if (e instanceof Player) {
                                return;
                            }
                        }
                    }
                    Car.CarNonDriveable(v);
                }
            }
            for (Seat s2 : seatInfo.values()) {
                ArmorStand vp = s2.parent;
                Location locvp = vp.getLocation().clone();
                Location fbvp = locvp.add(locvp.getDirection().setY(0).normalize().multiply(s2.offset.getX()));
                float zvp = (float) (fbvp.getZ() + (s2.offset.getZ() * Math.sin(Math.toRadians(fbvp.getYaw() + 90 * 0))));
                float xvp = (float) (fbvp.getX() + (s2.offset.getZ() * Math.cos(Math.toRadians(fbvp.getYaw() + 90 * 0))));
                EntityArmorStand seat = ((CraftArmorStand) s2.seat).getHandle();
                seat.setLocation(xvp, vp.getLocation().getY() + s2.offset.getY(), zvp, fbvp.getYaw(), fbvp.getPitch());
                Vehicle v = vehicleInfo.get(vp);
                if (v.holder.getLocation().getBlock().getType() == Material.STATIONARY_WATER && v.type != VehicleType.BOAT) {
                    v.setHealth(0);
                } else if (v.holder.getLocation().getBlock().getType() == Material.STATIONARY_WATER && v.type == VehicleType.BOAT) {
                    v.holder.setGravity(false);
                }
                EntityArmorStand s3 = ((CraftArmorStand) v.skinHolder).getHandle();
                s3.setLocation(vp.getLocation().getX(), vp.getLocation().getY(), vp.getLocation().getZ(), fbvp.getYaw(), fbvp.getPitch());
            }
        }
    }, 0L, 1L);
}
Also used : EntityDismount(me.legofreak107.vehicles.events.EntityDismount) Entity(org.bukkit.entity.Entity) PlayerInteractAtEntity(me.legofreak107.vehicles.events.PlayerInteractAtEntity) Seat(me.legofreak107.vehicles.objects.Seat) PlayerQuit(me.legofreak107.vehicles.events.PlayerQuit) SignChange(me.legofreak107.vehicles.events.SignChange) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Vehicle(me.legofreak107.vehicles.objects.Vehicle) InventoryClick(me.legofreak107.vehicles.events.InventoryClick) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) ArmorStand(org.bukkit.entity.ArmorStand) PacketAdapter(com.comphenix.protocol.events.PacketAdapter) PlayerInteract(me.legofreak107.vehicles.events.PlayerInteract) VPPlayer(me.legofreak107.vehicles.objects.VPPlayer) Player(org.bukkit.entity.Player) InventoryClose(me.legofreak107.vehicles.events.InventoryClose) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) ChunkUnload(me.legofreak107.vehicles.events.ChunkUnload) VehicleExit(me.legofreak107.vehicles.events.VehicleExit) PlayerJoin(me.legofreak107.vehicles.events.PlayerJoin) PlayerInteractAtEntity(me.legofreak107.vehicles.events.PlayerInteractAtEntity) ProtocolManager(com.comphenix.protocol.ProtocolManager) PacketEvent(com.comphenix.protocol.events.PacketEvent) ItemStack(org.bukkit.inventory.ItemStack) PlayerDropItem(me.legofreak107.vehicles.events.PlayerDropItem) EntityDamage(me.legofreak107.vehicles.events.EntityDamage) Location(org.bukkit.Location)

Example 20 with EntityArmorStand

use of net.minecraft.server.v1_16_R1.EntityArmorStand in project VehiclesPlus2.0 by legofreak107.

the class Plane method Plane.

public static void Plane(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);
    ArmorStand a3 = (ArmorStand) v.skinHolder;
    float forward = ppisv.b();
    float side = ppisv.a();
    boolean space = ppisv.c();
    v.fuelbar.setTitle("Fuel: " + (int) (v.fuel / v.maxFuel * 100) + "%");
    v.fuelbar.setProgress((v.fuel / v.maxFuel));
    if (v.fuelbar.getPlayers().contains(p)) {
    } else {
        v.fuelbar.addPlayer(p);
        v.fuelbar.setVisible(true);
    }
    if (v.fuel <= 0.5) {
        v.fuelbar.setTitle("Out of fuel!");
    } else {
        v.fuel -= v.fualUsage / 2;
        if (forward > 0) {
            // Forward[W]
            v.fuel -= v.fualUsage;
            if (v.curSpeed < v.fspeed) {
                v.curSpeed = v.curSpeed + v.acceleration / 20;
            }
            a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
        } else if (forward == 0) {
            if (v.curSpeed > 0) {
                v.curSpeed = v.curSpeed - v.acceleration / 20;
            }
            a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
        } else {
            if (v.curSpeed > 0) {
                v.curSpeed = v.curSpeed - v.acceleration / 20 * 3;
            }
            a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
        }
        if (forward > 0 && space) {
            if (v.curSpeed > (v.fspeed / 5 * 2)) {
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
            } else {
                if (v.curSpeed < v.fspeed) {
                    v.curSpeed = v.curSpeed + v.acceleration / 20;
                }
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
            }
        } else {
            a3.setHeadPose(new EulerAngle(0, 0, 0));
        }
        if (side > 0 && forward > 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());
            if (a.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
                a3.setHeadPose(new EulerAngle(0, 0, 170));
            }
        } else if (side < 0 && forward > 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 (a.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
                a3.setHeadPose(new EulerAngle(0, 0, -170));
            }
        } else {
            a3.setHeadPose(new EulerAngle(0, 0, 0));
        }
        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());
        }
        Location loc1 = new Location(a.getWorld(), a.getLocation().getBlockX() + 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
        Location loc2 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
        Location loc3 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() + 1);
        Location loc4 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() - 1);
        if ((loc1.getBlock().getType() != Material.AIR && loc1.getBlock().getType() != Material.LONG_GRASS && loc1.getBlock().getType() != Material.CHORUS_FLOWER && loc1.getBlock().getType() != Material.YELLOW_FLOWER && loc1.getBlock().getType() != Material.RED_ROSE && loc1.getBlock().getType() != Material.WHEAT) || (loc2.getBlock().getType() != Material.AIR && loc2.getBlock().getType() != Material.LONG_GRASS && loc2.getBlock().getType() != Material.CHORUS_FLOWER && loc2.getBlock().getType() != Material.YELLOW_FLOWER && loc2.getBlock().getType() != Material.RED_ROSE && loc2.getBlock().getType() != Material.WHEAT) || (loc3.getBlock().getType() != Material.AIR && loc3.getBlock().getType() != Material.LONG_GRASS && loc3.getBlock().getType() != Material.CHORUS_FLOWER && loc3.getBlock().getType() != Material.YELLOW_FLOWER && loc3.getBlock().getType() != Material.RED_ROSE && loc3.getBlock().getType() != Material.WHEAT) || (loc4.getBlock().getType() != Material.AIR && loc4.getBlock().getType() != Material.LONG_GRASS && loc4.getBlock().getType() != Material.CHORUS_FLOWER && loc4.getBlock().getType() != Material.YELLOW_FLOWER && loc4.getBlock().getType() != Material.RED_ROSE && loc4.getBlock().getType() != Material.WHEAT)) {
        }
    }
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Seat(me.legofreak107.vehicles.objects.Seat) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) ArmorStand(org.bukkit.entity.ArmorStand) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) EulerAngle(org.bukkit.util.EulerAngle) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Aggregations

Player (org.bukkit.entity.Player)16 MyPet (de.Keyle.MyPet.api.entity.MyPet)15 Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)11 EntityArmorStand (net.minecraft.server.v1_12_R1.EntityArmorStand)7 Behavior (de.Keyle.MyPet.skill.skills.Behavior)5 Seat (me.legofreak107.vehicles.objects.Seat)5 Vehicle (me.legofreak107.vehicles.objects.Vehicle)5 PacketPlayInSteerVehicle (net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle)5 Location (org.bukkit.Location)5 CraftArmorStand (org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand)5 ArmorStand (org.bukkit.entity.ArmorStand)5 EntityMyPet (de.Keyle.MyPet.compat.v1_8_R3.entity.EntityMyPet)3 BossBar (org.bukkit.boss.BossBar)3 PlayerInventory (org.bukkit.inventory.PlayerInventory)3 Vector (org.bukkit.util.Vector)3 EntityMyPet (de.Keyle.MyPet.compat.v1_12_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R1.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)2 EntityMyPet (de.Keyle.MyPet.compat.v1_9_R2.entity.EntityMyPet)2 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)2