congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
us.myles.ViaVersion.api
Code IndexAdd Tabnine to your IDE (free)

How to use us.myles.ViaVersion.api

Best Java code snippets using us.myles.ViaVersion.api (Showing top 20 results out of 315)

origin: MylesIsCool/ViaVersion

/**
 * Send this packet to the associated user.
 * Be careful not to send packets twice.
 * (Sends it after current)
 *
 * @param packetProtocol - The protocol version of the packet.
 * @throws Exception if it fails to write
 */
public void send(Class<? extends Protocol> packetProtocol) throws Exception {
  send(packetProtocol, true);
}
origin: MylesIsCool/ViaVersion

  @Override
  public void write(PacketWrapper output, T inputValue) {
    output.write(type, inputValue);
  }
}
origin: MylesIsCool/ViaVersion

  private static void updateBlockEntity(Position pos, short id, CompoundTag tag, UserConnection connection) throws Exception {
    PacketWrapper wrapper = new PacketWrapper(0x09, null, connection);
    wrapper.write(Type.POSITION, pos);
    wrapper.write(Type.UNSIGNED_BYTE, id);
    wrapper.write(Type.NBT, tag);
    wrapper.send(Protocol1_9_1_2TO1_9_3_4.class, false);
  }
}
origin: MylesIsCool/ViaVersion

private void sendPacket(UUID uuid, PacketWrapper wrapper) {
  if (!Via.getAPI().isPorted(uuid) || !(Via.getAPI().getPlayerVersion(uuid) >= ProtocolVersion.v1_9.getId())) {
    players.remove(uuid);
    return;
  }
  try {
    wrapper.send(Protocol1_9TO1_8.class);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Create a new packet for the target of this packet.
 *
 * @param packetID The ID of the new packet
 * @return The newly created packet wrapper
 */
public PacketWrapper create(int packetID) {
  return new PacketWrapper(packetID, null, user());
}
origin: MylesIsCool/ViaVersion

/**
 * Take a value from the input and write to the output.
 *
 * @param type The type to read and write.
 * @param <T>  The return type of the type you wish to pass through.
 * @return The type which was read/written.
 * @throws Exception If it failed to read or write
 */
public <T> T passthrough(Type<T> type) throws Exception {
  T value = read(type);
  write(type, value);
  return value;
}
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

private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) {
  Arrays.fill(oldToNew, (short) -1);
  mapIdentifiers(oldToNew, mapping1_12, mapping1_13);
  // Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
  if (Via.getConfig().isSnowCollisionFix()) {
    oldToNew[1248] = 3416;
  }
}
origin: MylesIsCool/ViaVersion

  @Override
  public void registerMap() {
    if (Via.getConfig().isServersideBlockConnections()) {
      handler(new PacketHandler() {
        @Override
        public void handle(PacketWrapper wrapper) throws Exception {
          int x = wrapper.passthrough(Type.INT);
          int z = wrapper.passthrough(Type.INT);
          ConnectionData.getProvider().unloadChunk(wrapper.user(), x, z);
        }
      });
    }
  }
});
origin: MylesIsCool/ViaVersion

@Override
public String description() {
  return "Forces ViaVersion to scan server protocol versions " +
      (((VelocityViaConfig) Via.getConfig()).getVelocityPingInterval() == -1 ?
          "" : "(Also happens at an interval)");
}
origin: MylesIsCool/ViaVersion

public static boolean isBaseProtocol(Protocol protocol) {
  for (Pair<Range<Integer>, Protocol> p : baseProtocols) {
    if (p.getValue() == protocol) {
      return true;
    }
  }
  return false;
}
origin: MylesIsCool/ViaVersion

@Override
public void onEnable() {
  // Inject
  Via.getManager().init();
}
origin: MylesIsCool/ViaVersion

public void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
  sendToServer(packetProtocol, skipCurrentPipeline, false);
}
origin: MylesIsCool/ViaVersion

/**
 * Map a type using a basic ValueReader to a ValueWriter
 *
 * @param inputReader  The reader to read with.
 * @param outputWriter The writer to write with
 * @param <T>          The return type
 */
public <T> void map(ValueReader<T> inputReader, ValueWriter<T> outputWriter) {
  valueRemappers.add(new Pair<ValueReader, ValueWriter>(inputReader, outputWriter));
}
origin: MylesIsCool/ViaVersion

@Override
public T read(PacketWrapper wrapper) throws Exception {
  return wrapper.read(type);
}
origin: MylesIsCool/ViaVersion

/**
 * Clear the packet, used if you have to change the packet completely
 */
public void clearPacket() {
  clearInputBuffer();
  packetValues.clear();
}
origin: MylesIsCool/ViaVersion

private void sendBlockChange(UserConnection user, Position position, int blockId) throws Exception {
  PacketWrapper wrapper = new PacketWrapper(0x0B, null, user);
  wrapper.write(Type.POSITION, position);
  wrapper.write(Type.VAR_INT, blockId);
  wrapper.send(Protocol1_13To1_12_2.class, true, true);
}
origin: MylesIsCool/ViaVersion

/**
 * Send this packet to the associated user.
 * Be careful not to send packets twice.
 * (Sends it after current)
 *
 * @param packetProtocol      - The protocol version of the packet.
 * @param skipCurrentPipeline - Skip the current pipeline
 * @throws Exception if it fails to write
 */
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
  send(packetProtocol, skipCurrentPipeline, false);
}
origin: MylesIsCool/ViaVersion

@Override
public String description() {
  return "Forces ViaVersion to scan server protocol versions " +
      (((BungeeViaConfig) Via.getConfig()).getBungeePingInterval() == -1 ?
          "" : "(Also happens at an interval)");
}
origin: MylesIsCool/ViaVersion

public void sendToServer(Class<? extends Protocol> packetProtocol) throws Exception {
  sendToServer(packetProtocol, true);
}
us.myles.ViaVersion.api

Most used classes

  • ViaVersion$api$data$UserConnection
  • ViaVersion$api$minecraft$item$Item
  • ViaVersion$api$minecraft$metadata$MetaType
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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