Tabnine Logo
Position.getX
Code IndexAdd Tabnine to your IDE (free)

How to use
getX
method
in
us.myles.ViaVersion.api.minecraft.Position

Best Java code snippets using us.myles.ViaVersion.api.minecraft.Position.getX (Showing top 8 results out of 315)

origin: MylesIsCool/ViaVersion

  public BlockPositon(Position position) {
    x = position.getX().intValue();
    y = position.getY().intValue();
    z = position.getZ().intValue();
  }
}
origin: MylesIsCool/ViaVersion

private Pair<Integer, Integer> getChunkCoords(Position position) {
  int chunkX = (int) Math.floor(position.getX() / 16);
  int chunkZ = (int) Math.floor(position.getZ() / 16);
  return new Pair<>(chunkX, chunkZ);
}
origin: MylesIsCool/ViaVersion

  @Override
  public void write(ByteBuf buffer, Position object) {
    buffer.writeLong(((object.getX() & 0x3ffffff) << 38) | ((object.getY() & 0xfff) << 26) | (object.getZ() & 0x3ffffff));
  }
}
origin: MylesIsCool/ViaVersion

public boolean interactedBlockRecently(int x, int y, int z) {
  if (blockInteractions.size() == 0)
    return false;
  for (Position p : blockInteractions.asMap().keySet()) {
    if (p.getX() == x)
      if (p.getY() == y)
        if (p.getZ() == z)
          return true;
  }
  return false;
}
origin: MylesIsCool/ViaVersion

private Pair<Integer, Integer> getPair(Position position) {
  int chunkX = (int) (position.getX() >> 4);
  int chunkZ = (int) (position.getZ() >> 4);
  return new Pair<>(chunkX, chunkZ);
}
origin: MylesIsCool/ViaVersion

  @Override
  public int getWorldBlockData(UserConnection user, Position position) {
    if (blockStateIds != null) {
      UUID uuid = user.get(ProtocolInfo.class).getUuid();
      Optional<Player> player = Sponge.getServer().getPlayer(uuid);
      if (player.isPresent()) {
        World world = player.get().getWorld();
        Optional<Chunk> chunk = world.getChunkAtBlock(position.getX().intValue(), position.getY().intValue(), position.getZ().intValue());
        if (chunk.isPresent()) {
          BlockState b = chunk.get().getBlock(position.getX().intValue(), position.getY().intValue(), position.getZ().intValue());
          Integer id = blockStateIds.get(b);
          if (id == null) {
            System.out.println("id not found");
          } else {
            return id;
          }
        }
      }
    }
    return 0;
  }
}
origin: MylesIsCool/ViaVersion

@Override
public int getWorldBlockData(UserConnection user, Position position) {
  UUID uuid = user.get(ProtocolInfo.class).getUuid();
  Player player = Bukkit.getPlayer(uuid);
  if (player != null) {
    World world = player.getWorld();
    int x = (int) (position.getX() >> 4);
    int z = (int) (position.getZ() >> 4);
    if (world.isChunkLoaded(x, z)) {
      Chunk c = getChunk(world, x, z);
      Block b = c.getBlock(position.getX().intValue(), position.getY().intValue(), position.getZ().intValue());
      return b.getTypeId() << 4 | b.getData();
    }
  }
  return 0;
}
origin: MylesIsCool/ViaVersion

public static void update(UserConnection user, Position position) {
  for (int x = -1; x <= 1; x++) {
    for (int z = -1; z <= 1; z++) {
      for (int y = -1; y <= 1; y++) {
        if (Math.abs(x) + Math.abs(y) + Math.abs(z) != 1) continue;
        Position pos = new Position(position.getX() + x, position.getY() + y, position.getZ() + z);
        int blockState = Via.getManager().getProviders().get(BlockConnectionProvider.class).getBlockdata(user, pos);
        if (!connects(blockState)) continue;
        int newBlockState = connect(user, pos, blockState);
        if (newBlockState == blockState) continue;
        PacketWrapper blockUpdatePacket = new PacketWrapper(0x0B, null, user);
        blockUpdatePacket.write(Type.POSITION, pos);
        blockUpdatePacket.write(Type.VAR_INT, newBlockState);
        try {
          blockUpdatePacket.send(Protocol1_13To1_12_2.class, true, false);
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    }
  }
}
us.myles.ViaVersion.api.minecraftPositiongetX

Popular methods of Position

    Popular in Java

    • Creating JSON documents from java classes using gson
    • startActivity (Activity)
    • requestLocationUpdates (LocationManager)
    • compareTo (BigDecimal)
    • Rectangle (java.awt)
      A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
    • SecureRandom (java.security)
      This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
    • Deque (java.util)
      A linear collection that supports element insertion and removal at both ends. The name deque is shor
    • Locale (java.util)
      Locale represents a language/country/variant combination. Locales are used to alter the presentatio
    • ResourceBundle (java.util)
      ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
    • UUID (java.util)
      UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
    • Top 12 Jupyter Notebook extensions
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now