3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Abstract mapping loading

Dieser Commit ist enthalten in:
KennyTV 2020-08-16 16:24:06 +02:00 committet von Nassim
Ursprung 074af0e282
Commit d36def89e1
66 geänderte Dateien mit 1264 neuen und 606 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -0,0 +1,128 @@
package us.myles.ViaVersion.api.data;
import com.google.gson.JsonObject;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.Int2IntBiMap;
public class MappingData {
protected final String oldVersion;
protected final String newVersion;
protected final boolean hasDiffFile;
protected Int2IntBiMap itemMappings;
protected Mappings blockMappings;
protected Mappings blockStateMappings;
protected Mappings soundMappings;
protected Mappings statisticsMappings;
protected boolean loadItems = true;
public MappingData(String oldVersion, String newVersion) {
this(oldVersion, newVersion, false);
}
public MappingData(String oldVersion, String newVersion, boolean hasDiffFile) {
this.oldVersion = oldVersion;
this.newVersion = newVersion;
this.hasDiffFile = hasDiffFile;
}
public void load() {
Via.getPlatform().getLogger().info("Loading " + oldVersion + " -> " + newVersion + " mappings...");
JsonObject diffmapping = hasDiffFile ? loadDiffFile() : null;
JsonObject oldMappings = MappingDataLoader.loadData("mapping-" + oldVersion + ".json", true);
JsonObject newMappings = MappingDataLoader.loadData("mapping-" + newVersion + ".json", true);
blockMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blocks");
blockStateMappings = loadFromObject(oldMappings, newMappings, diffmapping, "blockstates");
soundMappings = loadFromArray(oldMappings, newMappings, diffmapping, "sounds");
statisticsMappings = loadFromArray(oldMappings, newMappings, diffmapping, "statistics");
if (loadItems && newMappings.has("items")) {
itemMappings = new Int2IntBiMap();
itemMappings.defaultReturnValue(-1);
MappingDataLoader.mapIdentifiers(itemMappings, oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"),
diffmapping != null ? diffmapping.getAsJsonObject("items") : null);
}
loadExtras(oldMappings, newMappings, diffmapping);
}
public int getNewBlockStateId(int id) {
return checkValidity(blockStateMappings.getNewId(id), "blockstate");
}
public int getNewBlockId(int id) {
return checkValidity(blockMappings.getNewId(id), "block");
}
public int getNewItemId(int id) {
return checkValidity(itemMappings.get(id), "item");
}
public int getOldItemId(int id) {
int oldId = itemMappings.inverse().get(id);
return oldId != -1 ? oldId : 1;
}
@Nullable
public Int2IntBiMap getItemMappings() {
return itemMappings;
}
@Nullable
public Mappings getBlockMappings() {
return blockMappings;
}
@Nullable
public Mappings getBlockStateMappings() {
return blockStateMappings;
}
@Nullable
public Mappings getSoundMappings() {
return soundMappings;
}
@Nullable
public Mappings getStatisticsMappings() {
return statisticsMappings;
}
@Nullable
protected Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return new Mappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff);
}
@Nullable
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
return new Mappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff);
}
protected JsonObject loadDiffFile() {
return MappingDataLoader.loadData("mappingdiff-" + oldVersion + "to" + newVersion + ".json");
}
protected int checkValidity(int id, String type) {
if (id == -1) {
Via.getPlatform().getLogger().warning(String.format("Missing %s %s for %s %s %d", newVersion, type, oldVersion, type, id));
return 0;
}
return id;
}
/**
* To be overridden.
*
* @param oldMappings old mappings
* @param newMappings new mappings
* @param diffMappings diff mappings if present
*/
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
}
}

Datei anzeigen

@ -48,6 +48,7 @@ public class MappingDataLoader {
/** /**
* Loads the file from the plugin folder if present, else from the bundled resources. * Loads the file from the plugin folder if present, else from the bundled resources.
*/ */
@Nullable
public static JsonObject loadFromDataDir(String name) { public static JsonObject loadFromDataDir(String name) {
File file = new File(Via.getPlatform().getDataFolder(), name); File file = new File(Via.getPlatform().getDataFolder(), name);
if (!file.exists()) return loadData(name); if (!file.exists()) return loadData(name);
@ -68,6 +69,7 @@ public class MappingDataLoader {
/** /**
* Loads the file from the bundled resources. Uses the cache if enabled. * Loads the file from the bundled resources. Uses the cache if enabled.
*/ */
@Nullable
public static JsonObject loadData(String name) { public static JsonObject loadData(String name) {
return loadData(name, false); return loadData(name, false);
} }
@ -77,6 +79,7 @@ public class MappingDataLoader {
* *
* @param cacheIfEnabled whether loaded files should be cached * @param cacheIfEnabled whether loaded files should be cached
*/ */
@Nullable
public static JsonObject loadData(String name, boolean cacheIfEnabled) { public static JsonObject loadData(String name, boolean cacheIfEnabled) {
if (cacheJsonMappings) { if (cacheJsonMappings) {
JsonObject cached = MAPPINGS_CACHE.get(name); JsonObject cached = MAPPINGS_CACHE.get(name);
@ -86,6 +89,8 @@ public class MappingDataLoader {
} }
InputStream stream = getResource(name); InputStream stream = getResource(name);
if (stream == null) return null;
InputStreamReader reader = new InputStreamReader(stream); InputStreamReader reader = new InputStreamReader(stream);
try { try {
JsonObject object = GsonUtil.getGson().fromJson(reader, JsonObject.class); JsonObject object = GsonUtil.getGson().fromJson(reader, JsonObject.class);
@ -106,9 +111,9 @@ public class MappingDataLoader {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null); mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
} }
public static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { public static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) { for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = mapIdentifierEntry(entry, oldIdentifiers, newIdentifiers, diffIdentifiers); Map.Entry<String, JsonElement> value = mapIdentifierEntry(entry, newIdentifiers, diffIdentifiers);
if (value != null) { if (value != null) {
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey())); output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
} }
@ -119,9 +124,9 @@ public class MappingDataLoader {
MappingDataLoader.mapIdentifiers(output, oldIdentifiers, newIdentifiers, null); MappingDataLoader.mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
} }
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) { for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = mapIdentifierEntry(entry, oldIdentifiers, newIdentifiers, diffIdentifiers); Map.Entry<String, JsonElement> value = mapIdentifierEntry(entry, newIdentifiers, diffIdentifiers);
if (value != null) { if (value != null) {
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey()); output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
} }
@ -129,7 +134,7 @@ public class MappingDataLoader {
} }
@Nullable @Nullable
private static Map.Entry<String, JsonElement> mapIdentifierEntry(Map.Entry<String, JsonElement> entry, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { private static Map.Entry<String, JsonElement> mapIdentifierEntry(Map.Entry<String, JsonElement> entry, JsonObject newIdentifiers, @Nullable JsonObject diffIdentifiers) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString()); Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) { if (value == null) {
// Search in diff mappings // Search in diff mappings
@ -153,7 +158,7 @@ public class MappingDataLoader {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing); mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
} }
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) { public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, @Nullable JsonObject diffIdentifiers, boolean warnOnMissing) {
for (int i = 0; i < oldIdentifiers.size(); i++) { for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement value = oldIdentifiers.get(i); JsonElement value = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, value.getAsString()); Integer index = findIndex(newIdentifiers, value.getAsString());
@ -208,6 +213,7 @@ public class MappingDataLoader {
return null; return null;
} }
@Nullable
public static InputStream getResource(String name) { public static InputStream getResource(String name) {
return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name); return MappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viaversion/data/" + name);
} }

Datei anzeigen

@ -2,13 +2,14 @@ package us.myles.ViaVersion.api.data;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays; import java.util.Arrays;
public class Mappings { public class Mappings {
protected final short[] oldToNew; protected final short[] oldToNew;
protected Mappings(short[] oldToNew) { public Mappings(short[] oldToNew) {
this.oldToNew = oldToNew; this.oldToNew = oldToNew;
} }
@ -21,13 +22,13 @@ public class Mappings {
* @param newMapping mappings to map to * @param newMapping mappings to map to
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found * @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
*/ */
public Mappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) { public Mappings(int size, JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
oldToNew = new short[size]; oldToNew = new short[size];
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping); MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping);
} }
public Mappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) { public Mappings(JsonObject oldMapping, JsonObject newMapping, @Nullable JsonObject diffMapping) {
this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping); this(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping);
} }
@ -86,4 +87,8 @@ public class Mappings {
public int getNewId(int old) { public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1; return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
} }
public short[] getOldToNew() {
return oldToNew;
}
} }

Datei anzeigen

