/** * Called when a Block is right-clicked with this Item */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == Blocks.jukebox && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) { if (worldIn.isRemote) { return true; } else { ((BlockJukebox)Blocks.jukebox).insertRecord(worldIn, pos, iblockstate, stack); worldIn.playAuxSFXAtEntity((EntityPlayer)null, 1005, pos, Item.getIdFromItem(this)); --stack.stackSize; playerIn.triggerAchievement(StatList.field_181740_X); return true; } } else { return false; } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY) { IBlockState iblockstate = playerIn.getBlockState(worldIn); if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) { if (!playerIn.isRemote) { ItemStack itemstack = stack.getHeldItem(pos); ((BlockJukebox)Blocks.JUKEBOX).insertRecord(playerIn, worldIn, iblockstate, itemstack); playerIn.playEvent((EntityPlayer)null, 1010, worldIn, Item.getIdFromItem(this)); itemstack.func_190918_g(1); stack.addStat(StatList.RECORD_PLAYED); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) { if (!worldIn.isRemote) { ((BlockJukebox)Blocks.JUKEBOX).insertRecord(worldIn, pos, iblockstate, stack); worldIn.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this)); --stack.stackSize; playerIn.addStat(StatList.RECORD_PLAYED); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } }
@Override public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { //TODO: world.getBlock() if (world.getBlock(x, y, z) == Blocks.jukebox && world.getBlockMetadata(x, y, z) == 0) { if (world.isRemote) return true; else { //TODO: .insertRecord() ((BlockJukebox)Blocks.jukebox).func_149926_b(world, x, y, z, itemStack); //TODO: Item.getIdFromItem() world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, Item.getIdFromItem(this)); --itemStack.stackSize; return true; } } else return false; }
/** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par3World.getBlock(par4, par5, par6) == Blocks.jukebox && par3World.getBlockMetadata(par4, par5, par6) == 0) { if (par3World.isClient) { return true; } else { ((BlockJukebox)Blocks.jukebox).func_149926_b(par3World, par4, par5, par6, par1ItemStack); par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, Item.getIdFromItem(this)); --par1ItemStack.stackSize; return true; } } else { return false; } }
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if (p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_) == Blocks.jukebox && p_77648_3_.getBlockMetadata(p_77648_4_, p_77648_5_, p_77648_6_) == 0) { if (p_77648_3_.isRemote) { return true; } else { ((BlockJukebox)Blocks.jukebox).func_149926_b(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_1_); p_77648_3_.playAuxSFXAtEntity((EntityPlayer)null, 1005, p_77648_4_, p_77648_5_, p_77648_6_, Item.getIdFromItem(this)); --p_77648_1_.stackSize; return true; } } else { return false; } }
@SubscribeEvent public void onDrawBlockHighlight(DrawBlockHighlightEvent event) { int x = event.target.blockX; int y = event.target.blockY; int z = event.target.blockZ; World world = event.player.worldObj; if (world != null) { Block block = world.getBlock(x, y, z); if (block == Blocks.jukebox) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof BlockJukebox.TileEntityJukebox) { //BlockJukebox.TileEntityJukebox jb = (BlockJukebox.TileEntityJukebox) te; Physis.logger.info("test"); } } } }
@Override public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { if (world.getBlock(x, y, z) == Blocks.jukebox && world.getBlockMetadata(x, y, z) == 0) { if (world.isRemote) return true; else { ((BlockJukebox)Blocks.jukebox).func_149926_b(world, x, y, z, itemStack); world.playAuxSFXAtEntity((EntityPlayer)null, 1005, x, y, z, Item.getIdFromItem(this)); --itemStack.stackSize; return true; } } else return false; }
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { if (world.getBlock(x, y, z) == Blocks.jukebox && world.getBlockMetadata(x, y, z) == 0) { if (world.isRemote) { return true; } else { //TODO: .insertRecord() ((BlockJukebox) Blocks.jukebox).func_149926_b(world, x, y, z, stack); world.playAuxSFXAtEntity(null, 1005, x, y, z, Item.getIdFromItem(this)); --stack.stackSize; return true; } } else { return false; } }
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) { if (!worldIn.isRemote) { ItemStack itemstack = player.getHeldItem(hand); ((BlockJukebox)Blocks.JUKEBOX).insertRecord(worldIn, pos, iblockstate, itemstack); worldIn.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this)); itemstack.shrink(1); player.addStat(StatList.RECORD_PLAYED); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } }
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0 && !mod_Rediscovered.Calm4MusicDisk) { if (par3World.isRemote) { return true; } else { ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack); // par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID); // par3World.playSoundAtEntity(par2EntityPlayer, mod_Rediscovered.modid + ":calm", 2.0F, 1.0F); --par1ItemStack.stackSize; return true; } } else { return false; } }
/** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par3World.getBlockId(par4, par5, par6) == Block.jukebox.blockID && par3World.getBlockMetadata(par4, par5, par6) == 0) { if (par3World.isRemote) { return true; } else { ((BlockJukeBox)Block.jukebox).insertRecord(par3World, par4, par5, par6, par1ItemStack); par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, this.itemID); --par1ItemStack.stackSize; return true; } } else { return false; } }
@Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = world.getBlockState(pos); if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue()) { if (!world.isRemote) { ((BlockJukebox)Blocks.JUKEBOX).insertRecord(world, pos, iblockstate, player.getActiveItemStack()); world.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this)); player.getActiveItemStack().setCount(player.getActiveItemStack().getCount()-1); player.addStat(StatList.RECORD_PLAYED); } return EnumActionResult.SUCCESS; } else return EnumActionResult.PASS; }
public boolean func_77648_a(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { if(p_77648_3_.func_72798_a(p_77648_4_, p_77648_5_, p_77648_6_) == Block.field_72032_aY.field_71990_ca && p_77648_3_.func_72805_g(p_77648_4_, p_77648_5_, p_77648_6_) == 0) { if(p_77648_3_.field_72995_K) { return true; } else { ((BlockJukeBox)Block.field_72032_aY).func_85106_a(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_1_); p_77648_3_.func_72889_a((EntityPlayer)null, 1005, p_77648_4_, p_77648_5_, p_77648_6_, this.field_77779_bT); --p_77648_1_.field_77994_a; return true; } } else { return false; } }
@Override public boolean canHack(IBlockAccess world, BlockPos pos, EntityPlayer player) { return world.getBlockState(pos).getValue(BlockJukebox.HAS_RECORD); }
public boolean eject() { boolean result = isPlaying(); ((BlockJukebox) Blocks.jukebox).func_149925_e(world.getHandle(), getX(), getY(), getZ()); return result; }
public static DataFixer createFixer() { DataFixer datafixer = new DataFixer(512); WorldInfo.registerFixes(datafixer); EntityPlayer.registerFixesPlayer(datafixer); AnvilChunkLoader.registerFixes(datafixer); ItemStack.registerFixes(datafixer); EntityArmorStand.registerFixesArmorStand(datafixer); EntityArrow.registerFixesArrow(datafixer); EntityBat.registerFixesBat(datafixer); EntityBlaze.registerFixesBlaze(datafixer); EntityCaveSpider.registerFixesCaveSpider(datafixer); EntityChicken.registerFixesChicken(datafixer); EntityCow.registerFixesCow(datafixer); EntityCreeper.registerFixesCreeper(datafixer); EntityDragonFireball.registerFixesDragonFireball(datafixer); EntityDragon.registerFixesDragon(datafixer); EntityEnderman.registerFixesEnderman(datafixer); EntityEndermite.registerFixesEndermite(datafixer); EntityFallingBlock.registerFixesFallingBlock(datafixer); EntityLargeFireball.registerFixesLargeFireball(datafixer); EntityFireworkRocket.registerFixesFireworkRocket(datafixer); EntityGhast.registerFixesGhast(datafixer); EntityGiantZombie.registerFixesGiantZombie(datafixer); EntityGuardian.registerFixesGuardian(datafixer); EntityHorse.registerFixesHorse(datafixer); EntityItem.registerFixesItem(datafixer); EntityItemFrame.registerFixesItemFrame(datafixer); EntityMagmaCube.registerFixesMagmaCube(datafixer); EntityMinecartChest.registerFixesMinecartChest(datafixer); EntityMinecartCommandBlock.registerFixesMinecartCommand(datafixer); EntityMinecartFurnace.registerFixesMinecartFurnace(datafixer); EntityMinecartHopper.registerFixesMinecartHopper(datafixer); EntityMinecartEmpty.registerFixesMinecartEmpty(datafixer); EntityMinecartMobSpawner.registerFixesMinecartMobSpawner(datafixer); EntityMinecartTNT.registerFixesMinecartTNT(datafixer); EntityLiving.registerFixesMob(datafixer); EntityMob.registerFixesMonster(datafixer); EntityMooshroom.registerFixesMooshroom(datafixer); EntityOcelot.registerFixesOcelot(datafixer); EntityPig.registerFixesPig(datafixer); EntityPigZombie.registerFixesPigZombie(datafixer); EntityRabbit.registerFixesRabbit(datafixer); EntitySheep.registerFixesSheep(datafixer); EntityShulker.registerFixesShulker(datafixer); EntitySilverfish.registerFixesSilverfish(datafixer); EntitySkeleton.registerFixesSkeleton(datafixer); EntitySlime.registerFixesSlime(datafixer); EntitySmallFireball.registerFixesSmallFireball(datafixer); EntitySnowman.registerFixesSnowman(datafixer); EntitySnowball.registerFixesSnowball(datafixer); EntitySpectralArrow.registerFixesSpectralArrow(datafixer); EntitySpider.registerFixesSpider(datafixer); EntitySquid.registerFixesSquid(datafixer); EntityEgg.registerFixesEgg(datafixer); EntityEnderPearl.registerFixesEnderPearl(datafixer); EntityExpBottle.registerFixesExpBottle(datafixer); EntityPotion.registerFixesPotion(datafixer); EntityTippedArrow.registerFixesTippedArrow(datafixer); EntityVillager.registerFixesVillager(datafixer); EntityIronGolem.registerFixesIronGolem(datafixer); EntityWitch.registerFixesWitch(datafixer); EntityWither.registerFixesWither(datafixer); EntityWitherSkull.registerFixesWitherSkull(datafixer); EntityWolf.registerFixesWolf(datafixer); EntityZombie.registerFixesZombie(datafixer); TileEntityPiston.registerFixesPiston(datafixer); TileEntityFlowerPot.registerFixesFlowerPot(datafixer); TileEntityFurnace.registerFixesFurnace(datafixer); TileEntityChest.registerFixesChest(datafixer); TileEntityDispenser.registerFixes(datafixer); TileEntityDropper.registerFixesDropper(datafixer); TileEntityBrewingStand.registerFixesBrewingStand(datafixer); TileEntityHopper.registerFixesHopper(datafixer); BlockJukebox.registerFixesJukebox(datafixer); TileEntityMobSpawner.registerFixesMobSpawner(datafixer); registerFixes(datafixer); return datafixer; }
@Override public ResponseMessage onMessage(TileRequest message, MessageContext ctx) { World world = DimensionManager.getWorld(message.dim); if (world == null) return null; TileEntity te = world.getTileEntity(message.pos); if (te == null) return null; if (Helper.banned.contains(te.getClass().getCanonicalName())) return null; if (te instanceof ILockableContainer && !ctx.getServerHandler().player.canOpen(((ILockableContainer) te).getLockCode())) return null; if (te instanceof TileEntityEnderChest) { return new PlainInventory(message.pos, ctx.getServerHandler().player.getInventoryEnderChest()); } else if (te instanceof BlockJukebox.TileEntityJukebox) { InventoryBasic ib = new InventoryBasic("minecraft:jukebox", false, 1); ib.setInventorySlotContents(0, ((BlockJukebox.TileEntityJukebox) te).getRecord()); return new PlainInventory(message.pos, ib).setName(Blocks.JUKEBOX.getUnlocalizedName()); } else if (te instanceof TileEntityChest) { Block b = world.getBlockState(message.pos).getBlock(); if (b instanceof BlockChest) { IInventory i = ((BlockChest) b).getLockableContainer(world, message.pos); if (i != null) return new PlainInventory(message.pos, i); return null; } return new PlainInventory(message.pos, ((TileEntityChest) te)); } else if (te instanceof IInventory) { return new PlainInventory(message.pos, (IInventory) te); } else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { IItemHandler iih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); if (iih == null) { HoloInventory.getLogger().warn("Error: Block at {} (Class: {} Te: {} Block: {}) returned null after indicating the capability is available.", message.pos, te.getClass().getName(), te, te.getBlockType()); return null; } return new PlainInventory(message.pos, te.getBlockType().getUnlocalizedName(), iih); } return null; }
public static boolean accept(TileEntity te) { return te != null && (te instanceof IInventory || te instanceof BlockJukebox.TileEntityJukebox || te instanceof TileEntityEnderChest || te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)); }