Search in sources :

Example 51 with Vec3D

use of net.minecraft.server.v1_14_R1.Vec3D in project Citizens2 by CitizensDev.

the class PlayerNavigation method d.

@Override
public void d() {
    this.e += 1;
    if (this.g) {
        k();
    }
    if (o()) {
        return;
    }
    if (b()) {
        n();
    } else if ((this.c != null) && (this.c.e() < this.c.d())) {
        Vec3D localVec3D = c();
        Vec3D localObject = this.c.a(this.a, this.c.e());
        if ((localVec3D.y > localObject.y) && (!this.a.onGround) && (MathHelper.floor(localVec3D.x) == MathHelper.floor(localObject.x)) && (MathHelper.floor(localVec3D.z) == MathHelper.floor(localObject.z))) {
            this.c.c(this.c.e() + 1);
        }
    }
    m();
    if (o()) {
        return;
    }
    Vec3D localVec3D = this.c.a(this.a);
    Object localObject = new BlockPosition(localVec3D).down();
    AxisAlignedBB localAxisAlignedBB = this.b.getType((BlockPosition) localObject).e(this.b, (BlockPosition) localObject);
    localVec3D = localVec3D.a(0.0D, 1.0D - localAxisAlignedBB.e, 0.0D);
    this.a.getControllerMove().a(localVec3D.x, localVec3D.y, localVec3D.z, this.d);
}
Also used : AxisAlignedBB(net.minecraft.server.v1_12_R1.AxisAlignedBB) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition) Vec3D(net.minecraft.server.v1_12_R1.Vec3D)

Example 52 with Vec3D

use of net.minecraft.server.v1_14_R1.Vec3D in project Citizens2 by CitizensDev.

the class EntityHumanNPC method moveOnCurrentHeading.

private void moveOnCurrentHeading() {
    if (jumping) {
        if (onGround && jumpTicks == 0) {
            jump();
            jumpTicks = 10;
        }
    } else {
        jumpTicks = 0;
    }
    bb *= 0.98F;
    bd *= 0.98F;
    be *= 0.9F;
    // movement method
    moveWithFallDamage(new Vec3D(this.bb, this.bc, this.bd));
    NMS.setHeadYaw(getBukkitEntity(), yaw);
    if (jumpTicks > 0) {
        jumpTicks--;
    }
}
Also used : Vec3D(net.minecraft.server.v1_14_R1.Vec3D)

Example 53 with Vec3D

use of net.minecraft.server.v1_14_R1.Vec3D in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method hasLineOfSight.

@Override
public boolean hasLineOfSight(LivingEntity entity1, org.bukkit.entity.Entity entity2) {
    EntityLiving nmsEntity1 = ((CraftLivingEntity) entity1).getHandle();
    Entity nmsEntity2 = ((CraftEntity) entity2).getHandle();
    Vec3D vec3d = new Vec3D(nmsEntity1.locX(), nmsEntity1.getHeadY(), nmsEntity1.locZ());
    Vec3D vec3d1 = new Vec3D(nmsEntity2.locX(), nmsEntity2.getHeadY(), nmsEntity2.locZ());
    return nmsEntity1.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.VISUAL, RayTrace.FluidCollisionOption.NONE, nmsEntity1)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
}
Also used : Entity(net.minecraft.server.v1_16_R2.Entity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) TileEntity(net.minecraft.server.v1_16_R2.TileEntity) GroupDataEntity(net.minecraft.server.v1_16_R2.GroupDataEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity) EntityLiving(net.minecraft.server.v1_16_R2.EntityLiving) RayTrace(net.minecraft.server.v1_16_R2.RayTrace) CraftEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R2.entity.CraftLivingEntity) Vec3D(net.minecraft.server.v1_16_R2.Vec3D)

Example 54 with Vec3D

use of net.minecraft.server.v1_14_R1.Vec3D in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method hasLineOfSight.

@Override
public boolean hasLineOfSight(LivingEntity entity1, org.bukkit.entity.Entity entity2) {
    EntityLiving nmsEntity1 = ((CraftLivingEntity) entity1).getHandle();
    Entity nmsEntity2 = ((CraftEntity) entity2).getHandle();
    Vec3D vec3d = new Vec3D(nmsEntity1.locX(), nmsEntity1.getHeadY(), nmsEntity1.locZ());
    Vec3D vec3d1 = new Vec3D(nmsEntity2.locX(), nmsEntity2.getHeadY(), nmsEntity2.locZ());
    return nmsEntity1.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.VISUAL, RayTrace.FluidCollisionOption.NONE, nmsEntity1)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
}
Also used : Entity(net.minecraft.server.v1_16_R3.Entity) GroupDataEntity(net.minecraft.server.v1_16_R3.GroupDataEntity) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) TileEntity(net.minecraft.server.v1_16_R3.TileEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) RayTrace(net.minecraft.server.v1_16_R3.RayTrace) CraftEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) Vec3D(net.minecraft.server.v1_16_R3.Vec3D)

Example 55 with Vec3D

use of net.minecraft.server.v1_14_R1.Vec3D in project Warlords by ebicep.

