本文整理汇总了Java中net.minecraft.world.World.playSound方法的典型用法代码示例。如果您正苦于以下问题:Java World.playSound方法的具体用法?Java World.playSound怎么用?Java World.playSound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.playSound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemRightClick
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer playerIn, EnumHand handIn) {
ItemStack iStack = playerIn.getHeldItem(handIn);
if (iStack.getItemDamage() < iStack.getMaxDamage()) {
double factor = 0.2D * getPressure(iStack);
world.playSound(playerIn.posX, playerIn.posY, playerIn.posZ, Sounds.CANNON_SOUND, SoundCategory.PLAYERS, 1.0F, 0.7F + (float) factor * 0.2F, false);
EntityVortex vortex = new EntityVortex(world, playerIn);
Vec3d directionVec = playerIn.getLookVec().normalize();
vortex.posX += directionVec.x;
vortex.posY += directionVec.y;
vortex.posZ += directionVec.z;
vortex.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F);
vortex.motionX *= factor;
vortex.motionY *= factor;
vortex.motionZ *= factor;
if (!world.isRemote) world.spawnEntity(vortex);
iStack.setItemDamage(iStack.getItemDamage() + PneumaticValues.USAGE_VORTEX_CANNON);
if (iStack.getItemDamage() > iStack.getMaxDamage()) {
iStack.setItemDamage(iStack.getMaxDamage());
}
}
return ActionResult.newResult(EnumActionResult.SUCCESS, iStack);
}
示例2: onFinish
import net.minecraft.world.World; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void onFinish(TileCauldron tile, World world, BlockPos pos) {
for (int i = 0; i < 20; i++) {
final float x = pos.getX() + 0.2F + MathHelper.clamp(world.rand.nextFloat(), 0F, 0.5F);
final float y = pos.getY() + 0.2F + world.rand.nextFloat();
final float z = pos.getZ() + 0.2F + MathHelper.clamp(world.rand.nextFloat(), 0F, 0.5F);
PacketHandler.spawnParticle(ParticleF.STEAM, world, x, y, z, 10, 0, 0, 0);
}
if (!stack.isEmpty()) {
if (tile.getContainer().isEmpty()) {
tile.setContainer(stack);
} else {
spawnItem(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D);
}
}
world.playSound(null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1F, 1F);
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
handler.drain(1000, true);
}
示例3: playSound
import net.minecraft.world.World; //导入方法依赖的package包/类
private void playSound(World worldIn, BlockPos pos, boolean p_180694_3_, boolean p_180694_4_, boolean p_180694_5_, boolean p_180694_6_)
{
if (p_180694_4_ && !p_180694_6_)
{
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_TRIPWIRE_CLICK_ON, SoundCategory.BLOCKS, 0.4F, 0.6F);
}
else if (!p_180694_4_ && p_180694_6_)
{
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_TRIPWIRE_CLICK_OFF, SoundCategory.BLOCKS, 0.4F, 0.5F);
}
else if (p_180694_3_ && !p_180694_5_)
{
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_TRIPWIRE_ATTACH, SoundCategory.BLOCKS, 0.4F, 0.7F);
}
else if (!p_180694_3_ && p_180694_5_)
{
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_TRIPWIRE_DETACH, SoundCategory.BLOCKS, 0.4F, 1.2F / (worldIn.rand.nextFloat() * 0.2F + 0.9F));
}
}
示例4: onUseHoe
import net.minecraft.world.World; //导入方法依赖的package包/类
@SubscribeEvent
public static void onUseHoe(UseHoeEvent event) {
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == GenesisBlocks.HUMUS || block == GenesisBlocks.HUMUS_PATH) {
world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!world.isRemote) {
IBlockState farmland = GenesisBlocks.HUMUS_FARMLAND.getDefaultState();
world.setBlockState(pos, farmland, WorldFlags.UPDATE_BLOCK_AND_CLIENT_AND_RERENDER_ON_MAIN);
}
event.setResult(Event.Result.ALLOW);
}
}
示例5: triggerMixEffects
import net.minecraft.world.World; //导入方法依赖的package包/类
protected void triggerMixEffects(World worldIn, BlockPos pos)
{
double d0 = (double)pos.getX();
double d1 = (double)pos.getY();
double d2 = (double)pos.getZ();
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
for (int i = 0; i < 8; ++i)
{
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
示例6: setBlock
import net.minecraft.world.World; //导入方法依赖的package包/类
protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state)
{
worldIn.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!worldIn.isRemote)
{
worldIn.setBlockState(pos, state, 11);
stack.damageItem(1, player);
}
}
示例7: onItemRightClick
import net.minecraft.world.World; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
RayTraceResult raytraceresult = this.rayTrace(itemStackIn, worldIn, false);
if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && itemStackIn.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.END_PORTAL_FRAME)
{
return new ActionResult(EnumActionResult.PASS, itemstack);
}
else
{
worldIn.setActiveHand(playerIn);
if (!itemStackIn.isRemote)
{
BlockPos blockpos = ((WorldServer)itemStackIn).getChunkProvider().getStrongholdGen(itemStackIn, "Stronghold", new BlockPos(worldIn), false);
if (blockpos != null)
{
EntityEnderEye entityendereye = new EntityEnderEye(itemStackIn, worldIn.posX, worldIn.posY + (double)(worldIn.height / 2.0F), worldIn.posZ);
entityendereye.moveTowards(blockpos);
itemStackIn.spawnEntityInWorld(entityendereye);
itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_ENDEREYE_LAUNCH, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
itemStackIn.playEvent((EntityPlayer)null, 1003, new BlockPos(worldIn), 0);
if (!worldIn.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
}
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
}
示例8: explode
import net.minecraft.world.World; //导入方法依赖的package包/类
public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter)
{
if (!worldIn.isRemote)
{
if (((Boolean)state.getValue(EXPLODE)).booleanValue())
{
EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), igniter);
worldIn.spawnEntityInWorld(entitytntprimed);
worldIn.playSound((EntityPlayer)null, entitytntprimed.posX, entitytntprimed.posY, entitytntprimed.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
}
示例9: onPlayerStoppedUsing
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int count)
{
if (entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) entity;
Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (info != null)
{
// check to see if we have held it long enough
double attackSpeed = nbt.getDouble("AttackSpeed") + (PlayerStatHelper.ATTACK_SPEED_MULTIPLIER * (info.getTotalAgility()));
if (count > (this.getMaxItemUseDuration(stack) - ((1 / attackSpeed) * 20)))
{
return;
}
// fire projectile because check passed
if (statsCap != null)
{
world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F);
if (!world.isRemote)
{
// spawn entity and set position to specified direction
Vec3d look = player.getLookVec();
fireProjectile(world, player, stack, nbt, look);
// update mana and send to client
statsCap.decreaseMana(this.manaPerUse);
LootSlashConquer.network.sendTo(new PacketUpdateStats(statsCap), (EntityPlayerMP) player);
// damage item
stack.damageItem(1, player);
}
}
}
}
}
示例10: onItemRightClick
import net.minecraft.world.World; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem().equals(ModRegistry.WRITTEN_PARCHMENT))
{
Pair<NotebookCategory, Boolean> catInfo = getToUnlock(stack);
if (catInfo != null)
{
if (!world.isRemote)
{
INotebookInfo cap = player.getCapability(INotebookInfo.CAP, null);
if (cap != null)
{
NotebookCategory cat = catInfo.first();
if (cat != null)
{
if (!cat.equals(NotebookCategories.UNKNOWN_REALMS)
&& cap.isUnlocked(cat.getPrerequisiteTag())
&& !cap.isUnlocked(cat.getRequiredTag()))
{
cap.setUnlocked(cat.getRequiredTag());
}
if (catInfo.second())
{
for (NotebookCategory mightBeParent : NotebookCategory.REGISTRY.getValues())
{
if (mightBeParent != null && mightBeParent.getRequiredTag() != null)
{
if (mightBeParent.getRequiredTag().equals(cat.getPrerequisiteTag()))
{
ArcaneMagicPacketHandler.INSTANCE
.sendTo(new PacketNotebookToastExpanded(mightBeParent,
cat.getRequiredTag(), true), (EntityPlayerMP) player);
}
}
}
} else
{
ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookToastOrFail(cat, true),
(EntityPlayerMP) player);
}
} else
{
ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookToastOrFail(cat, true),
(EntityPlayerMP) player);
}
}
}
}
world.playSound(player, player.getPosition(), ArcaneMagicSoundHandler.randomWriteSound(),
SoundCategory.PLAYERS, 1, 1);
player.setHeldItem(hand, ItemStack.EMPTY);
player.swingArm(hand);
if (!world.isRemote)
{
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
示例11: onBlockActivated
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (this.getState() == EnumShrubState.BLOOMING)
{
if (!worldIn.isRemote)
{
ItemStack held = playerIn.getHeldItem(hand);
int allowHarvest;
if (!held.isEmpty() && held.getItem() == ExPItems.basket)
{
held.damageItem(1, playerIn);
allowHarvest = 2;
}
else
{
allowHarvest = worldIn.rand.nextFloat() < 0.1F ? 1 : 0;
if (allowHarvest == 0)
{
worldIn.playSound(null, pos, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.BLOCKS, 1, 1);
}
}
if (allowHarvest > 0)
{
worldIn.setBlockState(pos, ExPBlocks.berryBushes[EnumShrubState.NORMAL.ordinal()].getDefaultState().withProperty(ExPBlockProperties.BERRY_BUSH_TYPE, state.getValue(ExPBlockProperties.BERRY_BUSH_TYPE)));
if (allowHarvest == 2 || worldIn.rand.nextFloat() <= 0.75F)
{
float amt = 50 + worldIn.rand.nextFloat() * 250;
ItemStack food = new ItemStack(ExPItems.food, 1, EnumCrop.values().length + state.getValue(ExPBlockProperties.BERRY_BUSH_TYPE).ordinal() + 1);
ItemFood item = (ItemFood) food.getItem();
item.setLastTickTime(food, IExPWorld.of(worldIn).today());
item.setTotalWeight(food, amt);
EntityItem drop = new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, food.copy());
worldIn.spawnEntity(drop);
}
}
}
return true;
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
示例12: onItemUse
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* 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)
{
if (facing == EnumFacing.DOWN)
{
return EnumActionResult.FAIL;
}
else
{
boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
BlockPos blockpos = flag ? pos : pos.offset(facing);
if (!playerIn.canPlayerEdit(blockpos, facing, stack))
{
return EnumActionResult.FAIL;
}
else
{
BlockPos blockpos1 = blockpos.up();
boolean flag1 = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
flag1 = flag1 | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1));
if (flag1)
{
return EnumActionResult.FAIL;
}
else
{
double d0 = (double)blockpos.getX();
double d1 = (double)blockpos.getY();
double d2 = (double)blockpos.getZ();
List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, new AxisAlignedBB(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D));
if (!list.isEmpty())
{
return EnumActionResult.FAIL;
}
else
{
if (!worldIn.isRemote)
{
worldIn.setBlockToAir(blockpos);
worldIn.setBlockToAir(blockpos1);
EntityArmorStand entityarmorstand = new EntityArmorStand(worldIn, d0 + 0.5D, d1, d2 + 0.5D);
float f = (float)MathHelper.floor_float((MathHelper.wrapDegrees(playerIn.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F;
entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F);
this.applyRandomRotations(entityarmorstand, worldIn.rand);
ItemMonsterPlacer.applyItemEntityDataToEntity(worldIn, playerIn, stack, entityarmorstand);
worldIn.spawnEntityInWorld(entityarmorstand);
worldIn.playSound((EntityPlayer)null, entityarmorstand.posX, entityarmorstand.posY, entityarmorstand.posZ, SoundEvents.ENTITY_ARMORSTAND_PLACE, SoundCategory.BLOCKS, 0.75F, 0.8F);
}
--stack.stackSize;
return EnumActionResult.SUCCESS;
}
}
}
}
}
示例13: randomDisplayTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
{
if (rand.nextInt(24) == 0)
{
worldIn.playSound((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F + rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
}
if (!worldIn.getBlockState(pos.down()).isFullyOpaque() && !Blocks.FIRE.canCatchFire(worldIn, pos.down()))
{
if (Blocks.FIRE.canCatchFire(worldIn, pos.west()))
{
for (int j = 0; j < 2; ++j)
{
double d3 = (double)pos.getX() + rand.nextDouble() * 0.10000000149011612D;
double d8 = (double)pos.getY() + rand.nextDouble();
double d13 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d3, d8, d13, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.FIRE.canCatchFire(worldIn, pos.east()))
{
for (int k = 0; k < 2; ++k)
{
double d4 = (double)(pos.getX() + 1) - rand.nextDouble() * 0.10000000149011612D;
double d9 = (double)pos.getY() + rand.nextDouble();
double d14 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d4, d9, d14, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.FIRE.canCatchFire(worldIn, pos.north()))
{
for (int l = 0; l < 2; ++l)
{
double d5 = (double)pos.getX() + rand.nextDouble();
double d10 = (double)pos.getY() + rand.nextDouble();
double d15 = (double)pos.getZ() + rand.nextDouble() * 0.10000000149011612D;
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d5, d10, d15, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.FIRE.canCatchFire(worldIn, pos.south()))
{
for (int i1 = 0; i1 < 2; ++i1)
{
double d6 = (double)pos.getX() + rand.nextDouble();
double d11 = (double)pos.getY() + rand.nextDouble();
double d16 = (double)(pos.getZ() + 1) - rand.nextDouble() * 0.10000000149011612D;
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d6, d11, d16, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
if (Blocks.FIRE.canCatchFire(worldIn, pos.up()))
{
for (int j1 = 0; j1 < 2; ++j1)
{
double d7 = (double)pos.getX() + rand.nextDouble();
double d12 = (double)(pos.getY() + 1) - rand.nextDouble() * 0.10000000149011612D;
double d17 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d7, d12, d17, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
else
{
for (int i = 0; i < 3; ++i)
{
double d0 = (double)pos.getX() + rand.nextDouble();
double d1 = (double)pos.getY() + rand.nextDouble() * 0.5D + 0.5D;
double d2 = (double)pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}
示例14: onItemUse
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* 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);
Block block = iblockstate.getBlock();
if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
{
facing = EnumFacing.UP;
}
else if (!block.isReplaceable(worldIn, pos))
{
pos = pos.offset(facing);
}
if (playerIn.canPlayerEdit(pos, facing, stack) && stack.stackSize != 0 && worldIn.canBlockBePlaced(this.block, pos, false, facing, (Entity)null, stack))
{
IBlockState iblockstate1 = this.block.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, 0, playerIn, stack);
if (!worldIn.setBlockState(pos, iblockstate1, 11))
{
return EnumActionResult.FAIL;
}
else
{
iblockstate1 = worldIn.getBlockState(pos);
if (iblockstate1.getBlock() == this.block)
{
ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack);
iblockstate1.getBlock().onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
}
SoundType soundtype = iblockstate1.getBlock().getSoundType(iblockstate1, worldIn, pos, playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
return EnumActionResult.SUCCESS;
}
}
else
{
return EnumActionResult.FAIL;
}
}
示例15: onItemUse
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* 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)
{
if (worldIn.isRemote)
{
return EnumActionResult.SUCCESS;
}
else if (facing != EnumFacing.UP)
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
boolean flag = block.isReplaceable(worldIn, pos);
if (!flag)
{
pos = pos.up();
}
int i = MathHelper.floor_double((double)(playerIn.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
EnumFacing enumfacing = EnumFacing.getHorizontal(i);
BlockPos blockpos = pos.offset(enumfacing);
if (playerIn.canPlayerEdit(pos, facing, stack) && playerIn.canPlayerEdit(blockpos, facing, stack))
{
boolean flag1 = worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
boolean flag2 = flag || worldIn.isAirBlock(pos);
boolean flag3 = flag1 || worldIn.isAirBlock(blockpos);
if (flag2 && flag3 && worldIn.getBlockState(pos.down()).isFullyOpaque() && worldIn.getBlockState(blockpos.down()).isFullyOpaque())
{
IBlockState iblockstate1 = Blocks.BED.getDefaultState().withProperty(BlockBed.OCCUPIED, Boolean.valueOf(false)).withProperty(BlockBed.FACING, enumfacing).withProperty(BlockBed.PART, BlockBed.EnumPartType.FOOT);
if (worldIn.setBlockState(pos, iblockstate1, 11))
{
IBlockState iblockstate2 = iblockstate1.withProperty(BlockBed.PART, BlockBed.EnumPartType.HEAD);
worldIn.setBlockState(blockpos, iblockstate2, 11);
}
SoundType soundtype = iblockstate1.getBlock().getSoundType(iblockstate1, worldIn, pos, playerIn);
worldIn.playSound((EntityPlayer)null, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
--stack.stackSize;
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.FAIL;
}
}
else
{
return EnumActionResult.FAIL;
}
}
}