3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-25 15:50:12 +01:00

Rewrite item/block/entity ids in statistics

Dieser Commit ist enthalten in:
KennyTV 2020-08-12 22:32:19 +02:00
Ursprung 5e19a5af33
Commit 803c24f4d3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
6 geänderte Dateien mit 19 neuen und 31 gelöschten Zeilen

Datei anzeigen

@ -44,7 +44,7 @@ import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol
public interface ViaBackwardsPlatform {
String MINIMUM_VV_VERSION = "3.1.0";
String MINIMUM_VV_VERSION = "3.1.1";
/**
* Initialize ViaBackwards.

Datei anzeigen

@ -14,6 +14,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
@ -52,6 +53,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
new PlayerPackets1_14(this).register();
new SoundPackets1_14(this).register();
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_14.STATISTICS);
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_POSITION);
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
cancelOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);

Datei anzeigen

@ -13,6 +13,7 @@ import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
@ -80,6 +81,9 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id),
id -> MappingData.oldToNewItems.inverse().get(id), EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.TAGS);
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.STATISTICS);
}
public static int getNewBlockStateId(int id) {

Datei anzeigen

@ -12,6 +12,7 @@ import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
@ -95,38 +96,13 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
}
});
registerOutgoing(ClientboundPackets1_16.STATISTICS, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
int size = wrapper.passthrough(Type.VAR_INT);
int newSize = size;
for (int i = 0; i < size; i++) {
int categoryId = wrapper.read(Type.VAR_INT);
int statisticId = wrapper.read(Type.VAR_INT);
// New statistics
if (statisticId > 49) {
wrapper.read(Type.VAR_INT);
newSize--;
continue;
}
wrapper.write(Type.VAR_INT, categoryId);
wrapper.write(Type.VAR_INT, statisticId);
wrapper.passthrough(Type.VAR_INT); // value
}
if (newSize != size) {
wrapper.set(Type.VAR_INT, 0, newSize);
}
});
}
});
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId,
categoryId -> categoryId > 49 ? -1 : categoryId).register(ClientboundPackets1_15.STATISTICS);
registerIncoming(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
@Override
public void registerMap() {

Datei anzeigen

@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
@ -93,6 +94,9 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.TAGS);
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.STATISTICS);
}
public static int getNewBlockStateId(int id) {

Datei anzeigen

@ -65,7 +65,7 @@
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>3.1.0-1.16.2-RC2</version>
<version>3.1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>