當前位置: 首頁>>代碼示例>>Java>>正文


Java EnumFacing.fromAngle方法代碼示例

本文整理匯總了Java中net.minecraft.util.EnumFacing.fromAngle方法的典型用法代碼示例。如果您正苦於以下問題:Java EnumFacing.fromAngle方法的具體用法?Java EnumFacing.fromAngle怎麽用?Java EnumFacing.fromAngle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.EnumFacing的用法示例。


在下文中一共展示了EnumFacing.fromAngle方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBlockActivated

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (((Boolean)state.getValue(OPEN)).booleanValue())
    {
        state = state.withProperty(OPEN, Boolean.valueOf(false));
        worldIn.setBlockState(pos, state, 2);
    }
    else
    {
        EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);

        if (state.getValue(FACING) == enumfacing.getOpposite())
        {
            state = state.withProperty(FACING, enumfacing);
        }

        state = state.withProperty(OPEN, Boolean.valueOf(true));
        worldIn.setBlockState(pos, state, 2);
    }

    worldIn.playAuxSFXAtEntity(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1003 : 1006, pos, 0);
    return true;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:BlockFenceGate.java

示例2: onBlockActivated

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (((Boolean)state.getValue(OPEN)).booleanValue())
    {
        state = state.withProperty(OPEN, Boolean.valueOf(false));
        worldIn.setBlockState(pos, state, 10);
    }
    else
    {
        EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);

        if (state.getValue(FACING) == enumfacing.getOpposite())
        {
            state = state.withProperty(FACING, enumfacing);
        }

        state = state.withProperty(OPEN, Boolean.valueOf(true));
        worldIn.setBlockState(pos, state, 10);
    }

    worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1008 : 1014, pos, 0);
    return true;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:24,代碼來源:BlockFenceGate.java

示例3: onBlockActivated

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
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 (((Boolean)state.getValue(OPEN)).booleanValue())
    {
        state = state.withProperty(OPEN, Boolean.valueOf(false));
        worldIn.setBlockState(pos, state, 10);
    }
    else
    {
        EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);

        if (state.getValue(FACING) == enumfacing.getOpposite())
        {
            state = state.withProperty(FACING, enumfacing);
        }

        state = state.withProperty(OPEN, Boolean.valueOf(true));
        worldIn.setBlockState(pos, state, 10);
    }

    worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1008 : 1014, pos, 0);
    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:24,代碼來源:BlockFenceGate.java

示例4: onItemUse

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
/**
 * 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)
{
    if (hand != EnumFacing.UP)
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = playerIn.getBlockState(worldIn);
        Block block = iblockstate.getBlock();

        if (!block.isReplaceable(playerIn, worldIn))
        {
            worldIn = worldIn.offset(hand);
        }

        ItemStack itemstack = stack.getHeldItem(pos);

        if (stack.canPlayerEdit(worldIn, hand, itemstack) && this.block.canPlaceBlockAt(playerIn, worldIn))
        {
            EnumFacing enumfacing = EnumFacing.fromAngle((double)stack.rotationYaw);
            int i = enumfacing.getFrontOffsetX();
            int j = enumfacing.getFrontOffsetZ();
            boolean flag = i < 0 && hitY < 0.5F || i > 0 && hitY > 0.5F || j < 0 && facing > 0.5F || j > 0 && facing < 0.5F;
            placeDoor(playerIn, worldIn, enumfacing, this.block, flag);
            SoundType soundtype = this.block.getSoundType();
            playerIn.playSound(stack, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
            itemstack.func_190918_g(1);
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:40,代碼來源:ItemDoor.java

示例5: onItemUse

import net.minecraft.util.EnumFacing; //導入方法依賴的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.UP)
    {
        return EnumActionResult.FAIL;
    }
    else
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        Block block = iblockstate.getBlock();

        if (!block.isReplaceable(worldIn, pos))
        {
            pos = pos.offset(facing);
        }

        if (playerIn.canPlayerEdit(pos, facing, stack) && this.block.canPlaceBlockAt(worldIn, pos))
        {
            EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);
            int i = enumfacing.getFrontOffsetX();
            int j = enumfacing.getFrontOffsetZ();
            boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
            placeDoor(worldIn, pos, enumfacing, this.block, flag);
            SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), 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;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:38,代碼來源:ItemDoor.java

示例6: getStateForPlacement

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
	final EnumFacing enumfacing = EnumFacing.fromAngle(placer.rotationYaw);
	return this.getDefaultState().withProperty(FACING, enumfacing);
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:6,代碼來源:BlockOven.java

示例7: onBlockPlacedBy

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
	EnumFacing enumfacing = EnumFacing.fromAngle((double) placer.rotationYaw);
	worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
 
開發者ID:MinecraftModDevelopmentMods,項目名稱:Got-Wood,代碼行數:6,代碼來源:BlockDates.java

示例8: onBlockPlacedBy

import net.minecraft.util.EnumFacing; //導入方法依賴的package包/類
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    EnumFacing enumfacing = EnumFacing.fromAngle((double)placer.rotationYaw);
    worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:9,代碼來源:BlockCocoa.java


注:本文中的net.minecraft.util.EnumFacing.fromAngle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。