Search in sources :

Example 11 with WorldServer

use of net.minecraft.world.WorldServer in project Totemic by TeamTotemic.

the class CeremonyEagleDance method effect.

@Override
public void effect(World world, BlockPos pos, CeremonyEffectContext context) {
    if (world.isRemote)
        return;
    EntityUtil.getEntitiesInRange(EntityParrot.class, world, pos, 8, 8).stream().limit(2).forEach(parrot -> {
        EntityBaldEagle eagle = new EntityBaldEagle(world);
        EntityUtil.spawnEntity(world, parrot.posX, parrot.posY, parrot.posZ, eagle);
        if (parrot.getLeashed())
            eagle.setLeashHolder(parrot.getLeashHolder(), true);
        parrot.setDead();
        ((WorldServer) world).spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, parrot.posX, parrot.posY + 1.0, parrot.posZ, 24, 0.6D, 0.5D, 0.6D, 1.0D);
    });
}
Also used : EntityParrot(net.minecraft.entity.passive.EntityParrot) EntityBaldEagle(pokefenn.totemic.entity.animal.EntityBaldEagle) WorldServer(net.minecraft.world.WorldServer)

Example 12 with WorldServer

use of net.minecraft.world.WorldServer in project Totemic by TeamTotemic.

the class MusicAcceptor method acceptMusic.

/**
 * Accepts music from the given instrument, possibly played by an entity.
 *
 * <p><b>The default implementation is only provided for backwards compatibility and will be removed in a future release!
 * Please override this method instead of {@link #addMusic}. Keep in mind that particles are not being spawned by default anymore,
 * so you will have to add them to your implementation of this method.</b>
 *
 * @implNote The default implementation calls {@link #addMusic} and spawns note or cloud particles at the tile entity's location
 * (we assume that the default implementation will only be used when MusicAcceptor is implemented directly by a TileEntity).
 *
 * @param instr the music instrument
 * @param amount the amount of music
 * @param x
 * @param y the instrument's location. This might be different from the entity's position (e.g. Drum).
 * @param z
 * @param entity the entity playing the instrument. Might be {@code null} if the instrument is not driven by an entity (e.g. Wind Chime).
 * @return {@code true} if this call had any effect on the acceptor.
 */
default boolean acceptMusic(MusicInstrument instr, int amount, double x, double y, double z, @Nullable Entity entity) {
    boolean result = addMusic(instr, amount);
    // Backwards compatibility only, we can assume we won't have a capability.
    TileEntity tile = (TileEntity) this;
    BlockPos pos = tile.getPos();
    ((WorldServer) tile.getWorld()).spawnParticle(result ? EnumParticleTypes.NOTE : EnumParticleTypes.CLOUD, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 6, 0.5, 0.5, 0.5, 0.0);
    return result;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer)

Example 13 with WorldServer

use of net.minecraft.world.WorldServer in project Totemic by TeamTotemic.

the class BlockWindChime method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    TileWindChime tileWindChime = (TileWindChime) world.getTileEntity(pos);
    if (!world.isRemote && player.isSneaking()) {
        tileWindChime.canPlay = false;
        TotemUtil.playSound(world, pos, ModSounds.windChime, SoundCategory.PLAYERS, 1.0f, 1.0f);
        Totemic.api.music().playSelector(world, pos, player, ModContent.windChime);
        ((WorldServer) world).spawnParticle(EnumParticleTypes.NOTE, pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5, 6, 0.0, 0.0, 0.0, 0.0);
        ((WorldServer) world).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5, 6, 0.0, 0.0, 0.0, 0.0);
    }
    return true;
}
Also used : TileWindChime(pokefenn.totemic.tileentity.music.TileWindChime) WorldServer(net.minecraft.world.WorldServer)

Example 14 with WorldServer

use of net.minecraft.world.WorldServer in project Totemic by TeamTotemic.

the class StateStartup method startCeremony.

public void startCeremony() {
    BlockPos pos = tile.getPos();
    ((WorldServer) tile.getWorld()).spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 24, 0.6D, 0.5D, 0.6D, 1.0D);
    tile.setState(new StateCeremonyEffect(tile, ceremony));
    tile.getState().update();
    for (EntityPlayerMP player : EntityUtil.getEntitiesInRange(EntityPlayerMP.class, tile.getWorld(), tile.getPos(), 8, 8)) ModCriteriaTriggers.PERFORM_CEREMONY.trigger(player, ceremony);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) WorldServer(net.minecraft.world.WorldServer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 15 with WorldServer

use of net.minecraft.world.WorldServer in project Totemic by TeamTotemic.

the class TotemUtil method addMusic.

/**
 * Adds music to the given music acceptor tile entity and spawns particles at its location
 */
@Deprecated
public static void addMusic(MusicAcceptor tile, @Nullable Entity entity, MusicInstrument instr, int musicAmount) {
    TileEntity te = (TileEntity) tile;
    WorldServer world = (WorldServer) te.getWorld();
    BlockPos pos = te.getPos();
    if (tile.addMusic(instr, musicAmount))
        world.spawnParticle(EnumParticleTypes.NOTE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 6, 0.5, 0.5, 0.5, 0.0);
    else
        world.spawnParticle(EnumParticleTypes.CLOUD, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 6, 0.5, 0.5, 0.5, 0.0);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

WorldServer (net.minecraft.world.WorldServer)322 BlockPos (net.minecraft.util.math.BlockPos)96 EntityPlayer (net.minecraft.entity.player.EntityPlayer)63 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)51 ItemStack (net.minecraft.item.ItemStack)48 IMixinWorldServer (org.spongepowered.common.interfaces.world.IMixinWorldServer)48 TileEntity (net.minecraft.tileentity.TileEntity)42 Entity (net.minecraft.entity.Entity)41 IBlockState (net.minecraft.block.state.IBlockState)39 MinecraftServer (net.minecraft.server.MinecraftServer)35 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)31 World (net.minecraft.world.World)29 Block (net.minecraft.block.Block)26 EntityLivingBase (net.minecraft.entity.EntityLivingBase)23 ArrayList (java.util.ArrayList)20 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)18 Nullable (javax.annotation.Nullable)17 PotionEffect (net.minecraft.potion.PotionEffect)16 Chunk (net.minecraft.world.chunk.Chunk)16 World (org.spongepowered.api.world.World)13