Java Code Examples for us.myles.ViaVersion.api.PacketWrapper#passthrough()
The following examples show how to use
us.myles.ViaVersion.api.PacketWrapper#passthrough() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TagRewriter.java From ViaVersion with MIT License | 6 votes |
private void handle(PacketWrapper wrapper, IdRewriteFunction rewriteFunction, List<TagData> newTags) throws Exception { int tagsSize = wrapper.read(Type.VAR_INT); wrapper.write(Type.VAR_INT, newTags != null ? tagsSize + newTags.size() : tagsSize); // add new tags count for (int i = 0; i < tagsSize; i++) { wrapper.passthrough(Type.STRING); int[] ids = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); if (rewriteFunction != null) { for (int j = 0; j < ids.length; j++) { ids[j] = rewriteFunction.rewrite(ids[j]); } } } // Send new tags if present if (newTags != null) { for (TagData tag : newTags) { wrapper.write(Type.STRING, tag.identifier); wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, tag.entries); } } }
Example 2
Source File: BaseProtocol1_7.java From ViaVersion with MIT License | 5 votes |
protected UUID passthroughLoginUUID(PacketWrapper wrapper) throws Exception { String uuidString = wrapper.passthrough(Type.STRING); if (uuidString.length() == 32) { // Trimmed UUIDs are 32 characters // Trimmed uuidString = addDashes(uuidString); } return UUID.fromString(uuidString); }
Example 3
Source File: RecipeRewriter1_15.java From ViaBackwards with MIT License | 5 votes |
public void handleStonecutting(PacketWrapper wrapper) throws Exception { wrapper.passthrough(Type.STRING); Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients for (Item item : items) { rewriter.handleItemToClient(item); } rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result }
Example 4
Source File: RecipeRewriter1_14.java From ViaBackwards with MIT License | 5 votes |
public void handleSmelting(PacketWrapper wrapper) throws Exception { wrapper.passthrough(Type.STRING); // Group Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients for (Item item : items) { rewriter.handleItemToClient(item); } rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result wrapper.passthrough(Type.FLOAT); // EXP wrapper.passthrough(Type.VAR_INT); // Cooking time }
Example 5
Source File: RecipeRewriter1_14.java From ViaBackwards with MIT License | 5 votes |
public void handleCraftingShaped(PacketWrapper wrapper) throws Exception { int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.STRING); // Group for (int j = 0; j < ingredientsNo; j++) { Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients for (Item item : items) { rewriter.handleItemToClient(item); } } rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result }
Example 6
Source File: RecipeRewriter1_14.java From ViaBackwards with MIT License | 5 votes |
public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception { wrapper.passthrough(Type.STRING); // Group int ingredientsNo = wrapper.passthrough(Type.VAR_INT); for (int j = 0; j < ingredientsNo; j++) { Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients for (Item item : items) { rewriter.handleItemToClient(item); } } rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result }
Example 7
Source File: BaseProtocol1_16.java From ViaVersion with MIT License | 4 votes |
@Override protected UUID passthroughLoginUUID(final PacketWrapper wrapper) throws Exception { return wrapper.passthrough(Type.UUID_INT_ARRAY); }