Search in sources :

Example 86 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project LoliServer by Loli-Server.

the class CraftLivingEntity method launchProjectile.

@Override
@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    net.minecraft.world.World world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.entity.Entity launch = null;
    if (Snowball.class.isAssignableFrom(projectile)) {
        launch = new SnowballEntity(world, getHandle());
        // ItemSnowball
        ((ThrowableEntity) launch).shootFromRotation(getHandle(), getHandle().xRot, getHandle().yRot, 0.0F, 1.5F, 1.0F);
    } else if (Egg.class.isAssignableFrom(projectile)) {
        launch = new EggEntity(world, getHandle());
        // ItemEgg
        ((ThrowableEntity) launch).shootFromRotation(getHandle(), getHandle().xRot, getHandle().yRot, 0.0F, 1.5F, 1.0F);
    } else if (EnderPearl.class.isAssignableFrom(projectile)) {
        launch = new EnderPearlEntity(world, getHandle());
        // EnderPearlItem
        ((ThrowableEntity) launch).shootFromRotation(getHandle(), getHandle().xRot, getHandle().yRot, 0.0F, 1.5F, 1.0F);
    } else if (AbstractArrow.class.isAssignableFrom(projectile)) {
        if (TippedArrow.class.isAssignableFrom(projectile)) {
            launch = new ArrowEntity(world, getHandle());
            ((ArrowEntity) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
        } else if (SpectralArrow.class.isAssignableFrom(projectile)) {
            launch = new SpectralArrowEntity(world, getHandle());
        } else if (Trident.class.isAssignableFrom(projectile)) {
            launch = new TridentEntity(world, getHandle(), new net.minecraft.item.ItemStack(net.minecraft.item.Items.TRIDENT));
        } else {
            launch = new ArrowEntity(world, getHandle());
        }
        // ItemBow
        ((AbstractArrowEntity) launch).shootFromRotation(getHandle(), getHandle().xRot, getHandle().yRot, 0.0F, 3.0F, 1.0F);
    } else if (ThrownPotion.class.isAssignableFrom(projectile)) {
        if (LingeringPotion.class.isAssignableFrom(projectile)) {
            launch = new PotionEntity(world, getHandle());
            ((PotionEntity) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
        } else {
            launch = new PotionEntity(world, getHandle());
            ((PotionEntity) launch).setItem(CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
        }
        // SplashPotionItem
        ((ThrowableEntity) launch).shootFromRotation(getHandle(), getHandle().xRot, getHandle().yRot, -20.0F, 0.5F, 1.0F);
    } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
        launch = new ExperienceBottleEntity(world, getHandle());
        // ExperienceBottleItem
        ((ThrowableEntity) launch).shootFromRotation(getHandle(), getHandle().xRot, getHandle().yRot, -20.0F, 0.7F, 1.0F);
    } else if (FishHook.class.isAssignableFrom(projectile) && getHandle() instanceof PlayerEntity) {
        launch = new FishingBobberEntity((PlayerEntity) getHandle(), world, 0, 0);
    } else if (Fireball.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection().multiply(10);
        if (SmallFireball.class.isAssignableFrom(projectile)) {
            launch = new SmallFireballEntity(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (WitherSkull.class.isAssignableFrom(projectile)) {
            launch = new WitherSkullEntity(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (DragonFireball.class.isAssignableFrom(projectile)) {
            launch = new DragonFireballEntity(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else {
            launch = new FireballEntity(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        }
        ((DamagingProjectileEntity) launch).projectileSource = this;
        launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    } else if (LlamaSpit.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection();
        launch = net.minecraft.entity.EntityType.LLAMA_SPIT.create(world);
        ((LlamaSpitEntity) launch).setOwner(getHandle());
        // LlamaEntity
        ((LlamaSpitEntity) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F);
        launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    } else if (ShulkerBullet.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        launch = new ShulkerBulletEntity(world, getHandle(), null, null);
        launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    } else if (Firework.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        launch = new FireworkRocketEntity(world, net.minecraft.item.ItemStack.EMPTY, getHandle());
        launch.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    }
    Validate.notNull(launch, "Projectile not supported");
    if (velocity != null) {
        ((T) launch.getBukkitEntity()).setVelocity(velocity);
    }
    world.addFreshEntity(launch);
    return (T) launch.getBukkitEntity();
}
Also used : ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) AbstractArrowEntity(net.minecraft.entity.projectile.AbstractArrowEntity) SpectralArrowEntity(net.minecraft.entity.projectile.SpectralArrowEntity) SmallFireballEntity(net.minecraft.entity.projectile.SmallFireballEntity) ThrowableEntity(net.minecraft.entity.projectile.ThrowableEntity) EggEntity(net.minecraft.entity.projectile.EggEntity) SpectralArrowEntity(net.minecraft.entity.projectile.SpectralArrowEntity) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) ShulkerBullet(org.bukkit.entity.ShulkerBullet) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EnderPearlEntity(net.minecraft.entity.item.EnderPearlEntity) PotionData(org.bukkit.potion.PotionData) DragonFireball(org.bukkit.entity.DragonFireball) Fireball(org.bukkit.entity.Fireball) SmallFireball(org.bukkit.entity.SmallFireball) TippedArrow(org.bukkit.entity.TippedArrow) DragonFireball(org.bukkit.entity.DragonFireball) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) LlamaSpitEntity(net.minecraft.entity.projectile.LlamaSpitEntity) Trident(org.bukkit.entity.Trident) SmallFireball(org.bukkit.entity.SmallFireball) SnowballEntity(net.minecraft.entity.projectile.SnowballEntity) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Vector(org.bukkit.util.Vector) FishingBobberEntity(net.minecraft.entity.projectile.FishingBobberEntity) FishHook(org.bukkit.entity.FishHook) DragonFireballEntity(net.minecraft.entity.projectile.DragonFireballEntity) Egg(org.bukkit.entity.Egg) ShulkerBulletEntity(net.minecraft.entity.projectile.ShulkerBulletEntity) PotionEntity(net.minecraft.entity.projectile.PotionEntity) WitherSkullEntity(net.minecraft.entity.projectile.WitherSkullEntity) ThrownExpBottle(org.bukkit.entity.ThrownExpBottle) ExperienceBottleEntity(net.minecraft.entity.item.ExperienceBottleEntity) TridentEntity(net.minecraft.entity.projectile.TridentEntity) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) AbstractArrow(org.bukkit.entity.AbstractArrow) Location(org.bukkit.Location) FireballEntity(net.minecraft.entity.projectile.FireballEntity) SmallFireballEntity(net.minecraft.entity.projectile.SmallFireballEntity) DragonFireballEntity(net.minecraft.entity.projectile.DragonFireballEntity)

Example 87 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project LoliServer by Loli-Server.

the class CraftRabbit method setRabbitType.

@Override
public void setRabbitType(Type type) {
    RabbitEntity entity = getHandle();
    if (getRabbitType() == Type.THE_KILLER_BUNNY) {
        // Reset goals and target finders.
        World world = ((CraftWorld) this.getWorld()).getHandle();
        entity.goalSelector = new GoalSelector(world.getProfilerSupplier());
        entity.targetSelector = new GoalSelector(world.getProfilerSupplier());
        entity.registerGoals();
        entity.initializePathFinderGoals();
    }
    entity.setRabbitType(CraftMagicMapping.toMagic(type));
}
Also used : RabbitEntity(net.minecraft.entity.passive.RabbitEntity) GoalSelector(net.minecraft.entity.ai.goal.GoalSelector) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) World(net.minecraft.world.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 88 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project Magma-1.16.x by magmafoundation.

the class CraftDropper method drop.

@Override
public void drop() {
    Block block = getBlock();
    if (block.getType() == Material.DROPPER) {
        CraftWorld world = (CraftWorld) this.getWorld();
        DropperBlock drop = (DropperBlock) Blocks.DROPPER;
        drop.dispenseFrom(world.getHandle(), this.getPosition());
    }
}
Also used : Block(org.bukkit.block.Block) DropperBlock(net.minecraft.block.DropperBlock) DropperBlock(net.minecraft.block.DropperBlock) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 89 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project LoliServer by Loli-Server.

the class CraftDispenser method dispense.

@Override
public boolean dispense() {
    Block block = getBlock();
    if (block.getType() == Material.DISPENSER) {
        CraftWorld world = (CraftWorld) this.getWorld();
        DispenserBlock dispense = (DispenserBlock) Blocks.DISPENSER;
        dispense.dispenseFrom(world.getHandle(), this.getPosition());
        return true;
    } else {
        return false;
    }
}
Also used : DispenserBlock(net.minecraft.block.DispenserBlock) Block(org.bukkit.block.Block) DispenserBlock(net.minecraft.block.DispenserBlock) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Example 90 with CraftWorld

use of org.bukkit.craftbukkit.v1_13_R1.CraftWorld in project LoliServer by Loli-Server.

the class CraftJukebox method update.

@Override
public boolean update(boolean force, boolean applyPhysics) {
    boolean result = super.update(force, applyPhysics);
    if (result && this.isPlaced() && this.getType() == Material.JUKEBOX) {
        CraftWorld world = (CraftWorld) this.getWorld();
        Material record = this.getPlaying();
        if (record == Material.AIR) {
            world.getHandle().setBlock(this.getPosition(), Blocks.JUKEBOX.defaultBlockState().setValue(JukeboxBlock.HAS_RECORD, false), 3);
        } else {
            world.getHandle().setBlock(this.getPosition(), Blocks.JUKEBOX.defaultBlockState().setValue(JukeboxBlock.HAS_RECORD, true), 3);
        }
        world.playEffect(this.getLocation(), Effect.RECORD_PLAY, record);
    }
    return result;
}
Also used : Material(org.bukkit.Material) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld)

Aggregations

ServerLevel (net.minecraft.server.level.ServerLevel)147 Location (org.bukkit.Location)131 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)111 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)103 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)95 BlockPos (net.minecraft.core.BlockPos)83 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)74 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)66 ItemStack (org.bukkit.inventory.ItemStack)61 Block (org.bukkit.block.Block)57 LivingEntity (org.bukkit.entity.LivingEntity)54 CraftWorld (org.bukkit.craftbukkit.v1_8_R3.CraftWorld)53 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)47 ArrayList (java.util.ArrayList)43 World (org.bukkit.World)41 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)39 Entity (org.bukkit.entity.Entity)39 Level (net.minecraft.world.level.Level)38 List (java.util.List)34 GameProfile (com.mojang.authlib.GameProfile)32