3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-27 08:30:10 +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 String nbtTagName;
protected boolean jsonNameFormat = true; protected boolean jsonNameFormat = true;
@Override protected BlockItemRewriter(T protocol) {
public void register(T protocol) { super(protocol);
nbtTagName = "ViaBackwards|" + protocol.getClass().getSimpleName(); nbtTagName = "ViaBackwards|" + protocol.getClass().getSimpleName();
super.register(protocol);
} }
protected BlockItemSettings rewrite(int itemId) { protected BlockItemSettings rewrite(int itemId) {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -45,8 +45,12 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
private LegacyEnchantmentRewriter enchantmentRewriter; private LegacyEnchantmentRewriter enchantmentRewriter;
public BlockItemPackets1_11(Protocol1_10To1_11 protocol) {
super(protocol);
}
@Override @Override
protected void registerPackets(Protocol1_10To1_11 protocol) { protected void registerPackets() {
jsonNameFormat = false; jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); 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 class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
public EntityPackets1_11(Protocol1_10To1_11 protocol) {
super(protocol);
}
@Override @Override
protected void registerPackets(Protocol1_10To1_11 protocol) { protected void registerPackets() {
// Spawn Object // Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override @Override

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -44,10 +44,10 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
(blockItemPackets = new BlockItemPackets1_13()).register(this); (blockItemPackets = new BlockItemPackets1_13(this)).register();
new EntityPackets1_13().register(this); new EntityPackets1_13(this).register();
new PlayerPacket1_13().register(this); new PlayerPacket1_13(this).register();
new SoundPackets1_13().register(this); new SoundPackets1_13(this).register();
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150 // 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> { public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13> {
private static String NBT_TAG_NAME; private final Map<String, String> enchantmentMappings = new HashMap<>();
private static 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) { public static int toOldId(int oldId) {
if (oldId < 0) { if (oldId < 0) {
@ -77,9 +82,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
} }
@Override @Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) { protected void registerPackets() {
NBT_TAG_NAME = "ViaBackwards|" + protocol.getClass().getSimpleName() + "|Part2";
// Set Cooldown // Set Cooldown
protocol.out(State.PLAY, 0x18, 0x17, new PacketRemapper() { protocol.out(State.PLAY, 0x18, 0x17, new PacketRemapper() {
@Override @Override

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -15,8 +15,12 @@ import us.myles.ViaVersion.packets.State;
public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> { 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"}; 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 @Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) { protected void registerPackets() {
// Named Sound Event // Named Sound Event
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() { protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -19,7 +19,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
new EntityPackets1_13_1().register(this); new EntityPackets1_13_1(this).register();
InventoryPackets1_13_1.register(this); InventoryPackets1_13_1.register(this);
WorldPackets1_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 class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
public EntityPackets1_13_1(Protocol1_13To1_13_1 protocol) {
super(protocol);
}
@Override @Override
protected void registerPackets(Protocol1_13To1_13_1 protocol) { protected void registerPackets() {
// Spawn Object // Spawn Object
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() { protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {

Datei anzeigen

@ -25,9 +25,8 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
BackwardsMappings.init(); BackwardsMappings.init();
blockItemPackets = new BlockItemPackets1_15(); (blockItemPackets = new BlockItemPackets1_15(this)).register();
blockItemPackets.register(this); new EntityPackets1_15(this).register();
new EntityPackets1_15().register(this);
// Entity Sound Effect // Entity Sound Effect
registerOutgoing(State.PLAY, 0x51, 0x50, new PacketRemapper() { 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 class BlockItemPackets1_15 extends BlockItemRewriter<Protocol1_14_4To1_15> {
public BlockItemPackets1_15(Protocol1_14_4To1_15 protocol) {
super(protocol);
}
@Override @Override
protected void registerPackets(Protocol1_14_4To1_15 protocol) { protected void registerPackets() {
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); 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); 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 class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
public EntityPackets1_15(Protocol1_14_4To1_15 protocol) {
super(protocol);
}
@Override @Override
protected void registerPackets(Protocol1_14_4To1_15 protocol) { protected void registerPackets() {
// Update health // Update health
protocol.registerOutgoing(State.PLAY, 0x49, 0x48, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x49, 0x48, new PacketRemapper() {
@Override @Override

Datei anzeigen

@ -9,7 +9,7 @@ public class Protocol1_14To1_14_1 extends BackwardsProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
new EntityPackets1_14_1().register(this); new EntityPackets1_14_1(this).register();
} }
@Override @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 class EntityPackets1_14_1 extends EntityRewriter<Protocol1_14To1_14_1> {
public EntityPackets1_14_1(Protocol1_14To1_14_1 protocol) {
super(protocol);
}
@Override @Override
protected void registerPackets(Protocol1_14To1_14_1 protocol) { protected void registerPackets() {
registerExtraTracker(0x01, Entity1_14Types.EntityType.XP_ORB); registerExtraTracker(0x01, Entity1_14Types.EntityType.XP_ORB);
registerExtraTracker(0x02, Entity1_14Types.EntityType.LIGHTNING_BOLT); registerExtraTracker(0x02, Entity1_14Types.EntityType.LIGHTNING_BOLT);
registerExtraTracker(0x04, Entity1_14Types.EntityType.PAINTING); registerExtraTracker(0x04, Entity1_14Types.EntityType.PAINTING);

Datei anzeigen

@ -27,9 +27,9 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol {
protected void registerPackets() { protected void registerPackets() {
new ChangedPackets1_10().register(this); new ChangedPackets1_10().register(this);
new SoundPackets1_10().register(this); new SoundPackets1_10(this).register();
(entityPackets = new EntityPackets1_10()).register(this); (entityPackets = new EntityPackets1_10(this)).register();
(blockItemPackets = new BlockItemPackets1_10()).register(this); (blockItemPackets = new BlockItemPackets1_10(this)).register();
} }
public void init(UserConnection user) { 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> { 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; jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer); 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> { public class EntityPackets1_10 extends EntityRewriter<Protocol1_9_4To1_10> {
@Override public EntityPackets1_10(Protocol1_9_4To1_10 protocol) {
protected void registerPackets(Protocol1_9_4To1_10 protocol) { super(protocol);
}
@Override
protected void registerPackets() {
// Spawn Object // Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override @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 @Override
protected void registerPackets(Protocol1_9_4To1_10 protocol) { protected void registerPackets() {
// Named sound effect // Named sound effect
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override @Override