本文整理汇总了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;未经允许,请勿转载。 |
请发表评论