the class FlagSpawnPointOption method register.

@Override
public void register(Game game) {
    this.game = game;
    // We register a gamemarker to prevent any captures for our own team if we lost our flag
    game.registerGameMarker(FlagCaptureInhibitMarker.class, pFlag -> {
        return !(info.getFlag() instanceof SpawnFlagLocation) && info.getTeam() == pFlag.getPlayer().getTeam();
    });
    game.registerGameMarker(DebugLocationMarker.class, DebugLocationMarker.create(Material.BANNER, 0, this.getClass(), "Flag spawn: " + info.getTeam(), this.info.getSpawnLocation()));
    game.registerGameMarker(DebugLocationMarker.class, DebugLocationMarker.create(Material.BANNER, 15, this.getClass(), "Flag: " + info.getTeam(), () -> info.getFlag().getLocation(), () -> info.getFlag().getDebugInformation()));
    FlagHolder holder = FlagHolder.create(() -> info);
    game.registerGameMarker(FlagHolder.class, holder);
    if (this.registerCompassMarker) {
        game.registerGameMarker(CompassTargetMarker.class, holder);
    }
    game.registerGameMarker(ScoreboardHandler.class, scoreboard = new SimpleScoreboardHandler(info.getTeam() == Team.RED ? 20 : 21, "flag") {

        @Override
        public List<String> computeLines(@Nullable WarlordsPlayer player) {
            String flagName = info.getTeam().coloredPrefix();
            FlagLocation flag = info.getFlag();
            if (flag instanceof SpawnFlagLocation) {
                return singletonList(flagName + " Flag: " + ChatColor.GREEN + "Safe");
            } else if (flag instanceof PlayerFlagLocation) {
                PlayerFlagLocation pFlag = (PlayerFlagLocation) flag;
                String extra = pFlag.getPickUpTicks() == 0 ? "" : ChatColor.YELLOW + " +" + pFlag.getComputedHumanMultiplier() + "§e%";
                return singletonList(flagName + " Flag: " + ChatColor.RED + "Stolen!" + extra);
            } else if (flag instanceof GroundFlagLocation) {
                GroundFlagLocation gFlag = (GroundFlagLocation) flag;
                return singletonList(flagName + " Flag: " + ChatColor.YELLOW + "Dropped! " + ChatColor.GRAY + gFlag.getDespawnTimerSeconds());
            } else {
                return singletonList(flagName + " Flag: " + ChatColor.GRAY + "Respawning...");
            }
        }
    });
    game.registerEvents(new Listener() {

        @EventHandler(priority = EventPriority.LOW)
        public void onArmorStandBreak(EntityDamageByEntityEvent event) {
            boolean isOurArmorStand = renderer.getRenderedArmorStands().contains(event.getEntity());
            WarlordsPlayer wp = Warlords.getPlayer(event.getDamager());
            if (wp != null && wp.getGame() == game && isOurArmorStand) {
                onFlagInteract(wp);
                event.setCancelled(true);
            }
        }

        @EventHandler(priority = EventPriority.LOW)
        public void onPotentialFlagInteract(PlayerInteractEntityEvent event) {
            onPotentialFlagInteract((PlayerEvent) event);
        }

        @EventHandler(priority = EventPriority.LOW)
        public void onPotentialFlagInteract(PlayerInteractEvent event) {
            onPotentialFlagInteract((PlayerEvent) event);
        }

        private void onPotentialFlagInteract(PlayerEvent event) {
            WarlordsPlayer wp = Warlords.getPlayer(event.getPlayer());
            if (wp != null && wp.getGame() == game) {
                Location playerLocation = wp.getEntity().getEyeLocation();
                Vector direction = wp.getEntity().getLocation().getDirection().multiply(3);
                Vec3D from = new Vec3D(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ());
                Vec3D to = new Vec3D(playerLocation.getX() + direction.getX(), playerLocation.getY() + direction.getY(), playerLocation.getZ() + direction.getZ());
                checkFlagInteract(playerLocation, wp, from, to, renderer);
            }
        }

        private void checkFlagInteract(Location playerLocation, WarlordsPlayer wp, Vec3D from, Vec3D to, FlagRenderer render) {
            Location entityLoc = new Location(playerLocation.getWorld(), 0, 0, 0);
            for (Entity stand : render.getRenderedArmorStands()) {
                stand.getLocation(entityLoc);
                if (entityLoc.getWorld() == playerLocation.getWorld() && entityLoc.distanceSquared(playerLocation) < 5 * 5) {
                    AxisAlignedBB aabb = new AxisAlignedBB(entityLoc.getX() - 0.5, entityLoc.getY(), entityLoc.getZ() - 0.5, entityLoc.getX() + 0.5, entityLoc.getY() + 2, entityLoc.getZ() + 0.5);
                    MovingObjectPosition mop = aabb.a(from, to);
                    if (mop != null) {
                        onFlagInteract(wp);
                        break;
                    }
                }
            }
        }

        private void onFlagInteract(WarlordsPlayer wp) {
            Team team = wp.getTeam();
            if (wp.isDeath()) {
                return;
            }
            if (renderer.getLastFlagState() != info.getFlag()) {
                // Prevent the player from interacting when the render state is outdated
                return;
            }
            wp.setFlagCooldown(2);
            if (info.getFlag() instanceof GroundFlagLocation) {
                GroundFlagLocation groundFlagLocation = (GroundFlagLocation) info.getFlag();
                if (team == info.getTeam()) {
                    // Return flag
                    info.setFlag(new SpawnFlagLocation(info.getSpawnLocation(), wp));
                } else {
                    // Steal flag
                    info.setFlag(new PlayerFlagLocation(wp, groundFlagLocation.getDamageTimer()));
                    if (wp.getEntity().getVehicle() != null) {
                        wp.getEntity().getVehicle().remove();
                    }
                }
            } else if (info.getFlag() instanceof SpawnFlagLocation) {
                if (team == info.getTeam()) {
                    // Nothing
                    wp.sendMessage("§cYou can't steal your own team's flag!");
                } else {
                    // Steal flag
                    info.setFlag(new PlayerFlagLocation(wp, 0));
                    wp.getCooldownManager().addCooldown(new RegularCooldown<FlagSpawnPointOption>("Flag Damage Resistance", "RES", FlagSpawnPointOption.class, null, wp, CooldownTypes.BUFF, cooldownManager -> {
                    }, 15 * 20) {

                        @Override
                        public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
                            return currentDamageValue * .9f;
                        }
                    });
                }
            }
        }
    });
}
Also used : AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) MovingObjectPosition(net.minecraft.server.v1_8_R3.MovingObjectPosition) SimpleScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.SimpleScoreboardHandler) Collections.singletonList(java.util.Collections.singletonList) EventHandler(org.bukkit.event.EventHandler) Location(org.bukkit.Location) ScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) Nonnull(javax.annotation.Nonnull) Vec3D(net.minecraft.server.v1_8_R3.Vec3D) Material(org.bukkit.Material) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) Nullable(javax.annotation.Nullable) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Entity(org.bukkit.entity.Entity) Team(com.ebicep.warlords.game.Team) com.ebicep.warlords.game.flags(com.ebicep.warlords.game.flags) Warlords(com.ebicep.warlords.Warlords) CooldownTypes(com.ebicep.warlords.player.cooldowns.CooldownTypes) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) Vector(org.bukkit.util.Vector) List(java.util.List) Game(com.ebicep.warlords.game.Game) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) EventPriority(org.bukkit.event.EventPriority) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) PlayerEvent(org.bukkit.event.player.PlayerEvent) WarlordsFlagUpdatedEvent(com.ebicep.warlords.events.WarlordsFlagUpdatedEvent) ChatColor(org.bukkit.ChatColor) AxisAlignedBB(net.minecraft.server.v1_8_R3.AxisAlignedBB) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) com.ebicep.warlords.game.option.marker(com.ebicep.warlords.game.option.marker) Entity(org.bukkit.entity.Entity) Listener(org.bukkit.event.Listener) PlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent) EventHandler(org.bukkit.event.EventHandler) Vec3D(net.minecraft.server.v1_8_R3.Vec3D) Team(com.ebicep.warlords.game.Team) WarlordsDamageHealingEvent(com.ebicep.warlords.events.WarlordsDamageHealingEvent) Vector(org.bukkit.util.Vector) PlayerInteractEntityEvent(org.bukkit.event.player.PlayerInteractEntityEvent) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) PlayerEvent(org.bukkit.event.player.PlayerEvent) MovingObjectPosition(net.minecraft.server.v1_8_R3.MovingObjectPosition) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) SimpleScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.SimpleScoreboardHandler) Nullable(javax.annotation.Nullable) Location(org.bukkit.Location)

