• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NoteBlockEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: playNote

import net.minecraftforge.event.world.NoteBlockEvent; //导入依赖的package包/类
@SubscribeEvent
public static void playNote(NoteBlockEvent.Play event) {
	// Check the block underneath the Note Block
	Block belowBlock = event.getWorld().getBlockState(event.getPos().down()).getBlock();

	// If it's butter, cancel the regular event
	if (belowBlock == ModBlocks.butter)
	{
		int note = event.getVanillaNoteId();
		float pitch = (float)Math.pow(2.0D, (double)(note - 12) / 12.0D);

		BlockPos pos = event.getPos();
		event.getWorld().playSound(null, pos, ModSounds.airhorn, SoundCategory.RECORDS, 3.0F, pitch);
		((WorldServer)event.getWorld()).spawnParticle(EnumParticleTypes.NOTE, false, (double)pos.getX() + 0.5D, (double)pos.getY() + 1.2D, (double)pos.getZ() + 0.5D, 1, 0.0, 0.0, 0.0, (double)note / 24.0D);

		if (event.isCancelable())
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:DarkMorford,项目名称:BetterThanWeagles,代码行数:22,代码来源:EventHandlerNoteBlock.java


示例2: noteBlockPlayEvent

import net.minecraftforge.event.world.NoteBlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void noteBlockPlayEvent(NoteBlockEvent.Play event) {
	
	if (event.getWorld().isRemote)
		return;
	
	BlockPos epos = event.getPos();
	int range = 10;
	for (BlockPos pos : BlockPos.getAllInBoxMutable(epos.add(-range, -2, -range), epos.add(range, 2, range))) {
		TileEntity te = event.getWorld().getTileEntity(pos);
		if (te != null && te instanceof TileMusicaPlant) {
			TileMusicaPlant plant = (TileMusicaPlant)te;
			if (plant.getBeats().size() > 0)
			{
				for (int i = 0; i < plant.getBeats().size(); i++) {
					Beat beat = plant.getBeats().get(i);
					if (beat.beatMatches(new Beat(event.getNote(), event.getInstrument(), event.getOctave(), event.getWorld().getTotalWorldTime()))) {
						plant.setNewBeatTime(i, event.getWorld().getTotalWorldTime());
						return;
					}
				}
			}
			if (plant.canAddNote())
				plant.setNote(event.getNote(), event.getInstrument(), event.getOctave(), event.getWorld().getTotalWorldTime());
		}
	}
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:28,代码来源:UCEventHandlerServer.java


示例3: onNoteChange

import net.minecraftforge.event.world.NoteBlockEvent; //导入依赖的package包/类
public static boolean onNoteChange(TileEntityNote te, byte old)
{
    NoteBlockEvent.Change e = new NoteBlockEvent.Change(te.getWorld(), te.getPos(), te.getWorld().getBlockState(te.getPos()), old, te.note);
    if (MinecraftForge.EVENT_BUS.post(e))
    {
        te.note = old;
        return false;
    }
    te.note = (byte)e.getVanillaNoteId();
    return true;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:ForgeHooks.java


示例4: onNoteChange

import net.minecraftforge.event.world.NoteBlockEvent; //导入依赖的package包/类
public static boolean onNoteChange(TileEntityNote te, byte old)
{
    NoteBlockEvent.Change e = new NoteBlockEvent.Change(te.func_145831_w(), te.field_145851_c, te.field_145848_d, te.field_145849_e, te.func_145832_p(), old, te.field_145879_a);
    if (MinecraftForge.EVENT_BUS.post(e))
    {
        te.field_145879_a = old;
        return false;
    }
    te.field_145879_a = (byte)e.getVanillaNoteId();
    return true;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:12,代码来源:ForgeHooks.java


示例5: onNoteChange

import net.minecraftforge.event.world.NoteBlockEvent; //导入依赖的package包/类
public static boolean onNoteChange(TileEntityNote te, byte old)
{
    NoteBlockEvent.Change e = new NoteBlockEvent.Change(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, te.getBlockMetadata(), old, te.note);
    if (MinecraftForge.EVENT_BUS.post(e))
    {
        te.note = old;
        return false;
    }
    te.note = (byte)e.getVanillaNoteId();
    return true;
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:12,代码来源:ForgeHooks.java


示例6: triggerNoteBlock

import net.minecraftforge.event.world.NoteBlockEvent; //导入依赖的package包/类
public static void triggerNoteBlock(World world, BlockPos currentLocation, IChiseledSheepCapability capability) {
    final IBlockState blockState = world.getBlockState(currentLocation);
    final IBlockState blockStateBeneath = world.getBlockState(currentLocation.down());
    Material material = blockStateBeneath.getMaterial();
    int id = 0;

    if (material == Material.ROCK) {
        id = 1;
    }
    if (material == Material.SAND) {
        id = 2;
    }
    if (material == Material.GLASS) {
        id = 3;
    }
    if (material == Material.WOOD) {
        id = 4;
    }

    final NBTTagCompound extraData = capability.getExtraData();

    int param = getTuning(extraData);

    NoteBlockEvent.Play e = new NoteBlockEvent.Play(world, currentLocation, blockState, param, id);
    if (!MinecraftForge.EVENT_BUS.post(e)) {
        id = e.getInstrument().ordinal();
        if (blockStateBeneath.getBlock() == Blocks.WOOL) {
            id = -1;
        }
        param = e.getVanillaNoteId();
        float f = (float) Math.pow(2.0D, (param - 12) / 12.0D);
        world.playSound(null, currentLocation, getInstrument(id), SoundCategory.RECORDS, 3.0F, f);

        if (world instanceof WorldServer) {
            WorldServer worldserver = (WorldServer) world;
            worldserver.spawnParticle(
                    EnumParticleTypes.NOTE,
                    true,
                    currentLocation.getX() + 0.5D,
                    currentLocation.getY() + 1.2D,
                    currentLocation.getZ() + 0.5D,
                    0, //number of particles
                    param / 24.0D,
                    0.0D,
                    0.0D,
                    1
            );
        }
    }
}
 
开发者ID:AtomicBlom,项目名称:ShearMadness,代码行数:51,代码来源:NoteBlockBehaviour.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RepresentationDescription类代码示例发布时间:2022-05-23
下一篇:
Java PersistenceProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap