protocolsupport.api.ProtocolVersion Java Examples
The following examples show how to use
protocolsupport.api.ProtocolVersion.
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: StartGame.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void writeToClient() { ClientBoundPacketData startgame = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_START_GAME); startgame.writeInt(player.getId()); startgame.writeByte(gamemodeCurrent.getId() | (hardcore ? 0x8 : 0)); if (version.isBefore(ProtocolVersion.MINECRAFT_1_9_1)) { startgame.writeByte(LegacyDimension.getId(dimension)); } else { startgame.writeInt(LegacyDimension.getId(dimension)); } MiscSerializer.writeByteEnum(startgame, Difficulty.HARD); startgame.writeByte(maxplayers); StringSerializer.writeVarIntUTF8String(startgame, "default"); startgame.writeBoolean(reducedDebugInfo); codec.write(startgame); }
Example #2
Source File: WolfEntityMetadataRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
protected WolfEntityMetadataRemapper() { addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.BEGGING, 18), ProtocolVersionsHelper.UP_1_15); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.BEGGING, 18), ProtocolVersionsHelper.ALL_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.BEGGING, 16), ProtocolVersionsHelper.RANGE__1_11__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.BEGGING, 16), ProtocolVersion.MINECRAFT_1_10); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.BEGGING, 15), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Wolf.BEGGING, 19), ProtocolVersionsHelper.DOWN_1_8); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.COLLAR_COLOR, 19), ProtocolVersionsHelper.UP_1_15); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.COLLAR_COLOR, 19), ProtocolVersionsHelper.ALL_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.Wolf.COLLAR_COLOR, 17), ProtocolVersionsHelper.ALL_1_13); addRemap(new VarIntWolfCollarColorIndexValueRemapper(17), ProtocolVersionsHelper.RANGE__1_10__1_12_2); addRemap(new VarIntWolfCollarColorIndexValueRemapper(16), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapper<NetworkEntityMetadataObjectVarInt>(NetworkEntityMetadataObjectIndex.Wolf.COLLAR_COLOR, 20) { @Override public NetworkEntityMetadataObject<?> remapValue(NetworkEntityMetadataObjectVarInt object) { return new NetworkEntityMetadataObjectByte((byte) (15 - object.getValue())); } }, ProtocolVersion.MINECRAFT_1_8); addRemap(new IndexValueRemapperNumberToByte(NetworkEntityMetadataObjectIndex.Wolf.COLLAR_COLOR, 20), ProtocolVersionsHelper.DOWN_1_7_10); }
Example #3
Source File: WorldResourcepacks.java From ResourcepacksPlugins with GNU General Public License v3.0 | 6 votes |
@Override public int getPlayerProtocol(UUID playerId) { Player player = getServer().getPlayer(playerId); if (player != null) { int protocol = serverProtocolVersion; if (viaApi != null) { protocol = viaApi.getPlayerVersion(playerId); } if (protocolSupportApi && protocol == serverProtocolVersion) { // if still same format test if player is using previous version ProtocolVersion version = ProtocolSupportAPI.getProtocolVersion(player); if (version.getProtocolType() == ProtocolType.PC) { protocol = version.getId(); } } return protocol; } return -1; }
Example #4
Source File: ItemStackComplexRemapperRegistry.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
protected static NetworkItemStack remapComplex( Int2ObjectOpenHashMap<EnumMap<ProtocolVersion, List<ItemStackComplexRemapper>>> registry, ProtocolVersion version, String locale, NetworkItemStack itemstack ) { EnumMap<ProtocolVersion, List<ItemStackComplexRemapper>> map = registry.get(itemstack.getTypeId()); if (map != null) { List<ItemStackComplexRemapper> transformers = map.get(version); if (transformers != null) { for (ItemStackComplexRemapper transformer : transformers) { itemstack = transformer.remap(version, locale, itemstack); } } } return itemstack; }
Example #5
Source File: FeatureEmulation.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { Player player = event.getPlayer(); Connection connection = ProtocolSupportAPI.getConnection(player); if ( (connection != null) && (connection.getVersion().getProtocolType() == ProtocolType.PC) && connection.getVersion().isBefore(ProtocolVersion.MINECRAFT_1_9) ) { BlockDataEntry blockdataentry = MinecraftBlockData.get(MaterialAPI.getBlockDataNetworkId(event.getBlock().getBlockData())); player.playSound( event.getBlock().getLocation(), blockdataentry.getBreakSound(), SoundCategory.BLOCKS, (blockdataentry.getVolume() + 1.0F) / 2.0F, blockdataentry.getPitch() * 0.8F ); } }
Example #6
Source File: InitialPacketDecoder.java From ProtocolSupport with GNU Affero General Public License v3.0 | 6 votes |
protected static ConnectionImpl prepare(Channel channel, ProtocolVersion version) { channel.pipeline().remove(ChannelHandlers.INITIAL_DECODER); ConnectionImpl connection = ConnectionImpl.getFromChannel(channel); if (ServerPlatform.get().getMiscUtils().isDebugging()) { ProtocolSupport.logInfo(MessageFormat.format("{0} connected with protocol version {1}", connection.getAddress(), version)); } connection.getNetworkManagerWrapper().setPacketListener(ServerPlatform.get().getMiscUtils().createHandshakeListener(connection.getNetworkManagerWrapper())); if (!ProtocolSupportAPI.isProtocolVersionEnabled(version)) { if (version.getProtocolType() == ProtocolType.PC) { version = version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_6_4) ? ProtocolVersion.MINECRAFT_LEGACY : ProtocolVersion.MINECRAFT_FUTURE; } else { throw new IllegalArgumentException(MessageFormat.format("Unable to get legacy or future version for disabled protocol version {0}", version)); } } connection.setVersion(version); return connection; }
Example #7
Source File: InitialPacketDecoder.java From ProtocolSupportBungee with GNU Affero General Public License v3.0 | 6 votes |
protected void setProtocol(Channel channel, ProtocolVersion version) { ConnectionImpl connection = prepare(channel, version); IPipeLineBuilder builder = InitialPacketDecoder.BUILDERS.get(connection.getVersion()); builder.buildBungeeClientCodec(channel, connection); if (encapsulatedinfo == null) { builder.buildBungeeClientPipeLine(channel, connection); } else { ChannelPipeline pipeline = channel.pipeline(); pipeline.replace(PipelineUtils.FRAME_DECODER, PipelineUtils.FRAME_DECODER, new VarIntFrameDecoder()); if (encapsulatedinfo.hasCompression()) { pipeline.addAfter(PipelineUtils.FRAME_DECODER, "decompress", new PacketDecompressor()); pipeline.addAfter(PipelineUtils.FRAME_PREPENDER, "compress", new PacketCompressor(256)); } if ((encapsulatedinfo.getAddress() != null) && connection.getRawAddress().getAddress().isLoopbackAddress()) { connection.changeAddress(encapsulatedinfo.getAddress()); } } buffer.readerIndex(0); channel.pipeline().firstContext().fireChannelRead(buffer.unwrap()); }
Example #8
Source File: TimeUpdate.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { ClientBoundPacketData timeupdate = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_UPDATE_TIME); if (version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_5_2)) { timeOfDay = Math.abs(timeOfDay); } timeupdate.writeLong(worldAge); timeupdate.writeLong(timeOfDay); codec.write(timeupdate); }
Example #9
Source File: Explosion.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void writeToClient() { if (version.isBeforeOrEq(ProtocolVersion.MINECRAFT_1_14_4)) { codec.write(WorldCustomSound.create( version, (int) (x * 8), (int) (y * 8), (int) (z * 8), "entity.generic.explode", SoundCategory.BLOCKS, 4.0F, SoundRemapper.createEntityGenericExplodePitch() )); } ClientBoundPacketData explosion = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_EXPLOSION); explosion.writeFloat(x); explosion.writeFloat(y); explosion.writeFloat(z); explosion.writeFloat(radius); explosion.writeInt(blocks.length); for (Position block : blocks) { explosion.writeByte(block.getX()); explosion.writeByte(block.getY()); explosion.writeByte(block.getZ()); } explosion.writeFloat(pMotX); explosion.writeFloat(pMotY); explosion.writeFloat(pMotZ); codec.write(explosion); }
Example #10
Source File: LivingEntityMetadataRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
protected LivingEntityMetadataRemapper() { addRemap(new IndexValueRemapperOptionalChatToString(NetworkEntityMetadataObjectIndex.Entity.NAMETAG, 10), ProtocolVersionsHelper.ALL_1_7); addRemap(new IndexValueRemapperOptionalChatToString(NetworkEntityMetadataObjectIndex.Entity.NAMETAG, 10, 64), ProtocolVersionsHelper.ALL_1_6); addRemap(new IndexValueRemapperOptionalChatToString(NetworkEntityMetadataObjectIndex.Entity.NAMETAG, 5, 64), ProtocolVersionsHelper.DOWN_1_5_2); addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Entity.NAMETAG_VISIBLE, 11), ProtocolVersionsHelper.RANGE__1_6__1_7); addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.Entity.NAMETAG_VISIBLE, 6), ProtocolVersionsHelper.DOWN_1_5_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HAND_USE, 7), ProtocolVersionsHelper.UP_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HAND_USE, 6), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HAND_USE, 5), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HEALTH, 8), ProtocolVersionsHelper.UP_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HEALTH, 7), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.HEALTH, 6), ProtocolVersion.getAllBetween(ProtocolVersion.MINECRAFT_1_9_4, ProtocolVersion.MINECRAFT_1_6_1)); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 9), ProtocolVersionsHelper.UP_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 8), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 7), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 7), ProtocolVersionsHelper.RANGE__1_6__1_8); addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_COLOR, 8), ProtocolVersionsHelper.DOWN_1_5_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 10), ProtocolVersionsHelper.UP_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 9), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 8), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 8), ProtocolVersionsHelper.RANGE__1_6__1_8); addRemap(new IndexValueRemapperBooleanToByte(NetworkEntityMetadataObjectIndex.EntityLiving.POTION_AMBIENT, 9), ProtocolVersionsHelper.DOWN_1_5_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 11), ProtocolVersionsHelper.UP_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 10), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 9), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperNumberToByte(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 9), ProtocolVersionsHelper.RANGE__1_6__1_8); addRemap(new IndexValueRemapperNumberToByte(NetworkEntityMetadataObjectIndex.EntityLiving.ARROWS_IN, 10), ProtocolVersionsHelper.DOWN_1_5_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.ABSORBTION_HEALTH, 12), ProtocolVersionsHelper.UP_1_15); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.BED_LOCATION, 13), ProtocolVersionsHelper.UP_1_15); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.EntityLiving.BED_LOCATION, 12), ProtocolVersionsHelper.ALL_1_14); }
Example #11
Source File: StringSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public static void writeString(ByteBuf to, ProtocolVersion version, String string) { if (isUsingUTF16(version)) { writeShortUTF16BEString(to, string); } else if (isUsingUTF8(version)) { writeVarIntUTF8String(to, string); } else { throw new IllegalArgumentException(MessageFormat.format("Dont know how to write string of version {0}", version)); } }
Example #12
Source File: NetworkEntityMetadataObjectRegistry.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public static int getTypeId(@SuppressWarnings("rawtypes") Class<? extends NetworkEntityMetadataObject> clazz, ProtocolVersion version) { EnumMap<ProtocolVersion, Integer> mmap = registry.get(clazz); if (mmap == null) { throw new IllegalStateException(MessageFormat.format("No type id registry exists for object {0}", clazz)); } Integer id = mmap.get(version); if (id == null) { throw new IllegalArgumentException(MessageFormat.format("No type id exists for object {0} for protocol version {1}", clazz, version)); } return id; }
Example #13
Source File: EnchantToLegacyIdComplexRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public NBTCompound remapTag(ProtocolVersion version, String locale, NetworkItemStack itemstack, NBTCompound tag) { NBTList<NBTCompound> enchTag = tag.getTagListOfType(CommonNBT.MODERN_ENCHANTMENTS, NBTType.COMPOUND); if (enchTag != null) { tag.removeTag(CommonNBT.MODERN_ENCHANTMENTS); tag.setTag(CommonNBT.LEGACY_ENCHANTMENTS, remapEnchantList(enchTag)); } NBTList<NBTCompound> bookEnch = tag.getTagListOfType(CommonNBT.BOOK_ENCHANTMENTS, NBTType.COMPOUND); if (bookEnch != null) { tag.setTag(CommonNBT.BOOK_ENCHANTMENTS, remapEnchantList(bookEnch)); } return tag; }
Example #14
Source File: LegacyChatJsonServerTranslateComponentConverter.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public BaseComponent convert(ProtocolVersion version, String locale, BaseComponent component) { if (component instanceof TranslateComponent) { TranslateComponent tcomponent = (TranslateComponent) component; List<BaseComponent> tlargs = tcomponent.getTranslationArgs(); BaseComponent rootcomponent = cloneComponentAuxData(tcomponent, new TextComponent("")); String translation = TranslationAPI.getTranslationString(locale, tcomponent.getTranslationKey()); Matcher matcher = langFormat.matcher(translation); int index = 0; int tlargindex = 0; while (matcher.find()) { rootcomponent.addSibling(new TextComponent(translation.substring(index, matcher.start()))); index = matcher.end(); if (matcher.group(2).equals("%")) { rootcomponent.addSibling(new TextComponent("%")); } else if (matcher.group(2).equals("s")) { int ltlargindex = tlargindex; if (!matcher.group(1).isEmpty()) { ltlargindex = Integer.parseInt(matcher.group(1)) - 1; } if (tlargindex < tlargs.size()) { rootcomponent.addSibling(tlargs.get(ltlargindex)); } else { rootcomponent.addSibling(new TextComponent("[Invalid traslation argument index]")); } } tlargindex++; } rootcomponent.addSibling(new TextComponent(translation.substring(index))); return rootcomponent; } return component; }
Example #15
Source File: NetworkEntityMetadataObjectOptionalUUID.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public void writeToStream(ByteBuf to, ProtocolVersion version, String locale) { to.writeBoolean(value != null); if (value != null) { UUIDSerializer.writeUUID2L(to, value); } }
Example #16
Source File: SkinPacket.java From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 | 5 votes |
@Override public void readFromClientData(ConnectionImpl connection, ByteBuf clientdata) { ProtocolVersion version = connection.getVersion(); uuid = MiscSerializer.readUUID(clientdata); skinId = StringSerializer.readString(clientdata, version); skinName = StringSerializer.readString(clientdata, version); previousName = StringSerializer.readString(clientdata, version); skinData = ArraySerializer.readVarIntByteArray(clientdata); capeData = ArraySerializer.readVarIntByteArray(clientdata); geometryId = StringSerializer.readString(clientdata, version); geometryData = StringSerializer.readString(clientdata, version); clientdata.readBoolean(); }
Example #17
Source File: SkinPacket.java From ProtocolSupportPocketStuff with GNU Affero General Public License v3.0 | 5 votes |
@Override public void toData(ConnectionImpl connection, ByteBuf serializer) { ProtocolVersion version = connection.getVersion(); MiscSerializer.writePEUUID(serializer, uuid); StringSerializer.writeString(serializer, version, skinId); StringSerializer.writeString(serializer, version, skinName); StringSerializer.writeString(serializer, version, previousName); ArraySerializer.writeVarIntByteArray(serializer, skinData); ArraySerializer.writeVarIntByteArray(serializer, capeData); StringSerializer.writeString(serializer, version, geometryId); StringSerializer.writeString(serializer, version, geometryData); serializer.writeBoolean(false); //premium skin }
Example #18
Source File: MiddleCollectEffect.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public void handleReadData() { //TODO: send needed collect packets from middle packet itself after implementing serverside entity position cache if ( (collectorId == cache.getEntityCache().getSelfId()) && (version.getProtocolType() == ProtocolType.PC) && version.isBefore(ProtocolVersion.MINECRAFT_1_9) ) { Player player = connection.getPlayer(); NetworkEntity entity = cache.getEntityCache().getEntity(entityId); if ((entity != null) && (player != null)) { switch (entity.getType()) { case ITEM: { player.playSound( player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.2F, (((ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.7F) + 1.0F) * 2.0F ); break; } case EXP_ORB: { player.playSound( player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.2F, (((ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.7F) + 1.0F) * 2.0F ); break; } default: { break; } } } } }
Example #19
Source File: BattleHorseEntityMetadataRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
protected BattleHorseEntityMetadataRemapper() { addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.VARIANT, 18), ProtocolVersionsHelper.UP_1_15); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.VARIANT, 17), ProtocolVersionsHelper.ALL_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.VARIANT, 15), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.VARIANT, 14), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.BattleHorse.VARIANT, 20), ProtocolVersionsHelper.DOWN_1_8); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.ARMOR, 19), ProtocolVersionsHelper.UP_1_15); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.ARMOR, 18), ProtocolVersionsHelper.ALL_1_14); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.ARMOR, 16), ProtocolVersionsHelper.RANGE__1_10__1_13_2); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.ARMOR, 17), ProtocolVersion.MINECRAFT_1_10); addRemap(new IndexValueRemapperNoOp(NetworkEntityMetadataObjectIndex.BattleHorse.ARMOR, 16), ProtocolVersionsHelper.ALL_1_9); addRemap(new IndexValueRemapperNumberToInt(NetworkEntityMetadataObjectIndex.BattleHorse.ARMOR, 22), ProtocolVersionsHelper.DOWN_1_8); }
Example #20
Source File: TileEntityRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
protected static void register(TileEntityType type, Consumer<TileEntity> transformer, ProtocolVersion... versions) { for (ProtocolVersion version : versions) { tileEntityRemappers.get(version).tileToTile .computeIfAbsent(type, k -> new ArrayList<>()) .add((tile, blockdata) -> transformer.accept(tile)); } }
Example #21
Source File: WorldCustomSound.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public static ClientBoundPacketData create( ProtocolVersion version, int x, int y, int z, String sound, SoundCategory category, float volume, float pitch ) { ClientBoundPacketData worldcustomsound = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_WORLD_CUSTOM_SOUND); StringSerializer.writeVarIntUTF8String(worldcustomsound, SoundRemapper.getSoundName(version, sound)); MiscSerializer.writeVarIntEnum(worldcustomsound, category); worldcustomsound.writeInt(x); worldcustomsound.writeInt(y); worldcustomsound.writeInt(z); worldcustomsound.writeFloat(volume); worldcustomsound.writeByte((int) (pitch * 63.5)); return worldcustomsound; }
Example #22
Source File: EntityEquipment.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public static ClientBoundPacketData create( ProtocolVersion version, String locale, int entityId, Slot slot, NetworkItemStack itemstack ) { ClientBoundPacketData entityequipment = ClientBoundPacketData.create(PacketType.CLIENTBOUND_PLAY_ENTITY_EQUIPMENT); VarNumberSerializer.writeVarInt(entityequipment, entityId); MiscSerializer.writeVarIntEnum(entityequipment, slot); ItemStackSerializer.writeItemStack(entityequipment, version, locale, itemstack); return entityequipment; }
Example #23
Source File: EnchantFromLegacyIdComplexRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public NBTCompound remapTag(ProtocolVersion version, String locale, NetworkItemStack itemstack, NBTCompound tag) { NBTList<NBTCompound> enchTag = tag.getTagListOfType(CommonNBT.LEGACY_ENCHANTMENTS, NBTType.COMPOUND); if (enchTag != null) { tag.removeTag(CommonNBT.LEGACY_ENCHANTMENTS); tag.setTag(CommonNBT.MODERN_ENCHANTMENTS, remapEnchantList(enchTag)); } NBTList<NBTCompound> bookEnch = tag.getTagListOfType(CommonNBT.BOOK_ENCHANTMENTS, NBTType.COMPOUND); if (bookEnch != null) { tag.setTag(CommonNBT.BOOK_ENCHANTMENTS, remapEnchantList(bookEnch)); } return tag; }
Example #24
Source File: MapFromLegacyIdComplexRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public NetworkItemStack remap(ProtocolVersion version, String locale, NetworkItemStack itemstack) { NBTCompound tag = itemstack.getNBT(); if (tag == null) { tag = new NBTCompound(); itemstack.setNBT(tag); } tag.setTag(CommonNBT.MAP_ID, new NBTInt(itemstack.getLegacyData())); return itemstack; }
Example #25
Source File: SimpleTypeSerializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public BiConsumer<ByteBuf, T> get(ProtocolVersion version) { BiConsumer<ByteBuf, T> serializer = entries.get(version); if (serializer == null) { throw new IllegalArgumentException(MessageFormat.format("Don''t know how to serialize type for protocol version {0}", version)); } return entries.get(version); }
Example #26
Source File: MapToLegacyIdComplexRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public NetworkItemStack remap(ProtocolVersion version, String locale, NetworkItemStack itemstack) { NBTNumber mapId; if ((itemstack.getNBT() != null) && ((mapId = itemstack.getNBT().getNumberTag(CommonNBT.MAP_ID)) != null)) { itemstack.setLegacyData(mapId.getAsInt()); } return itemstack; }
Example #27
Source File: DragonHeadToDragonPlayerHeadComplexRemapper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override public NetworkItemStack remap(ProtocolVersion version, String locale, NetworkItemStack itemstack) { itemstack.setTypeId(ItemMaterialLookup.getRuntimeId(Material.PLAYER_HEAD)); NBTCompound wrapper = new NBTCompound(); wrapper.setTag("SkullOwner", createTag()); itemstack.setNBT(wrapper); return itemstack; }
Example #28
Source File: ItemStackWriteEventHelper.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public static void callEvent(ProtocolVersion version, String locale, NetworkItemStack itemstack) { if (ItemStackWriteEvent.getHandlerList().getRegisteredListeners().length > 0) { ItemStackWriteEvent event = new ItemStackWriteEvent(version, locale, new WrappedNetworkItemStack(itemstack)); Bukkit.getPluginManager().callEvent(event); List<String> additionalLore = event.getAdditionalLore(); BaseComponent forcedDisplayName = event.getForcedDisplayName(); if ((forcedDisplayName != null) || !additionalLore.isEmpty()) { NBTCompound rootTag = CommonNBT.getOrCreateRootTag(itemstack); NBTCompound displayNBT = CommonNBT.getOrCreateDisplayTag(rootTag); if (forcedDisplayName != null) { displayNBT.setTag(CommonNBT.DISPLAY_NAME, new NBTString(ChatAPI.toJSON(LegacyChatJson.convert(version, locale, forcedDisplayName)))); } if (!additionalLore.isEmpty()) { NBTList<NBTString> loreNBT = displayNBT.getTagListOfType(CommonNBT.DISPLAY_LORE, NBTType.STRING); if (loreNBT == null) { loreNBT = new NBTList<>(NBTType.STRING); } for (String lore : additionalLore) { loreNBT.addTag(new NBTString(ChatAPI.toJSON(new TextComponent(lore)))); } displayNBT.setTag(CommonNBT.DISPLAY_LORE, loreNBT); } } } }
Example #29
Source File: UpdateSign.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void readClientData(ByteBuf clientdata) { PositionSerializer.readPositionTo(clientdata, position); for (int i = 0; i < lines.length; i++) { String rawline = StringSerializer.readVarIntUTF8String(clientdata, Short.MAX_VALUE); lines[i] = version.isAfter(ProtocolVersion.MINECRAFT_1_8) ? rawline : ChatAPI.fromJSON(rawline).toLegacyText(cache.getClientCache().getLocale()); } }
Example #30
Source File: SimpleTypeDeserializer.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
public Function<ByteBuf, T> get(ProtocolVersion version) { Function<ByteBuf, T> serializer = entries.get(version); if (serializer == null) { throw new IllegalArgumentException(MessageFormat.format("Don''t know how to deserialize type for protocol version {0}", version)); } return entries.get(version); }