net.minecraft.util.EnumFacing.fromAngle()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(64)

本文整理了Java中net.minecraft.util.EnumFacing.fromAngle()方法的一些代码示例,展示了EnumFacing.fromAngle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EnumFacing.fromAngle()方法的具体详情如下:
包路径:net.minecraft.util.EnumFacing
类名称:EnumFacing
方法名:fromAngle

EnumFacing.fromAngle介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

EnumFacing rotationDir = EnumFacing.fromAngle(player.rotationYaw);

代码示例来源:origin: ldtteam/minecolonies

@Override
public void onBlockPlacedBy(final World worldIn, final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack)
{
  @NotNull final EnumFacing enumFacing = (placer == null) ? NORTH : fromAngle(placer.rotationYaw);
  this.getDefaultState().withProperty(FACING, enumFacing);
}

代码示例来源:origin: ldtteam/minecolonies

@SuppressWarnings(DEPRECATION)
@NotNull
@Override
public IBlockState getStateForPlacement(
                     final World worldIn,
                     final BlockPos pos,
                     final EnumFacing facing,
                     final float hitX,
                     final float hitY,
                     final float hitZ,
                     final int meta,
                     final EntityLivingBase placer)
{
  @NotNull final EnumFacing enumFacing = (placer == null) ? NORTH : fromAngle(placer.rotationYaw);
  return this.getDefaultState().withProperty(FACING, enumFacing);
}

代码示例来源:origin: ldtteam/minecolonies

/**
 * @deprecated (Remove this as soon as minecraft offers anything better).
 */
@SuppressWarnings(DEPRECATION)
@NotNull
@Override
@Deprecated
public IBlockState getStateForPlacement(
                     final World worldIn,
                     final BlockPos pos,
                     final EnumFacing facing,
                     final float hitX,
                     final float hitY,
                     final float hitZ,
                     final int meta,
                     final EntityLivingBase placer)
{
  @NotNull final EnumFacing enumFacing = (placer == null) ? NORTH : fromAngle(placer.rotationYaw);
  return this.getDefaultState().withProperty(FACING, enumFacing);
}

代码示例来源:origin: ldtteam/minecolonies

@SuppressWarnings(DEPRECATION)
@NotNull
@Override
public IBlockState getStateForPlacement(
                     final World worldIn,
                     final BlockPos pos,
                     final EnumFacing facing,
                     final float hitX,
                     final float hitY,
                     final float hitZ,
                     final int meta,
                     final EntityLivingBase placer)
{
  @NotNull final EnumFacing enumFacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
  return this.getDefaultState().withProperty(FACING, enumFacing);
}

代码示例来源:origin: ldtteam/minecolonies

@SuppressWarnings(DEPRECATION)
@NotNull
@Override
public IBlockState getStateForPlacement(
 final World worldIn,
 final BlockPos pos,
 final EnumFacing facing,
 final float hitX,
 final float hitY,
 final float hitZ,
 final int meta,
 final EntityLivingBase placer)
{
  @NotNull final EnumFacing enumFacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
  return this.getDefaultState().withProperty(FACING, enumFacing);
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos thisBlockPos, EnumFacing faceOfNeighbour,
                 float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
 EnumFacing directionTargetIsPointing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
 return this.getDefaultState().withProperty(PROPERTYFACING, directionTargetIsPointing);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

/**
 * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the IBlockstate
 */
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
 // find the quadrant the player is facing
 EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
 return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
 // find the quadrant the player is facing
 EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
 return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing);
}
//  public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public void onBlockPlacedBy(@Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull EntityLivingBase placer,
  @Nonnull ItemStack stack) {
 setTypeFromMeta(worldIn, pos, stack.getMetadata());
 setPaintSource(state, worldIn, pos, PaintUtil.getSourceBlock(stack));
 setRotation(worldIn, pos, EnumFacing.fromAngle(placer.rotationYaw));
 setMobType(worldIn, pos, CapturedMob.create(stack));
 if (!worldIn.isRemote) {
  worldIn.notifyBlockUpdate(pos, state, state, 3);
 }
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public IBlockState getStateFromMeta(int meta) {
  int facing = meta & 7;
  return getDefaultState().withProperty(FACING, EnumFacing.fromAngle(facing)).withProperty(MANUAL, (meta & 8) == 8);
}

代码示例来源:origin: Vazkii/Botania

if(side.getAxis() != Axis.Y) {
  float sideAngle = side.getHorizontalAngle() - potatoFacing.getHorizontalAngle();
  side = EnumFacing.fromAngle(sideAngle);

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
 // find the quadrant the player is facing
 EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
 return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing.getOpposite());
}

代码示例来源:origin: TheGreyGhost/MinecraftByExample