@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingData;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.platform.providers.ViaProviders; import us.myles.ViaVersion.api.platform.providers.ViaProviders;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
@ -36,14 +37,9 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
protected final Class<C2> newClientboundPacketEnum; protected final Class<C2> newClientboundPacketEnum;
protected final Class<S1> oldServerboundPacketEnum; protected final Class<S1> oldServerboundPacketEnum;
protected final Class<S2> newServerboundPacketEnum; protected final Class<S2> newServerboundPacketEnum;
protected final boolean hasMappingDataToLoad;
protected Protocol() { protected Protocol() {
this(null, null, null, null, false); this(null, null, null, null);
}
protected Protocol(boolean hasMappingDataToLoad) {
this(null, null, null, null, hasMappingDataToLoad);
} }
/** /**
@ -51,21 +47,10 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
*/ */
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum, protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) { @Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
this(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false);
}
/**
* Creates a protocol with automated id mapping if the respective enums are not null.
*
* @param hasMappingDataToLoad whether an async executor should call the {@Link #loadMappingData} method
*/
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum, boolean hasMappingDataToLoad) {
this.oldClientboundPacketEnum = oldClientboundPacketEnum; this.oldClientboundPacketEnum = oldClientboundPacketEnum;
this.newClientboundPacketEnum = clientboundPacketEnum; this.newClientboundPacketEnum = clientboundPacketEnum;
this.oldServerboundPacketEnum = oldServerboundPacketEnum; this.oldServerboundPacketEnum = oldServerboundPacketEnum;
this.newServerboundPacketEnum = serverboundPacketEnum; this.newServerboundPacketEnum = serverboundPacketEnum;
this.hasMappingDataToLoad = hasMappingDataToLoad;
registerPackets(); registerPackets();
// Register the rest of the ids with no handlers if necessary // Register the rest of the ids with no handlers if necessary
@ -157,11 +142,19 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
} }
/** /**
* Load mapping data for the protocol. * Loads the mappingdata.
*/
protected final void loadMappingData() {
getMappingData().load();
onMappingDataLoaded();
}
/**
* Called after {@link #loadMappingData()} is called; load extra mapping data for the protocol.
* <p> * <p>
* To be overridden if needed. * To be overridden if needed.
*/ */
protected void loadMappingData() { protected void onMappingDataLoaded() {
} }
/** /**
@ -387,10 +380,6 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
return incoming.containsKey(packet); return incoming.containsKey(packet);
} }
public boolean hasMappingDataToLoad() {
return hasMappingDataToLoad;
}
/** /**
* Transform a packet using this protocol * Transform a packet using this protocol
* *
@ -470,6 +459,16 @@ public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends Clie
storedObjects.put(object.getClass(), object); storedObjects.put(object.getClass(), object);
} }
public boolean hasMappingDataToLoad() {
return getMappingData() != null;
}
@Nullable
public MappingData getMappingData() {
//TODO Fully hold the instance here and get rid of all static usages (at some point:tm:)
return null; // Let the protocols hold the mappings to still have easy, static singleton access there
}
@Override @Override
public String toString() { public String toString() {
return "Protocol:" + getClass().getSimpleName(); return "Protocol:" + getClass().getSimpleName();

Datei anzeigen

@ -11,10 +11,6 @@ public abstract class SimpleProtocol extends Protocol<SimpleProtocol.DummyPacket
protected SimpleProtocol() { protected SimpleProtocol() {
} }
protected SimpleProtocol(boolean hasMappingDataToLoad) {
super(hasMappingDataToLoad);
}
public enum DummyPacketTypes implements ClientboundPacketType, ServerboundPacketType { public enum DummyPacketTypes implements ClientboundPacketType, ServerboundPacketType {
} }
} }

Datei anzeigen

@ -12,15 +12,11 @@ import us.myles.ViaVersion.api.type.Type;
// If any of these methods become outdated, just create a new rewriter overriding the methods // If any of these methods become outdated, just create a new rewriter overriding the methods
public class BlockRewriter { public class BlockRewriter {
private final Protocol protocol; private final Protocol protocol;
private final IdRewriteFunction blockStateRewriter;
private final IdRewriteFunction blockRewriter;
private final Type<Position> positionType; private final Type<Position> positionType;
public BlockRewriter(Protocol protocol, Type<Position> positionType, IdRewriteFunction blockStateRewriter, IdRewriteFunction blockRewriter) { public BlockRewriter(Protocol protocol, Type<Position> positionType) {
this.protocol = protocol; this.protocol = protocol;
this.positionType = positionType; this.positionType = positionType;
this.blockStateRewriter = blockStateRewriter;
this.blockRewriter = blockRewriter;
} }
public void registerBlockAction(ClientboundPacketType packetType) { public void registerBlockAction(ClientboundPacketType packetType) {
@ -33,7 +29,7 @@ public class BlockRewriter {
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
handler(wrapper -> { handler(wrapper -> {
int id = wrapper.get(Type.VAR_INT, 0); int id = wrapper.get(Type.VAR_INT, 0);
int mappedId = blockRewriter.rewrite(id); int mappedId = protocol.getMappingData().getNewBlockId(id);
if (mappedId == -1) { if (mappedId == -1) {
// Block (action) has been removed // Block (action) has been removed
wrapper.cancel(); wrapper.cancel();
@ -52,7 +48,7 @@ public class BlockRewriter {
public void registerMap() { public void registerMap() {
map(positionType); map(positionType);
map(Type.VAR_INT); map(Type.VAR_INT);
handler(wrapper -> wrapper.set(Type.VAR_INT, 0, blockStateRewriter.rewrite(wrapper.get(Type.VAR_INT, 0)))); handler(wrapper -> wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))));
} }
}); });
} }
@ -65,7 +61,7 @@ public class BlockRewriter {
map(Type.INT); // 1 - Chunk Z map(Type.INT); // 1 - Chunk Z
handler(wrapper -> { handler(wrapper -> {
for (BlockChangeRecord record : wrapper.passthrough(Type.BLOCK_CHANGE_RECORD_ARRAY)) { for (BlockChangeRecord record : wrapper.passthrough(Type.BLOCK_CHANGE_RECORD_ARRAY)) {
record.setBlockId(blockStateRewriter.rewrite(record.getBlockId())); record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId()));
} }
}); });
} }
@ -79,7 +75,7 @@ public class BlockRewriter {
map(Type.LONG); // Chunk position map(Type.LONG); // Chunk position
handler(wrapper -> { handler(wrapper -> {
for (BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) { for (BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) {
record.setBlockId(blockStateRewriter.rewrite(record.getBlockId())); record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId()));
} }
}); });
} }
@ -91,7 +87,7 @@ public class BlockRewriter {
registerBlockChange(packetType); registerBlockChange(packetType);
} }
public void registerEffect(ClientboundPacketType packetType, int playRecordId, int blockBreakId, IdRewriteFunction itemIdRewriteFunction) { public void registerEffect(ClientboundPacketType packetType, int playRecordId, int blockBreakId) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -102,9 +98,9 @@ public class BlockRewriter {
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
int data = wrapper.get(Type.INT, 1); int data = wrapper.get(Type.INT, 1);
if (id == playRecordId) { // Play record if (id == playRecordId) { // Play record
wrapper.set(Type.INT, 1, itemIdRewriteFunction.rewrite(data)); wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data));
} else if (id == blockBreakId) { // Block break + block break sound } else if (id == blockBreakId) { // Block break + block break sound
wrapper.set(Type.INT, 1, blockStateRewriter.rewrite(data)); wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data));
} }
}); });
} }
@ -136,7 +132,7 @@ public class BlockRewriter {
if (id == -1) return; if (id == -1) return;
if (id == blockId || id == fallingDustId) { if (id == blockId || id == fallingDustId) {
int data = wrapper.passthrough(Type.VAR_INT); int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, blockStateRewriter.rewrite(data)); wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == itemId) { } else if (id == itemId) {
// Has to be like this, until we make *everything* object oriented inside of each protocol :( // Has to be like this, until we make *everything* object oriented inside of each protocol :(
itemRewriteFunction.rewrite(wrapper.passthrough(itemType)); itemRewriteFunction.rewrite(wrapper.passthrough(itemType));

Datei anzeigen

@ -180,4 +180,8 @@ public class ComponentRewriter {
processText(jsonElement); processText(jsonElement);
} }
} }
public <T extends Protocol> T getProtocol() {
return (T) protocol;
}
} }

Datei anzeigen

@ -106,13 +106,13 @@ public class ItemRewriter {
}); });
} }
public void registerSetCooldown(ClientboundPacketType packetType, IdRewriteFunction itemIDRewriteFunction) { public void registerSetCooldown(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
int itemId = wrapper.read(Type.VAR_INT); int itemId = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, itemIDRewriteFunction.rewrite(itemId)); wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId));
}); });
} }
}); });

Datei anzeigen

@ -20,7 +20,7 @@ import java.util.logging.Logger;
public abstract class MetadataRewriter { public abstract class MetadataRewriter {
private final Class<? extends EntityTracker> entityTrackerClass; private final Class<? extends EntityTracker> entityTrackerClass;
private final Protocol protocol; protected final Protocol protocol;
private Int2IntMap typeMapping; private Int2IntMap typeMapping;
protected MetadataRewriter(Protocol protocol, Class<? extends EntityTracker> entityTrackerClass) { protected MetadataRewriter(Protocol protocol, Class<? extends EntityTracker> entityTrackerClass) {
@ -64,7 +64,7 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType, IdRewriteFunction itemRewriter) { public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) {
protocol.registerOutgoing(packetType, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -82,7 +82,7 @@ public abstract class MetadataRewriter {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
EntityType entityType = wrapper.user().get(entityTrackerClass).getEntity(entityId); EntityType entityType = wrapper.user().get(entityTrackerClass).getEntity(entityId);
if (entityType == fallingBlockType) { if (entityType == fallingBlockType) {
wrapper.set(Type.INT, 0, itemRewriter.rewrite(wrapper.get(Type.INT, 0))); wrapper.set(Type.INT, 0, protocol.getMappingData().getNewItemId(wrapper.get(Type.INT, 0)));
} }
}); });
} }

Datei anzeigen

@ -7,9 +7,13 @@ import us.myles.ViaVersion.api.type.Type;
public class SoundRewriter { public class SoundRewriter {
protected final Protocol protocol; protected final Protocol protocol;
// Can't hold the mappings instance here since it's loaded later
protected final IdRewriteFunction idRewriter; protected final IdRewriteFunction idRewriter;
public SoundRewriter(Protocol protocol) {
this.protocol = protocol;
this.idRewriter = id -> protocol.getMappingData().getSoundMappings().getNewId(id);
}
public SoundRewriter(Protocol protocol, IdRewriteFunction idRewriter) { public SoundRewriter(Protocol protocol, IdRewriteFunction idRewriter) {
this.protocol = protocol; this.protocol = protocol;
this.idRewriter = idRewriter; this.idRewriter = idRewriter;

Datei anzeigen

@ -8,24 +8,12 @@ import us.myles.ViaVersion.api.type.Type;
public class StatisticsRewriter { public class StatisticsRewriter {
private final Protocol protocol; private final Protocol protocol;
private final IdRewriteFunction blockRewriter;
private final IdRewriteFunction itemRewriter;
private final IdRewriteFunction entityRewriter; private final IdRewriteFunction entityRewriter;
private final IdRewriteFunction statisticsIdRewriter;
private final int customStatsCategory = 8; // Make this changeable if it differs in a future version private final int customStatsCategory = 8; // Make this changeable if it differs in a future version
public StatisticsRewriter(Protocol protocol, public StatisticsRewriter(Protocol protocol, @Nullable IdRewriteFunction entityRewriter) {
@Nullable IdRewriteFunction blockRewriter, @Nullable IdRewriteFunction itemRewriter, @Nullable IdRewriteFunction entityRewriter,
@Nullable IdRewriteFunction statisticsIdRewriter) {
this.protocol = protocol; this.protocol = protocol;
this.blockRewriter = blockRewriter;
this.itemRewriter = itemRewriter;
this.entityRewriter = entityRewriter; this.entityRewriter = entityRewriter;
this.statisticsIdRewriter = statisticsIdRewriter;
}
public StatisticsRewriter(Protocol protocol, @Nullable IdRewriteFunction blockRewriter, @Nullable IdRewriteFunction itemRewriter, @Nullable IdRewriteFunction entityRewriter) {
this(protocol, blockRewriter, itemRewriter, entityRewriter, null);
} }
public void register(ClientboundPacketType packetType) { public void register(ClientboundPacketType packetType) {
@ -39,9 +27,9 @@ public class StatisticsRewriter {
int categoryId = wrapper.read(Type.VAR_INT); int categoryId = wrapper.read(Type.VAR_INT);
int statisticId = wrapper.read(Type.VAR_INT); int statisticId = wrapper.read(Type.VAR_INT);
int value = wrapper.read(Type.VAR_INT); int value = wrapper.read(Type.VAR_INT);
if (categoryId == customStatsCategory && statisticsIdRewriter != null) { if (categoryId == customStatsCategory && protocol.getMappingData().getStatisticsMappings() != null) {
// Rewrite custom statistics id // Rewrite custom statistics id
statisticId = statisticsIdRewriter.rewrite(statisticId); statisticId = protocol.getMappingData().getStatisticsMappings().getNewId(statisticId);
if (statisticId == -1) { if (statisticId == -1) {
// Remove entry // Remove entry
newSize--; newSize--;
@ -73,9 +61,9 @@ public class StatisticsRewriter {
protected IdRewriteFunction getRewriter(RegistryType type) { protected IdRewriteFunction getRewriter(RegistryType type) {
switch (type) { switch (type) {
case BLOCK: case BLOCK:
return blockRewriter; return protocol.getMappingData().getBlockMappings() != null ? id -> protocol.getMappingData().getNewBlockId(id) : null;
case ITEM: case ITEM:
return itemRewriter; return protocol.getMappingData().getItemMappings() != null ? id -> protocol.getMappingData().getNewItemId(id) : null;
case ENTITY: case ENTITY:
return entityRewriter; return entityRewriter;
} }

Datei anzeigen

@ -2,7 +2,9 @@ package us.myles.ViaVersion.api.rewriters;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.MappingData;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType; import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
@ -14,18 +16,14 @@ import java.util.List;
public class TagRewriter { public class TagRewriter {
private static final int[] EMPTY_ARRAY = {}; private static final int[] EMPTY_ARRAY = {};
private final Protocol protocol; private final Protocol protocol;
private final IdRewriteFunction blockRewriter;
private final IdRewriteFunction itemRewriter;
private final IdRewriteFunction entityRewriter; private final IdRewriteFunction entityRewriter;
private final List<TagData> newBlockTags = new ArrayList<>(); private final List<TagData> newBlockTags = new ArrayList<>();
private final List<TagData> newItemTags = new ArrayList<>(); private final List<TagData> newItemTags = new ArrayList<>();
private final List<TagData> newEntityTags = new ArrayList<>(); private final List<TagData> newEntityTags = new ArrayList<>();
// add fluid tag list if needed at some point // add fluid tag list if needed at some point
public TagRewriter(Protocol protocol, IdRewriteFunction blockRewriter, IdRewriteFunction itemRewriter, IdRewriteFunction entityRewriter) { public TagRewriter(Protocol protocol, @Nullable IdRewriteFunction entityRewriter) {
this.protocol = protocol; this.protocol = protocol;
this.blockRewriter = blockRewriter;
this.itemRewriter = itemRewriter;
this.entityRewriter = entityRewriter; this.entityRewriter = entityRewriter;
} }
@ -58,8 +56,9 @@ public class TagRewriter {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
handle(wrapper, blockRewriter, newBlockTags); MappingData mappingData = protocol.getMappingData();
handle(wrapper, itemRewriter, newItemTags); handle(wrapper, id -> mappingData != null ? mappingData.getNewBlockId(id) : null, newBlockTags);
handle(wrapper, id -> mappingData != null ? mappingData.getNewItemId(id) : null, newItemTags);
if (entityRewriter == null && newEntityTags.isEmpty()) return; if (entityRewriter == null && newEntityTags.isEmpty()) return;
@ -122,12 +121,13 @@ public class TagRewriter {
} }
} }
@Nullable
private IdRewriteFunction getRewriter(RegistryType tagType) { private IdRewriteFunction getRewriter(RegistryType tagType) {
switch (tagType) { switch (tagType) {
case BLOCK: case BLOCK:
return blockRewriter; return protocol.getMappingData().getBlockMappings() != null ? id -> protocol.getMappingData().getNewBlockId(id) : null;
case ITEM: case ITEM:
return itemRewriter; return protocol.getMappingData().getItemMappings() != null ? id -> protocol.getMappingData().getNewItemId(id) : null;
case ENTITY: case ENTITY:
return entityRewriter; return entityRewriter;
case FLUID: case FLUID:

Datei anzeigen

@ -13,6 +13,7 @@ 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.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_9; import us.myles.ViaVersion.api.type.types.version.Types1_9;
@ -39,7 +40,7 @@ public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, Client
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_11To1_10 metadataRewriter = new MetadataRewriter1_11To1_10(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_11To1_10(this);
InventoryPackets.register(this); InventoryPackets.register(this);

Datei anzeigen

@ -13,6 +13,7 @@ import us.myles.ViaVersion.api.platform.providers.ViaProviders;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_12; import us.myles.ViaVersion.api.type.types.version.Types1_12;
@ -34,7 +35,7 @@ public class Protocol1_12To1_11_1 extends Protocol<ClientboundPackets1_9_3, Clie
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_12To1_11_1 metadataRewriter = new MetadataRewriter1_12To1_11_1(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_12To1_11_1(this);
InventoryPackets.register(this); InventoryPackets.register(this);

Datei anzeigen

@ -1,12 +1,14 @@
package us.myles.ViaVersion.protocols.protocol1_13_1to1_13; package us.myles.ViaVersion.protocols.protocol1_13_1to1_13;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.MappingData;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter; 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_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13;
@ -20,13 +22,15 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> { public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
public static final MappingData MAPPINGS = new MappingData("1.13", "1.13.2", true);
public Protocol1_13_1To1_13() { public Protocol1_13_1To1_13() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
new MetadataRewriter1_13_1To1_13(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_13_1To1_13(this);
EntityPackets.register(this); EntityPackets.register(this);
InventoryPackets.register(this); InventoryPackets.register(this);
@ -130,7 +134,7 @@ public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, Clien
wrapper.passthrough(Type.STRING); wrapper.passthrough(Type.STRING);
int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blocks.length; j++) { for (int j = 0; j < blocks.length; j++) {
blocks[j] = getNewBlockId(blocks[j]); blocks[j] = getMappingData().getNewBlockId(blocks[j]);
} }
} }
int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags
@ -138,7 +142,7 @@ public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, Clien
wrapper.passthrough(Type.STRING); wrapper.passthrough(Type.STRING);
int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < items.length; j++) { for (int j = 0; j < items.length; j++) {
items[j] = InventoryPackets.getNewItemId(items[j]); items[j] = getMappingData().getNewItemId(items[j]);
} }
} }
} }
@ -146,7 +150,7 @@ public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, Clien
} }
}); });
new StatisticsRewriter(this, null, null, null, id -> { new StatisticsRewriter(this, id -> {
int newId = id; int newId = id;
if (newId > 22) { if (newId > 22) {
newId += 2; newId += 2;
@ -169,26 +173,8 @@ public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, Clien
} }
} }
@Override
public static int getNewBlockStateId(int blockId) { public MappingData getMappingData() {
if (blockId > 8573) { return MAPPINGS;
blockId += 17;
} else if (blockId > 8463) {
blockId += 16;
} else if (blockId > 8458) {
blockId = 8470 + (blockId - 8459) * 2;
} else if (blockId > 1126) {
blockId += 1;
}
return blockId;
}
public static int getNewBlockId(final int oldBlockId) {
int blockId = oldBlockId;
if (oldBlockId >= 561) {
blockId += 5;
}
return blockId;
} }
} }

Datei anzeigen

@ -27,7 +27,7 @@ public class MetadataRewriter1_13_1To1_13 extends MetadataRewriter {
} else if (metadata.getMetaType() == MetaType1_13.BlockID) { } else if (metadata.getMetaType() == MetaType1_13.BlockID) {
// Convert to new block id // Convert to new block id
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_13_1To1_13.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
if (type == null) return; if (type == null) return;
@ -35,7 +35,7 @@ public class MetadataRewriter1_13_1To1_13 extends MetadataRewriter {
if (type.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) { if (type.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) {
// New block format // New block format
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_13_1To1_13.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
if (type.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW) && metadata.getId() >= 7) { if (type.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW) && metadata.getId() >= 7) {

Datei anzeigen

@ -40,7 +40,7 @@ public class EntityPackets {
if (entType != null) { if (entType != null) {
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) {
int data = wrapper.get(Type.INT, 0); int data = wrapper.get(Type.INT, 0);
wrapper.set(Type.INT, 0, Protocol1_13_1To1_13.getNewBlockStateId(data)); wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} }
// Register Type ID // Register Type ID
wrapper.user().get(EntityTracker1_13.class).addEntity(entityId, entType); wrapper.user().get(EntityTracker1_13.class).addEntity(entityId, entType);

Datei anzeigen

@ -2,26 +2,34 @@ package us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets;
import us.myles.ViaVersion.api.PacketWrapper; 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.protocol.Protocol;
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.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.rewriters.RecipeRewriter; import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
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;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol1_13_1To1_13 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);
itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY); itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_ITEM); itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_ITEM);
protocol.registerOutgoing(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
int itemId = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId));
});
}
});
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -80,25 +88,11 @@ public class InventoryPackets {
public static void toClient(Item item) { public static void toClient(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(Protocol1_13_1To1_13.MAPPINGS.getNewItemId(item.getIdentifier()));
}
public static int getNewItemId(int itemId) {
if (itemId >= 443) {
return itemId + 5;
}
return itemId;
} }
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getOldItemId(item.getIdentifier())); item.setIdentifier(Protocol1_13_1To1_13.MAPPINGS.getOldItemId(item.getIdentifier()));
}
public static int getOldItemId(int newId) {
if (newId >= 448) {
return newId - 5;
}
return newId;
} }
} }

Datei anzeigen

@ -8,7 +8,6 @@ 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.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
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.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@ -16,7 +15,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class WorldPackets { public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13_1To1_13::getNewBlockStateId, Protocol1_13_1To1_13::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION);
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
@Override @Override
@ -30,7 +29,7 @@ public class WorldPackets {
for (ChunkSection section : chunk.getSections()) { for (ChunkSection section : chunk.getSections()) {
if (section == null) continue; if (section == null) continue;
for (int i = 0; i < section.getPaletteSize(); i++) { for (int i = 0; i < section.getPaletteSize(); i++) {
section.setPaletteEntry(i, Protocol1_13_1To1_13.getNewBlockStateId(section.getPaletteEntry(i))); section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(section.getPaletteEntry(i)));
} }
} }
} }
@ -41,7 +40,7 @@ public class WorldPackets {
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION); blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE); blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE); blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets::getNewItemId); blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001);
protocol.registerOutgoing(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
@Override @Override

Datei anzeigen

@ -17,6 +17,7 @@ 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.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
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;
@ -25,7 +26,11 @@ import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.*; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.StatisticData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
@ -39,12 +44,18 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTra
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> { public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
public static final MappingData MAPPINGS = new MappingData();
public Protocol1_13To1_12_2() { public Protocol1_13To1_12_2() {
super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class, true); super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class);
} }
public static final PacketHandler POS_TO_3_INT = wrapper -> { public static final PacketHandler POS_TO_3_INT = wrapper -> {
@ -54,10 +65,8 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
wrapper.write(Type.INT, position.getZ()); wrapper.write(Type.INT, position.getZ());
}; };
public static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS = private static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS =
new PacketHandler() { // *insert here a good name* w -> {
@Override
public void handle(PacketWrapper w) throws Exception {
// Send fake declare commands // Send fake declare commands
w.create(0x11, new ValueCreator() { w.create(0x11, new ValueCreator() {
@Override @Override
@ -85,27 +94,26 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
w.create(0x55, new ValueCreator() { w.create(0x55, new ValueCreator() {
@Override @Override
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, MappingData.blockTags.size()); // block tags wrapper.write(Type.VAR_INT, MAPPINGS.getBlockTags().size()); // block tags
for (Map.Entry<String, Integer[]> tag : MappingData.blockTags.entrySet()) { for (Map.Entry<String, Integer[]> tag : MAPPINGS.getBlockTags().entrySet()) {
wrapper.write(Type.STRING, tag.getKey()); wrapper.write(Type.STRING, tag.getKey());
// Needs copy as other protocols may modify it // Needs copy as other protocols may modify it
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue())); wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
} }
wrapper.write(Type.VAR_INT, MappingData.itemTags.size()); // item tags wrapper.write(Type.VAR_INT, MAPPINGS.getItemTags().size()); // item tags
for (Map.Entry<String, Integer[]> tag : MappingData.itemTags.entrySet()) { for (Map.Entry<String, Integer[]> tag : MAPPINGS.getItemTags().entrySet()) {
wrapper.write(Type.STRING, tag.getKey()); wrapper.write(Type.STRING, tag.getKey());
// Needs copy as other protocols may modify it // Needs copy as other protocols may modify it
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue())); wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
} }
wrapper.write(Type.VAR_INT, MappingData.fluidTags.size()); // fluid tags wrapper.write(Type.VAR_INT, MAPPINGS.getFluidTags().size()); // fluid tags
for (Map.Entry<String, Integer[]> tag : MappingData.fluidTags.entrySet()) { for (Map.Entry<String, Integer[]> tag : MAPPINGS.getFluidTags().entrySet()) {
wrapper.write(Type.STRING, tag.getKey()); wrapper.write(Type.STRING, tag.getKey());
// Needs copy as other protocols may modify it // Needs copy as other protocols may modify it
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue())); wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, toPrimitive(tag.getValue()));
} }
} }
}).send(Protocol1_13To1_12_2.class); }).send(Protocol1_13To1_12_2.class);
}
}; };
// These are arbitrary rewrite values, it just needs an invalid color code character. // These are arbitrary rewrite values, it just needs an invalid color code character.
@ -140,7 +148,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
@Override @Override
protected void registerPackets() { protected void registerPackets() {
new MetadataRewriter1_13To1_12_2(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_13To1_12_2(this);
// Register grouped packet changes // Register grouped packet changes
EntityPackets.register(this); EntityPackets.register(this);
@ -330,7 +338,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
wrapper.cancel(); wrapper.cancel();
if (item == 383) { // Spawn egg if (item == 383) { // Spawn egg
for (int i = 0; i < 44; i++) { for (int i = 0; i < 44; i++) {
Integer newItem = MappingData.oldToNewItems.get(item << 16 | i); Integer newItem = getMappingData().getItemMappings().get(item << 16 | i);
if (newItem != null) { if (newItem != null) {
PacketWrapper packet = wrapper.create(0x18); PacketWrapper packet = wrapper.create(0x18);
packet.write(Type.VAR_INT, newItem); packet.write(Type.VAR_INT, newItem);
@ -342,7 +350,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
} }
} else { } else {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
int newItem = MappingData.oldToNewItems.get(item << 4 | i); int newItem = getMappingData().getItemMappings().get(item << 4 | i);
if (newItem != -1) { if (newItem != -1) {
PacketWrapper packet = wrapper.create(0x18); PacketWrapper packet = wrapper.create(0x18);
packet.write(Type.VAR_INT, newItem); packet.write(Type.VAR_INT, newItem);
@ -377,7 +385,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
int data = wrapper.get(Type.INT, 1); int data = wrapper.get(Type.INT, 1);
if (id == 1010) { // Play record if (id == 1010) { // Play record
wrapper.set(Type.INT, 1, MappingData.oldToNewItems.get(data << 4)); wrapper.set(Type.INT, 1, getMappingData().getItemMappings().get(data << 4));
} else if (id == 2001) { // Block break + block break sound } else if (id == 2001) { // Block break + block break sound
int blockId = data & 0xFFF; int blockId = data & 0xFFF;
int blockData = data >> 12; int blockData = data >> 12;
@ -679,7 +687,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
}); });
// New 0x4C - Stop Sound // New 0x4C - Stop Sound
new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(ClientboundPackets1_12_1.SOUND); new SoundRewriter(this).registerSound(ClientboundPackets1_12_1.SOUND);
registerOutgoing(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() { registerOutgoing(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() {
@Override @Override
@ -1015,8 +1023,7 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
} }
@Override @Override
protected void loadMappingData() { protected void onMappingDataLoaded() {
MappingData.init();
ConnectionData.init(); ConnectionData.init();
RecipeData.init(); RecipeData.init();
BlockIdData.init(); BlockIdData.init();
@ -1086,4 +1093,9 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
} }
return prim; return prim;
} }
@Override
public MappingData getMappingData() {
return MAPPINGS;
}
} }

Datei anzeigen

@ -205,7 +205,7 @@ public class ConnectionData {
Via.getPlatform().getLogger().info("Loading block connection mappings ..."); Via.getPlatform().getLogger().info("Loading block connection mappings ...");
JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json", true); JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json", true);
JsonObject blocks1_13 = mapping1_13.getAsJsonObject("blocks"); JsonObject blocks1_13 = mapping1_13.getAsJsonObject("blockstates");
for (Entry<String, JsonElement> blockState : blocks1_13.entrySet()) { for (Entry<String, JsonElement> blockState : blocks1_13.entrySet()) {
int id = Integer.parseInt(blockState.getKey()); int id = Integer.parseInt(blockState.getKey());
String key = blockState.getValue().getAsString(); String key = blockState.getValue().getAsString();

Datei anzeigen

@ -2,13 +2,13 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.prov
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.platform.providers.Provider; import us.myles.ViaVersion.api.platform.providers.Provider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
public class BlockConnectionProvider implements Provider { public class BlockConnectionProvider implements Provider {
public int getBlockData(UserConnection connection, int x, int y, int z) { public int getBlockData(UserConnection connection, int x, int y, int z) {
int oldId = getWorldBlockData(connection, x, y, z); int oldId = getWorldBlockData(connection, x, y, z);
return MappingData.blockMappings.getNewId(oldId); return Protocol1_13To1_12_2.MAPPINGS.getBlockMappings().getNewId(oldId);
} }
public int getWorldBlockData(UserConnection connection, int x, int y, int z) { public int getWorldBlockData(UserConnection connection, int x, int y, int z) {

Datei anzeigen

@ -11,6 +11,7 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.nbt.BinaryTagIO; import us.myles.ViaVersion.api.minecraft.nbt.BinaryTagIO;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.rewriters.ComponentRewriter; import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import java.io.IOException; import java.io.IOException;
@ -103,9 +104,10 @@ public class ComponentRewriter1_13 extends ComponentRewriter {
protected void handleTranslate(JsonObject object, String translate) { protected void handleTranslate(JsonObject object, String translate) {
super.handleTranslate(object, translate); super.handleTranslate(object, translate);
String newTranslate; String newTranslate;
newTranslate = MappingData.translateMapping.get(translate); Protocol1_13To1_12_2 protocol = getProtocol();
newTranslate = protocol.getMappingData().getTranslateMapping().get(translate);
if (newTranslate == null) { if (newTranslate == null) {
newTranslate = MappingData.mojangTranslation.get(translate); newTranslate = protocol.getMappingData().getMojangTranslation().get(translate);
} }
if (newTranslate != null) { if (newTranslate != null) {
object.addProperty("translate", newTranslate); object.addProperty("translate", newTranslate);

Datei anzeigen

@ -7,11 +7,11 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader; import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings; import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
import us.myles.ViaVersion.util.Int2IntBiMap;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -20,34 +20,44 @@ import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class MappingData { public class MappingData extends us.myles.ViaVersion.api.data.MappingData {
public static final Int2IntBiMap oldToNewItems = new Int2IntBiMap(); private final Map<String, Integer[]> blockTags = new HashMap<>();
public static final Map<String, Integer[]> blockTags = new HashMap<>(); private final Map<String, Integer[]> itemTags = new HashMap<>();
public static final Map<String, Integer[]> itemTags = new HashMap<>(); private final Map<String, Integer[]> fluidTags = new HashMap<>();
public static final Map<String, Integer[]> fluidTags = new HashMap<>(); private final BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create();
public static final BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create(); private final Map<String, String> translateMapping = new HashMap<>();
public static final Map<String, String> translateMapping = new HashMap<>(); private final Map<String, String> mojangTranslation = new HashMap<>();
public static final Map<String, String> mojangTranslation = new HashMap<>(); private final BiMap<String, String> channelMappings = HashBiMap.create(); // 1.12->1.13
public static final BiMap<String, String> channelMappings = HashBiMap.create(); // 1.12->1.13 private Mappings enchantmentMappings;
public static Mappings enchantmentMappings;
public static Mappings soundMappings;
public static Mappings blockMappings;
public static void init() { public MappingData() {
Via.getPlatform().getLogger().info("Loading 1.12.2 -> 1.13 mappings..."); super("1.12", "1.13");
JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json", true); }
JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json", true);
oldToNewItems.defaultReturnValue(-1); @Override
blockMappings = new BlockMappingsShortArray(mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks")); public void loadExtras(JsonObject oldMappings, JsonObject newMappings, JsonObject diffMappings) {
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items")); loadTags(blockTags, newMappings.getAsJsonObject("block_tags"));
loadTags(blockTags, mapping1_13.getAsJsonObject("block_tags")); loadTags(itemTags, newMappings.getAsJsonObject("item_tags"));
loadTags(itemTags, mapping1_13.getAsJsonObject("item_tags")); loadTags(fluidTags, newMappings.getAsJsonObject("fluid_tags"));
loadTags(fluidTags, mapping1_13.getAsJsonObject("fluid_tags"));
loadEnchantments(oldEnchantmentsIds, mapping1_12.getAsJsonObject("enchantments")); loadEnchantments(oldEnchantmentsIds, oldMappings.getAsJsonObject("enchantments"));
enchantmentMappings = new Mappings(72, mapping1_12.getAsJsonObject("enchantments"), mapping1_13.getAsJsonObject("enchantments")); enchantmentMappings = new Mappings(72, oldMappings.getAsJsonObject("enchantments"), newMappings.getAsJsonObject("enchantments"));
soundMappings = new Mappings(662, mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
// Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
if (Via.getConfig().isSnowCollisionFix()) {
blockMappings.getOldToNew()[1248] = 3416;
}
// Remap infested blocks, as they are instantly breakabale in 1.13+ and can't be broken by those clients on older servers
if (Via.getConfig().isInfestedBlocksFix()) {
short[] oldToNew = blockMappings.getOldToNew();
oldToNew[1552] = 1; // stone
oldToNew[1553] = 14; // cobblestone
oldToNew[1554] = 3983; // stone bricks
oldToNew[1555] = 3984; // mossy stone bricks
oldToNew[1556] = 3985; // cracked stone bricks
oldToNew[1557] = 3986; // chiseled stone bricks
}
JsonObject object = MappingDataLoader.loadFromDataDir("channelmappings-1.13.json"); JsonObject object = MappingDataLoader.loadFromDataDir("channelmappings-1.13.json");
if (object != null) { if (object != null) {
@ -94,6 +104,16 @@ public class MappingData {
} }
} }
@Override
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
if (key.equals("blocks")) {
// Need to use a custom size since there are larger gaps in ids
return new Mappings(4084, oldMappings.getAsJsonObject("blocks"), newMappings.getAsJsonObject("blockstates"));
} else {
return super.loadFromObject(oldMappings, newMappings, diffMappings, key);
}
}
public static String validateNewChannel(String newId) { public static String validateNewChannel(String newId) {
if (!isValid1_13Channel(newId)) { if (!isValid1_13Channel(newId)) {
return null; // Not valid return null; // Not valid
@ -110,7 +130,7 @@ public class MappingData {
return channelId.matches("([0-9a-z_.-]+):([0-9a-z_/.-]+)"); return channelId.matches("([0-9a-z_.-]+):([0-9a-z_/.-]+)");
} }
private static void loadTags(Map<String, Integer[]> output, JsonObject newTags) { private void loadTags(Map<String, Integer[]> output, JsonObject newTags) {
for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) { for (Map.Entry<String, JsonElement> entry : newTags.entrySet()) {
JsonArray ids = entry.getValue().getAsJsonArray(); JsonArray ids = entry.getValue().getAsJsonArray();
Integer[] idsArray = new Integer[ids.size()]; Integer[] idsArray = new Integer[ids.size()];
@ -121,31 +141,41 @@ public class MappingData {
} }
} }
private static void loadEnchantments(Map<Short, String> output, JsonObject enchantments) { private void loadEnchantments(Map<Short, String> output, JsonObject enchantments) {
for (Map.Entry<String, JsonElement> enchantment : enchantments.entrySet()) { for (Map.Entry<String, JsonElement> enchantment : enchantments.entrySet()) {
output.put(Short.parseShort(enchantment.getKey()), enchantment.getValue().getAsString()); output.put(Short.parseShort(enchantment.getKey()), enchantment.getValue().getAsString());
} }
} }
private static class BlockMappingsShortArray extends Mappings { public Map<String, Integer[]> getBlockTags() {
return blockTags;
private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) {
super(4084, mapping1_12, mapping1_13);
// Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
if (Via.getConfig().isSnowCollisionFix()) {
oldToNew[1248] = 3416;
} }
// Remap infested blocks, as they are instantly breakabale in 1.13+ and can't be broken by those clients on older servers public Map<String, Integer[]> getItemTags() {
if (Via.getConfig().isInfestedBlocksFix()) { return itemTags;
oldToNew[1552] = 1; // stone
oldToNew[1553] = 14; // cobblestone
oldToNew[1554] = 3983; // stone bricks
oldToNew[1555] = 3984; // mossy stone bricks
oldToNew[1556] = 3985; // cracked stone bricks
oldToNew[1557] = 3986; // chiseled stone bricks
} }
public Map<String, Integer[]> getFluidTags() {
return fluidTags;
} }
public BiMap<Short, String> getOldEnchantmentsIds() {
return oldEnchantmentsIds;
}
public Map<String, String> getTranslateMapping() {
return translateMapping;
}
public Map<String, String> getMojangTranslation() {
return mojangTranslation;
}
public BiMap<String, String> getChannelMappings() {
return channelMappings;
}
public Mappings getEnchantmentMappings() {
return enchantmentMappings;
} }
} }

Datei anzeigen

@ -12,7 +12,6 @@ import com.google.common.primitives.Ints;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol;
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.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
@ -35,7 +34,7 @@ import java.util.Optional;
public class InventoryPackets { public class InventoryPackets {
private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_13To1_12_2.class.getSimpleName(); private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_13To1_12_2.class.getSimpleName();
public static void register(Protocol protocol) { public static void register(Protocol1_13To1_12_2 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
protocol.registerOutgoing(ClientboundPackets1_12_1.SET_SLOT, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_12_1.SET_SLOT, new PacketRemapper() {
@ -69,7 +68,7 @@ public class InventoryPackets {
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
short property = wrapper.get(Type.SHORT, 0); short property = wrapper.get(Type.SHORT, 0);
if (property >= 4 && property <= 6) { // Enchantment id if (property >= 4 && property <= 6) { // Enchantment id
wrapper.set(Type.SHORT, 1, (short) MappingData.enchantmentMappings.getNewId(wrapper.get(Type.SHORT, 1))); wrapper.set(Type.SHORT, 1, (short) protocol.getMappingData().getEnchantmentMappings().getNewId(wrapper.get(Type.SHORT, 1)));
} }
} }
}); });
@ -315,7 +314,7 @@ public class InventoryPackets {
if (enchEntry instanceof CompoundTag) { if (enchEntry instanceof CompoundTag) {
CompoundTag enchantmentEntry = new CompoundTag(""); CompoundTag enchantmentEntry = new CompoundTag("");
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue(); short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
String newId = MappingData.oldEnchantmentsIds.get(oldId); String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
if (newId == null) { if (newId == null) {
newId = "viaversion:legacy/" + oldId; newId = "viaversion:legacy/" + oldId;
} }
@ -334,7 +333,7 @@ public class InventoryPackets {
if (enchEntry instanceof CompoundTag) { if (enchEntry instanceof CompoundTag) {
CompoundTag enchantmentEntry = new CompoundTag(""); CompoundTag enchantmentEntry = new CompoundTag("");
short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue(); short oldId = ((Number) ((CompoundTag) enchEntry).get("id").getValue()).shortValue();
String newId = MappingData.oldEnchantmentsIds.get(oldId); String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
if (newId == null) { if (newId == null) {
newId = "viaversion:legacy/" + oldId; newId = "viaversion:legacy/" + oldId;
} }
@ -420,14 +419,14 @@ public class InventoryPackets {
} }
} }
if (!MappingData.oldToNewItems.containsKey(rawId)) { if (!Protocol1_13To1_12_2.MAPPINGS.getItemMappings().containsKey(rawId)) {
if (!isDamageable(item.getIdentifier()) && item.getIdentifier() != 358) { // Map if (!isDamageable(item.getIdentifier()) && item.getIdentifier() != 358) { // Map
if (tag == null) item.setTag(tag = new CompoundTag("tag")); if (tag == null) item.setTag(tag = new CompoundTag("tag"));
tag.put(new IntTag(NBT_TAG_NAME, originalId)); // Data will be lost, saving original id tag.put(new IntTag(NBT_TAG_NAME, originalId)); // Data will be lost, saving original id
} }
if (item.getIdentifier() == 31 && item.getData() == 0) { // Shrub was removed if (item.getIdentifier() == 31 && item.getData() == 0) { // Shrub was removed
rawId = 32 << 4; // Dead Bush rawId = 32 << 4; // Dead Bush
} else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) { } else if (Protocol1_13To1_12_2.MAPPINGS.getItemMappings().containsKey(rawId & ~0xF)) {
rawId &= ~0xF; // Remove data rawId &= ~0xF; // Remove data
} else { } else {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
@ -437,7 +436,7 @@ public class InventoryPackets {
} }
} }
item.setIdentifier(MappingData.oldToNewItems.get(rawId)); item.setIdentifier(Protocol1_13To1_12_2.MAPPINGS.getItemMappings().get(rawId));
item.setData((short) 0); item.setData((short) 0);
} }
@ -463,7 +462,7 @@ public class InventoryPackets {
case "bungeecord:main": case "bungeecord:main":
return null; return null;
default: default:
String mappedChannel = MappingData.channelMappings.get(old); String mappedChannel = Protocol1_13To1_12_2.MAPPINGS.getChannelMappings().get(old);
if (mappedChannel != null) return mappedChannel; if (mappedChannel != null) return mappedChannel;
return MappingData.isValid1_13Channel(old) ? old : null; return MappingData.isValid1_13Channel(old) ? old : null;
} }
@ -489,7 +488,7 @@ public class InventoryPackets {
} }
if (rawId == null) { if (rawId == null) {
int oldId = MappingData.oldToNewItems.inverse().get(item.getIdentifier()); int oldId = Protocol1_13To1_12_2.MAPPINGS.getItemMappings().inverse().get(item.getIdentifier());
if (oldId != -1) { if (oldId != -1) {
// Handle spawn eggs // Handle spawn eggs
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId); Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
@ -576,7 +575,7 @@ public class InventoryPackets {
if (enchantmentEntry instanceof CompoundTag) { if (enchantmentEntry instanceof CompoundTag) {
CompoundTag enchEntry = new CompoundTag(""); CompoundTag enchEntry = new CompoundTag("");
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue(); String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId); Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
if (oldId == null && newId.startsWith("viaversion:legacy/")) { if (oldId == null && newId.startsWith("viaversion:legacy/")) {
oldId = Short.valueOf(newId.substring(18)); oldId = Short.valueOf(newId.substring(18));
} }
@ -602,7 +601,7 @@ public class InventoryPackets {
if (enchantmentEntry instanceof CompoundTag) { if (enchantmentEntry instanceof CompoundTag) {
CompoundTag enchEntry = new CompoundTag(""); CompoundTag enchEntry = new CompoundTag("");
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue(); String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId); Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
if (oldId == null && newId.startsWith("viaversion:legacy/")) { if (oldId == null && newId.startsWith("viaversion:legacy/")) {
oldId = Short.valueOf(newId.substring(18)); oldId = Short.valueOf(newId.substring(18));
} }
@ -695,7 +694,7 @@ public class InventoryPackets {
case "bungeecord:main": case "bungeecord:main":
return "BungeeCord"; return "BungeeCord";
default: default:
String mappedChannel = MappingData.channelMappings.inverse().get(newId); String mappedChannel = Protocol1_13To1_12_2.MAPPINGS.getChannelMappings().inverse().get(newId);
if (mappedChannel != null) return mappedChannel; if (mappedChannel != null) return mappedChannel;
return newId.length() > 20 ? newId.substring(0, 20) : newId; return newId.length() > 20 ? newId.substring(0, 20) : newId;
} }

Datei anzeigen

@ -19,7 +19,6 @@ import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
@ -535,11 +534,11 @@ public class WorldPackets {
if (oldId < 0) { if (oldId < 0) {
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air. oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
} }
int newId = MappingData.blockMappings.getNewId(oldId); int newId = Protocol1_13To1_12_2.MAPPINGS.getBlockMappings().getNewId(oldId);
if (newId != -1) { if (newId != -1) {
return newId; return newId;
} }
newId = MappingData.blockMappings.getNewId(oldId & ~0xF); // Remove data newId = Protocol1_13To1_12_2.MAPPINGS.getBlockMappings().getNewId(oldId & ~0xF); // Remove data
if (newId != -1) { if (newId != -1) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Missing block " + oldId); Via.getPlatform().getLogger().warning("Missing block " + oldId);

Datei anzeigen

@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray; import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -30,7 +30,7 @@ public class BlockConnectionStorage extends StoredObject {
Arrays.fill(REVERSE_BLOCK_MAPPINGS, (short) -1); Arrays.fill(REVERSE_BLOCK_MAPPINGS, (short) -1);
for (int i = 0; i < 4096; i++) { for (int i = 0; i < 4096; i++) {
int newBlock = MappingData.blockMappings.getNewId(i); int newBlock = Protocol1_13To1_12_2.MAPPINGS.getBlockMappings().getNewId(i);
if (newBlock != -1) { if (newBlock != -1) {
REVERSE_BLOCK_MAPPINGS[newBlock] = (short) i; REVERSE_BLOCK_MAPPINGS[newBlock] = (short) i;
} }

Datei anzeigen

@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_14_1to1_14;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1;
@ -16,7 +17,7 @@ public class Protocol1_14_1To1_14 extends Protocol<ClientboundPackets1_14, Clien
@Override @Override
protected void registerPackets() { protected void registerPackets() {
new MetadataRewriter1_14_1To1_14(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_14_1To1_14(this);
EntityPackets.register(this); EntityPackets.register(this);
} }

Datei anzeigen

@ -1,12 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2; package us.myles.ViaVersion.protocols.protocol1_14to1_13_2;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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.ComponentRewriter; import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter; import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@ -24,22 +24,23 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> { public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> {
public static final MappingData MAPPINGS = new MappingData();
public Protocol1_14To1_13_2() { public Protocol1_14To1_13_2() {
super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class, true); super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class);
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_14To1_13_2 metadataRewriter = new MetadataRewriter1_14To1_13_2(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_14To1_13_2(this);
InventoryPackets.register(this); InventoryPackets.register(this);
EntityPackets.register(this); EntityPackets.register(this);
WorldPackets.register(this); WorldPackets.register(this);
PlayerPackets.register(this); PlayerPackets.register(this);
new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(ClientboundPackets1_13.SOUND); new SoundRewriter(this).registerSound(ClientboundPackets1_13.SOUND);
new StatisticsRewriter(this, Protocol1_14To1_13_2::getNewBlockId, new StatisticsRewriter(this, metadataRewriter::getNewEntityId).register(ClientboundPackets1_13.STATISTICS);
InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId, id -> MappingData.statisticsMappings.getNewId(id)).register(ClientboundPackets1_13.STATISTICS);
ComponentRewriter componentRewriter = new ComponentRewriter1_14(this); ComponentRewriter componentRewriter = new ComponentRewriter1_14(this);
componentRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE); componentRewriter.registerChatMessage(ClientboundPackets1_13.CHAT_MESSAGE);
@ -56,21 +57,21 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
wrapper.passthrough(Type.STRING); wrapper.passthrough(Type.STRING);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blockIds.length; j++) { for (int j = 0; j < blockIds.length; j++) {
blockIds[j] = getNewBlockId(blockIds[j]); blockIds[j] = getMappingData().getNewBlockId(blockIds[j]);
} }
} }
// Minecraft crashes if we not send signs tags // Minecraft crashes if we not send signs tags
wrapper.write(Type.STRING, "minecraft:signs"); wrapper.write(Type.STRING, "minecraft:signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{
getNewBlockId(150), getNewBlockId(155) getMappingData().getNewBlockId(150), getMappingData().getNewBlockId(155)
}); });
wrapper.write(Type.STRING, "minecraft:wall_signs"); wrapper.write(Type.STRING, "minecraft:wall_signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{
getNewBlockId(155) getMappingData().getNewBlockId(155)
}); });
wrapper.write(Type.STRING, "minecraft:standing_signs"); wrapper.write(Type.STRING, "minecraft:standing_signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{
getNewBlockId(150) getMappingData().getNewBlockId(150)
}); });
// Fences and walls tags - used for block connections // Fences and walls tags - used for block connections
wrapper.write(Type.STRING, "minecraft:fences"); wrapper.write(Type.STRING, "minecraft:fences");
@ -85,13 +86,13 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
wrapper.passthrough(Type.STRING); wrapper.passthrough(Type.STRING);
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE); int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < itemIds.length; j++) { for (int j = 0; j < itemIds.length; j++) {
itemIds[j] = InventoryPackets.getNewItemId(itemIds[j]); itemIds[j] = getMappingData().getNewItemId(itemIds[j]);
} }
} }
// Should fix fuel shift clicking // Should fix fuel shift clicking
wrapper.write(Type.STRING, "minecraft:signs"); wrapper.write(Type.STRING, "minecraft:signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{ wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{
InventoryPackets.getNewItemId(541) getMappingData().getNewItemId(541)
}); });
// Arrows tag (used by bow) // Arrows tag (used by bow)
wrapper.write(Type.STRING, "minecraft:arrows"); wrapper.write(Type.STRING, "minecraft:arrows");
@ -116,29 +117,10 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
} }
@Override @Override
protected void loadMappingData() { protected void onMappingDataLoaded() {
MappingData.init(); WorldPackets.air = getMappingData().getBlockStateMappings().getNewId(0);
WorldPackets.air = MappingData.blockStateMappings.getNewId(0); WorldPackets.voidAir = getMappingData().getBlockStateMappings().getNewId(8591);
WorldPackets.voidAir = MappingData.blockStateMappings.getNewId(8591); WorldPackets.caveAir = getMappingData().getBlockStateMappings().getNewId(8592);
WorldPackets.caveAir = MappingData.blockStateMappings.getNewId(8592);
}
public static int getNewBlockStateId(int id) {
int newId = MappingData.blockStateMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.14 blockstate for 1.13.2 blockstate " + id);
return 0;
}
return newId;
}
public static int getNewBlockId(int id) {
int newId = MappingData.blockMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.14 block for 1.13.2 block " + id);
return 0;
}
return newId;
} }
@Override @Override
@ -148,4 +130,9 @@ public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, Clien
userConnection.put(new ClientWorld(userConnection)); userConnection.put(new ClientWorld(userConnection));
} }
} }
@Override
public MappingData getMappingData() {
return MAPPINGS;
}
} }

Datei anzeigen

@ -7,34 +7,21 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.ints.IntSet;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader; import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.util.Int2IntBiMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class MappingData { public class MappingData extends us.myles.ViaVersion.api.data.MappingData {
public static final Int2IntBiMap oldToNewItems = new Int2IntBiMap(); private IntSet motionBlocking;
public static Mappings blockStateMappings; private IntSet nonFullBlocks;
public static Mappings blockMappings;
public static Mappings soundMappings;
public static Mappings statisticsMappings;
public static IntSet motionBlocking;
public static IntSet nonFullBlocks;
public static void init() { public MappingData() {
Via.getPlatform().getLogger().info("Loading 1.13.2 -> 1.14 mappings..."); super("1.13.2", "1.14");
JsonObject mapping1_13_2 = MappingDataLoader.loadData("mapping-1.13.2.json", true); }
JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json", true);
oldToNewItems.defaultReturnValue(-1); @Override
blockStateMappings = new Mappings(mapping1_13_2.getAsJsonObject("blockstates"), mapping1_14.getAsJsonObject("blockstates")); public void loadExtras(JsonObject oldMappings, JsonObject newMappings, JsonObject diffMappings) {
blockMappings = new Mappings(mapping1_13_2.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks")); JsonObject blockStates = newMappings.getAsJsonObject("blockstates");
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_13_2.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items"));
soundMappings = new Mappings(mapping1_13_2.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"));
statisticsMappings = new Mappings(mapping1_13_2.getAsJsonArray("statistics"), mapping1_14.getAsJsonArray("statistics"));
JsonObject blockStates = mapping1_14.getAsJsonObject("blockstates");
Map<String, Integer> blockStateMap = new HashMap<>(blockStates.entrySet().size()); Map<String, Integer> blockStateMap = new HashMap<>(blockStates.entrySet().size());
for (Map.Entry<String, JsonElement> entry : blockStates.entrySet()) { for (Map.Entry<String, JsonElement> entry : blockStates.entrySet()) {
blockStateMap.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey())); blockStateMap.put(entry.getValue().getAsString(), Integer.parseInt(entry.getKey()));
@ -42,28 +29,37 @@ public class MappingData {
JsonObject heightMapData = MappingDataLoader.loadData("heightMapData-1.14.json"); JsonObject heightMapData = MappingDataLoader.loadData("heightMapData-1.14.json");
JsonArray motionBlocking = heightMapData.getAsJsonArray("MOTION_BLOCKING"); JsonArray motionBlocking = heightMapData.getAsJsonArray("MOTION_BLOCKING");
MappingData.motionBlocking = new IntOpenHashSet(motionBlocking.size(), 1F); this.motionBlocking = new IntOpenHashSet(motionBlocking.size(), 1F);
for (JsonElement blockState : motionBlocking) { for (JsonElement blockState : motionBlocking) {
String key = blockState.getAsString(); String key = blockState.getAsString();
Integer id = blockStateMap.get(key); Integer id = blockStateMap.get(key);
if (id == null) { if (id == null) {
Via.getPlatform().getLogger().warning("Unknown blockstate " + key + " :("); Via.getPlatform().getLogger().warning("Unknown blockstate " + key + " :(");
} else { } else {
MappingData.motionBlocking.add(id.intValue()); this.motionBlocking.add(id.intValue());
} }
} }
if (Via.getConfig().isNonFullBlockLightFix()) { if (Via.getConfig().isNonFullBlockLightFix()) {
nonFullBlocks = new IntOpenHashSet(1611, 1F); nonFullBlocks = new IntOpenHashSet(1611, 1F);
for (Map.Entry<String, JsonElement> blockstates : mapping1_13_2.getAsJsonObject("blockstates").entrySet()) { for (Map.Entry<String, JsonElement> blockstates : oldMappings.getAsJsonObject("blockstates").entrySet()) {
final String state = blockstates.getValue().getAsString(); final String state = blockstates.getValue().getAsString();
if (state.contains("_slab") || state.contains("_stairs") || state.contains("_wall[")) if (state.contains("_slab") || state.contains("_stairs") || state.contains("_wall[")) {
nonFullBlocks.add(blockStateMappings.getNewId(Integer.parseInt(blockstates.getKey()))); nonFullBlocks.add(blockStateMappings.getNewId(Integer.parseInt(blockstates.getKey())));
} }
}
nonFullBlocks.add(blockStateMappings.getNewId(8163)); // grass path nonFullBlocks.add(blockStateMappings.getNewId(8163)); // grass path
for (int i = 3060; i <= 3067; i++) { // farmland for (int i = 3060; i <= 3067; i++) { // farmland
nonFullBlocks.add(blockStateMappings.getNewId(i)); nonFullBlocks.add(blockStateMappings.getNewId(i));
} }
} }
} }
public IntSet getMotionBlocking() {
return motionBlocking;
}
public IntSet getNonFullBlocks() {
return nonFullBlocks;
}
} }

Datei anzeigen

@ -38,7 +38,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
} else if (metadata.getMetaType() == MetaType1_14.BlockID) { } else if (metadata.getMetaType() == MetaType1_14.BlockID) {
// Convert to new block id // Convert to new block id
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
if (type == null) return; if (type == null) return;
@ -95,7 +95,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
if (metadata.getId() == 10) { if (metadata.getId() == 10) {
// New block format // New block format
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_14To1_13_2.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
} else if (type.is(Entity1_14Types.EntityType.HORSE)) { } else if (type.is(Entity1_14Types.EntityType.HORSE)) {
if (metadata.getId() == 18) { if (metadata.getId() == 18) {
@ -104,11 +104,11 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
int armorType = (int) metadata.getValue(); int armorType = (int) metadata.getValue();
Item armorItem = null; Item armorItem = null;
if (armorType == 1) { //iron armor if (armorType == 1) { //iron armor
armorItem = new Item(InventoryPackets.getNewItemId(727), (byte) 1, (short) 0, null); armorItem = new Item(protocol.getMappingData().getNewItemId(727), (byte) 1, (short) 0, null);
} else if (armorType == 2) { //gold armor } else if (armorType == 2) { //gold armor
armorItem = new Item(InventoryPackets.getNewItemId(728), (byte) 1, (short) 0, null); armorItem = new Item(protocol.getMappingData().getNewItemId(728), (byte) 1, (short) 0, null);
} else if (armorType == 3) { //diamond armor } else if (armorType == 3) { //diamond armor
armorItem = new Item(InventoryPackets.getNewItemId(729), (byte) 1, (short) 0, null); armorItem = new Item(protocol.getMappingData().getNewItemId(729), (byte) 1, (short) 0, null);
} }
PacketWrapper equipmentPacket = new PacketWrapper(0x46, null, connection); PacketWrapper equipmentPacket = new PacketWrapper(0x46, null, connection);

Datei anzeigen

@ -55,7 +55,7 @@ public class EntityPackets {
if (type1_14 != null) { if (type1_14 != null) {
int data = wrapper.get(Type.INT, 0); int data = wrapper.get(Type.INT, 0);
if (type1_14.is(Entity1_14Types.EntityType.FALLING_BLOCK)) { if (type1_14.is(Entity1_14Types.EntityType.FALLING_BLOCK)) {
wrapper.set(Type.INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(data)); wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (type1_14.is(Entity1_14Types.EntityType.MINECART)) { } else if (type1_14.is(Entity1_14Types.EntityType.MINECART)) {
// default is 0 = rideable minecart // default is 0 = rideable minecart
switch (data) { switch (data) {

Datei anzeigen

@ -47,7 +47,7 @@ public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId); itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
protocol.registerOutgoing(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketRemapper() {
@ -234,7 +234,7 @@ public class InventoryPackets {
public static void toClient(Item item) { public static void toClient(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(Protocol1_14To1_13_2.MAPPINGS.getNewItemId(item.getIdentifier()));
CompoundTag tag; CompoundTag tag;
if ((tag = item.getTag()) != null) { if ((tag = item.getTag()) != null) {
@ -256,18 +256,9 @@ public class InventoryPackets {
} }
} }
public static int getNewItemId(int id) {
int newId = MappingData.oldToNewItems.get(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.14 item for 1.13.2 item " + id);
return 1;
}
return newId;
}
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getOldItemId(item.getIdentifier())); item.setIdentifier(Protocol1_14To1_13_2.MAPPINGS.getOldItemId(item.getIdentifier()));
CompoundTag tag; CompoundTag tag;
if ((tag = item.getTag()) != null) { if ((tag = item.getTag()) != null) {
@ -297,9 +288,4 @@ public class InventoryPackets {
} }
} }
} }
public static int getOldItemId(int id) {
int oldId = MappingData.oldToNewItems.inverse().get(id);
return oldId != -1 ? oldId : 1;
}
} }

Datei anzeigen

@ -9,7 +9,6 @@ import us.myles.ViaVersion.api.minecraft.BlockFace;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray; import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
import us.myles.ViaVersion.api.protocol.Protocol;
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.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
@ -18,7 +17,6 @@ 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.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
@ -38,8 +36,8 @@ public class WorldPackets {
Arrays.fill(FULL_LIGHT, (byte) 0xff); Arrays.fill(FULL_LIGHT, (byte) 0xff);
} }
public static void register(final Protocol protocol) { public static void register(Protocol1_14To1_13_2 protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, null, Protocol1_14To1_13_2::getNewBlockStateId, Protocol1_14To1_13_2::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, null);
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
@Override @Override
@ -65,7 +63,7 @@ public class WorldPackets {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockId(wrapper.get(Type.VAR_INT, 0))); wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockId(wrapper.get(Type.VAR_INT, 0)));
} }
}); });
} }
@ -80,7 +78,7 @@ public class WorldPackets {
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.VAR_INT, 0); int id = wrapper.get(Type.VAR_INT, 0);
wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(id)); wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(id));
} }
}); });
} }
@ -144,7 +142,7 @@ public class WorldPackets {
boolean hasBlock = false; boolean hasBlock = false;
for (int i = 0; i < section.getPaletteSize(); i++) { for (int i = 0; i < section.getPaletteSize(); i++) {
int old = section.getPaletteEntry(i); int old = section.getPaletteEntry(i);
int newId = Protocol1_14To1_13_2.getNewBlockStateId(old); int newId = protocol.getMappingData().getNewBlockStateId(old);
if (!hasBlock && newId != air && newId != voidAir && newId != caveAir) { // air, void_air, cave_air if (!hasBlock && newId != air && newId != voidAir && newId != caveAir) { // air, void_air, cave_air
hasBlock = true; hasBlock = true;
} }
@ -164,12 +162,12 @@ public class WorldPackets {
nonAirBlockCount++; nonAirBlockCount++;
worldSurface[x + z * 16] = y + s * 16 + 1; // +1 (top of the block) worldSurface[x + z * 16] = y + s * 16 + 1; // +1 (top of the block)
} }
if (MappingData.motionBlocking.contains(id)) { if (protocol.getMappingData().getMotionBlocking().contains(id)) {
motionBlocking[x + z * 16] = y + s * 16 + 1; // +1 (top of the block) motionBlocking[x + z * 16] = y + s * 16 + 1; // +1 (top of the block)
} }
// Manually update light for non full blocks (block light must not be sent) // Manually update light for non full blocks (block light must not be sent)
if (Via.getConfig().isNonFullBlockLightFix() && MappingData.nonFullBlocks.contains(id)) { if (Via.getConfig().isNonFullBlockLightFix() && protocol.getMappingData().getNonFullBlocks().contains(id)) {
setNonFullLight(chunk, section, s, x, y, z); setNonFullLight(chunk, section, s, x, y, z);
} }
} }
@ -265,9 +263,9 @@ public class WorldPackets {
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
int data = wrapper.get(Type.INT, 1); int data = wrapper.get(Type.INT, 1);
if (id == 1010) { // Play record if (id == 1010) { // Play record
wrapper.set(Type.INT, 1, InventoryPackets.getNewItemId(data)); wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data));
} else if (id == 2001) { // Block break + block break sound } else if (id == 2001) { // Block break + block break sound
wrapper.set(Type.INT, 1, Protocol1_14To1_13_2.getNewBlockStateId(data)); wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data));
} }
} }
}); });

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4; package us.myles.ViaVersion.protocols.protocol1_15to1_14_4;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.RegistryType; import us.myles.ViaVersion.api.rewriters.RegistryType;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter; import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
@ -21,27 +21,27 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1
public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> { public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
public static final MappingData MAPPINGS = new MappingData();
private TagRewriter tagRewriter; private TagRewriter tagRewriter;
public Protocol1_15To1_14_4() { public Protocol1_15To1_14_4() {
super(ClientboundPackets1_14.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class, true); super(ClientboundPackets1_14.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_15To1_14_4 metadataRewriter = new MetadataRewriter1_15To1_14_4(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_15To1_14_4(this);
EntityPackets.register(this); EntityPackets.register(this);
PlayerPackets.register(this); PlayerPackets.register(this);
WorldPackets.register(this); WorldPackets.register(this);
InventoryPackets.register(this); InventoryPackets.register(this);
SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)); SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_14.ENTITY_SOUND); // Entity Sound Effect (added somewhere in 1.14) soundRewriter.registerSound(ClientboundPackets1_14.ENTITY_SOUND); // Entity Sound Effect (added somewhere in 1.14)
soundRewriter.registerSound(ClientboundPackets1_14.SOUND); soundRewriter.registerSound(ClientboundPackets1_14.SOUND);
new StatisticsRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, new StatisticsRewriter(this, metadataRewriter::getNewEntityId).register(ClientboundPackets1_14.STATISTICS);
metadataRewriter::getNewEntityId, id -> MappingData.statisticsMappings.getNewId(id)).register(ClientboundPackets1_14.STATISTICS);
registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() { registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
@Override @Override
@ -50,14 +50,12 @@ public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, Clien
} }
}); });
tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId); tagRewriter = new TagRewriter(this, EntityPackets::getNewEntityId);
tagRewriter.register(ClientboundPackets1_14.TAGS); tagRewriter.register(ClientboundPackets1_14.TAGS);
} }
@Override @Override
protected void loadMappingData() { protected void onMappingDataLoaded() {
MappingData.init();
int[] shulkerBoxes = new int[17]; int[] shulkerBoxes = new int[17];
int shulkerBoxOffset = 501; int shulkerBoxOffset = 501;
for (int i = 0; i < 17; i++) { for (int i = 0; i < 17; i++) {
@ -66,26 +64,13 @@ public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, Clien
tagRewriter.addTag(RegistryType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes); tagRewriter.addTag(RegistryType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes);
} }
public static int getNewBlockStateId(int id) {
int newId = MappingData.blockStateMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.15 blockstate for 1.14.4 blockstate " + id);
return 0;
}
return newId;
}
public static int getNewBlockId(int id) {
int newId = MappingData.blockMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.15 block for 1.14.4 block " + id);
return 0;
}
return newId;
}
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_15(userConnection)); userConnection.put(new EntityTracker1_15(userConnection));
} }
@Override
public MappingData getMappingData() {
return MAPPINGS;
}
} }

Datei anzeigen

@ -1,29 +1,22 @@
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data; package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via; import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings; import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.util.Int2IntBiMap;
public class MappingData { public class MappingData extends us.myles.ViaVersion.api.data.MappingData {
public static Int2IntBiMap oldToNewItems = new Int2IntBiMap();
public static Mappings blockMappings;
public static Mappings blockStateMappings;
public static Mappings soundMappings;
public static Mappings statisticsMappings;
public static void init() { public MappingData() {
Via.getPlatform().getLogger().info("Loading 1.14.4 -> 1.15 mappings..."); super("1.14", "1.15", true);
JsonObject diffmapping = MappingDataLoader.loadData("mappingdiff-1.14to1.15.json"); }
JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json", true);
JsonObject mapping1_15 = MappingDataLoader.loadData("mapping-1.15.json", true);
oldToNewItems.defaultReturnValue(-1); @Override
blockStateMappings = new Mappings(mapping1_14.getAsJsonObject("blockstates"), mapping1_15.getAsJsonObject("blockstates"), diffmapping.getAsJsonObject("blockstates")); protected Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
blockMappings = new Mappings(mapping1_14.getAsJsonObject("blocks"), mapping1_15.getAsJsonObject("blocks")); if (!key.equals("sounds")) {
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_14.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items")); return super.loadFromArray(oldMappings, newMappings, diffMappings, key);
soundMappings = new Mappings(mapping1_14.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), false); }
statisticsMappings = new Mappings(mapping1_14.getAsJsonArray("statistics"), mapping1_15.getAsJsonArray("statistics"));
// Ignore removed sounds
return new Mappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), false);
} }
} }

Datei anzeigen

@ -27,7 +27,7 @@ public class MetadataRewriter1_15To1_14_4 extends MetadataRewriter {
} else if (metadata.getMetaType() == MetaType1_14.BlockID) { } else if (metadata.getMetaType() == MetaType1_14.BlockID) {
// Convert to new block id // Convert to new block id
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_15To1_14_4.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
if (type == null) return; if (type == null) return;

Datei anzeigen

@ -18,7 +18,7 @@ public class EntityPackets {
public static void register(Protocol1_15To1_14_4 protocol) { public static void register(Protocol1_15To1_14_4 protocol) {
MetadataRewriter1_15To1_14_4 metadataRewriter = protocol.get(MetadataRewriter1_15To1_14_4.class); MetadataRewriter1_15To1_14_4 metadataRewriter = protocol.get(MetadataRewriter1_15To1_14_4.class);
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_15To1_14_4::getNewBlockStateId); metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK);
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
@Override @Override

Datei anzeigen

@ -1,21 +1,19 @@
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets; package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
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;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol1_15To1_14_4 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, InventoryPackets::getNewItemId); itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN);
itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
itemRewriter.registerTradeList(ClientboundPackets1_14.TRADE_LIST, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerTradeList(ClientboundPackets1_14.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
@ -30,25 +28,11 @@ public class InventoryPackets {
public static void toClient(Item item) { public static void toClient(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(Protocol1_15To1_14_4.MAPPINGS.getNewItemId(item.getIdentifier()));
} }
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getOldItemId(item.getIdentifier())); item.setIdentifier(Protocol1_15To1_14_4.MAPPINGS.getOldItemId(item.getIdentifier()));
}
public static int getNewItemId(int id) {
int newId = MappingData.oldToNewItems.get(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.15 item for 1.14 item " + id);
return 1;
}
return newId;
}
public static int getOldItemId(int id) {
int oldId = MappingData.oldToNewItems.inverse().get(id);
return oldId != -1 ? oldId : 1;
} }
} }

Datei anzeigen

@ -3,7 +3,6 @@ package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.protocol.Protocol;
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.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
@ -15,8 +14,8 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
public class WorldPackets { public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol1_15To1_14_4 protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15To1_14_4::getNewBlockStateId, Protocol1_15To1_14_4::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
blockRewriter.registerBlockAction(ClientboundPackets1_14.BLOCK_ACTION); blockRewriter.registerBlockAction(ClientboundPackets1_14.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_14.BLOCK_CHANGE); blockRewriter.registerBlockChange(ClientboundPackets1_14.BLOCK_CHANGE);
@ -59,7 +58,7 @@ public class WorldPackets {
if (section == null) continue; if (section == null) continue;
for (int i = 0; i < section.getPaletteSize(); i++) { for (int i = 0; i < section.getPaletteSize(); i++) {
int old = section.getPaletteEntry(i); int old = section.getPaletteEntry(i);
int newId = Protocol1_15To1_14_4.getNewBlockStateId(old); int newId = protocol.getMappingData().getNewBlockStateId(old);
section.setPaletteEntry(i, newId); section.setPaletteEntry(i, newId);
} }
} }
@ -68,7 +67,7 @@ public class WorldPackets {
} }
}); });
blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001, InventoryPackets::getNewItemId); blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001);
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -88,7 +87,7 @@ public class WorldPackets {
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
if (id == 3 || id == 23) { if (id == 3 || id == 23) {
int data = wrapper.passthrough(Type.VAR_INT); int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, Protocol1_15To1_14_4.getNewBlockStateId(data)); wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == 32) { } else if (id == 32) {
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
} }

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1; package us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.RegistryType; import us.myles.ViaVersion.api.rewriters.RegistryType;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter; import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
@ -20,27 +20,27 @@ import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16
public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> { public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> {
public static final MappingData MAPPINGS = new MappingData();
private TagRewriter tagRewriter; private TagRewriter tagRewriter;
public Protocol1_16_2To1_16_1() { public Protocol1_16_2To1_16_1() {
super(ClientboundPackets1_16.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16.class, ServerboundPackets1_16_2.class, true); super(ClientboundPackets1_16.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16.class, ServerboundPackets1_16_2.class);
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_16_2To1_16_1 metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this);
EntityPackets.register(this); EntityPackets.register(this);
WorldPackets.register(this); WorldPackets.register(this);
InventoryPackets.register(this); InventoryPackets.register(this);
tagRewriter = new TagRewriter(this, Protocol1_16_2To1_16_1::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId); tagRewriter = new TagRewriter(this, metadataRewriter::getNewEntityId);
tagRewriter.register(ClientboundPackets1_16.TAGS); tagRewriter.register(ClientboundPackets1_16.TAGS);
new StatisticsRewriter(this, Protocol1_16_2To1_16_1::getNewBlockId, InventoryPackets::getNewItemId, new StatisticsRewriter(this, metadataRewriter::getNewEntityId).register(ClientboundPackets1_16.STATISTICS);
metadataRewriter::getNewEntityId).register(ClientboundPackets1_16.STATISTICS);
SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)); SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_16.SOUND); soundRewriter.registerSound(ClientboundPackets1_16.SOUND);
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
@ -77,9 +77,7 @@ public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, Cli
} }
@Override @Override
protected void loadMappingData() { protected void onMappingDataLoaded() {
MappingData.init();
tagRewriter.addTag(RegistryType.ITEM, "minecraft:stone_crafting_materials", 14, 962); tagRewriter.addTag(RegistryType.ITEM, "minecraft:stone_crafting_materials", 14, 962);
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:mushroom_grow_block"); tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:mushroom_grow_block");
@ -95,26 +93,13 @@ public class Protocol1_16_2To1_16_1 extends Protocol<ClientboundPackets1_16, Cli
"minecraft:base_stone_nether", "minecraft:base_stone_overworld"); "minecraft:base_stone_nether", "minecraft:base_stone_overworld");
} }
public static int getNewBlockStateId(int id) {
int newId = MappingData.blockStateMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.16.2 blockstate for 1.16 blockstate " + id);
return 0;
}
return newId;
}
public static int getNewBlockId(int id) {
int newId = MappingData.blockMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.16.2 block for 1.16 block " + id);
return 0;
}
return newId;
}
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_16_2(userConnection)); userConnection.put(new EntityTracker1_16_2(userConnection));
} }
@Override
public MappingData getMappingData() {
return MAPPINGS;
}
} }

Datei anzeigen

@ -7,28 +7,22 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader; import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.api.minecraft.nbt.BinaryTagIO; import us.myles.ViaVersion.api.minecraft.nbt.BinaryTagIO;
import us.myles.ViaVersion.util.Int2IntBiMap;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class MappingData { public class MappingData extends us.myles.ViaVersion.api.data.MappingData {
public static CompoundTag dimensionRegistry; private final Map<String, CompoundTag> dimensionDataMap = new HashMap<>();
public static Map<String, CompoundTag> dimensionDataMap = new HashMap<>(); private CompoundTag dimensionRegistry;
public static Int2IntBiMap oldToNewItems = new Int2IntBiMap();
public static Mappings blockMappings;
public static Mappings blockStateMappings;
public static Mappings soundMappings;
public static void init() { public MappingData() {
Via.getPlatform().getLogger().info("Loading 1.16.1 -> 1.16.2 mappings..."); super("1.16", "1.16.2", true);
JsonObject diffmapping = MappingDataLoader.loadData("mappingdiff-1.16.1to1.16.2.json"); }
JsonObject mapping1_16 = MappingDataLoader.loadData("mapping-1.16.json", true);
JsonObject mapping1_16_2 = MappingDataLoader.loadData("mapping-1.16.2.json", true);
@Override
public void loadExtras(JsonObject oldMappings, JsonObject newMappings, JsonObject diffMappings) {
try { try {
dimensionRegistry = BinaryTagIO.readCompressedInputStream(MappingDataLoader.getResource("dimension-registry-1.16.2.nbt")); dimensionRegistry = BinaryTagIO.readCompressedInputStream(MappingDataLoader.getResource("dimension-registry-1.16.2.nbt"));
} catch (IOException e) { } catch (IOException e) {
@ -36,12 +30,6 @@ public class MappingData {
e.printStackTrace(); e.printStackTrace();
} }
oldToNewItems.defaultReturnValue(-1);
blockStateMappings = new Mappings(mapping1_16.getAsJsonObject("blockstates"), mapping1_16_2.getAsJsonObject("blockstates"), diffmapping.getAsJsonObject("blockstates"));
blockMappings = new Mappings(mapping1_16.getAsJsonObject("blocks"), mapping1_16_2.getAsJsonObject("blocks"));
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_16.getAsJsonObject("items"), mapping1_16_2.getAsJsonObject("items"));
soundMappings = new Mappings(mapping1_16.getAsJsonArray("sounds"), mapping1_16_2.getAsJsonArray("sounds"));
// Data of each dimension // Data of each dimension
ListTag dimensions = ((CompoundTag) dimensionRegistry.get("minecraft:dimension_type")).get("value"); ListTag dimensions = ((CompoundTag) dimensionRegistry.get("minecraft:dimension_type")).get("value");
for (Tag dimension : dimensions) { for (Tag dimension : dimensions) {
@ -51,4 +39,12 @@ public class MappingData {
dimensionDataMap.put(((StringTag) dimensionCompound.get("name")).getValue(), dimensionData); dimensionDataMap.put(((StringTag) dimensionCompound.get("name")).getValue(), dimensionData);
} }
} }
public Map<String, CompoundTag> getDimensionDataMap() {
return dimensionDataMap;
}
public CompoundTag getDimensionRegistry() {
return dimensionRegistry;
}
} }

Datei anzeigen

@ -27,7 +27,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends MetadataRewriter {
InventoryPackets.toClient((Item) metadata.getValue()); InventoryPackets.toClient((Item) metadata.getValue());
} else if (metadata.getMetaType() == MetaType1_14.BlockID) { } else if (metadata.getMetaType() == MetaType1_14.BlockID) {
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_16_2To1_16_1.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
if (type == null) return; if (type == null) return;

Datei anzeigen

@ -7,7 +7,6 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1; import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.metadata.MetadataRewriter1_16_2To1_16_1; import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.metadata.MetadataRewriter1_16_2To1_16_1;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2; import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.storage.EntityTracker1_16_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
@ -16,8 +15,7 @@ public class EntityPackets {
public static void register(Protocol1_16_2To1_16_1 protocol) { public static void register(Protocol1_16_2To1_16_1 protocol) {
MetadataRewriter1_16_2To1_16_1 metadataRewriter = protocol.get(MetadataRewriter1_16_2To1_16_1.class); MetadataRewriter1_16_2To1_16_1 metadataRewriter = protocol.get(MetadataRewriter1_16_2To1_16_1.class);
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK);
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK, Protocol1_16_2To1_16_1::getNewBlockStateId);
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_MOB); metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_MOB);
metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER); metadataRewriter.registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST);
@ -39,7 +37,7 @@ public class EntityPackets {
handler(wrapper -> { handler(wrapper -> {
// Throw away the old dimension registry, extra conversion would be too hard of a hit // Throw away the old dimension registry, extra conversion would be too hard of a hit
wrapper.read(Type.NBT); wrapper.read(Type.NBT);
wrapper.write(Type.NBT, MappingData.dimensionRegistry); wrapper.write(Type.NBT, protocol.getMappingData().getDimensionRegistry());
// Instead of the dimension's resource key, it now just wants the data directly // Instead of the dimension's resource key, it now just wants the data directly
String dimensionType = wrapper.read(Type.STRING); String dimensionType = wrapper.read(Type.STRING);
@ -67,7 +65,7 @@ public class EntityPackets {
} }
public static CompoundTag getDimensionData(String dimensionType) { public static CompoundTag getDimensionData(String dimensionType) {
CompoundTag tag = MappingData.dimensionDataMap.get(dimensionType); CompoundTag tag = Protocol1_16_2To1_16_1.MAPPINGS.getDimensionDataMap().get(dimensionType);
if (tag == null) { if (tag == null) {
Via.getPlatform().getLogger().severe("Could not get dimension data of " + dimensionType); Via.getPlatform().getLogger().severe("Could not get dimension data of " + dimensionType);
throw new NullPointerException("Dimension data for " + dimensionType + " is null!"); throw new NullPointerException("Dimension data for " + dimensionType + " is null!");

Datei anzeigen

@ -1,13 +1,11 @@
package us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.packets; package us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.packets;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1; import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
@ -16,7 +14,7 @@ public class InventoryPackets {
public static void register(Protocol1_16_2To1_16_1 protocol) { public static void register(Protocol1_16_2To1_16_1 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, InventoryPackets::getNewItemId); itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN);
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
itemRewriter.registerTradeList(ClientboundPackets1_16.TRADE_LIST, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerTradeList(ClientboundPackets1_16.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
@ -55,25 +53,11 @@ public class InventoryPackets {
public static void toClient(Item item) { public static void toClient(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(Protocol1_16_2To1_16_1.MAPPINGS.getNewItemId(item.getIdentifier()));
} }
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getOldItemId(item.getIdentifier())); item.setIdentifier(Protocol1_16_2To1_16_1.MAPPINGS.getOldItemId(item.getIdentifier()));
}
public static int getNewItemId(int id) {
int newId = MappingData.oldToNewItems.get(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.16.2 item for 1.16 item " + id);
return 1;
}
return newId;
}
public static int getOldItemId(int id) {
int oldId = MappingData.oldToNewItems.inverse().get(id);
return oldId != -1 ? oldId : 1;
} }
} }

Datei anzeigen

@ -23,7 +23,7 @@ public class WorldPackets {
private static final BlockChangeRecord[] EMPTY_RECORDS = new BlockChangeRecord[0]; private static final BlockChangeRecord[] EMPTY_RECORDS = new BlockChangeRecord[0];
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16_2To1_16_1::getNewBlockStateId, Protocol1_16_2To1_16_1::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION); blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE); blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
@ -41,7 +41,7 @@ public class WorldPackets {
if (section == null) continue; if (section == null) continue;
for (int i = 0; i < section.getPaletteSize(); i++) { for (int i = 0; i < section.getPaletteSize(); i++) {
int old = section.getPaletteEntry(i); int old = section.getPaletteEntry(i);
section.setPaletteEntry(i, Protocol1_16_2To1_16_1.getNewBlockStateId(old)); section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
} }
} }
}); });
@ -71,7 +71,7 @@ public class WorldPackets {
} }
// Absolute y -> relative chunk section y // Absolute y -> relative chunk section y
int blockId = Protocol1_16_2To1_16_1.getNewBlockStateId(record.getBlockId()); int blockId = protocol.getMappingData().getNewBlockStateId(record.getBlockId());
list.add(new BlockChangeRecord1_16_2(record.getSectionX(), record.getSectionY(), record.getSectionZ(), blockId)); list.add(new BlockChangeRecord1_16_2(record.getSectionX(), record.getSectionY(), record.getSectionZ(), blockId));
} }
@ -90,7 +90,7 @@ public class WorldPackets {
} }
}); });
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001, InventoryPackets::getNewItemId); blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001);
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 34, blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 34,
null, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE); null, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
} }

Datei anzeigen

@ -9,6 +9,7 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ComponentRewriter; import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
import us.myles.ViaVersion.api.rewriters.RegistryType; import us.myles.ViaVersion.api.rewriters.RegistryType;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter; import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
@ -35,25 +36,25 @@ import java.util.UUID;
public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_16, ServerboundPackets1_14, ServerboundPackets1_16> { public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_16, ServerboundPackets1_14, ServerboundPackets1_16> {
private static final UUID ZERO_UUID = new UUID(0, 0); private static final UUID ZERO_UUID = new UUID(0, 0);
public static final MappingData MAPPINGS = new MappingData();
private TagRewriter tagRewriter; private TagRewriter tagRewriter;
public Protocol1_16To1_15_2() { public Protocol1_16To1_15_2() {
super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class, true); super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class);
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_16To1_15_2 metadataRewriter = new MetadataRewriter1_16To1_15_2(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_16To1_15_2(this);
EntityPackets.register(this); EntityPackets.register(this);
WorldPackets.register(this); WorldPackets.register(this);
InventoryPackets.register(this); InventoryPackets.register(this);
tagRewriter = new TagRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId); tagRewriter = new TagRewriter(this, metadataRewriter::getNewEntityId);
tagRewriter.register(ClientboundPackets1_15.TAGS); tagRewriter.register(ClientboundPackets1_15.TAGS);
new StatisticsRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, new StatisticsRewriter(this, metadataRewriter::getNewEntityId).register(ClientboundPackets1_15.STATISTICS);
metadataRewriter::getNewEntityId, id -> MappingData.statisticsMappings.getNewId(id)).register(ClientboundPackets1_15.STATISTICS);
// Login Success // Login Success
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() { registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
@ -124,7 +125,7 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
componentRewriter.registerTitle(ClientboundPackets1_15.TITLE); componentRewriter.registerTitle(ClientboundPackets1_15.TITLE);
componentRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT); componentRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT);
SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)); SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_15.SOUND); soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND); soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
@ -206,9 +207,7 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
} }
@Override @Override
protected void loadMappingData() { protected void onMappingDataLoaded() {
MappingData.init();
int[] wallPostOverrideTag = new int[47]; int[] wallPostOverrideTag = new int[47];
int arrayIndex = 0; int arrayIndex = 0;
wallPostOverrideTag[arrayIndex++] = 140; wallPostOverrideTag[arrayIndex++] = 140;
@ -253,27 +252,14 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
"minecraft:lectern_books", "minecraft:music_discs", "minecraft:small_flowers", "minecraft:tall_flowers", "minecraft:trapdoors", "minecraft:walls", "minecraft:wooden_fences"); "minecraft:lectern_books", "minecraft:music_discs", "minecraft:small_flowers", "minecraft:tall_flowers", "minecraft:trapdoors", "minecraft:walls", "minecraft:wooden_fences");
} }
public static int getNewBlockStateId(int id) {
int newId = MappingData.blockStateMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.16 blockstate for 1.15.2 blockstate " + id);
return 0;
}
return newId;
}
public static int getNewBlockId(int id) {
int newId = MappingData.blockMappings.getNewId(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.16 block for 1.15.2 block " + id);
return 0;
}
return newId;
}
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_16(userConnection)); userConnection.put(new EntityTracker1_16(userConnection));
userConnection.put(new InventoryTracker1_16(userConnection)); userConnection.put(new InventoryTracker1_16(userConnection));
} }
@Override
public MappingData getMappingData() {
return MAPPINGS;
}
} }

Datei anzeigen

@ -3,32 +3,16 @@ package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.util.Int2IntBiMap;
public class MappingData { public class MappingData extends us.myles.ViaVersion.api.data.MappingData {
public static Int2IntBiMap oldToNewItems = new Int2IntBiMap(); private final BiMap<String, String> attributeMappings = HashBiMap.create();
public static BiMap<String, String> attributeMappings = HashBiMap.create();
public static Mappings blockMappings;
public static Mappings blockStateMappings;
public static Mappings soundMappings;
public static Mappings statisticsMappings;
public static void init() { public MappingData() {
Via.getPlatform().getLogger().info("Loading 1.15 -> 1.16 mappings..."); super("1.15", "1.16", true);
JsonObject diffmapping = MappingDataLoader.loadData("mappingdiff-1.15to1.16.json"); }
JsonObject mapping1_15 = MappingDataLoader.loadData("mapping-1.15.json", true);
JsonObject mapping1_16 = MappingDataLoader.loadData("mapping-1.16.json", true);
oldToNewItems.defaultReturnValue(-1);
blockStateMappings = new Mappings(mapping1_15.getAsJsonObject("blockstates"), mapping1_16.getAsJsonObject("blockstates"), diffmapping.getAsJsonObject("blockstates"));
blockMappings = new Mappings(mapping1_15.getAsJsonObject("blocks"), mapping1_16.getAsJsonObject("blocks"));
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_15.getAsJsonObject("items"), mapping1_16.getAsJsonObject("items"), diffmapping.getAsJsonObject("items"));
soundMappings = new Mappings(mapping1_15.getAsJsonArray("sounds"), mapping1_16.getAsJsonArray("sounds"), diffmapping.getAsJsonObject("sounds"));
statisticsMappings = new Mappings(mapping1_15.getAsJsonArray("statistics"), mapping1_16.getAsJsonArray("statistics"));
@Override
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, JsonObject diffMappings) {
attributeMappings.put("generic.maxHealth", "minecraft:generic.max_health"); attributeMappings.put("generic.maxHealth", "minecraft:generic.max_health");
attributeMappings.put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements"); attributeMappings.put("zombie.spawnReinforcements", "minecraft:zombie.spawn_reinforcements");
attributeMappings.put("horse.jumpStrength", "minecraft:horse.jump_strength"); attributeMappings.put("horse.jumpStrength", "minecraft:horse.jump_strength");
@ -41,4 +25,8 @@ public class MappingData {
attributeMappings.put("generic.attackSpeed", "minecraft:generic.attack_speed"); attributeMappings.put("generic.attackSpeed", "minecraft:generic.attack_speed");
attributeMappings.put("generic.armorToughness", "minecraft:generic.armor_toughness"); attributeMappings.put("generic.armorToughness", "minecraft:generic.armor_toughness");
} }
public BiMap<String, String> getAttributeMappings() {
return attributeMappings;
}
} }

Datei anzeigen

@ -30,7 +30,7 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
InventoryPackets.toClient((Item) metadata.getValue()); InventoryPackets.toClient((Item) metadata.getValue());
} else if (metadata.getMetaType() == MetaType1_14.BlockID) { } else if (metadata.getMetaType() == MetaType1_14.BlockID) {
int data = (int) metadata.getValue(); int data = (int) metadata.getValue();
metadata.setValue(Protocol1_16To1_15_2.getNewBlockStateId(data)); metadata.setValue(protocol.getMappingData().getNewBlockStateId(data));
} }
if (type == null) return; if (type == null) return;

Datei anzeigen

@ -17,7 +17,6 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.EntityTracker1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.EntityTracker1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
@ -156,7 +155,7 @@ public class EntityPackets {
} }
}); });
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_16To1_15_2::getNewBlockStateId); metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK);
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_MOB); metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_MOB);
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.EntityType.PLAYER); metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.EntityType.PLAYER);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST);
@ -215,7 +214,7 @@ public class EntityPackets {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
// Attributes have been renamed and are now namespaced identifiers // Attributes have been renamed and are now namespaced identifiers
String key = wrapper.read(Type.STRING); String key = wrapper.read(Type.STRING);
String attributeIdentifier = MappingData.attributeMappings.get(key); String attributeIdentifier = protocol.getMappingData().getAttributeMappings().get(key);
if (attributeIdentifier == null) { if (attributeIdentifier == null) {
attributeIdentifier = "minecraft:" + key; attributeIdentifier = "minecraft:" + key;
if (!us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.isValid1_13Channel(attributeIdentifier)) { if (!us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.isValid1_13Channel(attributeIdentifier)) {

Datei anzeigen

@ -6,24 +6,22 @@ import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag; import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType; import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
import java.util.UUID; import java.util.UUID;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol1_16To1_15_2 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
protocol.registerOutgoing(ClientboundPackets1_15.OPEN_WINDOW, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_15.OPEN_WINDOW, new PacketRemapper() {
@ -76,7 +74,7 @@ public class InventoryPackets {
} }
}); });
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, InventoryPackets::getNewItemId); itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN);
itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
@ -137,13 +135,13 @@ public class InventoryPackets {
} }
oldToNewAttributes(item); oldToNewAttributes(item);
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(Protocol1_16To1_15_2.MAPPINGS.getNewItemId(item.getIdentifier()));
} }
public static void toServer(Item item) { public static void toServer(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getOldItemId(item.getIdentifier())); item.setIdentifier(Protocol1_16To1_15_2.MAPPINGS.getOldItemId(item.getIdentifier()));
if (item.getIdentifier() == 771 && item.getTag() != null) { if (item.getIdentifier() == 771 && item.getTag() != null) {
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
@ -200,7 +198,7 @@ public class InventoryPackets {
} }
public static void rewriteAttributeName(CompoundTag compoundTag, String entryName, boolean inverse) { public static void rewriteAttributeName(CompoundTag compoundTag, String entryName, boolean inverse) {
StringTag attributeNameTag = compoundTag.get("AttributeName"); StringTag attributeNameTag = compoundTag.get(entryName);
if (attributeNameTag == null) return; if (attributeNameTag == null) return;
String attributeName = attributeNameTag.getValue(); String attributeName = attributeNameTag.getValue();
@ -208,23 +206,10 @@ public class InventoryPackets {
attributeName = "minecraft:" + attributeName; attributeName = "minecraft:" + attributeName;
} }
String mappedAttribute = (inverse ? MappingData.attributeMappings.inverse() : MappingData.attributeMappings).get(attributeName); String mappedAttribute = (inverse ? Protocol1_16To1_15_2.MAPPINGS.getAttributeMappings().inverse()
: Protocol1_16To1_15_2.MAPPINGS.getAttributeMappings()).get(attributeName);
if (mappedAttribute == null) return; if (mappedAttribute == null) return;
attributeNameTag.setValue(mappedAttribute); attributeNameTag.setValue(mappedAttribute);
} }
public static int getNewItemId(int id) {
int newId = MappingData.oldToNewItems.get(id);
if (newId == -1) {
Via.getPlatform().getLogger().warning("Missing 1.16 item for 1.15.2 item " + id);
return 1;
}
return newId;
}
public static int getOldItemId(int id) {
int oldId = MappingData.oldToNewItems.inverse().get(id);
return oldId != -1 ? oldId : 1;
}
} }

Datei anzeigen

@ -8,7 +8,6 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@ -23,8 +22,8 @@ import java.util.UUID;
public class WorldPackets { public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol1_16To1_15_2 protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16To1_15_2::getNewBlockStateId, Protocol1_16To1_15_2::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION); blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE); blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
@ -54,7 +53,7 @@ public class WorldPackets {
if (section == null) continue; if (section == null) continue;
for (int i = 0; i < section.getPaletteSize(); i++) { for (int i = 0; i < section.getPaletteSize(); i++) {
int old = section.getPaletteEntry(i); int old = section.getPaletteEntry(i);
section.setPaletteEntry(i, Protocol1_16To1_15_2.getNewBlockStateId(old)); section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
} }
} }
@ -86,7 +85,7 @@ public class WorldPackets {
} }
}); });
blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001, InventoryPackets::getNewItemId); blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001);
blockRewriter.registerSpawnParticle(ClientboundPackets1_15.SPAWN_PARTICLE, 3, 23, 32, blockRewriter.registerSpawnParticle(ClientboundPackets1_15.SPAWN_PARTICLE, 3, 23, 32,
WorldPackets::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE); WorldPackets::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
} }

Datei anzeigen

@ -10,6 +10,7 @@ import us.myles.ViaVersion.api.platform.providers.ViaProviders;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.rewriters.MetadataRewriter;
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;
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8; import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
@ -94,7 +95,7 @@ public class Protocol1_9To1_8 extends Protocol<ClientboundPackets1_8, Clientboun
@Override @Override
protected void registerPackets() { protected void registerPackets() {
new MetadataRewriter1_9To1_8(this); MetadataRewriter metadataRewriter = new MetadataRewriter1_9To1_8(this);
// Disconnect workaround (JSON!) // Disconnect workaround (JSON!)
registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() { registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() {

Datei anzeigen

@ -1,5 +1,5 @@
{ {
"blocks": { "blockstates": {
"0": "minecraft:air", "0": "minecraft:air",
"1": "minecraft:stone", "1": "minecraft:stone",
"2": "minecraft:granite", "2": "minecraft:granite",
@ -9370,6 +9370,601 @@
"783": "minecraft:nautilus_shell", "783": "minecraft:nautilus_shell",
"784": "minecraft:heart_of_the_sea" "784": "minecraft:heart_of_the_sea"
}, },
"blocks": {
"0": "air",
"1": "stone",
"2": "granite",
"3": "polished_granite",
"4": "diorite",
"5": "polished_diorite",
"6": "andesite",
"7": "polished_andesite",
"8": "grass_block",
"9": "dirt",
"10": "coarse_dirt",
"11": "podzol",
"12": "cobblestone",
"13": "oak_planks",
"14": "spruce_planks",
"15": "birch_planks",
"16": "jungle_planks",
"17": "acacia_planks",
"18": "dark_oak_planks",
"19": "oak_sapling",
"20": "spruce_sapling",
"21": "birch_sapling",
"22": "jungle_sapling",
"23": "acacia_sapling",
"24": "dark_oak_sapling",
"25": "bedrock",
"26": "water",
"27": "lava",
"28": "sand",
"29": "red_sand",
"30": "gravel",
"31": "gold_ore",
"32": "iron_ore",
"33": "coal_ore",
"34": "oak_log",
"35": "spruce_log",
"36": "birch_log",
"37": "jungle_log",
"38": "acacia_log",
"39": "dark_oak_log",
"40": "stripped_spruce_log",
"41": "stripped_birch_log",
"42": "stripped_jungle_log",
"43": "stripped_acacia_log",
"44": "stripped_dark_oak_log",
"45": "stripped_oak_log",
"46": "oak_wood",
"47": "spruce_wood",
"48": "birch_wood",
"49": "jungle_wood",
"50": "acacia_wood",
"51": "dark_oak_wood",
"52": "stripped_oak_wood",
"53": "stripped_spruce_wood",
"54": "stripped_birch_wood",
"55": "stripped_jungle_wood",
"56": "stripped_acacia_wood",
"57": "stripped_dark_oak_wood",
"58": "oak_leaves",
"59": "spruce_leaves",
"60": "birch_leaves",
"61": "jungle_leaves",
"62": "acacia_leaves",
"63": "dark_oak_leaves",
"64": "sponge",
"65": "wet_sponge",
"66": "glass",
"67": "lapis_ore",
"68": "lapis_block",
"69": "dispenser",
"70": "sandstone",
"71": "chiseled_sandstone",
"72": "cut_sandstone",
"73": "note_block",
"74": "white_bed",
"75": "orange_bed",
"76": "magenta_bed",
"77": "light_blue_bed",
"78": "yellow_bed",
"79": "lime_bed",
"80": "pink_bed",
"81": "gray_bed",
"82": "light_gray_bed",
"83": "cyan_bed",
"84": "purple_bed",
"85": "blue_bed",
"86": "brown_bed",
"87": "green_bed",
"88": "red_bed",
"89": "black_bed",
"90": "powered_rail",
"91": "detector_rail",
"92": "sticky_piston",
"93": "cobweb",
"94": "grass",
"95": "fern",
"96": "dead_bush",
"97": "seagrass",
"98": "tall_seagrass",
"99": "piston",
"100": "piston_head",
"101": "white_wool",
"102": "orange_wool",
"103": "magenta_wool",
"104": "light_blue_wool",
"105": "yellow_wool",
"106": "lime_wool",
"107": "pink_wool",
"108": "gray_wool",
"109": "light_gray_wool",
"110": "cyan_wool",
"111": "purple_wool",
"112": "blue_wool",
"113": "brown_wool",
"114": "green_wool",
"115": "red_wool",
"116": "black_wool",
"117": "moving_piston",
"118": "dandelion",
"119": "poppy",
"120": "blue_orchid",
"121": "allium",
"122": "azure_bluet",
"123": "red_tulip",
"124": "orange_tulip",
"125": "white_tulip",
"126": "pink_tulip",
"127": "oxeye_daisy",
"128": "brown_mushroom",
"129": "red_mushroom",
"130": "gold_block",
"131": "iron_block",
"132": "bricks",
"133": "tnt",
"134": "bookshelf",
"135": "mossy_cobblestone",
"136": "obsidian",
"137": "torch",
"138": "wall_torch",
"139": "fire",
"140": "spawner",
"141": "oak_stairs",
"142": "chest",
"143": "redstone_wire",
"144": "diamond_ore",
"145": "diamond_block",
"146": "crafting_table",
"147": "wheat",
"148": "farmland",
"149": "furnace",
"150": "oak_sign",
"151": "oak_door",
"152": "ladder",
"153": "rail",
"154": "cobblestone_stairs",
"155": "oak_wall_sign",
"156": "lever",
"157": "stone_pressure_plate",
"158": "iron_door",
"159": "oak_pressure_plate",
"160": "spruce_pressure_plate",
"161": "birch_pressure_plate",
"162": "jungle_pressure_plate",
"163": "acacia_pressure_plate",
"164": "dark_oak_pressure_plate",
"165": "redstone_ore",
"166": "redstone_torch",
"167": "redstone_wall_torch",
"168": "stone_button",
"169": "snow",
"170": "ice",
"171": "snow_block",
"172": "cactus",
"173": "clay",
"174": "sugar_cane",
"175": "jukebox",
"176": "oak_fence",
"177": "pumpkin",
"178": "netherrack",
"179": "soul_sand",
"180": "glowstone",
"181": "nether_portal",
"182": "carved_pumpkin",
"183": "jack_o_lantern",
"184": "cake",
"185": "repeater",
"186": "white_stained_glass",
"187": "orange_stained_glass",
"188": "magenta_stained_glass",
"189": "light_blue_stained_glass",
"190": "yellow_stained_glass",
"191": "lime_stained_glass",
"192": "pink_stained_glass",
"193": "gray_stained_glass",
"194": "light_gray_stained_glass",
"195": "cyan_stained_glass",
"196": "purple_stained_glass",
"197": "blue_stained_glass",
"198": "brown_stained_glass",
"199": "green_stained_glass",
"200": "red_stained_glass",
"201": "black_stained_glass",
"202": "oak_trapdoor",
"203": "spruce_trapdoor",
"204": "birch_trapdoor",
"205": "jungle_trapdoor",
"206": "acacia_trapdoor",
"207": "dark_oak_trapdoor",
"208": "infested_stone",
"209": "infested_cobblestone",
"210": "infested_stone_bricks",
"211": "infested_mossy_stone_bricks",
"212": "infested_cracked_stone_bricks",
"213": "infested_chiseled_stone_bricks",
"214": "stone_bricks",
"215": "mossy_stone_bricks",
"216": "cracked_stone_bricks",
"217": "chiseled_stone_bricks",
"218": "brown_mushroom_block",
"219": "red_mushroom_block",
"220": "mushroom_stem",
"221": "iron_bars",
"222": "glass_pane",
"223": "melon",
"224": "attached_pumpkin_stem",
"225": "attached_melon_stem",
"226": "pumpkin_stem",
"227": "melon_stem",
"228": "vine",
"229": "oak_fence_gate",
"230": "brick_stairs",
"231": "stone_brick_stairs",
"232": "mycelium",
"233": "lily_pad",
"234": "nether_bricks",
"235": "nether_brick_fence",
"236": "nether_brick_stairs",
"237": "nether_wart",
"238": "enchanting_table",
"239": "brewing_stand",
"240": "cauldron",
"241": "end_portal",
"242": "end_portal_frame",
"243": "end_stone",
"244": "dragon_egg",
"245": "redstone_lamp",
"246": "cocoa",
"247": "sandstone_stairs",
"248": "emerald_ore",
"249": "ender_chest",
"250": "tripwire_hook",
"251": "tripwire",
"252": "emerald_block",
"253": "spruce_stairs",
"254": "birch_stairs",
"255": "jungle_stairs",
"256": "command_block",
"257": "beacon",
"258": "cobblestone_wall",
"259": "mossy_cobblestone_wall",
"260": "flower_pot",
"261": "potted_oak_sapling",
"262": "potted_spruce_sapling",
"263": "potted_birch_sapling",
"264": "potted_jungle_sapling",
"265": "potted_acacia_sapling",
"266": "potted_dark_oak_sapling",
"267": "potted_fern",
"268": "potted_dandelion",
"269": "potted_poppy",
"270": "potted_blue_orchid",
"271": "potted_allium",
"272": "potted_azure_bluet",
"273": "potted_red_tulip",
"274": "potted_orange_tulip",
"275": "potted_white_tulip",
"276": "potted_pink_tulip",
"277": "potted_oxeye_daisy",
"278": "potted_red_mushroom",
"279": "potted_brown_mushroom",
"280": "potted_dead_bush",
"281": "potted_cactus",
"282": "carrots",
"283": "potatoes",
"284": "oak_button",
"285": "spruce_button",
"286": "birch_button",
"287": "jungle_button",
"288": "acacia_button",
"289": "dark_oak_button",
"290": "skeleton_wall_skull",
"291": "skeleton_skull",
"292": "wither_skeleton_wall_skull",
"293": "wither_skeleton_skull",
"294": "zombie_wall_head",
"295": "zombie_head",
"296": "player_wall_head",
"297": "player_head",
"298": "creeper_wall_head",
"299": "creeper_head",
"300": "dragon_wall_head",
"301": "dragon_head",
"302": "anvil",
"303": "chipped_anvil",
"304": "damaged_anvil",
"305": "trapped_chest",
"306": "light_weighted_pressure_plate",
"307": "heavy_weighted_pressure_plate",
"308": "comparator",
"309": "daylight_detector",
"310": "redstone_block",
"311": "nether_quartz_ore",
"312": "hopper",
"313": "quartz_block",
"314": "chiseled_quartz_block",
"315": "quartz_pillar",
"316": "quartz_stairs",
"317": "activator_rail",
"318": "dropper",
"319": "white_terracotta",
"320": "orange_terracotta",
"321": "magenta_terracotta",
"322": "light_blue_terracotta",
"323": "yellow_terracotta",
"324": "lime_terracotta",
"325": "pink_terracotta",
"326": "gray_terracotta",
"327": "light_gray_terracotta",
"328": "cyan_terracotta",
"329": "purple_terracotta",
"330": "blue_terracotta",
"331": "brown_terracotta",
"332": "green_terracotta",
"333": "red_terracotta",
"334": "black_terracotta",
"335": "white_stained_glass_pane",
"336": "orange_stained_glass_pane",
"337": "magenta_stained_glass_pane",
"338": "light_blue_stained_glass_pane",
"339": "yellow_stained_glass_pane",
"340": "lime_stained_glass_pane",
"341": "pink_stained_glass_pane",
"342": "gray_stained_glass_pane",
"343": "light_gray_stained_glass_pane",
"344": "cyan_stained_glass_pane",
"345": "purple_stained_glass_pane",
"346": "blue_stained_glass_pane",
"347": "brown_stained_glass_pane",
"348": "green_stained_glass_pane",
"349": "red_stained_glass_pane",
"350": "black_stained_glass_pane",
"351": "acacia_stairs",
"352": "dark_oak_stairs",
"353": "slime_block",
"354": "barrier",
"355": "iron_trapdoor",
"356": "prismarine",
"357": "prismarine_bricks",
"358": "dark_prismarine",
"359": "prismarine_stairs",
"360": "prismarine_brick_stairs",
"361": "dark_prismarine_stairs",
"362": "prismarine_slab",
"363": "prismarine_brick_slab",
"364": "dark_prismarine_slab",
"365": "sea_lantern",
"366": "hay_block",
"367": "white_carpet",
"368": "orange_carpet",
"369": "magenta_carpet",
"370": "light_blue_carpet",
"371": "yellow_carpet",
"372": "lime_carpet",
"373": "pink_carpet",
"374": "gray_carpet",
"375": "light_gray_carpet",
"376": "cyan_carpet",
"377": "purple_carpet",
"378": "blue_carpet",
"379": "brown_carpet",
"380": "green_carpet",
"381": "red_carpet",
"382": "black_carpet",
"383": "terracotta",
"384": "coal_block",
"385": "packed_ice",
"386": "sunflower",
"387": "lilac",
"388": "rose_bush",
"389": "peony",
"390": "tall_grass",
"391": "large_fern",
"392": "white_banner",
"393": "orange_banner",
"394": "magenta_banner",
"395": "light_blue_banner",
"396": "yellow_banner",
"397": "lime_banner",
"398": "pink_banner",
"399": "gray_banner",
"400": "light_gray_banner",
"401": "cyan_banner",
"402": "purple_banner",
"403": "blue_banner",
"404": "brown_banner",
"405": "green_banner",
"406": "red_banner",
"407": "black_banner",
"408": "white_wall_banner",
"409": "orange_wall_banner",
"410": "magenta_wall_banner",
"411": "light_blue_wall_banner",
"412": "yellow_wall_banner",
"413": "lime_wall_banner",
"414": "pink_wall_banner",
"415": "gray_wall_banner",
"416": "light_gray_wall_banner",
"417": "cyan_wall_banner",
"418": "purple_wall_banner",
"419": "blue_wall_banner",
"420": "brown_wall_banner",
"421": "green_wall_banner",
"422": "red_wall_banner",
"423": "black_wall_banner",
"424": "red_sandstone",
"425": "chiseled_red_sandstone",
"426": "cut_red_sandstone",
"427": "red_sandstone_stairs",
"428": "oak_slab",
"429": "spruce_slab",
"430": "birch_slab",
"431": "jungle_slab",
"432": "acacia_slab",
"433": "dark_oak_slab",
"434": "smooth_stone_slab",
"435": "sandstone_slab",
"436": "petrified_oak_slab",
"437": "cobblestone_slab",
"438": "brick_slab",
"439": "stone_brick_slab",
"440": "nether_brick_slab",
"441": "quartz_slab",
"442": "red_sandstone_slab",
"443": "purpur_slab",
"444": "smooth_stone",
"445": "smooth_sandstone",
"446": "smooth_quartz",
"447": "smooth_red_sandstone",
"448": "spruce_fence_gate",
"449": "birch_fence_gate",
"450": "jungle_fence_gate",
"451": "acacia_fence_gate",
"452": "dark_oak_fence_gate",
"453": "spruce_fence",
"454": "birch_fence",
"455": "jungle_fence",
"456": "acacia_fence",
"457": "dark_oak_fence",
"458": "spruce_door",
"459": "birch_door",
"460": "jungle_door",
"461": "acacia_door",
"462": "dark_oak_door",
"463": "end_rod",
"464": "chorus_plant",
"465": "chorus_flower",
"466": "purpur_block",
"467": "purpur_pillar",
"468": "purpur_stairs",
"469": "end_stone_bricks",
"470": "beetroots",
"471": "grass_path",
"472": "end_gateway",
"473": "repeating_command_block",
"474": "chain_command_block",
"475": "frosted_ice",
"476": "magma_block",
"477": "nether_wart_block",
"478": "red_nether_bricks",
"479": "bone_block",
"480": "structure_void",
"481": "observer",
"482": "shulker_box",
"483": "white_shulker_box",
"484": "orange_shulker_box",
"485": "magenta_shulker_box",
"486": "light_blue_shulker_box",
"487": "yellow_shulker_box",
"488": "lime_shulker_box",
"489": "pink_shulker_box",
"490": "gray_shulker_box",
"491": "light_gray_shulker_box",
"492": "cyan_shulker_box",
"493": "purple_shulker_box",
"494": "blue_shulker_box",
"495": "brown_shulker_box",
"496": "green_shulker_box",
"497": "red_shulker_box",
"498": "black_shulker_box",
"499": "white_glazed_terracotta",
"500": "orange_glazed_terracotta",
"501": "magenta_glazed_terracotta",
"502": "light_blue_glazed_terracotta",
"503": "yellow_glazed_terracotta",
"504": "lime_glazed_terracotta",
"505": "pink_glazed_terracotta",
"506": "gray_glazed_terracotta",
"507": "light_gray_glazed_terracotta",
"508": "cyan_glazed_terracotta",
"509": "purple_glazed_terracotta",
"510": "blue_glazed_terracotta",
"511": "brown_glazed_terracotta",
"512": "green_glazed_terracotta",
"513": "red_glazed_terracotta",
"514": "black_glazed_terracotta",
"515": "white_concrete",
"516": "orange_concrete",
"517": "magenta_concrete",
"518": "light_blue_concrete",
"519": "yellow_concrete",
"520": "lime_concrete",
"521": "pink_concrete",
"522": "gray_concrete",
"523": "light_gray_concrete",
"524": "cyan_concrete",
"525": "purple_concrete",
"526": "blue_concrete",
"527": "brown_concrete",
"528": "green_concrete",
"529": "red_concrete",
"530": "black_concrete",
"531": "white_concrete_powder",
"532": "orange_concrete_powder",
"533": "magenta_concrete_powder",
"534": "light_blue_concrete_powder",
"535": "yellow_concrete_powder",
"536": "lime_concrete_powder",
"537": "pink_concrete_powder",
"538": "gray_concrete_powder",
"539": "light_gray_concrete_powder",
"540": "cyan_concrete_powder",
"541": "purple_concrete_powder",
"542": "blue_concrete_powder",
"543": "brown_concrete_powder",
"544": "green_concrete_powder",
"545": "red_concrete_powder",
"546": "black_concrete_powder",
"547": "kelp",
"548": "kelp_plant",
"549": "dried_kelp_block",
"550": "turtle_egg",
"551": "dead_tube_coral_block",
"552": "dead_brain_coral_block",
"553": "dead_bubble_coral_block",
"554": "dead_fire_coral_block",
"555": "dead_horn_coral_block",
"556": "tube_coral_block",
"557": "brain_coral_block",
"558": "bubble_coral_block",
"559": "fire_coral_block",
"560": "horn_coral_block",
"561": "tube_coral",
"562": "brain_coral",
"563": "bubble_coral",
"564": "fire_coral",
"565": "horn_coral",
"566": "dead_tube_coral_wall_fan",
"567": "dead_brain_coral_wall_fan",
"568": "dead_bubble_coral_wall_fan",
"569": "dead_fire_coral_wall_fan",
"570": "dead_horn_coral_wall_fan",
"571": "tube_coral_wall_fan",
"572": "brain_coral_wall_fan",
"573": "bubble_coral_wall_fan",
"574": "fire_coral_wall_fan",
"575": "horn_coral_wall_fan",
"576": "dead_tube_coral_fan",
"577": "dead_brain_coral_fan",
"578": "dead_bubble_coral_fan",
"579": "dead_fire_coral_fan",
"580": "dead_horn_coral_fan",
"581": "tube_coral_fan",
"582": "brain_coral_fan",
"583": "bubble_coral_fan",
"584": "fire_coral_fan",
"585": "horn_coral_fan",
"586": "sea_pickle",
"587": "blue_ice",
"588": "conduit",
"589": "void_air",
"590": "cave_air",
"591": "bubble_column",
"592": "structure_block"
},
"block_tags": { "block_tags": {
"minecraft:impermeable": [ "minecraft:impermeable": [
66, 66,

Datei anzeigen

@ -0,0 +1,64 @@
{
"blockstates": {
"1126": "minecraft:tnt[unstable=false]",
"3075": "minecraft:oak_sign[rotation=0,waterlogged=true]",
"3076": "minecraft:oak_sign[rotation=0,waterlogged=false]",
"3077": "minecraft:oak_sign[rotation=1,waterlogged=true]",
"3078": "minecraft:oak_sign[rotation=1,waterlogged=false]",
"3079": "minecraft:oak_sign[rotation=2,waterlogged=true]",
"3080": "minecraft:oak_sign[rotation=2,waterlogged=false]",
"3081": "minecraft:oak_sign[rotation=3,waterlogged=true]",
"3082": "minecraft:oak_sign[rotation=3,waterlogged=false]",
"3083": "minecraft:oak_sign[rotation=4,waterlogged=true]",
"3084": "minecraft:oak_sign[rotation=4,waterlogged=false]",
"3085": "minecraft:oak_sign[rotation=5,waterlogged=true]",
"3086": "minecraft:oak_sign[rotation=5,waterlogged=false]",
"3087": "minecraft:oak_sign[rotation=6,waterlogged=true]",
"3088": "minecraft:oak_sign[rotation=6,waterlogged=false]",
"3089": "minecraft:oak_sign[rotation=7,waterlogged=true]",
"3090": "minecraft:oak_sign[rotation=7,waterlogged=false]",
"3091": "minecraft:oak_sign[rotation=8,waterlogged=true]",
"3092": "minecraft:oak_sign[rotation=8,waterlogged=false]",
"3093": "minecraft:oak_sign[rotation=9,waterlogged=true]",
"3094": "minecraft:oak_sign[rotation=9,waterlogged=false]",
"3095": "minecraft:oak_sign[rotation=10,waterlogged=true]",
"3096": "minecraft:oak_sign[rotation=10,waterlogged=false]",
"3097": "minecraft:oak_sign[rotation=11,waterlogged=true]",
"3098": "minecraft:oak_sign[rotation=11,waterlogged=false]",
"3099": "minecraft:oak_sign[rotation=12,waterlogged=true]",
"3100": "minecraft:oak_sign[rotation=12,waterlogged=false]",
"3101": "minecraft:oak_sign[rotation=13,waterlogged=true]",
"3102": "minecraft:oak_sign[rotation=13,waterlogged=false]",
"3103": "minecraft:oak_sign[rotation=14,waterlogged=true]",
"3104": "minecraft:oak_sign[rotation=14,waterlogged=false]",
"3105": "minecraft:oak_sign[rotation=15,waterlogged=true]",
"3106": "minecraft:oak_sign[rotation=15,waterlogged=false]",
"3269": "minecraft:oak_wall_sign[facing=north,waterlogged=true]",
"3270": "minecraft:oak_wall_sign[facing=north,waterlogged=false]",
"3271": "minecraft:oak_wall_sign[facing=south,waterlogged=true]",
"3272": "minecraft:oak_wall_sign[facing=south,waterlogged=false]",
"3273": "minecraft:oak_wall_sign[facing=west,waterlogged=true]",
"3274": "minecraft:oak_wall_sign[facing=west,waterlogged=false]",
"3275": "minecraft:oak_wall_sign[facing=east,waterlogged=true]",
"3276": "minecraft:oak_wall_sign[facing=east,waterlogged=false]",
"7293": "minecraft:smooth_stone_slab[type=top,waterlogged=true]",
"7294": "minecraft:smooth_stone_slab[type=top,waterlogged=false]",
"7295": "minecraft:smooth_stone_slab[type=bottom,waterlogged=true]",
"7296": "minecraft:smooth_stone_slab[type=bottom,waterlogged=false]",
"7297": "minecraft:smooth_stone_slab[type=double,waterlogged=true]",
"7298": "minecraft:smooth_stone_slab[type=double,waterlogged=false]",
"8459": "minecraft:tube_coral[waterlogged=true]",
"8460": "minecraft:brain_coral[waterlogged=true]",
"8461": "minecraft:bubble_coral[waterlogged=true]",
"8462": "minecraft:fire_coral[waterlogged=true]",
"8463": "minecraft:horn_coral[waterlogged=true]",
"8573": "minecraft:conduit[waterlogged=true]"
},
"items": {
"118": "minecraft:smooth_stone_slab",
"536": "minecraft:oak_sign",
"573": "minecraft:red_dye",
"574": "minecraft:green_dye",
"583": "minecraft:yellow_dye"
}
}

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name> <name>viaversion-jar</name>

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>viaversion-parent</name> <name>viaversion-parent</name>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>viaversion-parent</artifactId> <artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<version>3.1.1-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>