本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
}
示例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);
}
示例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);
}
示例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);
}