Search in sources :

Example 31 with World

use of org.spongepowered.api.world.World 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 32 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class AntiRailDupeListener method onPistonMove.

@Listener
public void onPistonMove(ChangeBlockEvent event, @Named(NamedCause.SOURCE) Piston piston) {
    event.getTransactions().stream().map(Transaction::getFinal).forEach(block -> {
        BlockType finalType = block.getState().getType();
        if (railBlocks.contains(finalType)) {
            Location<World> location = block.getLocation().get();
            Task.builder().execute(() -> {
                location.setBlockType(BlockTypes.AIR, Cause.source(SkreePlugin.container()).build());
            }).delayTicks(1).submit(SkreePlugin.inst());
        }
    });
}
Also used : BlockType(org.spongepowered.api.block.BlockType) World(org.spongepowered.api.world.World) Listener(org.spongepowered.api.event.Listener)

Example 33 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class WorldSystem method loadWorld.

private void loadWorld(WorldConfig worldConfig) throws Throwable {
    World world = getOrCreateWorld(worldConfig);
    String targetWrapper = worldConfig.getWrapper();
    if (targetWrapper == null || targetWrapper.isEmpty()) {
        return;
    }
    wrappers.get(targetWrapper).addWorld(world);
}
Also used : World(org.spongepowered.api.world.World)

Example 34 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class ThorAttack method apply.

@Override
public Optional<Instruction<DamageCondition, Boss<Zombie, CatacombsBossDetail>>> apply(DamageCondition damageCondition, Boss<Zombie, CatacombsBossDetail> zombieCatacombsBossDetailBoss) {
    Living bossEnt = zombieCatacombsBossDetailBoss.getTargetEntity().get();
    Entity toHit = damageCondition.getAttacked();
    toHit.setVelocity(EntityDirectionUtil.getFacingVector(bossEnt).mul(2));
    Task.builder().execute(() -> {
        Location<World> targetLoc = toHit.getLocation();
        Task.builder().execute(() -> {
            Lightning lightning = (Lightning) toHit.getWorld().createEntity(EntityTypes.LIGHTNING, targetLoc.getPosition());
            toHit.getWorld().spawnEntity(lightning, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
        }).delay(750, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
    }).delay(1500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
    return Optional.empty();
}
Also used : Entity(org.spongepowered.api.entity.Entity) Living(org.spongepowered.api.entity.living.Living) Lightning(org.spongepowered.api.entity.weather.Lightning) World(org.spongepowered.api.world.World)

Example 35 with World

use of org.spongepowered.api.world.World in project Skree by Skelril.

the class TheForgeInstance method dropResults.

private void dropResults() {
    Location<World> targetDropPoint = centralDropPoint.add(Probability.pickOneOf(pointAdjustments));
    new FixedPointItemDropper(targetDropPoint).dropStacks(getProduce(), SpawnTypes.PLUGIN);
    state.save();
}
Also used : FixedPointItemDropper(com.skelril.nitro.item.FixedPointItemDropper) World(org.spongepowered.api.world.World)

Aggregations

World (org.spongepowered.api.world.World)81 Listener (org.spongepowered.api.event.Listener)24 Location (org.spongepowered.api.world.Location)23 Entity (org.spongepowered.api.entity.Entity)18 Player (org.spongepowered.api.entity.living.player.Player)18 Vector3i (com.flowpowered.math.vector.Vector3i)11 WorldService (com.skelril.skree.service.WorldService)11 BlockType (org.spongepowered.api.block.BlockType)10 ItemStack (org.spongepowered.api.item.inventory.ItemStack)10 Vector3d (com.flowpowered.math.vector.Vector3d)9 TileEntity (org.spongepowered.api.block.tileentity.TileEntity)8 ArrayList (java.util.ArrayList)7 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)7 BlockState (org.spongepowered.api.block.BlockState)7 ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)6 Living (org.spongepowered.api.entity.living.Living)5 Monster (org.spongepowered.api.entity.living.monster.Monster)5 ItemDropper (com.skelril.nitro.item.ItemDropper)4 ModifierService (com.skelril.skree.service.ModifierService)4 IOException (java.io.IOException)4