3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Merge pull request #829 from creeper123123321/dev2

18w19b
Dieser Commit ist enthalten in:
Myles 2018-05-13 14:45:03 +01:00 committet von GitHub
Commit f4d1c3fcf2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
14 geänderte Dateien mit 101 neuen und 57 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>1.4.0-18w16a</version> <version>1.4.0-18w19b</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>1.4.0-18w16a</version> <version>1.4.0-18w19b</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>1.4.0-18w16a</version> <version>1.4.0-18w19b</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

Datei anzeigen

@ -62,7 +62,7 @@ public class ProtocolVersion {
register(v1_12 = new ProtocolVersion(335, "1.12")); register(v1_12 = new ProtocolVersion(335, "1.12"));
register(v1_12_1 = new ProtocolVersion(338, "1.12.1")); register(v1_12_1 = new ProtocolVersion(338, "1.12.1"));
register(v1_12_2 = new ProtocolVersion(340, "1.12.2")); register(v1_12_2 = new ProtocolVersion(340, "1.12.2"));
register(v1_13 = new ProtocolVersion(372, "18w16a")); register(v1_13 = new ProtocolVersion(374, "18w19b"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -165,6 +165,7 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, 0); wrapper.write(Type.VAR_INT, 0);
wrapper.write(Type.VAR_INT, 0); wrapper.write(Type.VAR_INT, 0);
wrapper.write(Type.VAR_INT, 0);
} }
}); });
tagsPacket.send(ProtocolSnapshotTo1_12_2.class); tagsPacket.send(ProtocolSnapshotTo1_12_2.class);
@ -186,12 +187,22 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int iconCount = wrapper.passthrough(Type.VAR_INT); int iconCount = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < iconCount; i++) { for (int i = 0; i < iconCount; i++) {
byte directionAndType = wrapper.read(Type.BYTE);
int type = (directionAndType & 0xF0) >> 4;
wrapper.write(Type.VAR_INT, type);
wrapper.passthrough(Type.BYTE); // Icon X wrapper.passthrough(Type.BYTE); // Icon X
wrapper.passthrough(Type.BYTE); // Icon Y
wrapper.passthrough(Type.BYTE); // Icon Z wrapper.passthrough(Type.BYTE); // Icon Z
byte direction = (byte) (directionAndType & 0x0F);
wrapper.write(Type.BYTE, direction);
wrapper.write(Type.OPTIONAL_CHAT, null); // Display Name wrapper.write(Type.OPTIONAL_CHAT, null); // Display Name
} }
wrapper.passthroughAll(); int columns = wrapper.passthrough(Type.BYTE);
if (columns > 0) {
wrapper.passthrough(Type.BYTE); // rows
wrapper.passthrough(Type.BYTE); // x
wrapper.passthrough(Type.BYTE); // z
wrapper.passthrough(Type.BYTE_ARRAY); // data
}
} }
}); });
} }
@ -458,8 +469,12 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
int newId = oldID; int newId = oldID;
if (oldID >= 1) if (oldID >= 1)
newId += 6; newId += 6;
if (oldID >= 9)
newId += 4;
if (oldID >= 10) if (oldID >= 10)
newId += 5; newId += 5;
if (oldID >= 21)
newId += 5;
if (oldID >= 86) if (oldID >= 86)
newId += 1; newId += 1;
if (oldID >= 166) if (oldID >= 166)
@ -470,14 +485,22 @@ public class ProtocolSnapshotTo1_12_2 extends Protocol {
newId += 9; newId += 9;
if (oldID >= 226) if (oldID >= 226)
newId += 1; newId += 1;
if (oldID >= 271)
newId += 1;
if (oldID >= 326)
newId += 1;
if (oldID >= 335)
newId += 1;
if (oldID >= 352) if (oldID >= 352)
newId += 5; newId += 6;
if (oldID >= 373) if (oldID >= 373)
newId += 1; newId += 1;
if (oldID >= 380) if (oldID >= 380)
newId += 7; newId += 7;
if (oldID >= 385) if (oldID >= 385)
newId += 4; newId += 4;
if (oldID >= 412)
newId += 5;
if (oldID >= 438) if (oldID >= 438)
newId += 1; newId += 1;
if (oldID >= 443) if (oldID >= 443)

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data; package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data;
import com.google.common.base.Optional;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
@ -67,4 +68,9 @@ public class SpawnEggRewriter {
return 25100288; return 25100288;
return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF)); return (383 << 16 | (spawnEggs.get(entityIdentifier) & 0xFFFF));
} }
public static Optional<String> getEntityId(int spawnEggId) {
if (spawnEggId >> 16 != 383) return Optional.absent();
return Optional.fromNullable(spawnEggs.inverse().get(spawnEggId & 0xFFFF));
}
} }

