mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 10:05:12 +01:00
1.13-pre10, fix flower pots, comment debug message
This commit is contained in:
parent
4ad51649cc
commit
7cd1563805
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -62,7 +62,7 @@ public class ProtocolVersion {
|
||||
register(v1_12 = new ProtocolVersion(335, "1.12"));
|
||||
register(v1_12_1 = new ProtocolVersion(338, "1.12.1"));
|
||||
register(v1_12_2 = new ProtocolVersion(340, "1.12.2"));
|
||||
register(v1_13 = new ProtocolVersion(391, "1.13-pre9"));
|
||||
register(v1_13 = new ProtocolVersion(392, "1.13-pre10"));
|
||||
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,56 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
}
|
||||
};
|
||||
|
||||
public static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS = new PacketHandler() { // *insert here a good name*
|
||||
@Override
|
||||
public void handle(PacketWrapper w) throws Exception {
|
||||
// Send fake declare commands
|
||||
w.create(0x11, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) {
|
||||
wrapper.write(Type.VAR_INT, 2); // Size
|
||||
// Write root node
|
||||
wrapper.write(Type.VAR_INT, 0); // Mark as command
|
||||
wrapper.write(Type.VAR_INT, 1); // 1 child
|
||||
wrapper.write(Type.VAR_INT, 1); // Child is at 1
|
||||
|
||||
// Write arg node
|
||||
wrapper.write(Type.VAR_INT, 0x02 | 0x04 | 0x10); // Mark as command
|
||||
wrapper.write(Type.VAR_INT, 0); // No children
|
||||
// Extra data
|
||||
wrapper.write(Type.STRING, "args"); // Arg name
|
||||
wrapper.write(Type.STRING, "brigadier:string");
|
||||
wrapper.write(Type.VAR_INT, 2); // Greedy
|
||||
wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server
|
||||
|
||||
wrapper.write(Type.VAR_INT, 0); // Root node index
|
||||
}
|
||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
||||
|
||||
// Send tags packet
|
||||
w.create(0x55, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.VAR_INT, MappingData.blockTags.size()); // block tags
|
||||
for (Map.Entry<String, Integer[]> tag : MappingData.blockTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MappingData.itemTags.size()); // item tags
|
||||
for (Map.Entry<String, Integer[]> tag : MappingData.itemTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MappingData.fluidTags.size()); // fluid tags
|
||||
for (Map.Entry<String, Integer[]> tag : MappingData.fluidTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
|
||||
}
|
||||
}
|
||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
||||
}
|
||||
};
|
||||
|
||||
static {
|
||||
MappingData.init();
|
||||
}
|
||||
@ -165,53 +215,9 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
|
||||
// Send fake declare commands
|
||||
wrapper.create(0x11, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) {
|
||||
wrapper.write(Type.VAR_INT, 2); // Size
|
||||
// Write root node
|
||||
wrapper.write(Type.VAR_INT, 0); // Mark as command
|
||||
wrapper.write(Type.VAR_INT, 1); // 1 child
|
||||
wrapper.write(Type.VAR_INT, 1); // Child is at 1
|
||||
|
||||
// Write arg node
|
||||
wrapper.write(Type.VAR_INT, 0x02 | 0x04 | 0x10); // Mark as command
|
||||
wrapper.write(Type.VAR_INT, 0); // No children
|
||||
// Extra data
|
||||
wrapper.write(Type.STRING, "args"); // Arg name
|
||||
wrapper.write(Type.STRING, "brigadier:string");
|
||||
wrapper.write(Type.VAR_INT, 2); // Greedy
|
||||
wrapper.write(Type.STRING, "minecraft:ask_server"); // Ask server
|
||||
|
||||
wrapper.write(Type.VAR_INT, 0); // Root node index
|
||||
}
|
||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
||||
|
||||
// Send tags packet
|
||||
wrapper.create(0x55, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.VAR_INT, MappingData.blockTags.size()); // block tags
|
||||
for (Map.Entry<String, Integer[]> tag : MappingData.blockTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MappingData.itemTags.size()); // item tags
|
||||
for (Map.Entry<String, Integer[]> tag : MappingData.itemTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
|
||||
}
|
||||
wrapper.write(Type.VAR_INT, MappingData.fluidTags.size()); // fluid tags
|
||||
for (Map.Entry<String, Integer[]> tag : MappingData.fluidTags.entrySet()) {
|
||||
wrapper.write(Type.STRING, tag.getKey());
|
||||
wrapper.write(Type.VAR_INT_ARRAY, tag.getValue().clone());
|
||||
}
|
||||
}
|
||||
}).send(ProtocolSnapshotTo1_12_2.class);
|
||||
}
|
||||
});
|
||||
handler(SEND_DECLARE_COMMANDS_AND_TAGS);
|
||||
}
|
||||
});
|
||||
|
||||
@ -296,6 +302,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
handler(SEND_DECLARE_COMMANDS_AND_TAGS);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class BlockEntityProvider implements Provider {
|
||||
String id = (String) tag.get("id").getValue();
|
||||
|
||||
if (!handlers.containsKey(id)) {
|
||||
System.out.println("Unhandled BlockEntity " + id + " full tag: " + tag);
|
||||
//System.out.println("Unhandled BlockEntity " + id + " full tag: " + tag);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -9,47 +9,53 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FlowerPotHandler implements BlockEntityProvider.BlockEntityHandler {
|
||||
private static final Map<Pair<String, Integer>, Integer> flowers = new ConcurrentHashMap<>();
|
||||
private static final Map<Pair<String, Byte>, Integer> flowers = new ConcurrentHashMap<>();
|
||||
private static final Map<Pair<Byte, Byte>, Integer> flowersNumberId = new ConcurrentHashMap<>();
|
||||
|
||||
static {
|
||||
register("minecraft:air", 0, 5265);
|
||||
register("minecraft:sapling", 0, 5266);
|
||||
register("minecraft:sapling", 1, 5267);
|
||||
register("minecraft:sapling", 2, 5268);
|
||||
register("minecraft:sapling", 3, 5269);
|
||||
register("minecraft:sapling", 4, 5270);
|
||||
register("minecraft:sapling", 5, 5271);
|
||||
register("minecraft:tallgrass", 2, 5272);
|
||||
register("minecraft:yellow_flower", 0, 5273);
|
||||
register("minecraft:red_flower", 0, 5274);
|
||||
register("minecraft:red_flower", 1, 5275);
|
||||
register("minecraft:red_flower", 2, 5276);
|
||||
register("minecraft:red_flower", 3, 5277);
|
||||
register("minecraft:red_flower", 4, 5278);
|
||||
register("minecraft:red_flower", 5, 5279);
|
||||
register("minecraft:red_flower", 6, 5280);
|
||||
register("minecraft:red_flower", 7, 5281);
|
||||
register("minecraft:red_flower", 8, 5282);
|
||||
register("minecraft:red_mushroom", 0, 5283);
|
||||
register("minecraft:brown_mushroom", 0, 5284);
|
||||
register("minecraft:deadbush", 0, 5285);
|
||||
register("minecraft:cactus", 0, 5286);
|
||||
register("minecraft:air", (byte) 0, (byte) 0, 5265);
|
||||
register("minecraft:sapling", (byte) 6, (byte) 0, 5266);
|
||||
register("minecraft:sapling", (byte) 6, (byte) 1, 5267);
|
||||
register("minecraft:sapling", (byte) 6, (byte) 2, 5268);
|
||||
register("minecraft:sapling", (byte) 6, (byte) 3, 5269);
|
||||
register("minecraft:sapling", (byte) 6, (byte) 4, 5270);
|
||||
register("minecraft:sapling", (byte) 6, (byte) 5, 5271);
|
||||
register("minecraft:tallgrass", (byte) 31, (byte) 2, 5272);
|
||||
register("minecraft:yellow_flower", (byte) 37, (byte) 0, 5273);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 0, 5274);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 1, 5275);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 2, 5276);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 3, 5277);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 4, 5278);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 5, 5279);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 6, 5280);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 7, 5281);
|
||||
register("minecraft:red_flower", (byte) 38, (byte) 8, 5282);
|
||||
register("minecraft:red_mushroom", (byte) 40, (byte) 0, 5283);
|
||||
register("minecraft:brown_mushroom", (byte) 39, (byte) 0, 5284);
|
||||
register("minecraft:deadbush", (byte) 32, (byte) 0, 5285);
|
||||
register("minecraft:cactus", (byte) 81, (byte) 0, 5286);
|
||||
|
||||
}
|
||||
|
||||
public static void register(String identifier, int blockData, int newId) {
|
||||
public static void register(String identifier, byte numbericBlockId, byte blockData, int newId) {
|
||||
flowers.put(new Pair<>(identifier, blockData), newId);
|
||||
flowersNumberId.put(new Pair<>(numbericBlockId, blockData), newId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int transform(UserConnection user, CompoundTag tag) {
|
||||
String item = (String) tag.get("Item").getValue();
|
||||
int data = (int) tag.get("Data").getValue();
|
||||
Object item = tag.get("Item").getValue();
|
||||
byte data = ((Number) tag.get("Data").getValue()).byteValue();
|
||||
|
||||
Pair<String, Integer> pair = new Pair<>(item, data);
|
||||
Pair<?, Byte> pair = item instanceof Number
|
||||
? new Pair<>(((Number) item).byteValue(), data)
|
||||
: new Pair<>((String) item, data);
|
||||
|
||||
if (flowers.containsKey(pair)) {
|
||||
return flowers.get(pair);
|
||||
} else if (flowersNumberId.containsKey(pair)) {
|
||||
return flowersNumberId.get(pair);
|
||||
} else {
|
||||
System.out.println("Could not find flowerpot content " + item + " for " + tag);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>viaversion-jar</name>
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>viaversion-parent</name>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.4.0-1.13-pre9</version>
|
||||
<version>1.4.0-1.13-pre10</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user