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);
});
}
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;
}
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;
}
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);
}
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);
}
Aggregations