mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-02 09:09:55 +01:00
Rewrite custom stats ids
This commit is contained in:
parent
249a720cee
commit
ce49daa300
@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
|||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
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;
|
||||||
@ -72,5 +73,22 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
new StatisticsRewriter(this, null, null, null, id -> {
|
||||||
|
int newId = id;
|
||||||
|
if (newId > 40) {
|
||||||
|
if (id == 41) return -1;
|
||||||
|
newId--;
|
||||||
|
}
|
||||||
|
if (newId > 25) {
|
||||||
|
if (id <= 28) return -1;
|
||||||
|
newId -= 3;
|
||||||
|
}
|
||||||
|
if (newId > 22) {
|
||||||
|
if (id <= 24) return -1;
|
||||||
|
newId -= 2;
|
||||||
|
}
|
||||||
|
return newId;
|
||||||
|
}).register(ClientboundPackets1_13.STATISTICS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ 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 ->
|
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> MappingData.oldToNewItems.inverse().get(id),
|
||||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_14.STATISTICS);
|
entityPackets::getOldEntityId, id -> BackwardsMappings.statisticsMappings.getNewId(id)).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);
|
||||||
|
@ -12,6 +12,7 @@ import us.myles.viaversion.libs.gson.JsonObject;
|
|||||||
public class BackwardsMappings {
|
public class BackwardsMappings {
|
||||||
public static Mappings blockStateMappings;
|
public static Mappings blockStateMappings;
|
||||||
public static Mappings blockMappings;
|
public static Mappings blockMappings;
|
||||||
|
public static Mappings statisticsMappings;
|
||||||
public static VBSoundMappings soundMappings;
|
public static VBSoundMappings soundMappings;
|
||||||
public static VBItemMappings itemMappings;
|
public static VBItemMappings itemMappings;
|
||||||
|
|
||||||
@ -25,5 +26,6 @@ public class BackwardsMappings {
|
|||||||
blockMappings = new VBMappings(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"), false);
|
blockMappings = new VBMappings(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"), false);
|
||||||
itemMappings = new VBItemMappings(mapping1_14.getAsJsonObject("items"), mapping1_13_2.getAsJsonObject("items"), mapping1_13_2to1_14.getAsJsonObject("items"));
|
itemMappings = new VBItemMappings(mapping1_14.getAsJsonObject("items"), mapping1_13_2.getAsJsonObject("items"), mapping1_13_2to1_14.getAsJsonObject("items"));
|
||||||
soundMappings = new VBSoundMappings(mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"), mapping1_13_2to1_14.getAsJsonObject("sounds"));
|
soundMappings = new VBSoundMappings(mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"), mapping1_13_2to1_14.getAsJsonObject("sounds"));
|
||||||
|
statisticsMappings = new Mappings(mapping1_14.getAsJsonArray("statistics"), mapping1_13_2.getAsJsonArray("statistics"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ 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 ->
|
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> MappingData.oldToNewItems.inverse().get(id),
|
||||||
MappingData.oldToNewItems.inverse().get(id), EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.STATISTICS);
|
EntityTypeMapping::getOldEntityId, id -> BackwardsMappings.statisticsMappings.getNewId(id)).register(ClientboundPackets1_15.STATISTICS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getNewBlockStateId(int id) {
|
public static int getNewBlockStateId(int id) {
|
||||||
|
@ -12,6 +12,7 @@ import us.myles.viaversion.libs.gson.JsonObject;
|
|||||||
public class BackwardsMappings {
|
public class BackwardsMappings {
|
||||||
public static Mappings blockStateMappings;
|
public static Mappings blockStateMappings;
|
||||||
public static Mappings blockMappings;
|
public static Mappings blockMappings;
|
||||||
|
public static Mappings statisticsMappings;
|
||||||
public static VBSoundMappings soundMappings;
|
public static VBSoundMappings soundMappings;
|
||||||
public static VBItemMappings itemMappings;
|
public static VBItemMappings itemMappings;
|
||||||
|
|
||||||
@ -25,5 +26,6 @@ public class BackwardsMappings {
|
|||||||
blockMappings = new VBMappings(mapping1_15.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks"), mapping1_14to1_15.getAsJsonObject("blocks"), false);
|
blockMappings = new VBMappings(mapping1_15.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks"), mapping1_14to1_15.getAsJsonObject("blocks"), false);
|
||||||
itemMappings = new VBItemMappings(mapping1_15.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items"), mapping1_14to1_15.getAsJsonObject("items"));
|
itemMappings = new VBItemMappings(mapping1_15.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items"), mapping1_14to1_15.getAsJsonObject("items"));
|
||||||
soundMappings = new VBSoundMappings(mapping1_15.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"), mapping1_14to1_15.getAsJsonObject("sounds"));
|
soundMappings = new VBSoundMappings(mapping1_15.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"), mapping1_14to1_15.getAsJsonObject("sounds"));
|
||||||
|
statisticsMappings = new Mappings(mapping1_15.getAsJsonArray("statistics"), mapping1_14.getAsJsonArray("statistics"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -99,9 +99,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
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 ->
|
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> MappingData.oldToNewItems.inverse().get(id),
|
||||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId,
|
entityPackets::getOldEntityId, id -> BackwardsMappings.statisticsMappings.getNewId(id)).register(ClientboundPackets1_16.STATISTICS);
|
||||||
categoryId -> categoryId > 49 ? -1 : categoryId).register(ClientboundPackets1_16.STATISTICS);
|
|
||||||
|
|
||||||
registerIncoming(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
|
registerIncoming(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,7 @@ import java.util.Map;
|
|||||||
public class BackwardsMappings {
|
public class BackwardsMappings {
|
||||||
public static Mappings blockStateMappings;
|
public static Mappings blockStateMappings;
|
||||||
public static Mappings blockMappings;
|
public static Mappings blockMappings;
|
||||||
|
public static Mappings statisticsMappings;
|
||||||
public static VBSoundMappings soundMappings;
|
public static VBSoundMappings soundMappings;
|
||||||
public static VBItemMappings itemMappings;
|
public static VBItemMappings itemMappings;
|
||||||
public static Map<String, String> attributeMappings = new HashMap<>();
|
public static Map<String, String> attributeMappings = new HashMap<>();
|
||||||
@ -30,6 +31,7 @@ public class BackwardsMappings {
|
|||||||
blockMappings = new VBMappings(mapping1_16.getAsJsonObject("blocks"), mapping1_15.getAsJsonObject("blocks"), mapping1_15to1_16.getAsJsonObject("blocks"), false);
|
blockMappings = new VBMappings(mapping1_16.getAsJsonObject("blocks"), mapping1_15.getAsJsonObject("blocks"), mapping1_15to1_16.getAsJsonObject("blocks"), false);
|
||||||
itemMappings = new VBItemMappings(mapping1_16.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items"), mapping1_15to1_16.getAsJsonObject("items"));
|
itemMappings = new VBItemMappings(mapping1_16.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items"), mapping1_15to1_16.getAsJsonObject("items"));
|
||||||
soundMappings = new VBSoundMappings(mapping1_16.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), mapping1_15to1_16.getAsJsonObject("sounds"));
|
soundMappings = new VBSoundMappings(mapping1_16.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), mapping1_15to1_16.getAsJsonObject("sounds"));
|
||||||
|
statisticsMappings = new Mappings(mapping1_16.getAsJsonArray("statistics"), mapping1_15.getAsJsonArray("statistics"), false);
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : MappingData.attributeMappings.entrySet()) {
|
for (Map.Entry<String, String> entry : MappingData.attributeMappings.entrySet()) {
|
||||||
attributeMappings.put(entry.getValue(), entry.getKey());
|
attributeMappings.put(entry.getValue(), entry.getKey());
|
||||||
|
Loading…
Reference in New Issue
Block a user