Search in sources :

Example 6 with PacketPlayInSteerVehicle

use of net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle 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)

Example 7 with PacketPlayInSteerVehicle

use of net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle 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);
        	}
        }*/
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Seat(me.legofreak107.vehicles.objects.Seat) ArmorStand(org.bukkit.entity.ArmorStand)

Aggregations

Seat (me.legofreak107.vehicles.objects.Seat)6 Vehicle (me.legofreak107.vehicles.objects.Vehicle)6 PacketPlayInSteerVehicle (net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle)6 ArmorStand (org.bukkit.entity.ArmorStand)6 EntityArmorStand (net.minecraft.server.v1_12_R1.EntityArmorStand)5 Location (org.bukkit.Location)5 CraftArmorStand (org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand)5 Vector (org.bukkit.util.Vector)4 BossBar (org.bukkit.boss.BossBar)3 PlayerInventory (org.bukkit.inventory.PlayerInventory)3 EulerAngle (org.bukkit.util.EulerAngle)3 ProtocolManager (com.comphenix.protocol.ProtocolManager)2 PacketAdapter (com.comphenix.protocol.events.PacketAdapter)2 PacketEvent (com.comphenix.protocol.events.PacketEvent)2 Player (org.bukkit.entity.Player)2 BotCommands (com.ebicep.jda.BotCommands)1 BotListener (com.ebicep.jda.BotListener)1 FutureMessageManager (com.ebicep.warlords.database.FutureMessageManager)1 LeaderboardCommand (com.ebicep.warlords.database.leaderboards.LeaderboardCommand)1 FireWorkEffectPlayer (com.ebicep.warlords.effects.FireWorkEffectPlayer)1