Datei anzeigen

@ -250,8 +250,8 @@ public class InventoryPackets {
} }
if (!MappingData.oldToNewItems.containsKey(rawId)) { if (!MappingData.oldToNewItems.containsKey(rawId)) {
if (MappingData.oldToNewItems.containsKey(item.getId() << 4)) { if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
rawId = item.getId() << 4; rawId &= ~0xF; // Remove data
} else { } else {
System.out.println("FAILED TO GET 1.13 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T System.out.println("FAILED TO GET 1.13 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
rawId = 16; // Stone rawId = 16; // Stone
@ -286,45 +286,59 @@ public class InventoryPackets {
for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) { for (Map.Entry<Integer, Integer> entry : MappingData.oldToNewItems.entrySet()) {
if (entry.getValue() == item.getId()) { if (entry.getValue() == item.getId()) {
int oldId = entry.getKey(); int oldId = entry.getKey();
rawId = (oldId >> 4) << 16 | oldId & 0xF; // Handle spawn eggs
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
if (eggEntityId.isPresent()) {
rawId = 383 << 16;
if (tag == null)
item.setTag(tag = new CompoundTag("tag"));
if (!tag.contains("EntityTag")) {
CompoundTag entityTag = new CompoundTag("EntityTag");
entityTag.put(new StringTag("id", eggEntityId.get()));
tag.put(entityTag);
}
} else {
rawId = (oldId >> 4) << 16 | oldId & 0xF;
}
break; break;
} }
} }
} }
if (rawId != null) { if (rawId == null) {
item.setId((short) (rawId >> 16)); System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId());
item.setData((short) (rawId & 0xFFFF)); rawId = 0x10000; // Stone
}
if (tag != null) { item.setId((short) (rawId >> 16));
if (isDamageable(item.getId())) { item.setData((short) (rawId & 0xFFFF));
if (tag.get("Damage") instanceof IntTag) {
if (!gotRawIdFromTag) if (tag != null) {
item.setData((short) (int) tag.get("Damage").getValue()); if (isDamageable(item.getId())) {
tag.remove("Damage"); if (tag.get("Damage") instanceof IntTag) {
} if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("Damage").getValue());
tag.remove("Damage");
} }
}
if (item.getId() == 358) { // map if (item.getId() == 358) { // map
if (tag.get("map") instanceof IntTag) { if (tag.get("map") instanceof IntTag) {
if (!gotRawIdFromTag) if (!gotRawIdFromTag)
item.setData((short) (int) tag.get("map").getValue()); item.setData((short) (int) tag.get("map").getValue());
tag.remove("map"); tag.remove("map");
}
} }
}
if (item.getId() == 442) { // shield if (item.getId() == 442) { // shield
if (tag.get("BlockEntityTag") instanceof CompoundTag) { if (tag.get("BlockEntityTag") instanceof CompoundTag) {
CompoundTag blockEntityTag = tag.get("BlockEntityTag"); CompoundTag blockEntityTag = tag.get("BlockEntityTag");
if (blockEntityTag.get("Base") instanceof IntTag) { if (blockEntityTag.get("Base") instanceof IntTag) {
IntTag base = blockEntityTag.get("Base"); IntTag base = blockEntityTag.get("Base");
base.setValue(15 - base.getValue()); // invert color id base.setValue(15 - base.getValue()); // invert color id
}
} }
} }
} }
} else {
System.out.println("FAILED TO GET 1.12 ITEM FOR " + item.getId()); // TODO: Make this nicer etc, perhaps fix issues with mapping :T
} }
} }

Datei anzeigen

