us.myles.ViaVersion.api.protocol.Protocol Java Examples

The following examples show how to use us.myles.ViaVersion.api.protocol.Protocol. 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: BungeeServerHandler.java    From ViaVersion with MIT License 6 votes vote down vote up
@EventHandler(priority = 120)
public void onServerConnect(ServerConnectEvent e) {
    if (e.isCancelled()) {
        return;
    }

    UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId());
    if (user == null) return;
    if (!user.has(BungeeStorage.class)) {
        user.put(new BungeeStorage(user, e.getPlayer()));
    }

    int protocolId = ProtocolDetectorService.getProtocolId(e.getTarget().getName());
    List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.getProtocolInfo().getProtocolVersion(), protocolId);

    // Check if ViaVersion can support that version
    try {
        //Object pendingConnection = getPendingConnection.invoke(e.getPlayer());
        Object handshake = getHandshake.invoke(e.getPlayer().getPendingConnection());
        setProtocol.invoke(handshake, protocols == null ? user.getProtocolInfo().getProtocolVersion() : protocolId);
    } catch (InvocationTargetException | IllegalAccessException e1) {
        e1.printStackTrace();
    }
}
 
Example #2
Source File: TranslationMappings.java    From ViaVersion with MIT License 6 votes vote down vote up
public TranslationMappings(Protocol protocol) {
    super(protocol);
    mappings.put("block.minecraft.flowing_water", "Flowing Water");
    mappings.put("block.minecraft.flowing_lava", "Flowing Lava");
    mappings.put("block.minecraft.bed", "Bed");
    mappings.put("block.minecraft.bed.not_valid", "Your home bed was missing or obstructed");
    mappings.put("block.minecraft.bed.set_spawn", "Respawn point set");
    mappings.put("block.minecraft.two_turtle_eggs", "Two Turtle Eggs");
    mappings.put("block.minecraft.three_turtle_eggs", "Three Turtle Eggs");
    mappings.put("block.minecraft.four_turtle_eggs", "Four Turtle Eggs");
    mappings.put("block.minecraft.banner", "Banner");
    mappings.put("block.minecraft.wall_banner", "Wall Banner");
    mappings.put("item.minecraft.zombie_pigman_spawn_egg", "Zombie Pigman Spawn Egg");
    mappings.put("item.minecraft.skeleton_skull", "Skeleton Skull");
    mappings.put("item.minecraft.wither_skeleton_skull", "Wither Skeleton Skull");
    mappings.put("item.minecraft.zombie_head", "Zombie Head");
    mappings.put("item.minecraft.creeper_head", "Creeper Head");
    mappings.put("item.minecraft.dragon_head", "Dragon Head");
    mappings.put("entity.minecraft.zombie_pigman", "Zombie Pigman");
    mappings.put("death.fell.accident.water", "%1$s fell out of the water");
    mappings.put("death.attack.netherBed.message", "%1$s was killed by %2$s");
    mappings.put("death.attack.netherBed.link", "Intentional Game Design");
    mappings.put("advancements.husbandry.break_diamond_hoe.title", "Serious Dedication");
    mappings.put("advancements.husbandry.break_diamond_hoe.description", "Completely use up a diamond hoe, and then reevaluate your life choices");
    mappings.put("biome.minecraft.nether", "Nether");
}
 
Example #3
Source File: VelocityServerHandler.java    From ViaVersion with MIT License 6 votes vote down vote up
@Subscribe
public void preServerConnect(ServerPreConnectEvent e) {
    try {
        UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId());
        if (user == null) return;
        if (!user.has(VelocityStorage.class)) {
            user.put(new VelocityStorage(user, e.getPlayer()));
        }

        int protocolId = ProtocolDetectorService.getProtocolId(e.getOriginalServer().getServerInfo().getName());
        List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.getProtocolInfo().getProtocolVersion(), protocolId);

        // Check if ViaVersion can support that version
        Object connection = getMinecraftConnection.invoke(e.getPlayer());
        setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
                ? user.getProtocolInfo().getProtocolVersion()
                : protocolId));

    } catch (IllegalAccessException | InvocationTargetException e1) {
        e1.printStackTrace();
    }
}
 
