Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 00:00:33 +01:00
Rewrite item/block/entity ids in statistics
Dieser Commit ist enthalten in:
Ursprung
5e19a5af33
Commit
803c24f4d3
@ -44,7 +44,7 @@ import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol
|
|||||||
|
|
||||||
public interface ViaBackwardsPlatform {
|
public interface ViaBackwardsPlatform {
|
||||||
|
|
||||||
String MINIMUM_VV_VERSION = "3.1.0";
|
String MINIMUM_VV_VERSION = "3.1.1";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize ViaBackwards.
|
* Initialize ViaBackwards.
|
||||||
|
@ -14,6 +14,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
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.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_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 PlayerPackets1_14(this).register();
|
||||||
new SoundPackets1_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_POSITION);
|
||||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
||||||
cancelOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
cancelOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||||
|
@ -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.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
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.rewriters.TagRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
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),
|
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id),
|
||||||
id -> MappingData.oldToNewItems.inverse().get(id), EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.TAGS);
|
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) {
|
public static int getNewBlockStateId(int id) {
|
||||||
|
@ -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 nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
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.rewriters.TagRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
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 ->
|
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
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() {
|
registerIncoming(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
|
@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
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.rewriters.TagRewriter;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
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 ->
|
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.TAGS);
|
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) {
|
public static int getNewBlockStateId(int id) {
|
||||||
|
2
pom.xml
2
pom.xml
@ -65,7 +65,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.myles</groupId>
|
<groupId>us.myles</groupId>
|
||||||
<artifactId>viaversion</artifactId>
|
<artifactId>viaversion</artifactId>
|
||||||
<version>3.1.0-1.16.2-RC2</version>
|
<version>3.1.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren