Java Code Examples for cn.nukkit.utils.BinaryStream#putUnsignedVarInt()
The following examples show how to use
cn.nukkit.utils.BinaryStream#putUnsignedVarInt() .
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: CraftingDataPacket.java From Jupiter with GNU General Public License v3.0 | 6 votes |
private static int writeShapedRecipe(ShapedRecipe recipe, BinaryStream stream) { stream.putVarInt(recipe.getWidth()); stream.putVarInt(recipe.getHeight()); for (int z = 0; z < recipe.getHeight(); ++z) { for (int x = 0; x < recipe.getWidth(); ++x) { stream.putSlot(recipe.getIngredient(x, z)); } } stream.putUnsignedVarInt(1); stream.putSlot(recipe.getResult()); stream.putUUID(recipe.getId()); return CraftingDataPacket.ENTRY_SHAPED; }
Example 2
Source File: CraftingDataPacket.java From Nukkit with GNU General Public License v3.0 | 6 votes |
private static int writeShapedRecipe(ShapedRecipe recipe, BinaryStream stream) { stream.putVarInt(recipe.getWidth()); stream.putVarInt(recipe.getHeight()); for (int z = 0; z < recipe.getHeight(); ++z) { for (int x = 0; x < recipe.getWidth(); ++x) { stream.putSlot(recipe.getIngredient(x, z)); } } stream.putUnsignedVarInt(1); stream.putSlot(recipe.getResult()); stream.putUUID(recipe.getId()); return CraftingDataPacket.ENTRY_SHAPED; }
Example 3
Source File: CraftingDataPacket.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private static int writeShapelessRecipe(ShapelessRecipe recipe, BinaryStream stream) { stream.putUnsignedVarInt(recipe.getIngredientCount()); for (Item item : recipe.getIngredientList()) { stream.putSlot(item); } stream.putUnsignedVarInt(1); stream.putSlot(recipe.getResult()); stream.putUUID(recipe.getId()); return CraftingDataPacket.ENTRY_SHAPELESS; }
Example 4
Source File: CraftingDataPacket.java From Jupiter with GNU General Public License v3.0 | 5 votes |
private static int writeEnchantList(EnchantmentList list, BinaryStream stream) { stream.putByte((byte) list.getSize()); for (int i = 0; i < list.getSize(); ++i) { EnchantmentEntry entry = list.getSlot(i); stream.putUnsignedVarInt(entry.getCost()); stream.putUnsignedVarInt(entry.getEnchantments().length); for (Enchantment enchantment : entry.getEnchantments()) { stream.putUnsignedVarInt(enchantment.getId()); stream.putUnsignedVarInt(enchantment.getLevel()); } stream.putString(entry.getRandomName()); } return CraftingDataPacket.ENTRY_ENCHANT_LIST; }
Example 5
Source File: CraftingDataPacket.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private static int writeShapelessRecipe(ShapelessRecipe recipe, BinaryStream stream) { stream.putUnsignedVarInt(recipe.getIngredientCount()); for (Item item : recipe.getIngredientList()) { stream.putSlot(item); } stream.putUnsignedVarInt(1); stream.putSlot(recipe.getResult()); stream.putUUID(recipe.getId()); return CraftingDataPacket.ENTRY_SHAPELESS; }
Example 6
Source File: CraftingDataPacket.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private static int writeEnchantList(EnchantmentList list, BinaryStream stream) { stream.putByte((byte) list.getSize()); for (int i = 0; i < list.getSize(); ++i) { EnchantmentEntry entry = list.getSlot(i); stream.putUnsignedVarInt(entry.getCost()); stream.putUnsignedVarInt(entry.getEnchantments().length); for (Enchantment enchantment : entry.getEnchantments()) { stream.putUnsignedVarInt(enchantment.getId()); stream.putUnsignedVarInt(enchantment.getLevel()); } stream.putString(entry.getRandomName()); } return CraftingDataPacket.ENTRY_ENCHANT_LIST; }
Example 7
Source File: CraftingManager.java From Nukkit with GNU General Public License v3.0 | 5 votes |
private String getMultiItemHash(Collection<Item> items) { BinaryStream stream = new BinaryStream(); for (Item item : items) { stream.putUnsignedVarInt(item.getId()); stream.putVarInt(item.getDamage()); } return new String(stream.getByteArray()); }
Example 8
Source File: GameRules.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override void write(BinaryStream pk, Value value) { pk.putUnsignedVarInt(value.getValueAsInteger()); }
Example 9
Source File: GameRules.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public void write(BinaryStream pk) { pk.putUnsignedVarInt(type.ordinal()); type.write(pk, this); }
Example 10
Source File: GameRules.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override void write(BinaryStream pk, Value value) { pk.putUnsignedVarInt(value.getValueAsInteger()); }
Example 11
Source File: GameRules.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public void write(BinaryStream pk) { pk.putUnsignedVarInt(type.ordinal()); type.write(pk, this); }