Example #4
Source File: WorldPackets.java    From ViaVersion with MIT License 6 votes vote down vote up
public static void register(Protocol protocol) {
    protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
        @Override
        public void registerMap() {
            map(Type.INT); // 0 - Particle ID
            map(Type.BOOLEAN); // 1 - Long Distance
            map(Type.FLOAT); // 2 - X
            map(Type.FLOAT); // 3 - Y
            map(Type.FLOAT); // 4 - Z
            map(Type.FLOAT); // 5 - Offset X
            map(Type.FLOAT); // 6 - Offset Y
            map(Type.FLOAT); // 7 - Offset Z
            map(Type.FLOAT); // 8 - Particle Data
            map(Type.INT); // 9 - Particle Count
            handler(new PacketHandler() {
                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int id = wrapper.get(Type.INT, 0);
                    if (id == 27) {
                        wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
                    }
                }
            });
        }
    });
}
 
Example #5
Source File: PacketWrapper.java    From ViaVersion with MIT License 5 votes vote down vote up
/**
 * 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
 * @param currentThread       Run in the same thread
 * @throws Exception if it fails to write
 */
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
    if (!isCancelled()) {
        try {
            ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline, Direction.OUTGOING);
            user().sendRawPacket(output, currentThread);
        } catch (Exception e) {
            if (!PipelineUtil.containsCause(e, CancelException.class)) {
                throw e;
            }
        }
    }
}
 
Example #6
Source File: ScoreboardPackets.java    From ViaRewind with MIT License 5 votes vote down vote up
public static void register(Protocol protocol) {
	/*  OUTGOING  */

	//Display Scoreboard
	protocol.registerOutgoing(State.PLAY, 0x38, 0x3D);

	//Scoreboard Objective
	protocol.registerOutgoing(State.PLAY, 0x3F, 0x3B);

	//Scoreboard Team
	protocol.registerOutgoing(State.PLAY, 0x41, 0x3E, new PacketRemapper() {
		@Override
		public void registerMap() {
			map(Type.STRING);
			map(Type.BYTE);
			handler(new PacketHandler() {
				@Override
				public void handle(PacketWrapper packetWrapper) throws Exception {
					byte mode = packetWrapper.get(Type.BYTE, 0);
					if (mode == 0 || mode == 2) {
						packetWrapper.passthrough(Type.STRING);  //Display Name
						packetWrapper.passthrough(Type.STRING);  //Prefix
						packetWrapper.passthrough(Type.STRING);  //Suffix
						packetWrapper.passthrough(Type.BYTE);  //Friendly Flags
						packetWrapper.passthrough(Type.STRING);  //Name Tag Visibility
						packetWrapper.read(Type.STRING);  //Skip Collision Rule
						packetWrapper.passthrough(Type.BYTE);  //Friendly Flags
					}

					if (mode == 0 || mode == 3 || mode == 4) {
						packetWrapper.passthrough(Type.STRING_ARRAY);
					}
				}
			});
		}
	});

	//Update Score
	protocol.registerOutgoing(State.PLAY, 0x42, 0x3C);
}
 
Example #7
Source File: PacketUtil.java    From ViaRewind with MIT License 5 votes vote down vote up
public static void sendToServer(PacketWrapper packet, Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) {
	try {
		packet.sendToServer(packetProtocol, skipCurrentPipeline, currentThread);
	} catch (CancelException ignored) {
		;
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
Example #8
Source File: WorldPackets1_13_1.java    From ViaBackwards with MIT License 5 votes vote down vote up
public static void register(Protocol protocol) {
    BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13To1_13_1::getNewBlockStateId, Protocol1_13To1_13_1::getNewBlockId);

    protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
        @Override
        public void registerMap() {
            handler(new PacketHandler() {
                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                    Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld));

                    for (ChunkSection section : chunk.getSections()) {
                        if (section != null) {
                            for (int i = 0; i < section.getPaletteSize(); i++) {
                                section.setPaletteEntry(i, Protocol1_13To1_13_1.getNewBlockStateId(section.getPaletteEntry(i)));
                            }
                        }
                    }
                }
            });
        }
    });

    blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
    blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
    blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
    blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets1_13_1::getOldItemId);
    blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets1_13_1::toClient, Type.FLAT_ITEM, Type.FLOAT);
}
 
Example #9
Source File: PacketWrapper.java    From ViaVersion with MIT License 5 votes vote down vote up
/**
 * Let the packet go through the protocol pipes and write it to ByteBuf
 *
 * @param packetProtocol      The protocol version of the packet.
 * @param skipCurrentPipeline Skip the current pipeline
 * @return Packet buffer
 * @throws Exception if it fails to write
 */
