当前位置: 首页>>代码示例>>Java>>正文


Java PlaySoundAtEntityEvent类代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.PlaySoundAtEntityEvent的典型用法代码示例。如果您正苦于以下问题:Java PlaySoundAtEntityEvent类的具体用法?Java PlaySoundAtEntityEvent怎么用?Java PlaySoundAtEntityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlaySoundAtEntityEvent类属于net.minecraftforge.event.entity包,在下文中一共展示了PlaySoundAtEntityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlaySoundAtEntity

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event)
{
    if(event.getEntity() instanceof EntityWolf && event.getSound() == SoundEvents.ENTITY_WOLF_AMBIENT && !event.getEntity().world.isRemote)
    {
        EntityWolf wolf = (EntityWolf)event.getEntity();
        NBTTagCompound wolfData = wolf.getEntityData();
        if(wolfData.getBoolean(BARKABLE_STRING) && wolf.getRNG().nextFloat() < 0.05F)
        {
            for(int i = 0; i < wolf.getRNG().nextInt(5) + 1; i++)
            {
                wolf.world.spawnEntity(new EntityBee(wolf.world, wolf));
            }
        }
    }
}
 
开发者ID:iChun,项目名称:BeeBarker,代码行数:17,代码来源:EventHandlerServer.java

示例2: playSoundAtEntity

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
/**
 * Plays a sound at the entity's position. Args: entity, sound, volume (relative to 1.0), and frequency (or pitch,
 * also relative to 1.0).
 */
public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1Entity, par2Str, par3, par4);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return;
    }
    par2Str = event.name;
    if (par1Entity != null && par2Str != null)
    {
        for (int i = 0; i < this.worldAccesses.size(); ++i)
        {
            ((IWorldAccess)this.worldAccesses.get(i)).playSound(par2Str, par1Entity.posX, par1Entity.posY - (double)par1Entity.yOffset, par1Entity.posZ, par3, par4);
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:21,代码来源:World.java

示例3: playSoundToNearExcept

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
/**
 * Plays sound to all near players except the player reference given
 */
public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, float par3, float par4)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1EntityPlayer, par2Str, par3, par4);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return;
    }
    par2Str = event.name;
    if (par1EntityPlayer != null && par2Str != null)
    {
        for (int i = 0; i < this.worldAccesses.size(); ++i)
        {
            ((IWorldAccess)this.worldAccesses.get(i)).playSoundToNearExcept(par1EntityPlayer, par2Str, par1EntityPlayer.posX, par1EntityPlayer.posY - (double)par1EntityPlayer.yOffset, par1EntityPlayer.posZ, par3, par4);
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:20,代码来源:World.java

示例4: onPlaySoundAtEntity

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (player.getActiveItemStack().getItem() == TrumpetSkeletonItems.TRUMPET) {
            if (event.getSound() == SoundEvents.ENTITY_GENERIC_EAT) {
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:JamiesWhiteShirt,项目名称:trumpet-skeleton,代码行数:13,代码来源:TrumpetSkeleton.java

示例5: onPlaySound

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlaySound(PlaySoundAtEntityEvent event) {
    if(event.getSound().equals(SoundEvents.ENTITY_BAT_AMBIENT) ||
            event.getSound().equals(SoundEvents.ENTITY_BAT_DEATH) ||
            event.getSound().equals(SoundEvents.ENTITY_BAT_HURT) ||
            event.getSound().equals(SoundEvents.ENTITY_BAT_LOOP) ||
            event.getSound().equals(SoundEvents.ENTITY_BAT_TAKEOFF))
        event.setCanceled(true);
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:10,代码来源:AntiBatsMod.java

示例6: on

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent e) {
    EntityPlayer player = e.entityPlayer;
    if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH
            && player.isSneaking()) {
        e.setCanceled(true);

        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target)
                && e.target.isDead) {
            CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f));
        }
    }
}
 
开发者ID:makeoo,项目名称:Gadomancy,代码行数:15,代码来源:IntegrationThaumicHorizions.java

