3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00
Dieser Commit ist enthalten in:
KennyTV 2020-12-16 20:32:16 +01:00
Ursprung 54dcb32232
Commit 963630db7e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
4 geänderte Dateien mit 98 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,7 @@
package nl.matsv.viabackwards.protocol.protocol1_16_4to1_17;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.data.BackwardsMappings;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
@ -8,6 +10,7 @@ import nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.packets.BlockItemPack
import nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.packets.EntityPackets1_17;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
import us.myles.ViaVersion.api.rewriters.RegistryType;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
@ -17,9 +20,15 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPackets1_17, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.17", "1.16.2", Protocol1_17To1_16_4.class, true);
private static final int[] EMPTY_ARRAY = {};
private BlockItemPackets1_17 blockItemPackets;
public Protocol1_16_4To1_17() {
@ -45,13 +54,55 @@ public class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPackets1_
registerOutgoing(ClientboundPackets1_17.TAGS, new PacketRemapper() {
@Override
public void registerMap() {
handler(tagRewriter.getHandler(RegistryType.ENTITY));
handler(wrapper -> {
// Goodbye Game Event tags
Map<String, List<TagRewriter.TagData>> tags = new HashMap<>();
int length = wrapper.read(Type.VAR_INT);
for (int i = 0; i < length; i++) {
wrapper.read(Type.STRING);
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
String resourceKey = wrapper.read(Type.STRING);
if (resourceKey.startsWith("minecraft:")) {
resourceKey = resourceKey.substring(10);
}
List<TagRewriter.TagData> tagList = new ArrayList<>();
tags.put(resourceKey, tagList);
int tagLength = wrapper.read(Type.VAR_INT);
for (int j = 0; j < tagLength; j++) {
String identifier = wrapper.read(Type.STRING);
int[] entries = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
tagList.add(new TagRewriter.TagData(identifier, entries));
}
}
// Put them into the hardcoded order of Vanilla tags (and only those)
for (RegistryType type : RegistryType.getValues()) {
List<TagRewriter.TagData> tagList = tags.get(type.getResourceLocation());
IdRewriteFunction rewriter = tagRewriter.getRewriter(type);
wrapper.write(Type.VAR_INT, tagList.size());
for (TagRewriter.TagData tagData : tagList) {
int[] entries = tagData.getEntries();
if (rewriter != null) {
// Handle id rewriting now
IntList idList = new IntArrayList(entries.length);
for (int id : entries) {
int mappedId = rewriter.rewrite(id);
if (mappedId != -1) {
idList.add(mappedId);
}
}
entries = idList.toArray(EMPTY_ARRAY);
}
wrapper.write(Type.STRING, tagData.getIdentifier());
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, entries);
}
// Stop after the entityt types
if (type == RegistryType.ENTITY) {
break;
}
}
});
}
@ -106,4 +157,15 @@ public class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPackets1_
public BackwardsMappings getMappingData() {
return MAPPINGS;
}
private static final class Tag {
private final String key;
private final int[] values;
private Tag(String key, int[] values) {
this.key = key;
this.values = values;
}
}
}

Datei anzeigen

@ -4,6 +4,7 @@ import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
import us.myles.ViaVersion.api.entities.Entity1_17Types;
import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
@ -69,8 +70,9 @@ public class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17> {
protected void registerRewrites() {
registerMetaHandler().handle(e -> {
Metadata meta = e.getData();
meta.setMetaType(MetaType1_14.byId(meta.getMetaType().getTypeID()));
MetaType type = meta.getMetaType();
meta.setMetaType(MetaType1_14.byId(type.getTypeID()));
if (type == MetaType1_14.Slot) {
meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue()));
} else if (type == MetaType1_14.BlockID) {
@ -106,6 +108,13 @@ public class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17> {
return meta;
});
mapTypes(Entity1_17Types.EntityType.values(), Entity1_16_2Types.EntityType.class);
registerMetaHandler().filter(Entity1_17Types.EntityType.AXOLOTL, 17).removed();
registerMetaHandler().filter(Entity1_17Types.EntityType.AXOLOTL, 18).removed();
registerMetaHandler().filter(Entity1_17Types.EntityType.AXOLOTL, 19).removed();
mapEntity(Entity1_17Types.EntityType.AXOLOTL, Entity1_17Types.EntityType.TROPICAL_FISH).jsonName("Axolotl");
registerMetaHandler().filter(7).removed(); // Ticks frozen
registerMetaHandler().handle(meta -> {
if (meta.getIndex() > 7) {
@ -117,14 +126,15 @@ public class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17> {
@Override
protected EntityType getTypeFromId(int typeId) {
return Entity1_16_2Types.getTypeFromId(typeId);
return Entity1_17Types.getTypeFromId(typeId);
}
private void warnForExtendedHeight(CompoundTag tag) {
IntTag minY = tag.get("min_y");
IntTag height = tag.get("min_y");
IntTag height = tag.get("height");
if (minY.getValue() != 0 || height.getValue() != 256) {
ViaBackwards.getPlatform().getLogger().severe("Custom worlds heights are NOT SUPPORTED for 1.16 players and older and may lead to errors!");
ViaBackwards.getPlatform().getLogger().severe("You have min/max set to " + minY.getValue() + "/" + height.getValue());
}
}
}

Datei anzeigen

@ -928,6 +928,14 @@
"minecraft:sculk_sensor": {
"id": "minecraft:dark_prismarine_slab",
"name": "1.17 Sculk Sensor"
},
"minecraft:axolotl_bucket": {
"id": "minecraft:tropical_fish_bucket",
"name": "1.17 Bucket of Axolotl"
},
"minecraft:axolotl_spawn_egg": {
"id": "minecraft:shulker_spawn_egg",
"name": "1.17 Axolotl Spawn Egg"
}
},
"sounds": {
@ -1003,7 +1011,16 @@
"block.sculk_sensor.fall": "",
"block.sculk_sensor.hit": "",
"block.sculk_sensor.place": "",
"block.sculk_sensor.step": ""
"block.sculk_sensor.step": "",
"entity.axolotl.attack": "",
"entity.axolotl.death": "",
"entity.axolotl.hurt": "",
"entity.axolotl.idle_air": "",
"entity.axolotl.idle_water": "",
"entity.axolotl.splash": "",
"entity.axolotl.swim": "",
"item.bucket.empty_axolotl": "",
"item.bucket.fill_axolotl": ""
},
"particles": {
"small_flame": "flame",

Datei anzeigen

@ -65,7 +65,7 @@
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>3.3.0-20w49a</version>
<version>3.3.0-20w51a</version>
<scope>provided</scope>
</dependency>