Search in sources :

Example 16 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class AntiJumpListener method onBlockPlace.

@Listener(order = Order.POST)
@IsCancelled(value = Tristate.TRUE)
public void onBlockPlace(ChangeBlockEvent.Place event, @Root Player player) {
    final Location<World> playerLoc = player.getLocation();
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        Optional<Location<World>> optLoc = transaction.getOriginal().getLocation();
        if (!optLoc.isPresent()) {
            continue;
        }
        Location<World> blockLoc = optLoc.get();
        final int blockY = blockLoc.getBlockY();
        if (Math.abs(player.getVelocity().getY()) > UPWARDS_VELOCITY && playerLoc.getY() > blockY) {
            Task.builder().execute(() -> {
                Vector3d position = player.getLocation().getPosition();
                if (position.getY() >= (blockY + LEAP_DISTANCE)) {
                    if (playerLoc.getPosition().distanceSquared(blockLoc.getPosition()) > Math.pow(RADIUS, 2)) {
                        return;
                    }
                    player.sendMessage(Text.of(TextColors.RED, "Hack jumping detected."));
                    player.setLocation(playerLoc.setPosition(new Vector3d(position.getX(), blockY, position.getZ())));
                }
            }).delayTicks(4).submit(SkreePlugin.inst());
        }
    }
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location) Listener(org.spongepowered.api.event.Listener) IsCancelled(org.spongepowered.api.event.filter.IsCancelled)

Example 17 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class EntityDirectionUtil method getFacingVector.

public static Vector3d getFacingVector(Living living) {
    Vector3d rot = living.getHeadRotation();
    double xRot = (rot.getY() + 90) % 360;
    double yRot = rot.getX() * -1;
    double h = Math.cos(Math.toRadians(yRot));
    return new Vector3d(h * Math.cos(Math.toRadians(xRot)), Math.sin(Math.toRadians(yRot)), h * Math.sin(Math.toRadians(xRot)));
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d)

Example 18 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class FreakyFourInstance method dabombDetonate.

public void dabombDetonate(double percentEffectiveness) {
    ZoneBoundingBox dabomb_RG = getRegion(FreakyFourBoss.DA_BOMB);
    Vector3i min = dabomb_RG.getMinimumPoint();
    Vector3i max = dabomb_RG.getMaximumPoint();
    int minX = min.getX();
    int minY = min.getY();
    int minZ = min.getZ();
    int maxX = max.getX();
    int maxZ = max.getZ();
    int dmgFact = (int) Math.max(3, percentEffectiveness * config.daBombTNTStrength);
    for (int x = minX; x < maxX; ++x) {
        for (int z = minZ; z < maxZ; ++z) {
            if (Probability.getChance(config.daBombTNT)) {
                getRegion().getExtent().triggerExplosion(Explosion.builder().location(new Location<>(getRegion().getExtent(), new Vector3d(x, minY, z))).radius(dmgFact).canCauseFire(false).shouldDamageEntities(true).build(), Cause.source(SkreePlugin.container()).build());
            }
        }
    }
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d) Vector3i(com.flowpowered.math.vector.Vector3i) ZoneBoundingBox(com.skelril.skree.service.internal.zone.ZoneBoundingBox) Location(org.spongepowered.api.world.Location)

Example 19 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class TheForgeInstance method setUp.

private void setUp() {
    Vector3d centerPoint = getRegion().getCenter();
    centralDropPoint = new Location<>(getRegion().getExtent(), new Vector3d(centerPoint.getX(), getRegion().getMinimumPoint().getY() + 11, centerPoint.getZ()));
    state = ForgeState.load();
}
Also used : Vector3d(com.flowpowered.math.vector.Vector3d)

Example 20 with Vector3d

use of com.flowpowered.math.vector.Vector3d in project Skree by Skelril.

the class BlipDefense method apply.

@Override
public Optional<Instruction<DamagedCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamagedCondition damagedCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
    CatacombsBossDetail detail = zombieCatacombsBossDetailBoss.getDetail();
    if (activate(detail)) {
        Zombie boss = zombieCatacombsBossDetailBoss.getTargetEntity().get();
        Vector3d vel = EntityDirectionUtil.getFacingVector(boss);
        vel = vel.mul(getMultiplier());
        vel = new Vector3d(vel.getX(), Math.min(getYCiel(), Math.max(getYFloor(), vel.getY())), vel.getZ());
        boss.setVelocity(vel);
    }
    return Optional.empty();
}
Also used : CatacombsBossDetail(com.skelril.skree.content.zone.group.catacombs.CatacombsBossDetail) Zombie(org.spongepowered.api.entity.living.monster.Zombie) Vector3d(com.flowpowered.math.vector.Vector3d)

Aggregations

Vector3d (com.flowpowered.math.vector.Vector3d)30 Location (org.spongepowered.api.world.Location)11 Entity (org.spongepowered.api.entity.Entity)10 Player (org.spongepowered.api.entity.living.player.Player)9 World (org.spongepowered.api.world.World)9 BlockType (org.spongepowered.api.block.BlockType)5 Listener (org.spongepowered.api.event.Listener)5 ItemStack (org.spongepowered.api.item.inventory.ItemStack)5 Vector3i (com.flowpowered.math.vector.Vector3i)4 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)4 PotionEffect (org.spongepowered.api.effect.potion.PotionEffect)4 Zombie (org.spongepowered.api.entity.living.monster.Zombie)4 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)4 ItemDropper (com.skelril.nitro.item.ItemDropper)3 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)3 IntegratedRunnable (com.skelril.nitro.time.IntegratedRunnable)3 TimedRunnable (com.skelril.nitro.time.TimedRunnable)3 ParticleEffect (org.spongepowered.api.effect.particle.ParticleEffect)3 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)3 EntityDamageSource (org.spongepowered.api.event.cause.entity.damage.source.EntityDamageSource)3