Aggregations

Vec3D (net.minecraft.server.v1_16_R3.Vec3D)11 Vec3D (net.minecraft.server.v1_15_R1.Vec3D)10 Vec3D (net.minecraft.server.v1_14_R1.Vec3D)9 Vec3D (net.minecraft.server.v1_12_R1.Vec3D)7 Vec3D (net.minecraft.server.v1_10_R1.Vec3D)5 Vec3D (net.minecraft.server.v1_11_R1.Vec3D)5 Vec3D (net.minecraft.server.v1_8_R3.Vec3D)4 Gravity (net.citizensnpcs.trait.Gravity)3 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)3 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)2 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)2 AxisAlignedBB (net.minecraft.server.v1_12_R1.AxisAlignedBB)2 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)2 MovingObjectPosition (net.minecraft.server.v1_12_R1.MovingObjectPosition)2 PathPoint (net.minecraft.server.v1_14_R1.PathPoint)2 AxisAlignedBB (net.minecraft.server.v1_16_R3.AxisAlignedBB)2 BaseBlockPosition (net.minecraft.server.v1_16_R3.BaseBlockPosition)2 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)2 PathPoint (net.minecraft.server.v1_16_R3.PathPoint)2 AxisAlignedBB (net.minecraft.server.v1_8_R3.AxisAlignedBB)2