supertile.getWorld().playEvent(2001, coords, Block.getStateId(stateToPlace)); validPositions.remove(coords); ItemBlock.setTileEntityNBT(supertile.getWorld(), null, coords, stack);
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { if(!world.setBlockState(pos, newState, 11)) return false; IBlockState state = world.getBlockState(pos); if(state.getBlock() == FurnitureBlocks.CUP) { ItemBlock.setTileEntityNBT(world, player, pos, stack); FurnitureBlocks.CUP.onBlockPlacedBy(world, pos, state, player, stack); } return true; } }
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) { if (!world.setBlockState(pos, newState, 3)) { return false; } IBlockState state = world.getBlockState(pos); if (state.getBlock() == ModuleFlowers.flower) { ItemBlock.setTileEntityNBT(world, player, pos, stack); ModuleFlowers.flower.onBlockPlacedBy(world, pos, state, player, stack); } return true; }
ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack); iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
@Nonnull public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloadedMod.MODID, NameBuilder.buildRegistryName(fruitType.toString(), "cake"))); if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1) facing = EnumFacing.UP; else if (!block.isReplaceable(worldIn, pos)) pos = pos.offset(facing); ItemStack itemstack = player.getHeldItem(hand); if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) { IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand); if (!worldIn.setBlockState(pos, blockState, 11)) return EnumActionResult.FAIL; else { blockState = worldIn.getBlockState(pos); if (blockState.getBlock() == cake) { ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack); blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack); } SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); itemstack.shrink(1); return EnumActionResult.SUCCESS; } } else return EnumActionResult.FAIL; }
@Nonnull public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); Block cake = Block.REGISTRY.getObject(new ResourceLocation(FoodCraftReloadedMod.MODID, NameBuilder.buildRegistryName(vegetableType.toString(), "cake"))); if (block == Blocks.SNOW_LAYER && iblockstate.getValue(BlockSnow.LAYERS) < 1) facing = EnumFacing.UP; else if (!block.isReplaceable(worldIn, pos)) pos = pos.offset(facing); ItemStack itemstack = player.getHeldItem(hand); if (!itemstack.isEmpty() && player.canPlayerEdit(pos, facing, itemstack) && worldIn.mayPlace(cake, pos, false, facing, null)) { IBlockState blockState = cake.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, player, hand); if (!worldIn.setBlockState(pos, blockState, 11)) return EnumActionResult.FAIL; else { blockState = worldIn.getBlockState(pos); if (blockState.getBlock() == cake) { ItemBlock.setTileEntityNBT(worldIn, player, pos, itemstack); blockState.getBlock().onBlockPlacedBy(worldIn, pos, blockState, player, itemstack); } SoundType soundtype = blockState.getBlock().getSoundType(blockState, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); itemstack.shrink(1); return EnumActionResult.SUCCESS; } } else return EnumActionResult.FAIL; }