private ByteBuf constructPacket(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, Direction direction) throws Exception {
    // Apply current pipeline
    List<Protocol> protocols = new ArrayList<>(user().getProtocolInfo().getPipeline().pipes());
    if (direction == Direction.OUTGOING) {
        // Other way if outgoing
        Collections.reverse(protocols);
    }
    int index = -1;
    for (int i = 0; i < protocols.size(); i++) {
        if (protocols.get(i).getClass().equals(packetProtocol)) {
            index = skipCurrentPipeline ? (i + 1) : (i);
            break;
        }
    }
    if (index == -1) throw new NoSuchElementException(packetProtocol.getCanonicalName());

    // Reset reader before we start
    resetReader();

    // Apply other protocols
    apply(direction, user().getProtocolInfo().getState(), index, protocols);
    // Send
    ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
    writeToBuffer(output);

    return output;
}
 
Example #10
Source File: PacketUtil.java    From ViaRewind with MIT License 5 votes vote down vote up
public static boolean sendPacket(PacketWrapper packet, Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) {
	try {
		packet.send(packetProtocol, skipCurrentPipeline, currentThread);
		return true;
	} catch (CancelException ignored) {
		;
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return false;
}
 
Example #11
Source File: PacketWrapper.java    From ViaVersion with MIT License 5 votes vote down vote up
/**
 * Send this packet to the server.
 *
 * @param packetProtocol      The protocol version of the packet.
 * @param skipCurrentPipeline Skip the current pipeline
 * @param currentThread       Run in the same thread
 * @throws Exception if it fails to write
 */
public void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
    if (!isCancelled()) {
        try {
            ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline, Direction.INCOMING);
            user().sendRawPacketToServer(output, currentThread);
        } catch (Exception e) {
            if (!PipelineUtil.containsCause(e, CancelException.class)) {
                throw e;
            }
        }
    }
}
 
Example #12
Source File: ComponentRewriter1_14.java    From ViaVersion with MIT License 4 votes vote down vote up
public ComponentRewriter1_14(Protocol protocol) {
    super(protocol);
}
 
Example #13
Source File: PacketWrapper.java    From ViaVersion with MIT License 4 votes vote down vote up
public void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
    sendToServer(packetProtocol, skipCurrentPipeline, false);
}
 
Example #14
Source File: PacketWrapper.java    From ViaVersion with MIT License 4 votes vote down vote up
public void sendToServer(Class<? extends Protocol> packetProtocol) throws Exception {
    sendToServer(packetProtocol, true);
}
 
Example #15
Source File: BaseProtocol.java    From ViaVersion with MIT License 4 votes vote down vote up
@Override
protected void registerPackets() {
    /* Incoming Packets */

    // Handshake Packet
    registerIncoming(State.HANDSHAKE, 0x00, 0x00, new PacketRemapper() {
        @Override
        public void registerMap() {
            // select right protocol
            map(Type.VAR_INT); // 0 - Client Protocol Version
            map(Type.STRING); // 1 - Server Address
            map(Type.UNSIGNED_SHORT); // 2 - Server Port
            map(Type.VAR_INT); // 3 - Next State
            handler(new PacketHandler() {
                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    int protVer = wrapper.get(Type.VAR_INT, 0);
                    int state = wrapper.get(Type.VAR_INT, 1);

                    ProtocolInfo info = wrapper.user().getProtocolInfo();
                    info.setProtocolVersion(protVer);
                    // Ensure the server has a version provider
                    if (Via.getManager().getProviders().get(VersionProvider.class) == null) {
                        wrapper.user().setActive(false);
                        return;
                    }
                    // Choose the pipe
                    int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
                    info.setServerProtocolVersion(protocol);
                    List<Pair<Integer, Protocol>> protocols = null;

                    // Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
                    if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
                        protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
                    }

                    ProtocolPipeline pipeline = wrapper.user().getProtocolInfo().getPipeline();
                    if (protocols != null) {
                        for (Pair<Integer, Protocol> prot : protocols) {
                            pipeline.add(prot.getValue());
                            // Ensure mapping data has already been loaded
                            ProtocolRegistry.completeMappingDataLoading(prot.getValue().getClass());
                        }
                        wrapper.set(Type.VAR_INT, 0, protocol);
                    }

                    // Add Base Protocol
                    pipeline.add(ProtocolRegistry.getBaseProtocol(protocol));

                    // Change state
                    if (state == 1) {
                        info.setState(State.STATUS);
                    }
                    if (state == 2) {
                        info.setState(State.LOGIN);
                    }
                }
            });
        }
    });
}
 
