/** * Called when a neighboring block changes. */ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { boolean flag = worldIn.isBlockPowered(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; if (tileentitynote.previousRedstoneState != flag) { if (flag) { tileentitynote.triggerNote(worldIn, pos); } tileentitynote.previousRedstoneState = flag; } } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; tileentitynote.changePitch(); tileentitynote.triggerNote(worldIn, pos); playerIn.triggerAchievement(StatList.field_181735_S); } return true; } }
/** * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid * block, etc. */ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_) { boolean flag = worldIn.isBlockPowered(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; if (tileentitynote.previousRedstoneState != flag) { if (flag) { tileentitynote.triggerNote(worldIn, pos); } tileentitynote.previousRedstoneState = flag; } } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; tileentitynote.changePitch(); tileentitynote.triggerNote(worldIn, pos); playerIn.addStat(StatList.NOTEBLOCK_TUNED); } return true; } }
/** * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid * block, etc. */ public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { boolean flag = worldIn.isBlockPowered(pos); TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; if (tileentitynote.previousRedstoneState != flag) { if (flag) { tileentitynote.triggerNote(worldIn, pos); } tileentitynote.previousRedstoneState = flag; } } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; int old = tileentitynote.note; tileentitynote.changePitch(); if (old == tileentitynote.note) return false; tileentitynote.triggerNote(worldIn, pos); playerIn.addStat(StatList.NOTEBLOCK_TUNED); } return true; } }
@Override public IMessage onMessage(BlockMessage message, MessageContext ctx) { /*int d = message.dimension == 0 ? 0 : (message.dimension == -1 ? 1 : 2); switch(message.id){ case 0: MinecraftServer.getServer().worldServers[d].setBlock(message.x, message.y - 1, message.z, Blocks.planks);break; case 1: MinecraftServer.getServer().worldServers[d].setBlock(message.x, message.y - 1, message.z, Blocks.dirt);break; case 2: MinecraftServer.getServer().worldServers[d].setBlock(message.x, message.y - 1, message.z, Blocks.stone);break; }*/ int d = message.dimension == 0 ? 0 : (message.dimension == -1 ? 1 : 2); switch(message.id){ case 0: ctx.getServerHandler().playerEntity.worldObj.setBlock(message.x, message.y - 1, message.z, Blocks.planks);break; case 1: ctx.getServerHandler().playerEntity.worldObj.setBlock(message.x, message.y - 1, message.z, Blocks.dirt);break; case 2: ctx.getServerHandler().playerEntity.worldObj.setBlock(message.x, message.y - 1, message.z, Blocks.stone);break; } TileEntityNote entity = (TileEntityNote) ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z); entity.note = (byte) message.note; entity.triggerNote(ctx.getServerHandler().playerEntity.worldObj, message.x, message.y, message.z); return null; }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (p_149727_1_.isClient) { return true; } else { TileEntityNote var10 = (TileEntityNote)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); if (var10 != null) { var10.func_145877_a(); var10.func_145878_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); } return true; } }
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (p_149727_1_.isRemote) { return true; } else { TileEntityNote tileentitynote = (TileEntityNote)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); if (tileentitynote != null) { int old = tileentitynote.note; tileentitynote.changePitch(); if (old == tileentitynote.note) return false; tileentitynote.triggerNote(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); } return true; } }
/** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are * their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { boolean flag = par1World.isBlockIndirectlyGettingPowered(par2, par3, par4); TileEntityNote tileentitynote = (TileEntityNote)par1World.getBlockTileEntity(par2, par3, par4); if (tileentitynote != null && tileentitynote.previousRedstoneState != flag) { if (flag) { tileentitynote.triggerNote(par1World, par2, par3, par4); } tileentitynote.previousRedstoneState = flag; } }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } else { TileEntityNote tileentitynote = (TileEntityNote)par1World.getBlockTileEntity(par2, par3, par4); if (tileentitynote != null) { tileentitynote.changePitch(); tileentitynote.triggerNote(par1World, par2, par3, par4); } return true; } }
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { ((TileEntityNote)tileentity).triggerNote(worldIn, pos); playerIn.triggerAchievement(StatList.field_181734_R); } } }
public void onBlockClicked(World worldIn, BlockPos pos, EntityPlayer playerIn) { if (!worldIn.isRemote) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityNote) { ((TileEntityNote)tileentity).triggerNote(worldIn, pos); playerIn.addStat(StatList.NOTEBLOCK_PLAYED); } } }
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; }
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; }
@SubscribeEvent public void blockPlaced(BlockEvent.PlaceEvent event){ if(event.block instanceof BlockNote){ TileEntityNote entity = (TileEntityNote) Minecraft.getMinecraft().theWorld.getTileEntity(event.x, event.y, event.z); Minecraft.getMinecraft().displayGuiScreen(new GuiSet(entity, Minecraft.getMinecraft().currentScreen)); } }
@SubscribeEvent(priority = EventPriority.HIGH) public void rightClick(PlayerInteractEvent event){ if(event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() instanceof ItemNoteblockFork){ if(Minecraft.getMinecraft().theWorld.getBlock(event.x, event.y, event.z) instanceof BlockNote){ if(!event.entityPlayer.isSneaking()){ event.setCanceled(true); TileEntityNote entity = (TileEntityNote) Minecraft.getMinecraft().theWorld.getTileEntity(event.x, event.y, event.z); Minecraft.getMinecraft().displayGuiScreen(new GuiSet(entity, Minecraft.getMinecraft().currentScreen)); } } } }
@Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { Coord c = new Coord(world, pos); TileEntityNote noteBlock = c.getTE(TileEntityNote.class); if (noteBlock != null) { if (world.isRemote) return false; byte orig_note = noteBlock.note; int delta = player.isSneaking() ? -1 : 1; byte new_note = (byte) (orig_note + delta); if (new_note < 0) { new_note = 24; } else if (new_note > 24) { new_note = 0; } noteBlock.note = new_note; if (ForgeHooks.onNoteChange(noteBlock, orig_note)) { noteBlock.markDirty(); } if (noteBlock.note != orig_note) { noteBlock.triggerNote(world, pos); } new Notice(noteBlock, "noteblock.pitch." + noteBlock.note).withStyle(Style.EXACTPOSITION).sendTo(player); return true; } /*if (!player.isSneaking()) { if (Core.dev_environ && !world.isRemote) { } return false; }*/ return false; }
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; }
public static void pasteNote(World world, EntityPlayer entityPlayer, TileEntityNote noteblock, ItemStack held) { if (held.getTagCompound() == null) { return; } // nothing ot paste if (held.getTagCompound().getByte(KEY_NOTE) == NOTE_EMPTY) { return; } noteblock.note = held.getTagCompound().getByte(KEY_NOTE); }
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) { boolean var6 = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_); TileEntityNote var7 = (TileEntityNote)p_149695_1_.getTileEntity(p_149695_2_, p_149695_3_, p_149695_4_); if (var7 != null && var7.field_145880_i != var6) { if (var6) { var7.func_145878_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); } var7.field_145880_i = var6; } }
/** * Called when a player hits the block. Args: world, x, y, z, player */ public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) { if (!p_149699_1_.isClient) { TileEntityNote var6 = (TileEntityNote)p_149699_1_.getTileEntity(p_149699_2_, p_149699_3_, p_149699_4_); if (var6 != null) { var6.func_145878_a(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_); } } }
@ScriptCallable(description = "Set the note on the noteblock", returnTypes = { ReturnType.BOOLEAN }) public boolean setPitch(TileEntityNote noteblock, @Arg(name = "note", description = "The note you want. From 0 to 25") int newNote) { final byte oldNote = noteblock.note; noteblock.note = (byte)(newNote % 25); if (!net.minecraftforge.common.ForgeHooks.onNoteChange(noteblock, oldNote)) return false; noteblock.markDirty(); return true; }
@Asynchronous @ScriptCallable(description = "Plays a minecraft sound") public void playSound(TileEntityNote noteblock, @Arg(name = "sound", description = "The identifier for the sound") String name, @Arg(name = "pitch", description = "The pitch from 0 to 1") float pitch, @Arg(name = "volume", description = "The volume from 0 to 1") float volume, @Optionals @Arg(name = "x", description = "X coordinate od sound (relative to block)") Double dx, @Arg(name = "y", description = "Y coordinate of sound (relative to block)") Double dy, @Arg(name = "z", description = "Z coordinate of sound (relative to block)") Double dz) { noteblock.getWorldObj().playSoundEffect( noteblock.xCoord + 0.5 + Objects.firstNonNull(dx, 0.0), noteblock.yCoord + 0.5 + Objects.firstNonNull(dy, 0.0), noteblock.zCoord + 0.5 + Objects.firstNonNull(dz, 0.0), name, volume, pitch); }