3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Minor change to rewriter register

Dieser Commit ist enthalten in:
KennyTV 2020-01-16 17:12:25 +01:00
Ursprung b00ae1b701
Commit 80ef8a401d
38 geänderte Dateien mit 241 neuen und 136 gelöschten Zeilen

Datei anzeigen

@ -38,10 +38,9 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
protected String nbtTagName;
protected boolean jsonNameFormat = true;
@Override
public void register(T protocol) {
protected BlockItemRewriter(T protocol) {
super(protocol);
nbtTagName = "ViaBackwards|" + protocol.getClass().getSimpleName();
super.register(protocol);
}
protected BlockItemSettings rewrite(int itemId) {

Datei anzeigen

@ -10,7 +10,6 @@
package nl.matsv.viabackwards.api.rewriters;
import lombok.RequiredArgsConstructor;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.meta.MetaHandlerEvent;
@ -42,7 +41,6 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
@RequiredArgsConstructor
public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
private final Map<EntityType, EntityData> entityTypes = new ConcurrentHashMap<>();
private final Map<ObjectType, EntityData> objectTypes = new ConcurrentHashMap<>();
@ -52,6 +50,10 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
private int displayNameIndex = 2;
private boolean isDisplayNameJson;
protected EntityRewriter(T protocol) {
super(protocol);
}
protected EntityType getEntityType(UserConnection connection, int id) {
return getEntityTracker(connection).getEntityType(id);
}

Datei anzeigen

@ -13,28 +13,27 @@ package nl.matsv.viabackwards.api.rewriters;
import nl.matsv.viabackwards.api.BackwardsProtocol;
public abstract class Rewriter<T extends BackwardsProtocol> {
protected T protocol;
protected final T protocol;
protected Rewriter(final T protocol) {
this.protocol = protocol;
}
/**
* Register everything
*
* @param protocol Protocol instance
* Register everything.
*/
public void register(T protocol) {
this.protocol = protocol;
registerPackets(protocol);
public void register() {
registerPackets();
registerRewrites();
}
/**
* Register packet listeners
*
* @param protocol Protocol instance
* Register packet listeners.
*/
protected abstract void registerPackets(T protocol);
protected abstract void registerPackets();
/**
* Register rewrites
* Register rewrites.
*/
protected abstract void registerRewrites();

Datei anzeigen

@ -20,6 +20,10 @@ import java.util.Map;
public abstract class SoundRewriter<T extends BackwardsProtocol> extends Rewriter<T> {
private final Map<Integer, SoundData> soundRewrites = new HashMap<>();
protected SoundRewriter(T protocol) {
super(protocol);
}
public SoundData added(int id, int replacement) {
return added(id, replacement, -1);
}

Datei anzeigen

@ -29,10 +29,10 @@ public class Protocol1_10To1_11 extends BackwardsProtocol {
@Override
protected void registerPackets() {
(entityPackets = new EntityPackets1_11()).register(this);
(entityPackets = new EntityPackets1_11(this)).register();
new PlayerPackets1_11().register(this);
(blockItemPackets = new BlockItemPackets1_11()).register(this);
new SoundPackets1_11().register(this);
(blockItemPackets = new BlockItemPackets1_11(this)).register();
new SoundPackets1_11(this).register();
}
@Override

Datei anzeigen

@ -45,8 +45,12 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
private LegacyEnchantmentRewriter enchantmentRewriter;
public BlockItemPackets1_11(Protocol1_10To1_11 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_10To1_11 protocol) {
protected void registerPackets() {
jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);

Datei anzeigen

@ -35,8 +35,12 @@ import java.util.Optional;
public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
public EntityPackets1_11(Protocol1_10To1_11 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_10To1_11 protocol) {
protected void registerPackets() {
// Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override

Datei anzeigen

@ -19,8 +19,13 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class SoundPackets1_11 extends SoundRewriter<Protocol1_10To1_11> {
public SoundPackets1_11(Protocol1_10To1_11 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_10To1_11 protocol) {
protected void registerPackets() {
// Named sound effect
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override

Datei anzeigen

@ -25,11 +25,11 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol {
@Override
protected void registerPackets() {
new ChangedPacketIds1_12().register(this);
(entityPackets = new EntityPackets1_12()).register(this);
(blockItemPackets = new BlockItemPackets1_12()).register(this);
new SoundPackets1_12().register(this);
new ChatPackets1_12().register(this);
new ChangedPacketIds1_12(this).register();
(entityPackets = new EntityPackets1_12(this)).register();
(blockItemPackets = new BlockItemPackets1_12(this)).register();
new SoundPackets1_12(this).register();
new ChatPackets1_12(this).register();
}
@Override

Datei anzeigen

@ -34,8 +34,12 @@ import java.util.Collections;
public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12> {
public BlockItemPackets1_12(Protocol1_11_1To1_12 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
protected void registerPackets() {
jsonNameFormat = false;
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
@Override

Datei anzeigen

@ -12,89 +12,90 @@ package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
import nl.matsv.viabackwards.api.rewriters.Rewriter;
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.packets.State;
public class ChangedPacketIds1_12 extends Rewriter<Protocol1_11_1To1_12> {
@Override
protected void registerPackets(Protocol1_11_1To1_12 p) {
p.registerOutgoing(State.PLAY, 0x25, 0x28); // Entity
p.registerOutgoing(State.PLAY, 0x26, 0x25); // Entity Relative Move
p.registerOutgoing(State.PLAY, 0x27, 0x26); // Entity Look and Relative Move
p.registerOutgoing(State.PLAY, 0x28, 0x27); // Entity Look
public ChangedPacketIds1_12(Protocol1_11_1To1_12 protocol) {
super(protocol);
}
p.cancelOutgoing(State.PLAY, 0x30); // Unlock Recipes
@Override
protected void registerPackets() {
protocol.registerOutgoing(State.PLAY, 0x25, 0x28); // Entity
protocol.registerOutgoing(State.PLAY, 0x26, 0x25); // Entity Relative Move
protocol.registerOutgoing(State.PLAY, 0x27, 0x26); // Entity Look and Relative Move
protocol.registerOutgoing(State.PLAY, 0x28, 0x27); // Entity Look
protocol.cancelOutgoing(State.PLAY, 0x30); // Unlock Recipes
// 0x31 -> 0x30 Destroy Entities handled in EntityPackets1_12.java
p.registerOutgoing(State.PLAY, 0x32, 0x31); // Remove Entity Effect
p.registerOutgoing(State.PLAY, 0x33, 0x32); // Resource Pack Send
protocol.registerOutgoing(State.PLAY, 0x32, 0x31); // Remove Entity Effect
protocol.registerOutgoing(State.PLAY, 0x33, 0x32); // Resource Pack Send
// 0x34 -> 0x33 Respawn handled in EntityPackets1_12.java
p.registerOutgoing(State.PLAY, 0x35, 0x34); // Entity Head Look
protocol.registerOutgoing(State.PLAY, 0x35, 0x34); // Entity Head Look
p.cancelOutgoing(State.PLAY, 0x36); // Advancement Progress
protocol.cancelOutgoing(State.PLAY, 0x36); // Advancement Progress
p.registerOutgoing(State.PLAY, 0x37, 0x35); // World Border
p.registerOutgoing(State.PLAY, 0x38, 0x36); //Camera
p.registerOutgoing(State.PLAY, 0x39, 0x37); // Held Item Change (ClientBound)
p.registerOutgoing(State.PLAY, 0x3A, 0x38); // Display Scoreboard
protocol.registerOutgoing(State.PLAY, 0x37, 0x35); // World Border
protocol.registerOutgoing(State.PLAY, 0x38, 0x36); //Camera
protocol.registerOutgoing(State.PLAY, 0x39, 0x37); // Held Item Change (ClientBound)
protocol.registerOutgoing(State.PLAY, 0x3A, 0x38); // Display Scoreboard
// 0x3B -> 0x39 Entity Metadata handled in EntityPackets1_12.java
p.registerOutgoing(State.PLAY, 0x3C, 0x3A); // Attach Entity
p.registerOutgoing(State.PLAY, 0x3D, 0x3B); // Entity Velocity
protocol.registerOutgoing(State.PLAY, 0x3C, 0x3A); // Attach Entity
protocol.registerOutgoing(State.PLAY, 0x3D, 0x3B); // Entity Velocity
// 0x3E -> 0x3C Entity Equipment handled in BlockItemPackets1_12.java
p.registerOutgoing(State.PLAY, 0x3F, 0x3D); // Set Experience
p.registerOutgoing(State.PLAY, 0x40, 0x3E); // Update Health
p.registerOutgoing(State.PLAY, 0x41, 0x3F); // ScoreBoard Objective
p.registerOutgoing(State.PLAY, 0x42, 0x40); // Set Passengers
p.registerOutgoing(State.PLAY, 0x43, 0x41); // Teams
p.registerOutgoing(State.PLAY, 0x44, 0x42); // Update Score
p.registerOutgoing(State.PLAY, 0x45, 0x43); // Spawn Position
p.registerOutgoing(State.PLAY, 0x46, 0x44); // Time Update
p.registerOutgoing(State.PLAY, 0x47, 0x45); // Title
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3D); // Set Experience
protocol.registerOutgoing(State.PLAY, 0x40, 0x3E); // Update Health
protocol.registerOutgoing(State.PLAY, 0x41, 0x3F); // ScoreBoard Objective
protocol.registerOutgoing(State.PLAY, 0x42, 0x40); // Set Passengers
protocol.registerOutgoing(State.PLAY, 0x43, 0x41); // Teams
protocol.registerOutgoing(State.PLAY, 0x44, 0x42); // Update Score
protocol.registerOutgoing(State.PLAY, 0x45, 0x43); // Spawn Position
protocol.registerOutgoing(State.PLAY, 0x46, 0x44); // Time Update
protocol.registerOutgoing(State.PLAY, 0x47, 0x45); // Title
// 0x48 -> 0x46 Sound Effect handled in SoundPackets1_12.java
p.registerOutgoing(State.PLAY, 0x49, 0x47); // Player List Header And Footer
p.registerOutgoing(State.PLAY, 0x4A, 0x48); // Collect Item
p.registerOutgoing(State.PLAY, 0x4B, 0x49); // Entity Teleport
protocol.registerOutgoing(State.PLAY, 0x49, 0x47); // Player List Header And Footer
protocol.registerOutgoing(State.PLAY, 0x4A, 0x48); // Collect Item
protocol.registerOutgoing(State.PLAY, 0x4B, 0x49); // Entity Teleport
p.cancelOutgoing(State.PLAY, 0x4C); // Advancements
protocol.cancelOutgoing(State.PLAY, 0x4C); // Advancements
p.registerOutgoing(State.PLAY, 0x4D, 0x4A); // Entity Properties
p.registerOutgoing(State.PLAY, 0x4E, 0x4B); // Entity Effect
protocol.registerOutgoing(State.PLAY, 0x4D, 0x4A); // Entity Properties
protocol.registerOutgoing(State.PLAY, 0x4E, 0x4B); // Entity Effect
// New incoming packet 0x01 - Prepare Crafting Grid
p.registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (Serverbound)
p.registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (Serverbound)
protocol.registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (Serverbound)
protocol.registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (Serverbound)
// 0x04->0x03 Client Status handled in BlockItemPackets1_12.java
p.registerIncoming(State.PLAY, 0x05, 0x04); // Client Settings
p.registerIncoming(State.PLAY, 0x06, 0x05); // Confirm Transaction (Serverbound)
p.registerIncoming(State.PLAY, 0x07, 0x06); // Enchant Item
protocol.registerIncoming(State.PLAY, 0x05, 0x04); // Client Settings
protocol.registerIncoming(State.PLAY, 0x06, 0x05); // Confirm Transaction (Serverbound)
protocol.registerIncoming(State.PLAY, 0x07, 0x06); // Enchant Item
// 0x08 -> 0x07 Click Window handled in BlockItemPackets1_12.java
p.registerIncoming(State.PLAY, 0x09, 0x08); // Close Window (Serverbound)
p.registerIncoming(State.PLAY, 0x0A, 0x09); // Plugin message (Serverbound)
p.registerIncoming(State.PLAY, 0x0B, 0x0A); // Use Entity
p.registerIncoming(State.PLAY, 0x0C, 0x0B); // Keep Alive (Serverbound)
p.registerIncoming(State.PLAY, 0x0D, 0x0F); // Player
p.registerIncoming(State.PLAY, 0x0E, 0x0C); // Player Position
p.registerIncoming(State.PLAY, 0x0F, 0x0D); // Player Position And Look (ServerBound)
p.registerIncoming(State.PLAY, 0x10, 0x0E); // Player Look
p.registerIncoming(State.PLAY, 0x11, 0x10); // Vehicle Move
p.registerIncoming(State.PLAY, 0x12, 0x11); // Steer Boat
p.registerIncoming(State.PLAY, 0x13, 0x12); // Player Abilities (Serverbound)
p.registerIncoming(State.PLAY, 0x14, 0x13); // Player Digging
p.registerIncoming(State.PLAY, 0x15, 0x14); // Entity Action
p.registerIncoming(State.PLAY, 0x16, 0x15); // Steer Vehicle
protocol.registerIncoming(State.PLAY, 0x09, 0x08); // Close Window (Serverbound)
protocol.registerIncoming(State.PLAY, 0x0A, 0x09); // Plugin message (Serverbound)
protocol.registerIncoming(State.PLAY, 0x0B, 0x0A); // Use Entity
protocol.registerIncoming(State.PLAY, 0x0C, 0x0B); // Keep Alive (Serverbound)
protocol.registerIncoming(State.PLAY, 0x0D, 0x0F); // Player
protocol.registerIncoming(State.PLAY, 0x0E, 0x0C); // Player Position
protocol.registerIncoming(State.PLAY, 0x0F, 0x0D); // Player Position And Look (ServerBound)
protocol.registerIncoming(State.PLAY, 0x10, 0x0E); // Player Look
protocol.registerIncoming(State.PLAY, 0x11, 0x10); // Vehicle Move
protocol.registerIncoming(State.PLAY, 0x12, 0x11); // Steer Boat
protocol.registerIncoming(State.PLAY, 0x13, 0x12); // Player Abilities (Serverbound)
protocol.registerIncoming(State.PLAY, 0x14, 0x13); // Player Digging
protocol.registerIncoming(State.PLAY, 0x15, 0x14); // Entity Action
protocol.registerIncoming(State.PLAY, 0x16, 0x15); // Steer Vehicle
// New incoming packet 0x17 - Crafting Book Data
p.registerIncoming(State.PLAY, 0x18, 0x16); // Resource Pack Status
protocol.registerIncoming(State.PLAY, 0x18, 0x16); // Resource Pack Status
// New incoming packet 0x19 - Advancement Tab
p.registerIncoming(State.PLAY, 0x1A, 0x17); // Held Item Change (Serverbound)
protocol.registerIncoming(State.PLAY, 0x1A, 0x17); // Held Item Change (Serverbound)
// 0x1B -> 0x18 Creative Inventory Action handled in BlockItemPackets.java
p.registerIncoming(State.PLAY, 0x1C, 0x19); // Update Sign
p.registerIncoming(State.PLAY, 0x1D, 0x1A); // Animatin (Serverbound)
p.registerIncoming(State.PLAY, 0x1E, 0x1B); // Spectate
p.registerIncoming(State.PLAY, 0x1F, 0x1C); // Player Block Placement
p.registerIncoming(State.PLAY, 0x20, 0x1D); // Use Item
protocol.registerIncoming(State.PLAY, 0x1C, 0x19); // Update Sign
protocol.registerIncoming(State.PLAY, 0x1D, 0x1A); // Animatin (Serverbound)
protocol.registerIncoming(State.PLAY, 0x1E, 0x1B); // Spectate
protocol.registerIncoming(State.PLAY, 0x1F, 0x1C); // Player Block Placement
protocol.registerIncoming(State.PLAY, 0x20, 0x1D); // Use Item
}
@Override

Datei anzeigen

@ -27,8 +27,13 @@ import us.myles.ViaVersion.packets.State;
import java.util.Map;
public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
public ChatPackets1_12(Protocol1_11_1To1_12 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
protected void registerPackets() {
// Chat Message (ClientBound)
protocol.registerOutgoing(State.PLAY, 0x0F, 0x0F, new PacketRemapper() {
@Override

Datei anzeigen

@ -35,8 +35,12 @@ import java.util.Optional;
public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
public EntityPackets1_12(Protocol1_11_1To1_12 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
protected void registerPackets() {
// Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override

Datei anzeigen

@ -19,8 +19,13 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class SoundPackets1_12 extends SoundRewriter<Protocol1_11_1To1_12> {
public SoundPackets1_12(Protocol1_11_1To1_12 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
protected void registerPackets() {
// Named sound effect
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override

Datei anzeigen

@ -24,8 +24,8 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol {
@Override
protected void registerPackets() {
(entityPackets = new EntityPackets1_11_1()).register(this);
new ItemPackets1_11_1().register(this);
(entityPackets = new EntityPackets1_11_1(this)).register();
new ItemPackets1_11_1(this).register();
}
@Override

Datei anzeigen

@ -28,8 +28,12 @@ import java.util.Optional;
public class EntityPackets1_11_1 extends EntityRewriter<Protocol1_11To1_11_1> {
public EntityPackets1_11_1(Protocol1_11To1_11_1 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_11To1_11_1 protocol) {
protected void registerPackets() {
// Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override

Datei anzeigen

@ -28,8 +28,12 @@ public class ItemPackets1_11_1 extends BlockItemRewriter<Protocol1_11To1_11_1> {
private LegacyEnchantmentRewriter enchantmentRewriter;
public ItemPackets1_11_1(Protocol1_11To1_11_1 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_11To1_11_1 protocol) {
protected void registerPackets() {
jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);

Datei anzeigen

@ -44,10 +44,10 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
@Override
protected void registerPackets() {
(blockItemPackets = new BlockItemPackets1_13()).register(this);
new EntityPackets1_13().register(this);
new PlayerPacket1_13().register(this);
new SoundPackets1_13().register(this);
(blockItemPackets = new BlockItemPackets1_13(this)).register();
new EntityPackets1_13(this).register();
new PlayerPacket1_13(this).register();
new SoundPackets1_13(this).register();
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150

Datei anzeigen

@ -46,8 +46,13 @@ import java.util.*;
public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13> {
private static String NBT_TAG_NAME;
private static final Map<String, String> enchantmentMappings = new HashMap<>();
private final Map<String, String> enchantmentMappings = new HashMap<>();
private final String NBT_TAG_NAME;
public BlockItemPackets1_13(Protocol1_12_2To1_13 protocol) {
super(protocol);
NBT_TAG_NAME = "ViaBackwards|" + protocol.getClass().getSimpleName() + "|Part2";
}
public static int toOldId(int oldId) {
if (oldId < 0) {
@ -77,9 +82,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
}
@Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
NBT_TAG_NAME = "ViaBackwards|" + protocol.getClass().getSimpleName() + "|Part2";
protected void registerPackets() {
// Set Cooldown
protocol.out(State.PLAY, 0x18, 0x17, new PacketRemapper() {
@Override

Datei anzeigen

@ -28,8 +28,12 @@ import java.util.Optional;
public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
public EntityPackets1_13(Protocol1_12_2To1_13 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
protected void registerPackets() {
// Player Position And Look (clientbound)
protocol.out(State.PLAY, 0x32, 0x2F, new PacketRemapper() {
@Override

Datei anzeigen

@ -27,8 +27,13 @@ import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
public PlayerPacket1_13(Protocol1_12_2To1_13 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
protected void registerPackets() {
// Login Plugin Request
protocol.out(State.LOGIN, 0x04, -1, new PacketRemapper() {
@Override

Datei anzeigen

@ -15,8 +15,12 @@ import us.myles.ViaVersion.packets.State;
public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"};
public SoundPackets1_13(Protocol1_12_2To1_13 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
protected void registerPackets() {
// Named Sound Event
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {

Datei anzeigen

@ -32,12 +32,12 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
@Override
protected void registerPackets() {
blockItemPackets = new BlockItemPackets1_14();
blockItemPackets.register(this);
entityPackets = new EntityPackets1_14();
entityPackets.register(this);
new PlayerPackets1_14().register(this);
new SoundPackets1_14().register(this);
blockItemPackets = new BlockItemPackets1_14(this);
blockItemPackets.register();
entityPackets = new EntityPackets1_14(this);
entityPackets.register();
new PlayerPackets1_14(this).register();
new SoundPackets1_14(this).register();
registerOutgoing(State.PLAY, 0x15, 0x16);

Datei anzeigen

@ -47,8 +47,12 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
private EnchantmentRewriter enchantmentRewriter;
public BlockItemPackets1_14(Protocol1_13_2To1_14 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
protected void registerPackets() {
// Open window
protocol.registerOutgoing(State.PLAY, 0x2E, 0x14, new PacketRemapper() {
@Override

Datei anzeigen

@ -35,6 +35,10 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
private EntityPositionHandler positionHandler;
public EntityPackets1_14(Protocol1_13_2To1_14 protocol) {
super(protocol);
}
@Override
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
super.addTrackedEntity(wrapper, entityId, type);
@ -49,7 +53,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
}
@Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
protected void registerPackets() {
positionHandler = new EntityPositionHandler(this, EntityPositionStorage1_14.class, EntityPositionStorage1_14::new);
// Entity teleport

Datei anzeigen

@ -10,8 +10,13 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
public PlayerPackets1_14(Protocol1_13_2To1_14 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
protected void registerPackets() {
// Server Difficulty
protocol.registerOutgoing(State.PLAY, 0x0D, 0x0D, new PacketRemapper() {

Datei anzeigen

@ -15,8 +15,13 @@ import us.myles.ViaVersion.packets.State;
import java.util.Optional;
public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
public SoundPackets1_14(Protocol1_13_2To1_14 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
protected void registerPackets() {
// Sound Effect
protocol.registerOutgoing(State.PLAY, 0x51, 0x4D, new PacketRemapper() {
@Override

Datei anzeigen

@ -19,7 +19,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
@Override
protected void registerPackets() {
new EntityPackets1_13_1().register(this);
new EntityPackets1_13_1(this).register();
InventoryPackets1_13_1.register(this);
WorldPackets1_13_1.register(this);

Datei anzeigen

@ -18,8 +18,12 @@ import us.myles.ViaVersion.packets.State;
public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
public EntityPackets1_13_1(Protocol1_13To1_13_1 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_13To1_13_1 protocol) {
protected void registerPackets() {
// Spawn Object
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {

Datei anzeigen

@ -25,9 +25,8 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
@Override
protected void registerPackets() {
BackwardsMappings.init();
blockItemPackets = new BlockItemPackets1_15();
blockItemPackets.register(this);
new EntityPackets1_15().register(this);
(blockItemPackets = new BlockItemPackets1_15(this)).register();
new EntityPackets1_15(this).register();
// Entity Sound Effect
registerOutgoing(State.PLAY, 0x51, 0x50, new PacketRemapper() {

Datei anzeigen

@ -23,8 +23,12 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class BlockItemPackets1_15 extends BlockItemRewriter<Protocol1_14_4To1_15> {
public BlockItemPackets1_15(Protocol1_14_4To1_15 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_14_4To1_15 protocol) {
protected void registerPackets() {
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_14_4To1_15::getNewBlockStateId, Protocol1_14_4To1_15::getNewBlockId);

Datei anzeigen

@ -26,8 +26,12 @@ import java.util.ArrayList;
public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
public EntityPackets1_15(Protocol1_14_4To1_15 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_14_4To1_15 protocol) {
protected void registerPackets() {
// Update health
protocol.registerOutgoing(State.PLAY, 0x49, 0x48, new PacketRemapper() {
@Override

Datei anzeigen

@ -9,7 +9,7 @@ public class Protocol1_14To1_14_1 extends BackwardsProtocol {
@Override
protected void registerPackets() {
new EntityPackets1_14_1().register(this);
new EntityPackets1_14_1(this).register();
}
@Override

Datei anzeigen

@ -14,8 +14,12 @@ import us.myles.ViaVersion.packets.State;
public class EntityPackets1_14_1 extends EntityRewriter<Protocol1_14To1_14_1> {
public EntityPackets1_14_1(Protocol1_14To1_14_1 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_14To1_14_1 protocol) {
protected void registerPackets() {
registerExtraTracker(0x01, Entity1_14Types.EntityType.XP_ORB);
registerExtraTracker(0x02, Entity1_14Types.EntityType.LIGHTNING_BOLT);
registerExtraTracker(0x04, Entity1_14Types.EntityType.PAINTING);

Datei anzeigen

@ -27,9 +27,9 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol {
protected void registerPackets() {
new ChangedPackets1_10().register(this);
new SoundPackets1_10().register(this);
(entityPackets = new EntityPackets1_10()).register(this);
(blockItemPackets = new BlockItemPackets1_10()).register(this);
new SoundPackets1_10(this).register();
(entityPackets = new EntityPackets1_10(this)).register();
(blockItemPackets = new BlockItemPackets1_10(this)).register();
}
public void init(UserConnection user) {

Datei anzeigen

@ -28,7 +28,12 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10> {
protected void registerPackets(Protocol1_9_4To1_10 protocol) {
public BlockItemPackets1_10(Protocol1_9_4To1_10 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);

Datei anzeigen

@ -35,9 +35,12 @@ import java.util.Optional;
public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
@Override
protected void registerPackets(Protocol1_9_4To1_10 protocol) {
public EntityPackets1_10(Protocol1_9_4To1_10 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
// Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override

Datei anzeigen

@ -26,8 +26,12 @@ public class SoundPackets1_10 extends SoundRewriter<Protocol1_9_4To1_10> {
}
};
public SoundPackets1_10(Protocol1_9_4To1_10 protocol) {
super(protocol);
}
@Override
protected void registerPackets(Protocol1_9_4To1_10 protocol) {
protected void registerPackets() {
// Named sound effect
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override