Example #16
Source File: EntityPackets.java    From ViaVersion with MIT License 4 votes vote down vote up
public static void register(Protocol protocol) {
    final PacketHandler metaTypeHandler = wrapper -> {
        for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
            metadata.setMetaType(MetaType1_13_2.byId(metadata.getMetaType().getTypeID()));
        }
    };

    protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
        @Override
        public void registerMap() {
            map(Type.VAR_INT); // 0 - Entity ID
            map(Type.UUID); // 1 - Entity UUID
            map(Type.VAR_INT); // 2 - Entity Type
            map(Type.DOUBLE); // 3 - X
            map(Type.DOUBLE); // 4 - Y
            map(Type.DOUBLE); // 5 - Z
            map(Type.BYTE); // 6 - Yaw
            map(Type.BYTE); // 7 - Pitch
            map(Type.BYTE); // 8 - Head Pitch
            map(Type.SHORT); // 9 - Velocity X
            map(Type.SHORT); // 10 - Velocity Y
            map(Type.SHORT); // 11 - Velocity Z
            map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata

            handler(metaTypeHandler);
        }
    });

    protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
        @Override
        public void registerMap() {
            map(Type.VAR_INT); // 0 - Entity ID
            map(Type.UUID); // 1 - Player UUID
            map(Type.DOUBLE); // 2 - X
            map(Type.DOUBLE); // 3 - Y
            map(Type.DOUBLE); // 4 - Z
            map(Type.BYTE); // 5 - Yaw
            map(Type.BYTE); // 6 - Pitch
            map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata

            handler(metaTypeHandler);
        }
    });

    protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_METADATA, new PacketRemapper() {
        @Override
        public void registerMap() {
            map(Type.VAR_INT); // 0 - Entity ID
            map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list

            handler(metaTypeHandler);
        }
    });
}
 
Example #17
Source File: ViaListener.java    From ViaVersion with MIT License 4 votes vote down vote up
protected Class<? extends Protocol> getRequiredPipeline() {
    return requiredPipeline;
}
 
Example #18
Source File: WorldPackets.java    From ViaVersion with MIT License 4 votes vote down vote up
public static void register(Protocol protocol) {
    BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16To1_15_2::getNewBlockStateId, Protocol1_16To1_15_2::getNewBlockId);

    blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
    blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
    blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
    blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);

    protocol.registerOutgoing(ClientboundPackets1_15.UPDATE_LIGHT, new PacketRemapper() {
        @Override
        public void registerMap() {
            map(Type.VAR_INT); // x
            map(Type.VAR_INT); // y
            handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well
        }
    });

    protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
        @Override
        public void registerMap() {
            handler(wrapper -> {
                ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
                Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
                wrapper.write(new Chunk1_16Type(clientWorld), chunk);

                chunk.setIgnoreOldLightData(chunk.isFullChunk());

                for (int s = 0; s < 16; s++) {
                    ChunkSection section = chunk.getSections()[s];
                    if (section == null) continue;
                    for (int i = 0; i < section.getPaletteSize(); i++) {
                        int old = section.getPaletteEntry(i);
                        section.setPaletteEntry(i, Protocol1_16To1_15_2.getNewBlockStateId(old));
                    }
                }

                CompoundTag heightMaps = chunk.getHeightMap();
                for (Tag heightMapTag : heightMaps) {
                    LongArrayTag heightMap = (LongArrayTag) heightMapTag;
                    int[] heightMapData = new int[256];
                    CompactArrayUtil.iterateCompactArray(9, heightMapData.length, heightMap.getValue(), (i, v) -> heightMapData[i] = v);
                    heightMap.setValue(CompactArrayUtil.createCompactArrayWithPadding(9, heightMapData.length, i -> heightMapData[i]));
                }

                if (chunk.getBlockEntities() == null) return;
                for (CompoundTag blockEntity : chunk.getBlockEntities()) {
                    handleBlockEntity(blockEntity);
                }
            });
        }
    });

    protocol.registerOutgoing(ClientboundPackets1_15.BLOCK_ENTITY_DATA, new PacketRemapper() {
        @Override
        public void registerMap() {
            handler(wrapper -> {
                Position position = wrapper.passthrough(Type.POSITION1_14);
                short action = wrapper.passthrough(Type.UNSIGNED_BYTE);
                CompoundTag tag = wrapper.passthrough(Type.NBT);
                handleBlockEntity(tag);
            });
        }
    });

    blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
    blockRewriter.registerSpawnParticle(ClientboundPackets1_15.SPAWN_PARTICLE, 3, 23, 32,
            WorldPackets::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
}
 