示例7: playWorldSound

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@ForgeSubscribe
public void playWorldSound(PlaySoundAtEntityEvent event)
{
	if(event != null && event.name != null)
	{
		if(event.name.equalsIgnoreCase("random.bow"))
		{
			event.name = "minefantasy:oldbow";
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:12,代码来源:EventManagerMF.java

示例8: playSoundAtEntity

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
public void playSoundAtEntity(Entity p_72956_1_, String p_72956_2_, float p_72956_3_, float p_72956_4_)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(p_72956_1_, p_72956_2_, p_72956_3_, p_72956_4_);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return;
    }
    p_72956_2_ = event.name;
    for (int i = 0; i < this.worldAccesses.size(); ++i)
    {
        ((IWorldAccess)this.worldAccesses.get(i)).playSound(p_72956_2_, p_72956_1_.posX, p_72956_1_.posY - (double)p_72956_1_.yOffset, p_72956_1_.posZ, p_72956_3_, p_72956_4_);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:14,代码来源:World.java

示例9: playSoundToNearExcept

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
public void playSoundToNearExcept(EntityPlayer p_85173_1_, String p_85173_2_, float p_85173_3_, float p_85173_4_)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(p_85173_1_, p_85173_2_, p_85173_3_, p_85173_4_);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return;
    }
    p_85173_2_ = event.name;
    for (int i = 0; i < this.worldAccesses.size(); ++i)
    {
        ((IWorldAccess)this.worldAccesses.get(i)).playSoundToNearExcept(p_85173_1_, p_85173_2_, p_85173_1_.posX, p_85173_1_.posY - (double)p_85173_1_.yOffset, p_85173_1_.posZ, p_85173_3_, p_85173_4_);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:14,代码来源:World.java

示例10: playSound

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
public void playSound(String p_85030_1_, float p_85030_2_, float p_85030_3_)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(this, p_85030_1_, p_85030_2_, p_85030_3_);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return;
    }
    p_85030_1_ = event.name;
    this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, p_85030_1_, p_85030_2_, p_85030_3_, false);
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:11,代码来源:EntityPlayerSP.java

示例11: playSound

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
public void playSound(String par1Str, float par2, float par3)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(this, par1Str, par2, par3);
    if (MinecraftForge.EVENT_BUS.post(event))
    {
        return;
    }
    par1Str = event.name;
    this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, par1Str, par2, par3, false);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:11,代码来源:EntityPlayerSP.java

示例12: onPlaySoundAtEntityEvent

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
/**
 * Override sounds when walking on block.
 *
 * @param event
 */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySoundAtEntityEvent(PlaySoundAtEntityEvent event)
{
    if (event != null && event.name != null && event.name.contains(CarpentersBlocks.MODID))
    {
        Entity entity = event.entity;

        /*
         * The function to my knowledge is only used for playing walking sounds
         * at entity, so we'll check for the conditions first.
         */
        if (!isMovingOnGround(entity))
        {
            return;
        }

        TEBase TE = getTileEntityAtFeet(entity);
        if (TE != null) {

            // Give SoundType a valid resource by default
            event.name = Blocks.planks.stepSound.getStepResourcePath();

            // Gather accurate SoundType based on block properties
            Block block = BlockProperties.toBlock(BlockProperties.getFeatureSensitiveSideItemStack(TE, ForgeDirection.UP));
            if (!(block instanceof BlockCoverable))
            {
                event.name = block.stepSound.getStepResourcePath();
            }

        }
    }
}
 
开发者ID:Mineshopper,项目名称:carpentersblocks,代码行数:39,代码来源:EventHandler.java

示例13: onPlaySoundAtEntity

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@ForgeSubscribe
public void onPlaySoundAtEntity(PlaySoundAtEntityEvent event)
{
    if (event.name != null
    && event.name.equals("random.fuse")
    && event.entity != null
    && event.entity instanceof EntityCreeper)
    {
        if (event.entity.isEntityAlive())
        {
            EntityLightAdapter adapter = new EntityLightAdapter((EntityCreeper) event.entity);
            adapter.onTick();
        }
    }
}
 
开发者ID:liosha2007,项目名称:minecraft-dynamic-lights,代码行数:16,代码来源:ChargingCreeperLightSource.java

示例14: onPlaySoundAtEntity

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch)
{
    PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, category, volume, pitch);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:7,代码来源:ForgeEventFactory.java

示例15: on

import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void on(PlaySoundAtEntityEvent event) {
    if(!event.entity.worldObj.isRemote && event.entity instanceof EntityGolemBase
            && event.name.equals("thaumcraft:zap") && event.volume == 0.5F && event.pitch == 1.0F) {
        EntityGolemBase golem = (EntityGolemBase) event.entity;
        if(markedGolems.containsKey(golem)) {
            EntityPlayer player = markedGolems.get(golem);
            markedGolems.remove(golem);

            AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(golem);

            boolean movedPlacer = false;
            boolean movedCore = core == null || !player.isSneaking();

            for(EntityItem entityItem : golem.capturedDrops) {
                ItemStack item = entityItem.getEntityItem();

                if(!movedCore && item.getItem() == ConfigItems.itemGolemCore) {
                    entityItem.setEntityItemStack(core.getItem());
                }

                if(!movedPlacer && item.getItem() instanceof ItemGolemPlacer
                        || item.getItem() instanceof ItemAdditionalGolemPlacer) {
                    //move persistent data to item
                    NBTTagCompound persistent = (NBTTagCompound) NBTHelper.getPersistentData(golem).copy();
                    if(player.isSneaking()) {
                        persistent.removeTag("Core");
                    }
                    NBTHelper.getData(item).setTag(Gadomancy.MODID, persistent);
                    event.entity.setDead();
                    entityItem.setEntityItemStack(item);

                    MinecraftForge.EVENT_BUS.post(new GolemDropPlacerEvent(player, entityItem, golem));

                    movedPlacer = true;
                }
                event.entity.worldObj.spawnEntityInWorld(entityItem);
            }
            golem.capturedDrops.clear();
            golem.captureDrops = false;
        }
    }
}
 
开发者ID:makeoo,项目名称:Gadomancy,代码行数:44,代码来源:EventHandlerGolem.java


注:本文中的net.minecraftforge.event.entity.PlaySoundAtEntityEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。