@ -248,17 +248,18 @@ public class WorldPackets {
} }
public static int toNewId(int oldId) { public static int toNewId(int oldId) {
if (MappingData.oldToNewBlocks.containsKey(oldId)) { Integer newId = MappingData.oldToNewBlocks.get(oldId);
return MappingData.oldToNewBlocks.get(oldId); if (newId != null) {
} else { return newId;
if (MappingData.oldToNewBlocks.containsKey((oldId >> 4) << 4)) {
System.out.println("Missing block " + oldId);
return MappingData.oldToNewBlocks.get((oldId >> 4) << 4);
}
System.out.println("Missing block completely " + oldId);
// Default stone
return 1;
} }
newId = MappingData.oldToNewBlocks.get(oldId & ~0xF); // Remove data
if (newId != null) {
System.out.println("Missing block " + oldId);
return newId;
}
System.out.println("Missing block completely " + oldId);
// Default stone
return 1;
} }
private static int checkStorage(UserConnection user, Position position, int newId) { private static int checkStorage(UserConnection user, Position position, int newId) {

Datei anzeigen

@ -1,19 +1,19 @@
package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage; package us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage;
import com.google.common.collect.Sets;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import us.myles.ViaVersion.api.data.StoredObject; 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 java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
public class BlockStorage extends StoredObject { public class BlockStorage extends StoredObject {
// This BlockStorage is very exclusive (; // This BlockStorage is very exclusive (;
private static final List<Integer> whitelist = new CopyOnWriteArrayList<>(); private static final Set<Integer> whitelist = Sets.newConcurrentHashSet();
static { static {
// Flower pots // Flower pots

Datei anzeigen

@ -954,9 +954,9 @@
"951": "minecraft:grass", "951": "minecraft:grass",
"952": "minecraft:fern", "952": "minecraft:fern",
"953": "minecraft:dead_bush", "953": "minecraft:dead_bush",
"954": "minecraft:sea_grass", "954": "minecraft:seagrass",
"955": "minecraft:tall_sea_grass[half=upper]", "955": "minecraft:tall_seagrass[half=upper]",
"956": "minecraft:tall_sea_grass[half=lower]", "956": "minecraft:tall_seagrass[half=lower]",
"957": "minecraft:piston[extended=true,facing=north]", "957": "minecraft:piston[extended=true,facing=north]",
"958": "minecraft:piston[extended=true,facing=east]", "958": "minecraft:piston[extended=true,facing=east]",
"959": "minecraft:piston[extended=true,facing=south]", "959": "minecraft:piston[extended=true,facing=south]",
@ -8487,7 +8487,7 @@
"70": "minecraft:grass", "70": "minecraft:grass",
"71": "minecraft:fern", "71": "minecraft:fern",
"72": "minecraft:dead_bush", "72": "minecraft:dead_bush",
"73": "minecraft:sea_grass", "73": "minecraft:seagrass",
"74": "minecraft:sea_pickle", "74": "minecraft:sea_pickle",
"75": "minecraft:piston", "75": "minecraft:piston",
"76": "minecraft:white_wool", "76": "minecraft:white_wool",
@ -9064,7 +9064,7 @@
"647": "minecraft:pig_spawn_egg", "647": "minecraft:pig_spawn_egg",
"648": "minecraft:phantom_spawn_egg", "648": "minecraft:phantom_spawn_egg",
"649": "minecraft:polar_bear_spawn_egg", "649": "minecraft:polar_bear_spawn_egg",
"650": "minecraft:puffer_fish_spawn_egg", "650": "minecraft:pufferfish_spawn_egg",
"651": "minecraft:rabbit_spawn_egg", "651": "minecraft:rabbit_spawn_egg",
"652": "minecraft:salmon_mob_spawn_egg", "652": "minecraft:salmon_mob_spawn_egg",
"653": "minecraft:sheep_spawn_egg", "653": "minecraft:sheep_spawn_egg",

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>1.4.0-18w16a</version> <version>1.4.0-18w19b</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>1.4.0-18w16a</version> <version>1.4.0-18w19b</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>1.4.0-18w16a</version> <version>1.4.0-18w19b</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>1.4.0-18w16a</version> <version>1.4.0-18w19b</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>