Example #19
Source File: ComponentRewriter1_13.java    From ViaVersion with MIT License 4 votes vote down vote up
public ComponentRewriter1_13(Protocol protocol) {
    super(protocol);
}
 
Example #20
Source File: InventoryPackets1_13_1.java    From ViaBackwards with MIT License 4 votes vote down vote up
public static void register(Protocol protocol) {
    ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets1_13_1::toClient, InventoryPackets1_13_1::toServer);

    itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets1_13_1::getOldItemId);
    itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
    itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);

    protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
        @Override
        public void registerMap() {
            handler(new PacketHandler() {
                @Override
                public void handle(PacketWrapper wrapper) throws Exception {
                    String channel = wrapper.passthrough(Type.STRING);
                    if (channel.equals("minecraft:trader_list")) {
                        wrapper.passthrough(Type.INT); //Passthrough Window ID

                        int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
                        for (int i = 0; i < size; i++) {
                            //Input Item
                            Item input = wrapper.passthrough(Type.FLAT_ITEM);
                            toClient(input);
                            //Output Item
                            Item output = wrapper.passthrough(Type.FLAT_ITEM);
                            toClient(output);

                            boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
                            if (secondItem) {
                                //Second Item
                                Item second = wrapper.passthrough(Type.FLAT_ITEM);
                                toClient(second);
                            }

                            wrapper.passthrough(Type.BOOLEAN); //Trade disabled
                            wrapper.passthrough(Type.INT); //Number of tools uses
                            wrapper.passthrough(Type.INT); //Maximum number of trade uses
                        }
                    }
                }
            });
        }
    });

    itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
    itemRewriter.registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_ITEM);
    itemRewriter.registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_ITEM);
}
 
Example #21
Source File: BackwardsProtocol.java    From ViaBackwards with MIT License 4 votes vote down vote up
/**
 * Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
 */
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
    ProtocolRegistry.addMappingLoaderFuture(getClass(), protocolClass, runnable);
}
 
Example #22
Source File: SoundRewriter.java    From ViaVersion with MIT License 4 votes vote down vote up
public SoundRewriter(Protocol protocol, IdRewriteFunction idRewriter) {
    this.protocol = protocol;
    this.idRewriter = idRewriter;
}
 
Example #23
Source File: PacketUtil.java    From ViaRewind with MIT License 4 votes vote down vote up
public static void sendToServer(PacketWrapper packet, Class<? extends Protocol> packetProtocol) {
	sendToServer(packet, packetProtocol, true);
}
 
Example #24
Source File: PacketUtil.java    From ViaRewind with MIT License 4 votes vote down vote up
public static void sendToServer(PacketWrapper packet, Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) {
	sendToServer(packet, packetProtocol, skipCurrentPipeline, false);
}
 
Example #25
Source File: PacketUtil.java    From ViaRewind with MIT License 4 votes vote down vote up
public static boolean sendPacket(PacketWrapper packet, Class<? extends Protocol> packetProtocol) {
	return sendPacket(packet, packetProtocol, true);
}
 
Example #26
Source File: PacketUtil.java    From ViaRewind with MIT License 4 votes vote down vote up
public static boolean sendPacket(PacketWrapper packet, Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) {
	return sendPacket(packet, packetProtocol, true, false);
}
 
Example #27
Source File: ViaSpongeListener.java    From ViaVersion with MIT License 4 votes vote down vote up
public ViaSpongeListener(SpongePlugin plugin, Class<? extends Protocol> requiredPipeline) {
    super(requiredPipeline);
    this.plugin = plugin;
}
 
Example #28
Source File: ViaBukkitListener.java    From ViaVersion with MIT License 4 votes vote down vote up
public ViaBukkitListener(Plugin plugin, Class<? extends Protocol> requiredPipeline) {
    super(requiredPipeline);
    this.plugin = plugin;
}
 
Example #29
Source File: BlockRewriter.java    From ViaVersion with MIT License 4 votes vote down vote up
public BlockRewriter(Protocol protocol, Type<Position> positionType, IdRewriteFunction blockStateRewriter, IdRewriteFunction blockRewriter) {
    this.protocol = protocol;
    this.positionType = positionType;
    this.blockStateRewriter = blockStateRewriter;
    this.blockRewriter = blockRewriter;
}
 
Example #30
Source File: ItemRewriter.java    From ViaVersion with MIT License 4 votes vote down vote up
public ItemRewriter(Protocol protocol, RewriteFunction toClient, RewriteFunction toServer) {
    this.protocol = protocol;
    this.toClient = toClient;
    this.toServer = toServer;
}