@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
 EnumColour colour = EnumColour.byMetadata(meta);
 // find the quadrant the player is facing
 EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : EnumFacing.fromAngle(placer.rotationYaw);
 return this.getDefaultState().withProperty(PROPERTYFACING, enumfacing).withProperty(PROPERTYCOLOUR, colour);
}

代码示例来源:origin: vadis365/TheErebus

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  if (((Boolean) state.getValue(OPEN)).booleanValue()) {
    state = state.withProperty(OPEN, Boolean.valueOf(false));
    world.setBlockState(pos, state, 10);
  } else {
    EnumFacing enumfacing = EnumFacing.fromAngle((double) player.rotationYaw);
    if (state.getValue(FACING) == enumfacing.getOpposite())
      state = state.withProperty(FACING, enumfacing);
    state = state.withProperty(OPEN, Boolean.valueOf(true));
    world.setBlockState(pos, state, 10);
  }
  world.playEvent(player, ((Boolean) state.getValue(OPEN)).booleanValue() ? 1008 : 1014, pos, 0);
  return true;
}

代码示例来源:origin: SleepyTrousers/EnderIO

EnumFacing enumfacing = EnumFacing.fromAngle((double) player.rotationYaw);
int i = enumfacing.getFrontOffsetX();
int j = enumfacing.getFrontOffsetZ();

代码示例来源:origin: WayofTime/BloodMagic

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  ItemStack stack = player.getHeldItem(hand);
  BlockPos newPos = blockPos.offset(side);
  if (world.isAirBlock(newPos)) {
    if (!world.isRemote) {
      EnumFacing rotation = EnumFacing.fromAngle(player.getRotationYawHead());
      world.setBlockState(newPos, RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getDefaultState());
      TileEntity tile = world.getTileEntity(newPos);
      if (tile instanceof TileAlchemyArray) {
        ((TileAlchemyArray) tile).setRotation(rotation);
      }
      stack.damageItem(1, player);
    }
    return EnumActionResult.SUCCESS;
  }
  return EnumActionResult.FAIL;
}

代码示例来源:origin: TeamLapen/Vampirism

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  if (facing != EnumFacing.UP)
    return EnumActionResult.PASS;
  if (world.isRemote) return EnumActionResult.PASS;
  ItemStack stack = player.getHeldItem(hand);
  EnumFacing dir = EnumFacing.fromAngle(player.rotationYaw);
  boolean flag = placeAt(world, pos.up(), dir, false, false);
  if (flag) {
    TileEntity tile = world.getTileEntity(pos.up());
    if (tile instanceof TileTent) {
      if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("spawner")) {
        ((TileTent) tile).setSpawn(true);
      }
    }
    if (!player.capabilities.isCreativeMode) {
      stack.shrink(1);
    }
  }
  return flag ? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

private void interactWithFenceGate(BlockPos doorPos, boolean isOpening, IBlockState doorState) {
  boolean fenceGateOpen = doorState.getValue(BlockFenceGate.OPEN);
  if (isOpening) {
    if (!fenceGateOpen) {
      EnumFacing entityFacing = EnumFacing.fromAngle((double) theEntity.rotationYaw);
      openFenceGate(doorState, doorPos, entityFacing);
      IBlockState state = theEntity.world.getBlockState(doorPos.up());
      if (state.getBlock() instanceof BlockFenceGate) {
        openFenceGate(state, doorPos.up(), entityFacing);
      }
    }
  } else {
    doorState = doorState.withProperty(BlockFenceGate.OPEN, false);
    theEntity.world.setBlockState(doorPos, doorState, 10);
    IBlockState state = theEntity.world.getBlockState(doorPos.up());
    if (state.getBlock() instanceof BlockFenceGate) {
      state = state.withProperty(BlockFenceGate.OPEN, false);
      theEntity.world.setBlockState(doorPos.up(), state, 10);
    }
  }
  theEntity.world.playEvent(null, doorState.getValue(BlockFenceGate.OPEN) ? 1008 : 1014, doorPos, 0);
}

代码示例来源:origin: vadis365/TheErebus

@Override
  public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (facing != EnumFacing.UP)
      return EnumActionResult.FAIL;
    else {
      IBlockState iblockstate = world.getBlockState(pos);
      Block block = iblockstate.getBlock();

      if (!block.isReplaceable(world, pos))
        pos = pos.offset(facing);

      if (player.canPlayerEdit(pos, facing, stack) && this.block.canPlaceBlockAt(world, pos)) {
        EnumFacing enumfacing = EnumFacing.fromAngle(player.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;
        ItemDoor.placeDoor(world, pos, enumfacing, this.block, flag);
        SoundType soundtype = world.getBlockState(pos).getBlock().getSoundType(world.getBlockState(pos), world, pos, player);
        world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
        stack.shrink(1);
        return EnumActionResult.SUCCESS;
      } else
        return EnumActionResult.FAIL;
    }
  }
}

相关文章