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

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

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

EnumFacing.equals介绍

暂无

代码示例

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
  return direction.equals(EnumFacing.DOWN);
}

代码示例来源:origin: raoulvdberge/refinedstorage

@Override
public boolean canConduct(@Nullable EnumFacing direction) {
  return direction != null && EnumFacing.DOWN.equals(direction);
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
public boolean equals(Object aThat) {
  //check for self-comparison
  if (this == aThat) {
    return true;
  }
  if (!(aThat instanceof ExitRoute)) {
    return false;
  }
  ExitRoute that = (ExitRoute) aThat;
  return exitOrientation.equals(that.exitOrientation) && insertOrientation.equals(that.insertOrientation) && connectionDetails.equals(that.connectionDetails) && distanceToDestination == that.distanceToDestination && destinationDistanceToRoot == that.destinationDistanceToRoot && destination == that.destination
      && filters.equals(that.filters);
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@Override
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
  if (direction.equals(EnumFacing.DOWN)) {
    return isItemValidForSlot(index, itemStackIn);
  }
  return false;
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
public TextureType getNonRoutedTexture(EnumFacing connection) {
  if (connection.equals(pointedDirection)) {
    return Textures.LOGISTICSPIPE_CHASSI_DIRECTION_TEXTURE;
  }
  if (isPowerProvider(connection)) {
    return Textures.LOGISTICSPIPE_POWERED_TEXTURE;
  }
  return Textures.LOGISTICSPIPE_CHASSI_NOTROUTED_TEXTURE;
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
public ITubeOrientation getTubeOrientation(EntityPlayer player, int xPos, int zPos) {
  double x = xPos + 0.5 - player.posX;
  double z = zPos + 0.5 - player.posZ;
  double w = Math.atan2(x, z);
  double halfPI = Math.PI / 2;
  double halfhalfPI = halfPI / 2;
  w -= halfhalfPI;
  if (w < 0) {
    w += 2 * Math.PI;
  }
  EnumFacing dir = null;
  if (0 < w && w <= halfPI) {
    dir = EnumFacing.WEST;
  } else if (halfPI < w && w <= 2 * halfPI) {
    dir = EnumFacing.SOUTH;
  } else if (2 * halfPI < w && w <= 3 * halfPI) {
    dir = EnumFacing.EAST;
  } else if (3 * halfPI < w && w <= 4 * halfPI) {
    dir = EnumFacing.NORTH;
  }
  for (TubeLineOrientation ori : TubeLineOrientation.values()) {
    if (ori.dir.equals(dir)) {
      return ori;
    }
  }
  return null;
}

代码示例来源:origin: Direwolf20-MC/BuildingGadgets

EnumFacing depth = side.getOpposite();
if (side.equals(EnumFacing.NORTH) || side.equals(EnumFacing.SOUTH) || side.equals(EnumFacing.EAST) || side.equals(EnumFacing.WEST)) {
  up = EnumFacing.UP;
} else {
if (side.equals(EnumFacing.WEST)) {
  left = EnumFacing.SOUTH;
} else if (side.equals(EnumFacing.EAST)) {
  left = EnumFacing.NORTH;
} else if (side.equals(EnumFacing.NORTH)) {
  left = EnumFacing.WEST;
} else if (side.equals(EnumFacing.SOUTH)) {
  left = EnumFacing.EAST;
} else {

代码示例来源:origin: RS485/LogisticsPipes

@Override
public ITubeOrientation getTubeOrientation(EntityPlayer player, int xPos, int zPos) {
  double x = xPos + 0.5 - player.posX;
  double z = zPos + 0.5 - player.posZ;
  double w = Math.atan2(x, z);
  double halfPI = Math.PI / 2;
  double halfhalfPI = halfPI / 2;
  w -= halfhalfPI;
  if (w < 0) {
    w += 2 * Math.PI;
  }
  EnumFacing dir = null;
  if (0 < w && w <= halfPI) {
    dir = EnumFacing.EAST;
  } else if (halfPI < w && w <= 2 * halfPI) {
    dir = EnumFacing.NORTH;
  } else if (2 * halfPI < w && w <= 3 * halfPI) {
    dir = EnumFacing.WEST;
  } else if (3 * halfPI < w && w <= 4 * halfPI) {
    dir = EnumFacing.SOUTH;
  }
  for (TubeGainOrientation ori : TubeGainOrientation.values()) {
    if (ori.dir.equals(dir)) {
      return ori;
    }
  }
  return null;
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

@Override
public boolean canConnectFromSide(IBlockState blockState, EnumFacing side) {
  return blockState.getValue(MOBlock.PROPERTY_DIRECTION).getOpposite().equals(side);
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
public ITubeOrientation getTubeOrientation(EntityPlayer player, int xPos, int zPos) {
  double x = xPos + 0.5 - player.posX;
  double z = zPos + 0.5 - player.posZ;
  double w = Math.atan2(x, z);
  double halfPI = Math.PI / 2;
  double halfhalfPI = halfPI / 2;
  w -= halfhalfPI;
  if (w < 0) {
    w += 2 * Math.PI;
  }
  EnumFacing dir = null;
  if (0 < w && w <= halfPI) {
    dir = EnumFacing.WEST;
  } else if (halfPI < w && w <= 2 * halfPI) {
    dir = EnumFacing.SOUTH;
  } else if (2 * halfPI < w && w <= 3 * halfPI) {
    dir = EnumFacing.EAST;
  } else if (3 * halfPI < w && w <= 4 * halfPI) {
    dir = EnumFacing.NORTH;
  }
  for (SpeedupDirection ori : SpeedupDirection.values()) {
    if (ori.dir1.getOpposite().equals(dir)) {
      return ori;
    }
  }
  return null;
}

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

@Override
public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
  if (!p_185477_7_)
    state = state.getActualState(world, pos);
  addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE);
  addCollisionBoxToList(pos, entityBox, collidingBoxes, TOP);
  if (state.getValue(FACING).equals(EnumFacing.NORTH) || state.getValue(FACING).equals(EnumFacing.SOUTH)) {
    addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB);
    addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB);
  }
  if (state.getValue(FACING).equals(EnumFacing.EAST) || state.getValue(FACING).equals(EnumFacing.WEST)) {
    addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB);
    addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB);
  }
}

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

private boolean canPlaceAt(World world, BlockPos pos, EnumFacing facing) {
  BlockPos blockPos = pos.offset(facing.getOpposite());
  boolean flag = facing.getAxis().isHorizontal();
  return flag && world.isSideSolid(blockPos, facing, true) && canPlaceOn(world, blockPos) || ((facing.equals(EnumFacing.DOWN) || facing.equals(EnumFacing.UP)) && canPlaceOn(world, blockPos));
}

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

private boolean canPlaceAt(World world, BlockPos pos, EnumFacing facing) {
  BlockPos blockPos = pos.offset(facing.getOpposite());
  boolean flag = facing.getAxis().isHorizontal();
  return flag && world.isSideSolid(blockPos, facing, true) && canPlaceOn(world, blockPos) || ((facing.equals(EnumFacing.DOWN) || facing.equals(EnumFacing.UP)) && canPlaceOn(world, blockPos));
}

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

/**
 * Checks if the destination has been reached.
 * Meaning that the avoid distance has been reached.
 *
 * @param n Node to test.
 * @return true if so.
 */
@Override
protected boolean isAtDestination(@NotNull final Node n)
{
  final BlockPos vector = n.pos.subtract(avoid);
  final double nodeResult = getNodeResultScore(n);
  final int avoidSq = (avoidDistance * avoidDistance);
  return nodeResult >= avoidSq && (EnumFacing.getFacingFromVector(vector.getX(), 0, vector.getZ()).equals(direction) || nodeResult > avoidSq * avoidDistance);
}

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

public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean isActualState) {
  if (!isActualState)
    state = state.getActualState(world, pos);
  boolean front = canConnectBridgeTo(world, pos.add(0, 0, - 1));
  boolean back = canConnectBridgeTo(world, pos.add(0, 0, 1));
  boolean left = canConnectBridgeTo(world, pos.add(- 1, 0, 0));
  boolean right = canConnectBridgeTo(world, pos.add(1, 0, 0));
  addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE);
  if (state.getValue(FACING).equals(EnumFacing.NORTH) || state.getValue(FACING).equals(EnumFacing.SOUTH)) {
    if (!right)
      addCollisionBoxToList(pos, entityBox, collidingBoxes, RIGHT_AABB);
    if (!left)
      addCollisionBoxToList(pos, entityBox, collidingBoxes, LEFT_AABB);
  }
  if (state.getValue(FACING).equals(EnumFacing.EAST) || state.getValue(FACING).equals(EnumFacing.WEST)) {
    if (!back)
      addCollisionBoxToList(pos, entityBox, collidingBoxes, BACK_AABB);
    if (!front) 
      addCollisionBoxToList(pos, entityBox, collidingBoxes, FRONT_AABB);
  }
}

代码示例来源:origin: Ellpeck/ActuallyAdditions

private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing){
  BlockPos blockpos = pos.offset(facing.getOpposite());
  boolean flag = facing.getAxis().isHorizontal();
  return flag && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos);
}

代码示例来源:origin: OpenMods/OpenModsLib

@Override
public Orientation getPlacementOrientationFromEntity(BlockPos pos, EntityLivingBase player) {
  final EnumFacing player3d = BlockUtils.get3dOrientation(player, pos).getOpposite();
  if (player3d.equals(EnumFacing.UP)) {
    final EnumFacing player2d = player.getHorizontalFacing().getOpposite();
    return Orientation.lookupYZ(HalfAxis.POS_Y, HalfAxis.fromEnumFacing(player2d));
  } else if (player3d.equals(EnumFacing.DOWN)) {
    final EnumFacing player2d = player.getHorizontalFacing().getOpposite();
    return Orientation.lookupYZ(HalfAxis.NEG_Y, HalfAxis.fromEnumFacing(player2d));
  } else {
    return Orientation.lookupYZ(HalfAxis.fromEnumFacing(player3d), HalfAxis.POS_Y);
  }
}

代码示例来源:origin: McJtyMods/XNet

private void updateConnector(int channel, SidedPos pos, TypedMap params) {
  WorldBlob worldBlob = XNetBlobData.getBlobData(getWorld()).getWorldBlob(getWorld());
  ConsumerId consumerId = worldBlob.getConsumerAt(pos.getPos().offset(pos.getSide()));
  for (Map.Entry<SidedConsumer, ConnectorInfo> entry : channels[channel].getConnectors().entrySet()) {
    SidedConsumer key = entry.getKey();
    if (key.getConsumerId().equals(consumerId) && key.getSide().getOpposite().equals(pos.getSide())) {
      Map<String, Object> data = new HashMap<>();
      for (Key<?> k : params.getKeys()) {
        data.put(k.getName(), params.get(k));
      }
      channels[channel].getConnectors().get(key).getConnectorSettings().update(data);
      networkDirty();
      markDirtyQuick();
      return;
    }
  }
}

代码示例来源:origin: McJtyMods/XNet

private void removeConnector(int channel, SidedPos pos) {
  WorldBlob worldBlob = XNetBlobData.getBlobData(getWorld()).getWorldBlob(getWorld());
  ConsumerId consumerId = worldBlob.getConsumerAt(pos.getPos().offset(pos.getSide()));
  SidedConsumer toremove = null;
  for (Map.Entry<SidedConsumer, ConnectorInfo> entry : channels[channel].getConnectors().entrySet()) {
    SidedConsumer key = entry.getKey();
    if (key.getSide().getOpposite().equals(pos.getSide())) {
      if (key.getConsumerId().equals(consumerId)) {
        toremove = key;
        break;
      }
    }
  }
  if (toremove != null) {
    channels[channel].getConnectors().remove(toremove);
    networkDirty();
    markDirtyQuick();
  }
}

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

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
  ItemStack heldItem = player.getHeldItem(hand);
  if (!heldItem.isEmpty() && player != null && ((state.getValue(HALF).equals(EnumBlockHalf.TOP) && facing.equals(EnumFacing.DOWN)) || (state.getValue(HALF).equals(EnumBlockHalf.BOTTOM) && facing.equals(EnumFacing.UP)))){
    if (heldItem.getItem() == Item.getItemFromBlock(this)) {
      worldIn.setBlockState(pos, state.withProperty(HALF, EnumBlockHalf.FULL));
      if(!player.capabilities.isCreativeMode)
        heldItem.shrink(1);
      SoundType soundtype = this.getSoundType();
      worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
      return true;
    }
  }
  return super.onBlockActivated(worldIn, pos, state, player, hand, facing, hitX, hitY, hitZ);
}

相关文章