Merge pull request #168 from KennyTV/1.15

1.15 (and a lot of other improvements/fixes) 🎉
This commit is contained in:
Myles 2019-12-07 17:10:55 +00:00 committed by GitHub
commit f959a388c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
60 changed files with 2210 additions and 743 deletions

View File

@ -3,19 +3,25 @@
Allows older Minecraft versions on a newer Minecraft server
### Supported versions:
![supported_versions](https://camo.githubusercontent.com/75fd692876cdeadbb8a84ed3175e6f0fc23a640a/68747470733a2f2f692e696d6775722e636f6d2f695741744431702e706e67)
**Orange** = Native server version\
**Green** = ViaVersion\
**Blue** = ViaBackwards addition
![supported_versions](https://i.imgur.com/dlxakYT.png)
---
### Releases / Dev Builds:
***Requires [ViaVersion](http://viaversion.com) to be installed***
**Requires [ViaVersion](http://viaversion.com) to be installed**
You can find official releases here:
**Spgot page:** https://www.spigotmc.org/resources/viabackwards.27448/ **[1.9.x - 1.12.x]**
You can find the latest builds here:\
**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/
You can find official dev builds here:
**Jenkins:** https://ci.viaversion.com/view/ViaBackwards/ **[1.9.x - 1.14.x]**
Spigot page (possibly outdated):\
**Spigot page:** https://www.spigotmc.org/resources/viabackwards.27448/
---
**Maven:** https://repo.viaversion.com/

View File

@ -3,8 +3,8 @@ version: ${project.version}
description: Allow older Minecraft versions to connect to a newer server version.
main: nl.matsv.viabackwards.BukkitPlugin
authors: [Matsv]
website: https://matsv.nl
authors: [Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1]
website: ${project.url}
load: STARTUP
depend: [ViaVersion]

View File

@ -1,5 +1,5 @@
name: ViaBackwards
main: nl.matsv.viabackwards.BungeePlugin
author: Matsv
author: "Matsv, KennyTV, Gerrygames, creeper123123321, ForceUpdate1"
version: ${project.version}
depends: [ViaVersion]

View File

@ -24,20 +24,21 @@ import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
import nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2;
import nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3;
import nl.matsv.viabackwards.protocol.protocol1_14_3to1_14_4.Protocol1_14_3To1_14_4;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.update.Version;
import java.io.File;
import java.util.Collections;
import java.util.logging.Logger;
import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol;
public interface ViaBackwardsPlatform {
/**
* Initialize ViaBackwards
* Initialize ViaBackwards.
*/
default void init(File dataFolder) {
ViaBackwardsConfig config = new ViaBackwardsConfig(new File(dataFolder, "config.yml"));
@ -47,20 +48,21 @@ public interface ViaBackwardsPlatform {
if (isOutdated()) return;
ProtocolRegistry.registerProtocol(new Protocol1_9_4To1_10(), Collections.singletonList(ProtocolVersion.v1_9_3.getId()), ProtocolVersion.v1_10.getId());
ProtocolRegistry.registerProtocol(new Protocol1_10To1_11(), Collections.singletonList(ProtocolVersion.v1_10.getId()), ProtocolVersion.v1_11.getId());
ProtocolRegistry.registerProtocol(new Protocol1_11To1_11_1(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_11_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_11_1To1_12(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_12.getId());
ProtocolRegistry.registerProtocol(new Protocol1_12To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_12_1To1_12_2(), Collections.singletonList(ProtocolVersion.v1_12_1.getId()), ProtocolVersion.v1_12_2.getId());
ProtocolRegistry.registerProtocol(new Protocol1_12_2To1_13(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_13.getId());
ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_13_1To1_13_2(), Collections.singletonList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13_2.getId());
ProtocolRegistry.registerProtocol(new Protocol1_13_2To1_14(), Collections.singletonList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_14.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_14_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14_1To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14_2.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14_2To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_3.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14_3To1_14_4(), Collections.singletonList(ProtocolVersion.v1_14_3.getId()), ProtocolVersion.v1_14_4.getId());
registerProtocol(new Protocol1_9_4To1_10(), ProtocolVersion.v1_9_3, ProtocolVersion.v1_10);
registerProtocol(new Protocol1_10To1_11(), ProtocolVersion.v1_10, ProtocolVersion.v1_11);
registerProtocol(new Protocol1_11To1_11_1(), ProtocolVersion.v1_11, ProtocolVersion.v1_11_1);
registerProtocol(new Protocol1_11_1To1_12(), ProtocolVersion.v1_11_1, ProtocolVersion.v1_12);
registerProtocol(new Protocol1_12To1_12_1(), ProtocolVersion.v1_12, ProtocolVersion.v1_12_1);
registerProtocol(new Protocol1_12_1To1_12_2(), ProtocolVersion.v1_12_1, ProtocolVersion.v1_12_2);
registerProtocol(new Protocol1_12_2To1_13(), ProtocolVersion.v1_12_2, ProtocolVersion.v1_13);
registerProtocol(new Protocol1_13To1_13_1(), ProtocolVersion.v1_13, ProtocolVersion.v1_13_1);
registerProtocol(new Protocol1_13_1To1_13_2(), ProtocolVersion.v1_13_1, ProtocolVersion.v1_13_2);
registerProtocol(new Protocol1_13_2To1_14(), ProtocolVersion.v1_13_2, ProtocolVersion.v1_14);
registerProtocol(new Protocol1_14To1_14_1(), ProtocolVersion.v1_14, ProtocolVersion.v1_14_1);
registerProtocol(new Protocol1_14_1To1_14_2(), ProtocolVersion.v1_14_1, ProtocolVersion.v1_14_2);
registerProtocol(new Protocol1_14_2To1_14_3(), ProtocolVersion.v1_14_2, ProtocolVersion.v1_14_3);
registerProtocol(new Protocol1_14_3To1_14_4(), ProtocolVersion.v1_14_3, ProtocolVersion.v1_14_4);
registerProtocol(new Protocol1_14_4To1_15(), ProtocolVersion.v1_14_4, ProtocolVersion.v1_15);
}
/**
@ -71,7 +73,7 @@ public interface ViaBackwardsPlatform {
Logger getLogger();
default boolean isOutdated() {
String minimumVVVersion = "2.0.0";
String minimumVVVersion = "3.0.0";
boolean upToDate = false;
try {
Class<?> vvVersionInfo = Class.forName("us.myles.ViaVersion.sponge.VersionInfo");
@ -98,7 +100,7 @@ public interface ViaBackwardsPlatform {
}
/**
* Disable the plugin
* Disable the plugin.
*/
void disable();
}

View File

@ -0,0 +1,98 @@
package nl.matsv.viabackwards.api.data;
import nl.matsv.viabackwards.ViaBackwards;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.viaversion.libs.gson.JsonArray;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.viaversion.libs.gson.JsonObject;
import us.myles.viaversion.libs.gson.JsonPrimitive;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
public class VBMappingDataLoader {
public static JsonObject loadData(String name) {
InputStream stream = VBMappingDataLoader.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name);
InputStreamReader reader = new InputStreamReader(stream);
try {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} finally {
try {
reader.close();
} catch (IOException ignored) {
// Ignored
}
}
}
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, diffIdentifiers, true);
}
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
String key = entry.getValue().getAsString();
Map.Entry<String, JsonElement> value = MappingDataLoader.findValue(newIdentifiers, key);
if (value == null) {
// Search in diff mappings
if (diffIdentifiers != null) {
JsonPrimitive diffValue = diffIdentifiers.getAsJsonPrimitive(key);
if (diffValue == null && key.contains("[")) {
diffValue = diffIdentifiers.getAsJsonPrimitive(key.substring(0, key.indexOf('[')));
}
if (diffValue == null) {
if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("No diff key for " + entry.getValue() + " :( ");
}
continue;
}
value = MappingDataLoader.findValue(newIdentifiers, diffValue.getAsString());
}
if (value == null) {
if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
int i = -1;
for (JsonElement oldIdentifier : oldIdentifiers) {
i++;
String key = oldIdentifier.getAsString();
Integer index = MappingDataLoader.findIndex(newIdentifiers, key);
if (index == null) {
// Search in diff mappings
if (diffIdentifiers != null) {
JsonPrimitive diffValue = diffIdentifiers.getAsJsonPrimitive(key);
if (diffValue == null) {
if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("No diff key for " + key + " :( ");
}
continue;
}
String mappedName = diffValue.getAsString();
if (mappedName.isEmpty()) continue; // "empty" remaps
index = MappingDataLoader.findIndex(newIdentifiers, mappedName);
}
if (index == null) {
if (warnOnMissing && !Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
ViaBackwards.getPlatform().getLogger().warning("No key for " + key + " :( ");
}
continue;
}
}
output[i] = index.shortValue();
}
}
}

View File

@ -0,0 +1,44 @@
package nl.matsv.viabackwards.api.data;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.viaversion.libs.gson.JsonArray;
import us.myles.viaversion.libs.gson.JsonObject;
import java.util.Arrays;
public class VBMappings extends Mappings {
public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
this(size, oldMapping, newMapping, diffMapping, true);
}
public VBMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
this(oldMapping, newMapping, diffMapping, true);
}
public VBMappings(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
super(create(size, oldMapping, newMapping, diffMapping, warnOnMissing));
}
public VBMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
super(create(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping, warnOnMissing));
}
public VBMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
super(create(oldMapping, newMapping, diffMapping, true));
}
private static short[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
short[] oldToNew = new short[size];
Arrays.fill(oldToNew, (short) -1);
VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
return oldToNew;
}
private static short[] create(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
short[] oldToNew = new short[oldMapping.size()];
Arrays.fill(oldToNew, (short) -1);
VBMappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
return oldToNew;
}
}

View File

@ -12,6 +12,7 @@ package nl.matsv.viabackwards.api.entities.storage;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.data.StoredObject;

View File

@ -17,5 +17,9 @@ public class RemovedValueException extends IOException {
/**
* May be cached since it is never actually printed, only checked.
*/
public static final RemovedValueException EX = new RemovedValueException();
public static final RemovedValueException EX = new RemovedValueException() {
public synchronized Throwable fillInStackTrace() {
return this;
}
};
}

View File

@ -23,6 +23,7 @@ import nl.matsv.viabackwards.utils.ItemUtil;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.viaversion.libs.opennbt.conversion.builtin.CompoundTagConverter;
import us.myles.viaversion.libs.opennbt.tag.builtin.*;
@ -35,6 +36,7 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
private static final CompoundTagConverter converter = new CompoundTagConverter();
private final Map<Integer, BlockItemSettings> replacementData = new ConcurrentHashMap<>();
protected String nbtTagName;
protected boolean jsonNameFormat = true;
@Override
public void register(T protocol) {
@ -48,7 +50,7 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
return settings;
}
protected Item handleItemToClient(Item i) {
public Item handleItemToClient(Item i) {
if (i == null) return null;
BlockItemSettings data = replacementData.get(i.getIdentifier());
@ -57,14 +59,14 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
Item original = ItemUtil.copyItem(i);
if (data.hasRepItem()) {
ItemUtil.copyItem(i, data.getRepItem());
if (i.getTag() == null)
if (i.getTag() == null) {
i.setTag(new CompoundTag(""));
}
// Backup data for toServer
i.getTag().put(createViaNBT(original));
// Keep original data
// Keep original data (aisde from the name)
if (original.getTag() != null) {
for (Tag ai : original.getTag()) {
i.getTag().put(ai);
@ -76,7 +78,6 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
CompoundTag tag = i.getTag().get("display");
if (tag.contains("Name")) {
String value = (String) tag.get("Name").getValue();
tag.put(new StringTag("Name",
value.replaceAll("%viabackwards_color%", BlockColors.get((int) original.getData()))));
}
@ -84,19 +85,21 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
i.setAmount(original.getAmount());
// Keep original data when -1
if (i.getData() == -1)
if (i.getData() == -1) {
i.setData(original.getData());
}
}
if (data.hasItemTagHandler()) {
if (!i.getTag().contains(nbtTagName))
if (!i.getTag().contains(nbtTagName)) {
i.getTag().put(createViaNBT(original));
}
data.getItemHandler().handle(i);
}
return i;
}
protected Item handleItemToServer(Item item) {
public Item handleItemToServer(Item item) {
if (item == null) return null;
if (item.getTag() == null) return item;
@ -242,7 +245,15 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
protected CompoundTag getNamedTag(String text) {
CompoundTag tag = new CompoundTag("");
tag.put(new CompoundTag("display"));
((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatColor.RESET + text));
text = ChatColor.RESET + text;
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text) : text));
return tag;
}
protected CompoundTag getNamedJsonTag(String text) {
CompoundTag tag = new CompoundTag("");
tag.put(new CompoundTag("display"));
return tag;
}

View File

@ -56,8 +56,8 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
return getEntityTracker(connection).getEntityType(id);
}
protected void addTrackedEntity(UserConnection connection, int entityId, EntityType type) {
getEntityTracker(connection).trackEntityType(entityId, type);
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
getEntityTracker(wrapper.user()).trackEntityType(entityId, type);
}
protected boolean hasData(EntityType type) {
@ -101,9 +101,10 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
protected MetaStorage handleMeta(UserConnection user, int entityId, MetaStorage storage) throws Exception {
Optional<EntityTracker.StoredEntity> optEntity = getEntityTracker(user).getEntity(entityId);
if (!optEntity.isPresent()) {
if (!Via.getConfig().isSuppressMetadataErrors())
if (!Via.getConfig().isSuppressMetadataErrors()) {
ViaBackwards.getPlatform().getLogger().warning("Metadata for entity id: " + entityId + " not sent because the entity doesn't exist. " + storage);
throw new CancelException();
}
throw CancelException.CACHED;
}
EntityTracker.StoredEntity entity = optEntity.get();
@ -171,7 +172,6 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
data.setValue(mobName);
}
}
}
return storage;
@ -202,6 +202,47 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
});
}
protected void register1_15MetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> metaType) {
register1_15MetadataRewriter(oldPacketId, newPacketId, null, metaType);
}
/**
* Helper method to handle a metadata list packet and its full initial meta rewrite.
*/
protected void register1_15MetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
if (oldMetaType != null) {
map(oldMetaType, newMetaType);
} else {
map(newMetaType);
}
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
EntityType type = getEntityType(wrapper.user(), entityId);
MetaStorage storage = new MetaStorage(wrapper.get(newMetaType, 0));
handleMeta(wrapper.user(), entityId, storage);
Optional<EntityData> optEntDat = getEntityData(type);
if (optEntDat.isPresent()) {
EntityData data = optEntDat.get();
if (data.hasBaseMeta()) {
data.getDefaultMeta().handle(storage);
}
}
wrapper.set(newMetaType, 0, storage.getMetaDataList());
}
});
}
});
}
protected void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> metaType) {
registerMetadataRewriter(oldPacketId, newPacketId, null, metaType);
}
@ -217,7 +258,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper.user(), (int) wrapper.get(intType, 0), entityType);
addTrackedEntity(wrapper, (int) wrapper.get(intType, 0), entityType);
}
});
}
@ -235,12 +276,12 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
getProtocol().registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT_ARRAY); // 0 - Entity ids
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
EntityTracker.ProtocolEntityTracker tracker = getEntityTracker(wrapper.user());
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0)) {
for (int entity : wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0)) {
tracker.removeEntity(entity);
}
}
@ -257,7 +298,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
return new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), getObjectTypeFromId(wrapper.get(Type.BYTE, 0)));
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), getObjectTypeFromId(wrapper.get(Type.BYTE, 0)));
}
};
}
@ -267,7 +308,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Number id = (Number) wrapper.get(intType, typeIndex);
addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), getTypeFromId(id.intValue()));
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), getTypeFromId(id.intValue()));
}
};
}
@ -280,7 +321,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
return new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper.user(), (int) wrapper.get(intType, 0), entityType);
addTrackedEntity(wrapper, (int) wrapper.get(intType, 0), entityType);
}
};
}
@ -316,7 +357,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
return new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), entityType);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
List<Metadata> metaDataList = handleMeta(wrapper.user(), wrapper.get(Type.VAR_INT, 0),
new MetaStorage(wrapper.get(metaType, 0))).getMetaDataList();

View File

@ -0,0 +1,14 @@
package nl.matsv.viabackwards.api.rewriters;
import us.myles.ViaVersion.api.PacketWrapper;
public abstract class RecipeRewriter {
protected final BlockItemRewriter rewriter;
protected RecipeRewriter(final BlockItemRewriter rewriter) {
this.rewriter = rewriter;
}
public abstract void handle(PacketWrapper wrapper, String type) throws Exception;
}

View File

@ -17,10 +17,10 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
/*
Copied from ViaVersion //TODO implement in EntityTypes?
Copied from ViaVersion
*/
public class EntityTypeNames {
private static BiMap<String, String> newToOldNames = HashBiMap.create();
private static final BiMap<String, String> NEW_TO_OLD_NAMES = HashBiMap.create();
static {
add("AreaEffectCloud", "minecraft:area_effect_cloud");
@ -102,14 +102,14 @@ public class EntityTypeNames {
// Other way around (-:
private static void add(String oldName, String newName) {
newToOldNames.put(newName, oldName);
NEW_TO_OLD_NAMES.put(newName, oldName);
}
public static void toClient(CompoundTag tag) {
if (tag.get("id") instanceof StringTag) {
StringTag id = tag.get("id");
if (newToOldNames.containsKey(id.getValue())) {
id.setValue(newToOldNames.get(id.getValue()));
if (NEW_TO_OLD_NAMES.containsKey(id.getValue())) {
id.setValue(NEW_TO_OLD_NAMES.get(id.getValue()));
}
}
}
@ -130,7 +130,7 @@ public class EntityTypeNames {
}
private static boolean hasEntityTag(Item item) {
if (item != null && item.getId() == 383) { // Monster Egg
if (item != null && item.getIdentifier() == 383) { // Monster Egg
CompoundTag tag = item.getTag();
if (tag != null && tag.contains("EntityTag") && tag.get("EntityTag") instanceof CompoundTag) {
if (((CompoundTag) tag.get("EntityTag")).get("id") instanceof StringTag) {

View File

@ -47,6 +47,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
@Override
protected void registerPackets(Protocol1_10To1_11 protocol) {
jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
// Set slot packet
@ -351,8 +352,8 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
// ShulkerBoxes to EnderChest
for (int i = 219; i < 235; i++)
rewrite(i)
.repItem(new Item((short) 130, (byte) 1, (short) 0, getNamedTag("1.11 " + BlockColors.get(i - 219) + " Shulker Box")))
.repBlock(new Block(130, 4)) // TODO investigate this
.repItem(new Item(130, (byte) 1, (short) 0, getNamedTag("1.11 " + BlockColors.get(i - 219) + " Shulker Box")))
.repBlock(new Block(130, 4))
.blockEntityHandler((block, tag) -> {
tag.remove("id");
tag.put(new StringTag("id", "minecraft:chest"));
@ -360,7 +361,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
});
// Observer to Dispenser
rewrite(218).repItem(new Item((short) 23, (byte) 1, (short) 0, getNamedTag("1.11 Observer"))).repBlock(new Block(23, -1));
rewrite(218).repItem(new Item(23, (byte) 1, (short) 0, getNamedTag("1.11 Observer"))).repBlock(new Block(23, -1));
// Handle spawner block entity
rewrite(52).blockEntityHandler((b, tag) -> {
@ -375,10 +376,10 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
});
// Totem of Undying to Dead Bush
rewrite(449).repItem(new Item((short) 32, (byte) 1, (short) 0, getNamedTag("1.11 Totem of Undying")));
rewrite(449).repItem(new Item(32, (byte) 1, (short) 0, getNamedTag("1.11 Totem of Undying")));
// Shulker shell to Popped Chorus Fruit
rewrite(450).repItem(new Item((short) 433, (byte) 1, (short) 0, getNamedTag("1.11 Shulker Shell")));
rewrite(450).repItem(new Item(433, (byte) 1, (short) 0, getNamedTag("1.11 Shulker Shell")));
enchantmentRewriter = new LegacyEnchantmentRewriter(nbtTagName);
enchantmentRewriter.registerEnchantment(71, "§cCurse of Vanishing");
@ -388,7 +389,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
}
@Override
protected Item handleItemToClient(final Item item) {
public Item handleItemToClient(final Item item) {
if (item == null) return null;
super.handleItemToClient(item);
@ -405,7 +406,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
}
@Override
protected Item handleItemToServer(final Item item) {
public Item handleItemToServer(final Item item) {
if (item == null) return null;
super.handleItemToServer(item);
@ -442,7 +443,6 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
return Optional.empty();
}
// TODO improve the llama inventory part
private int getNewSlotId(ChestedHorseStorage storage, int slotId) {
int totalSlots = !storage.isChested() ? 38 : 53;
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
@ -477,7 +477,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
return new Item((short) 166, (byte) 1, (short) 0, getNamedTag(ChatColor.RED + "SLOT DISABLED"));
return new Item(166, (byte) 1, (short) 0, getNamedTag(ChatColor.RED + "SLOT DISABLED"));
if (slotId == 1)
return null;
return current;

View File

@ -344,7 +344,7 @@ public class EntityPackets1_11 extends EntityRewriter<Protocol1_10To1_11> {
return data;
});
// Create chested horse storage TODO create on mob spawn?
// Create chested horse storage
registerMetaHandler().filter(Entity1_11Types.EntityType.CHESTED_HORSE, true).handle(e -> {
if (!e.getEntity().has(ChestedHorseStorage.class))
e.getEntity().put(new ChestedHorseStorage());

View File

@ -20,7 +20,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_11_1To1_12 extends BackwardsProtocol {
// TODO checkAndStore all rewriters and make them easy accessible?
private EntityPackets1_12 entityPackets;
private BlockItemPackets1_12 blockItemPackets;

View File

@ -10,11 +10,11 @@
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class BlockColors {
private static Map<Integer, String> colors = new ConcurrentHashMap<>();
private static final Map<Integer, String> COLORS = new HashMap<>();
private static int count = 0;
static {
@ -37,14 +37,14 @@ public class BlockColors {
}
private static void add(String value) {
colors.put(count++, value);
COLORS.put(count++, value);
}
public static boolean has(Integer key) {
return colors.containsKey(key);
return COLORS.containsKey(key);
}
public static String get(Integer key) {
return colors.getOrDefault(key, "Unknown color");
return COLORS.getOrDefault(key, "Unknown color");
}
}

View File

@ -4,75 +4,76 @@ import java.util.HashMap;
import java.util.Map;
public class MapColorMapping {
private static Map<Integer, Integer> mapping = new HashMap<>();
static {
mapping.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
mapping.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
mapping.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
mapping.put(147, 45); // (111, 94, 85) -> (111, 94, 85)
mapping.put(148, 63); // (112, 58, 25) -> (112, 58, 25)
mapping.put(149, 60); // (137, 71, 31) -> (137, 71, 31)
mapping.put(150, 60); // (159, 82, 36) -> (159, 82, 36)
mapping.put(151, 136); // (84, 43, 19) -> (84, 43, 19)
mapping.put(152, 83); // (105, 61, 76) -> (105, 61, 76)
mapping.put(153, 83); // (129, 75, 93) -> (129, 75, 93)
mapping.put(154, 80); // (149, 87, 108) -> (149, 87, 108)
mapping.put(155, 115); // (79, 46, 57) -> (79, 46, 57)
mapping.put(156, 39); // (79, 76, 97) -> (79, 76, 97)
mapping.put(157, 39); // (97, 93, 119) -> (97, 93, 119)
mapping.put(158, 36); // (112, 108, 138) -> (112, 108, 138)
mapping.put(159, 47); // (59, 57, 73) -> (59, 57, 73)
mapping.put(160, 60); // (131, 94, 25) -> (131, 94, 25)
mapping.put(161, 61); // (160, 115, 31) -> (160, 115, 31)
mapping.put(162, 62); // (186, 133, 36) -> (186, 133, 36)
mapping.put(163, 137); // (98, 70, 19) -> (98, 70, 19)
mapping.put(164, 108); // (73, 83, 37) -> (73, 83, 37)
mapping.put(165, 108); // (89, 101, 46) -> (89, 101, 46)
mapping.put(166, 109); // (103, 117, 53) -> (103, 117, 53)
mapping.put(167, 111); // (55, 62, 28) -> (55, 62, 28)
mapping.put(168, 112); // (113, 54, 55) -> (113, 54, 55)
mapping.put(169, 113); // (138, 66, 67) -> (138, 66, 67)
mapping.put(170, 114); // (160, 77, 78) -> (160, 77, 78)
mapping.put(171, 115); // (85, 41, 41) -> (85, 41, 41)
mapping.put(172, 118); // (40, 29, 25) -> (40, 29, 25)
mapping.put(173, 107); // (49, 35, 30) -> (49, 35, 30)
mapping.put(174, 107); // (57, 41, 35) -> (57, 41, 35)
mapping.put(175, 118); // (30, 22, 19) -> (30, 22, 19)
mapping.put(176, 91); // (95, 76, 69) -> (95, 76, 69)
mapping.put(177, 45); // (116, 92, 85) -> (116, 92, 85)
mapping.put(178, 46); // (135, 107, 98) -> (135, 107, 98)
mapping.put(179, 47); // (71, 57, 52) -> (71, 57, 52)
mapping.put(180, 85); // (61, 65, 65) -> (61, 65, 65)
mapping.put(181, 44); // (75, 79, 79) -> (75, 79, 79)
mapping.put(182, 27); // (87, 92, 92) -> (87, 92, 92)
mapping.put(183, 84); // (46, 49, 49) -> (46, 49, 49)
mapping.put(184, 83); // (86, 52, 62) -> (86, 52, 62)
mapping.put(185, 83); // (105, 63, 76) -> (105, 63, 76)
mapping.put(186, 83); // (122, 73, 88) -> (122, 73, 88)
mapping.put(187, 84); // (65, 39, 47) -> (65, 39, 47)
mapping.put(188, 84); // (54, 44, 65) -> (54, 44, 65)
mapping.put(189, 71); // (66, 53, 79) -> (66, 53, 79)
mapping.put(190, 71); // (76, 62, 92) -> (76, 62, 92)
mapping.put(191, 87); // (40, 33, 49) -> (40, 33, 49)
mapping.put(192, 107); // (54, 35, 25) -> (54, 35, 25)
mapping.put(193, 139); // (66, 43, 30) -> (66, 43, 30)
mapping.put(194, 43); // (76, 50, 35) -> (76, 50, 35)
mapping.put(195, 107); // (40, 26, 19) -> (40, 26, 19)
mapping.put(196, 111); // (54, 58, 30) -> (54, 58, 30)
mapping.put(197, 111); // (66, 71, 36) -> (66, 71, 36)
mapping.put(198, 111); // (76, 82, 42) -> (76, 82, 42)
mapping.put(199, 107); // (40, 43, 22) -> (40, 43, 22)
mapping.put(200, 112); // (100, 42, 32) -> (100, 42, 32)
mapping.put(201, 113); // (123, 52, 40) -> (123, 52, 40)
mapping.put(202, 113); // (142, 60, 46) -> (142, 60, 46)
mapping.put(203, 115); // (75, 32, 24) -> (75, 32, 24)
mapping.put(204, 116); // (26, 16, 11) -> (26, 16, 11)
mapping.put(205, 117); // (32, 19, 14) -> (32, 19, 14)
mapping.put(206, 107); // (37, 22, 16) -> (37, 22, 16)
mapping.put(207, 119); // (20, 12, 8) -> (20, 12, 8)
}
private static final Map<Integer, Integer> MAPPING = new HashMap<>();
public static int getNearestOldColor(int color) {
return mapping.getOrDefault(color, color);
}
static {
MAPPING.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
MAPPING.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
MAPPING.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
MAPPING.put(147, 45); // (111, 94, 85) -> (111, 94, 85)
MAPPING.put(148, 63); // (112, 58, 25) -> (112, 58, 25)
MAPPING.put(149, 60); // (137, 71, 31) -> (137, 71, 31)
MAPPING.put(150, 60); // (159, 82, 36) -> (159, 82, 36)
MAPPING.put(151, 136); // (84, 43, 19) -> (84, 43, 19)
MAPPING.put(152, 83); // (105, 61, 76) -> (105, 61, 76)
MAPPING.put(153, 83); // (129, 75, 93) -> (129, 75, 93)
MAPPING.put(154, 80); // (149, 87, 108) -> (149, 87, 108)
MAPPING.put(155, 115); // (79, 46, 57) -> (79, 46, 57)
MAPPING.put(156, 39); // (79, 76, 97) -> (79, 76, 97)
MAPPING.put(157, 39); // (97, 93, 119) -> (97, 93, 119)
MAPPING.put(158, 36); // (112, 108, 138) -> (112, 108, 138)
MAPPING.put(159, 47); // (59, 57, 73) -> (59, 57, 73)
MAPPING.put(160, 60); // (131, 94, 25) -> (131, 94, 25)
MAPPING.put(161, 61); // (160, 115, 31) -> (160, 115, 31)
MAPPING.put(162, 62); // (186, 133, 36) -> (186, 133, 36)
MAPPING.put(163, 137); // (98, 70, 19) -> (98, 70, 19)
MAPPING.put(164, 108); // (73, 83, 37) -> (73, 83, 37)
MAPPING.put(165, 108); // (89, 101, 46) -> (89, 101, 46)
MAPPING.put(166, 109); // (103, 117, 53) -> (103, 117, 53)
MAPPING.put(167, 111); // (55, 62, 28) -> (55, 62, 28)
MAPPING.put(168, 112); // (113, 54, 55) -> (113, 54, 55)
MAPPING.put(169, 113); // (138, 66, 67) -> (138, 66, 67)
MAPPING.put(170, 114); // (160, 77, 78) -> (160, 77, 78)
MAPPING.put(171, 115); // (85, 41, 41) -> (85, 41, 41)
MAPPING.put(172, 118); // (40, 29, 25) -> (40, 29, 25)
MAPPING.put(173, 107); // (49, 35, 30) -> (49, 35, 30)
MAPPING.put(174, 107); // (57, 41, 35) -> (57, 41, 35)
MAPPING.put(175, 118); // (30, 22, 19) -> (30, 22, 19)
MAPPING.put(176, 91); // (95, 76, 69) -> (95, 76, 69)
MAPPING.put(177, 45); // (116, 92, 85) -> (116, 92, 85)
MAPPING.put(178, 46); // (135, 107, 98) -> (135, 107, 98)
MAPPING.put(179, 47); // (71, 57, 52) -> (71, 57, 52)
MAPPING.put(180, 85); // (61, 65, 65) -> (61, 65, 65)
MAPPING.put(181, 44); // (75, 79, 79) -> (75, 79, 79)
MAPPING.put(182, 27); // (87, 92, 92) -> (87, 92, 92)
MAPPING.put(183, 84); // (46, 49, 49) -> (46, 49, 49)
MAPPING.put(184, 83); // (86, 52, 62) -> (86, 52, 62)
MAPPING.put(185, 83); // (105, 63, 76) -> (105, 63, 76)
MAPPING.put(186, 83); // (122, 73, 88) -> (122, 73, 88)
MAPPING.put(187, 84); // (65, 39, 47) -> (65, 39, 47)
MAPPING.put(188, 84); // (54, 44, 65) -> (54, 44, 65)
MAPPING.put(189, 71); // (66, 53, 79) -> (66, 53, 79)
MAPPING.put(190, 71); // (76, 62, 92) -> (76, 62, 92)
MAPPING.put(191, 87); // (40, 33, 49) -> (40, 33, 49)
MAPPING.put(192, 107); // (54, 35, 25) -> (54, 35, 25)
MAPPING.put(193, 139); // (66, 43, 30) -> (66, 43, 30)
MAPPING.put(194, 43); // (76, 50, 35) -> (76, 50, 35)
MAPPING.put(195, 107); // (40, 26, 19) -> (40, 26, 19)
MAPPING.put(196, 111); // (54, 58, 30) -> (54, 58, 30)
MAPPING.put(197, 111); // (66, 71, 36) -> (66, 71, 36)
MAPPING.put(198, 111); // (76, 82, 42) -> (76, 82, 42)
MAPPING.put(199, 107); // (40, 43, 22) -> (40, 43, 22)
MAPPING.put(200, 112); // (100, 42, 32) -> (100, 42, 32)
MAPPING.put(201, 113); // (123, 52, 40) -> (123, 52, 40)
MAPPING.put(202, 113); // (142, 60, 46) -> (142, 60, 46)
MAPPING.put(203, 115); // (75, 32, 24) -> (75, 32, 24)
MAPPING.put(204, 116); // (26, 16, 11) -> (26, 16, 11)
MAPPING.put(205, 117); // (32, 19, 14) -> (32, 19, 14)
MAPPING.put(206, 107); // (37, 22, 16) -> (37, 22, 16)
MAPPING.put(207, 119); // (20, 12, 8) -> (20, 12, 8)
}
public static int getNearestOldColor(int color) {
return MAPPING.getOrDefault(color, color);
}
}

View File

@ -33,9 +33,10 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
import java.util.Collections;
public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12> {
@Override
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
jsonNameFormat = false;
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
@Override
public void registerMap() {
@ -59,7 +60,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
wrapper.passthrough(Type.BYTE); //X
wrapper.passthrough(Type.BYTE); //Z
Byte[] data = wrapper.read(Type.BYTE_ARRAY);
byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
for (int i = 0; i < data.length; i++) {
short color = (short) (data[i] & 0xFF);
if (color > 143) {
@ -67,7 +68,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
data[i] = (byte) color;
}
}
wrapper.write(Type.BYTE_ARRAY, data);
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, data);
}
});
}
@ -264,17 +265,17 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
protected void registerRewrites() {
// Concrete -> Stained clay? (Also got a new name Terracota?)
rewrite(251)
.repItem(new Item((short) 159, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete")))
.repItem(new Item(159, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete")))
.repBlock(new Block(159, -1));
// Concrete Powder -> Wool
rewrite(252)
.repItem(new Item((short) 35, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete Powder")))
.repItem(new Item(35, (byte) 1, (short) -1, getNamedTag("1.12 %viabackwards_color% Concrete Powder")))
.repBlock(new Block(35, -1));
// Knowledge book -> book
rewrite(453)
.repItem(new Item((short) 340, (byte) 1, (short) 0, getNamedTag("1.12 Knowledge Book")))
.repItem(new Item(340, (byte) 1, (short) 0, getNamedTag("1.12 Knowledge Book")))
.itemHandler(i -> {
CompoundTag tag = i.getTag();
@ -286,11 +287,11 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
// Glazed Terracotta -> Stained Clay
for (int i = 235; i < 251; i++) {
rewrite(i).repItem(new Item((short) 159, (byte) 1, (short) (i - 235), getNamedTag("1.12 " + BlockColors.get(i - 235) + " Glazed Terracotta")))
rewrite(i).repItem(new Item(159, (byte) 1, (short) (i - 235), getNamedTag("1.12 " + BlockColors.get(i - 235) + " Glazed Terracotta")))
.repBlock(new Block(159, (i - 235)));
}
// Handle beds
rewrite(355).repItem(new Item((short) 355, (byte) 1, (short) 0, getNamedTag("1.12 %viabackwards_color% Bed")));
rewrite(355).repItem(new Item(355, (byte) 1, (short) 0, getNamedTag("1.12 %viabackwards_color% Bed")));
}
}

View File

@ -63,7 +63,7 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
}
// TODO improve this, not copying will cause ConcurrentModificationException
// improve this, not copying will cause ConcurrentModificationException
public void handleTranslations(JsonObject object) {
JsonObject copiedObj = copy(object);

View File

@ -30,6 +30,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter<Protocol1_11To1_11_1> {
@Override
protected void registerPackets(Protocol1_11To1_11_1 protocol) {
jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
// Set slot packet
@ -98,7 +99,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter<Protocol1_11To1_11_1> {
}
@Override
protected Item handleItemToClient(final Item item) {
public Item handleItemToClient(final Item item) {
if (item == null) return null;
super.handleItemToClient(item);
@ -115,7 +116,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter<Protocol1_11To1_11_1> {
}
@Override
protected Item handleItemToServer(final Item item) {
public Item handleItemToServer(final Item item) {
if (item == null) return null;
super.handleItemToServer(item);

View File

@ -15,7 +15,6 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.SoundMapping;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.EntityPackets1_13;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerPacket1_13;
@ -39,7 +38,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
static {
BackwardsMappings.init();
PaintingMapping.init();
SoundMapping.init();
}
@Override
@ -59,7 +57,6 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
out(State.PLAY, 0x13, 0x12); // Close Window (clientbound)
out(State.PLAY, 0x14, 0x13); // Open Window
out(State.PLAY, 0x16, 0x15); // Window Property
out(State.PLAY, 0x18, 0x17); // Set Cooldown
out(State.PLAY, 0x1B, 0x1A); // Disconnect (play)
out(State.PLAY, 0x1C, 0x1B); // Entity Status
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer)
@ -166,14 +163,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
return new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper packetWrapper) throws Exception {
packetWrapper.cancel();
}
});
handler(PacketWrapper::cancel);
}
};
}
}

View File

@ -53,7 +53,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
// There doesn't seem to be a nicer way around it :(
private void addEntries(String data, int id) {
id = BackwardsMappings.blockMappings.getNewBlock(id);
id = BackwardsMappings.blockMappings.getNewId(id);
pistonIds.put(data, id);
String substring = data.substring(10);

View File

@ -11,35 +11,50 @@
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
import nl.matsv.viabackwards.api.data.VBMappings;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.viaversion.libs.gson.JsonObject;
import us.myles.viaversion.libs.gson.JsonPrimitive;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;
public class BackwardsMappings {
public static BlockMappings blockMappings;
public static BlockMappingsShortArray blockMappings;
public static Mappings soundMappings;
public static void init() {
JsonObject mapping1_12 = MappingDataLoader.loadData("mapping-1.12.json");
JsonObject mapping1_13 = MappingDataLoader.loadData("mapping-1.13.json");
JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json");
JsonObject mapping1_12_2to1_13 = VBMappingDataLoader.loadData("mapping-1.12.2to1.13.json");
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 sound mapping...");
soundMappings = new VBMappings(mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"), mapping1_12_2to1_13.getAsJsonObject("sounds"));
/*
// Simulate some trident sounds
SOUNDS[628] = 138; // throw -> shoot
SOUNDS[629] = 137; // hit -> hit_player
SOUNDS[630] = 137; // hit_ground -> hit
SOUNDS[631] = 139; // riptide_1 -> shoot
SOUNDS[632] = 139; // riptide_2
SOUNDS[633] = 139; // riptide_3
SOUNDS[634] = 139; // throw -> shoot
// no fitting thunder remap
*/
}
// Has lots of compat layers, so we can't use the default Via method
private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
String key = entry.getValue().getAsString();
Map.Entry<String, JsonElement> value = findValue(oldIdentifiers, key);
Map.Entry<String, JsonElement> value = MappingDataLoader.findValue(oldIdentifiers, key);
if (value == null) {
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
if (replacement == null && key.contains("[")) {
@ -48,9 +63,9 @@ public class BackwardsMappings {
if (replacement != null) {
if (replacement.getAsString().startsWith("id:")) {
String id = replacement.getAsString().replace("id:", "");
value = findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString());
value = MappingDataLoader.findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString());
} else {
value = findValue(oldIdentifiers, replacement.getAsString());
value = MappingDataLoader.findValue(oldIdentifiers, replacement.getAsString());
}
}
if (value == null) {
@ -68,41 +83,15 @@ public class BackwardsMappings {
}
}
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString();
if (value.equals(needle)) {
return entry;
}
}
return null;
}
public static JsonObject loadData(String name) {
try (InputStreamReader reader = new InputStreamReader(BackwardsMappings.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name))) {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
public interface BlockMappings {
int getNewBlock(int old);
}
private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew = new short[8582];
public static class BlockMappingsShortArray {
private final short[] oldToNew = new short[8582];
private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping);
}
@Override
public int getNewBlock(int old) {
public int getNewId(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
}
}

View File

@ -10,16 +10,14 @@
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class EntityNameRewrites {
private static Map<String, String> entityNames = new ConcurrentHashMap<>();
private static final Map<String, String> ENTITY_NAMES = new HashMap<>();
static {
/*
CHANGED NAMES IN 1.13
*/
// CHANGED NAMES IN 1.13
reg("commandblock_minecart", "command_block_minecart");
reg("ender_crystal", "end_crystal");
reg("evocation_fangs", "evoker_fangs");
@ -36,15 +34,15 @@ public class EntityNameRewrites {
private static void reg(String past, String future) {
entityNames.put("minecraft:" + future, "minecraft:" + past);
ENTITY_NAMES.put("minecraft:" + future, "minecraft:" + past);
}
public static String rewrite(String entName) {
String entityName = entityNames.get(entName);
String entityName = ENTITY_NAMES.get(entName);
if (entityName != null) {
return entityName;
}
entityName = entityNames.get("minecraft:" + entName);
entityName = ENTITY_NAMES.get("minecraft:" + entName);
if (entityName != null) {
return entityName;
} else

View File

@ -7,20 +7,20 @@ import java.util.HashMap;
import java.util.Map;
public class NamedSoundMapping {
private static Map<String, String> sounds = new HashMap<>();
private static final Map<String, String> SOUNDS = new HashMap<>();
static {
try {
Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew");
field.setAccessible(true);
Map<String, String> sounds = (Map<String, String>) field.get(null);
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.sounds.put(sound1_13, sound1_12));
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.SOUNDS.put(sound1_13, sound1_12));
} catch (NoSuchFieldException | IllegalAccessException ex) {
ex.printStackTrace();
}
}
public static String getOldId(String sound1_13) {
return sounds.get(sound1_13);
return SOUNDS.get(sound1_13);
}
}

View File

@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
public class PaintingMapping {
private static Map<Integer, String> paintings = new HashMap<>();
private static final Map<Integer, String> PAINTINGS = new HashMap<>();
public static void init() {
add("Kebab");
@ -36,10 +36,10 @@ public class PaintingMapping {
}
private static void add(String motive) {
paintings.put(paintings.size(), motive);
PAINTINGS.put(PAINTINGS.size(), motive);
}
public static String getStringId(int id) {
return paintings.getOrDefault(id, "kebab");
return PAINTINGS.getOrDefault(id, "kebab");
}
}

View File

@ -70,8 +70,7 @@ public class ParticleMapping {
Item item = protocol.getBlockItemPackets().handleItemToClient(
wrapper.read(Type.FLAT_ITEM)
);
return new Integer[]{Integer.valueOf(item.getId()), Integer.valueOf(item.getData())};
return new Integer[]{item.getIdentifier(), (int) item.getData()};
}), // (27->36) minecraft:item -> iconcrack
rewrite(33), // (28->33) minecraft:item_slime -> slime
rewrite(31), // (29->31) minecraft:item_snowball -> snowballpoof
@ -127,12 +126,12 @@ public class ParticleMapping {
@AllArgsConstructor
@RequiredArgsConstructor
public static class ParticleData {
private static final Integer[] A = new Integer[0];
private final int historyId;
private ParticleHandler handler;
public Integer[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
if (handler == null)
return new Integer[0];
if (handler == null) return A;
return handler.rewrite(protocol, wrapper);
}
}

View File

@ -1,54 +0,0 @@
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
import us.myles.viaversion.libs.gson.JsonArray;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.viaversion.libs.gson.JsonObject;
import java.util.Arrays;
import static us.myles.ViaVersion.api.data.MappingDataLoader.loadData;
public class SoundMapping {
private static short[] sounds = new short[662];
public static void init() {
JsonObject mapping1_12 = loadData("mapping-1.12.json");
JsonObject mapping1_13 = loadData("mapping-1.13.json");
Arrays.fill(sounds, (short) -1);
mapIdentifiers(sounds, mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"));
// Simulate some trident sounds
sounds[628] = 138; // throw -> shoot
sounds[629] = 137; // hit -> hit_player
sounds[630] = 137; // hit_ground -> hit
sounds[631] = 139; // riptide_1 -> shoot
sounds[632] = 139; // riptide_2
sounds[633] = 139; // riptide_3
sounds[634] = 139; // throw -> shoot
// no fitting thunder remap
}
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) continue; //There will be missing sounds, since we are goind backwards
output[i] = index.shortValue();
}
}
private static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i);
if (v.getAsString().equals(value)) {
return i;
}
}
return null;
}
public static int getOldSound(int newSound) {
return newSound < 0 || newSound >= sounds.length ? -1 : sounds[newSound];
}
}

View File

@ -52,7 +52,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
if (oldId < 0) {
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
}
int newId = BackwardsMappings.blockMappings.getNewBlock(oldId);
int newId = BackwardsMappings.blockMappings.getNewId(oldId);
if (newId != -1)
return newId;
@ -78,6 +78,30 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
@Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
NBT_TAG_NAME = "ViaBackwards|" + protocol.getClass().getSimpleName() + "|Part2";
// Set Cooldown
protocol.out(State.PLAY, 0x18, 0x17, new PacketRemapper() {
@Override
public void registerMap() { //TODO is this actually the correct id conversion?
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int itemId = wrapper.read(Type.VAR_INT);
Integer oldId = MappingData.oldToNewItems.inverse().get(itemId);
if (oldId != null) {
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
if (eggEntityId.isPresent()) {
itemId = 383 << 16;
} else {
itemId = (oldId >> 4) << 16 | oldId & 0xF;
}
}
wrapper.write(Type.VAR_INT, itemId);
}
});
}
});
// Block Action
protocol.out(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
@Override
@ -451,130 +475,130 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
@Override
protected void registerRewrites() {
rewrite(245).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Button")));
rewrite(243).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Birch Button")));
rewrite(242).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Button")));
rewrite(244).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Button")));
rewrite(246).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Button")));
rewrite(245).repItem(new Item(241, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Button")));
rewrite(243).repItem(new Item(241, (byte) 1, (short) -1, getNamedTag("1.13 Birch Button")));
rewrite(242).repItem(new Item(241, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Button")));
rewrite(244).repItem(new Item(241, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Button")));
rewrite(246).repItem(new Item(241, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Button")));
rewrite(191).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Trapdoor")));
rewrite(189).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Trapdoor")));
rewrite(188).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Trapdoor")));
rewrite(190).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Trapdoor")));
rewrite(192).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Trapdoor")));
rewrite(191).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Trapdoor")));
rewrite(189).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Trapdoor")));
rewrite(188).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Trapdoor")));
rewrite(190).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Trapdoor")));
rewrite(192).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Trapdoor")));
rewrite(164).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Pressure Plate")));
rewrite(162).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Pressure Plate")));
rewrite(161).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Pressure Plate")));
rewrite(163).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Pressure Plate")));
rewrite(165).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Pressure Plate")));
rewrite(164).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Pressure Plate")));
rewrite(162).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Pressure Plate")));
rewrite(161).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Pressure Plate")));
rewrite(163).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Pressure Plate")));
rewrite(165).repItem(new Item(187, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Pressure Plate")));
rewrite(762).repItem(new Item((short) 544, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Boat")));
rewrite(760).repItem(new Item((short) 544, (byte) 1, (short) -1, getNamedTag("1.13 Birch Boat")));
rewrite(759).repItem(new Item((short) 544, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Boat")));
rewrite(761).repItem(new Item((short) 544, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Boat")));
rewrite(763).repItem(new Item((short) 544, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Boat")));
rewrite(762).repItem(new Item(544, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Boat")));
rewrite(760).repItem(new Item(544, (byte) 1, (short) -1, getNamedTag("1.13 Birch Boat")));
rewrite(759).repItem(new Item(544, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Boat")));
rewrite(761).repItem(new Item(544, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Boat")));
rewrite(763).repItem(new Item(544, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Boat")));
rewrite(453).repItem(new Item((short) 300, (byte) 1, (short) -1, getNamedTag("1.13 Blue Ice")));
rewrite(453).repItem(new Item(300, (byte) 1, (short) -1, getNamedTag("1.13 Blue Ice")));
rewrite(547).repItem(new Item((short) 538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Pufferfish")));
rewrite(548).repItem(new Item((short) 538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Salmon")));
rewrite(549).repItem(new Item((short) 538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Cod")));
rewrite(550).repItem(new Item((short) 538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Tropical Fish")));
rewrite(547).repItem(new Item(538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Pufferfish")));
rewrite(548).repItem(new Item(538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Salmon")));
rewrite(549).repItem(new Item(538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Cod")));
rewrite(550).repItem(new Item(538, (byte) 1, (short) -1, getNamedTag("1.13 Bucket of Tropical Fish")));
rewrite(784).repItem(new Item((short) 543, (byte) 1, (short) -1, getNamedTag("1.13 Heart of the Sea")));
rewrite(783).repItem(new Item((short) 587, (byte) 1, (short) -1, getNamedTag("1.13 Nautilus Shell")));
rewrite(782).repItem(new Item((short) 545, (byte) 1, (short) -1, getNamedTag("1.13 Phantom Membrane")));
rewrite(465).repItem(new Item((short) 510, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Shell")));
rewrite(427).repItem(new Item((short) 561, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Egg")));
rewrite(466).repItem(new Item((short) 582, (byte) 1, (short) -1, getNamedTag("1.13 Scute")));
rewrite(781).repItem(new Item((short) 488, (byte) 1, (short) -1, getNamedTag("1.13 Trident")));
rewrite(80).repItem(new Item((short) 561, (byte) 1, (short) -1, getNamedTag("1.13 Sea Pickle")));
rewrite(79).repItem(new Item((short) 76, (byte) 1, (short) -1, getNamedTag("1.13 Seagrass")));
rewrite(454).repItem(new Item((short) 238, (byte) 1, (short) -1, getNamedTag("1.13 Conduit")));
rewrite(784).repItem(new Item(543, (byte) 1, (short) -1, getNamedTag("1.13 Heart of the Sea")));
rewrite(783).repItem(new Item(587, (byte) 1, (short) -1, getNamedTag("1.13 Nautilus Shell")));
rewrite(782).repItem(new Item(545, (byte) 1, (short) -1, getNamedTag("1.13 Phantom Membrane")));
rewrite(465).repItem(new Item(510, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Shell")));
rewrite(427).repItem(new Item(561, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Egg")));
rewrite(466).repItem(new Item(582, (byte) 1, (short) -1, getNamedTag("1.13 Scute")));
rewrite(781).repItem(new Item(488, (byte) 1, (short) -1, getNamedTag("1.13 Trident")));
rewrite(80).repItem(new Item(561, (byte) 1, (short) -1, getNamedTag("1.13 Sea Pickle")));
rewrite(79).repItem(new Item(76, (byte) 1, (short) -1, getNamedTag("1.13 Seagrass")));
rewrite(454).repItem(new Item(238, (byte) 1, (short) -1, getNamedTag("1.13 Conduit")));
rewrite(554).repItem(new Item((short) 76, (byte) 1, (short) -1, getNamedTag("1.13 Kelp")));
rewrite(611).repItem(new Item((short) 508, (byte) 1, (short) -1, getNamedTag("1.13 Dried Kelp")));
rewrite(555).repItem(new Item((short) 281, (byte) 1, (short) -1, getNamedTag("1.13 Dried Kelp Block")));
rewrite(554).repItem(new Item(76, (byte) 1, (short) -1, getNamedTag("1.13 Kelp")));
rewrite(611).repItem(new Item(508, (byte) 1, (short) -1, getNamedTag("1.13 Dried Kelp")));
rewrite(555).repItem(new Item(281, (byte) 1, (short) -1, getNamedTag("1.13 Dried Kelp Block")));
rewrite(38).repItem(new Item((short) 32, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Oak Log")));
rewrite(42).repItem(new Item((short) 36, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Acacia Log")));
rewrite(40).repItem(new Item((short) 34, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Birch Log")));
rewrite(39).repItem(new Item((short) 33, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Spruce Log")));
rewrite(41).repItem(new Item((short) 35, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Jungle Log")));
rewrite(43).repItem(new Item((short) 37, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Dark Oak Log")));
rewrite(38).repItem(new Item(32, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Oak Log")));
rewrite(42).repItem(new Item(36, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Acacia Log")));
rewrite(40).repItem(new Item(34, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Birch Log")));
rewrite(39).repItem(new Item(33, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Spruce Log")));
rewrite(41).repItem(new Item(35, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Jungle Log")));
rewrite(43).repItem(new Item(37, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Dark Oak Log")));
rewrite(44).repItem(new Item((short) 32, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Oak Wood")));
rewrite(48).repItem(new Item((short) 36, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Acacia Wood")));
rewrite(46).repItem(new Item((short) 34, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Birch Wood")));
rewrite(45).repItem(new Item((short) 33, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Spruce Wood")));
rewrite(47).repItem(new Item((short) 35, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Jungle Wood")));
rewrite(49).repItem(new Item((short) 37, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Dark Oak Wood")));
rewrite(44).repItem(new Item(32, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Oak Wood")));
rewrite(48).repItem(new Item(36, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Acacia Wood")));
rewrite(46).repItem(new Item(34, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Birch Wood")));
rewrite(45).repItem(new Item(33, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Spruce Wood")));
rewrite(47).repItem(new Item(35, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Jungle Wood")));
rewrite(49).repItem(new Item(37, (byte) 1, (short) -1, getNamedTag("1.13 Stripped Dark Oak Wood")));
rewrite(50).repItem(new Item((short) 32, (byte) 1, (short) -1, getNamedTag("1.13 Oak Wood")));
rewrite(51).repItem(new Item((short) 33, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Wood")));
rewrite(52).repItem(new Item((short) 34, (byte) 1, (short) -1, getNamedTag("1.13 Birch Wood")));
rewrite(53).repItem(new Item((short) 35, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Wood")));
rewrite(54).repItem(new Item((short) 36, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Wood")));
rewrite(55).repItem(new Item((short) 37, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Wood")));
rewrite(50).repItem(new Item(32, (byte) 1, (short) -1, getNamedTag("1.13 Oak Wood")));
rewrite(51).repItem(new Item(33, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Wood")));
rewrite(52).repItem(new Item(34, (byte) 1, (short) -1, getNamedTag("1.13 Birch Wood")));
rewrite(53).repItem(new Item(35, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Wood")));
rewrite(54).repItem(new Item(36, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Wood")));
rewrite(55).repItem(new Item(37, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Wood")));
rewrite(128).repItem(new Item((short) 121, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Slab")));
rewrite(129).repItem(new Item((short) 122, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Brick Slab")));
rewrite(130).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.13 Dark Prismarine Slab")));
rewrite(346).repItem(new Item((short) 157, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Stairs")));
rewrite(347).repItem(new Item((short) 216, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Brick Stairs")));
rewrite(348).repItem(new Item((short) 217, (byte) 1, (short) -1, getNamedTag("1.13 Dark Prismarine Brick Stairs")));
rewrite(128).repItem(new Item(121, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Slab")));
rewrite(129).repItem(new Item(122, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Brick Slab")));
rewrite(130).repItem(new Item(123, (byte) 1, (short) -1, getNamedTag("1.13 Dark Prismarine Slab")));
rewrite(346).repItem(new Item(157, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Stairs")));
rewrite(347).repItem(new Item(216, (byte) 1, (short) -1, getNamedTag("1.13 Prismarine Brick Stairs")));
rewrite(348).repItem(new Item(217, (byte) 1, (short) -1, getNamedTag("1.13 Dark Prismarine Brick Stairs")));
//Spawn Eggs:
rewrite(643).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Drowned Spawn Egg")));
rewrite(658).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Phantom Spawn Egg")));
rewrite(641).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Dolphin Spawn Egg")));
rewrite(674).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Spawn Egg")));
rewrite(638).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Cod Spawn Egg")));
rewrite(663).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Salmon Spawn Egg")));
rewrite(661).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Pufferfish Spawn Egg")));
rewrite(673).repItem(new Item((short) 662, (byte) 1, (short) -1, getNamedTag("1.13 Tropical Fish Spawn Egg")));
rewrite(643).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Drowned Spawn Egg")));
rewrite(658).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Phantom Spawn Egg")));
rewrite(641).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Dolphin Spawn Egg")));
rewrite(674).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Spawn Egg")));
rewrite(638).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Cod Spawn Egg")));
rewrite(663).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Salmon Spawn Egg")));
rewrite(661).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Pufferfish Spawn Egg")));
rewrite(673).repItem(new Item(662, (byte) 1, (short) -1, getNamedTag("1.13 Tropical Fish Spawn Egg")));
//Corals
rewrite(438).repItem(new Item((short) 100, (byte) 1, (short) -1, getNamedTag("1.13 Tube Coral")));
rewrite(439).repItem(new Item((short) 106, (byte) 1, (short) -1, getNamedTag("1.13 Brain Coral")));
rewrite(440).repItem(new Item((short) 101, (byte) 1, (short) -1, getNamedTag("1.13 Bubble Coral")));
rewrite(441).repItem(new Item((short) 103, (byte) 1, (short) -1, getNamedTag("1.13 Fire Coral")));
rewrite(442).repItem(new Item((short) 98, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral")));
rewrite(438).repItem(new Item(100, (byte) 1, (short) -1, getNamedTag("1.13 Tube Coral")));
rewrite(439).repItem(new Item(106, (byte) 1, (short) -1, getNamedTag("1.13 Brain Coral")));
rewrite(440).repItem(new Item(101, (byte) 1, (short) -1, getNamedTag("1.13 Bubble Coral")));
rewrite(441).repItem(new Item(103, (byte) 1, (short) -1, getNamedTag("1.13 Fire Coral")));
rewrite(442).repItem(new Item(98, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral")));
rewrite(443).repItem(new Item((short) 100, (byte) 1, (short) -1, getNamedTag("1.13 Tube Coral Fan")));
rewrite(444).repItem(new Item((short) 106, (byte) 1, (short) -1, getNamedTag("1.13 Brain Coral Fan")));
rewrite(445).repItem(new Item((short) 101, (byte) 1, (short) -1, getNamedTag("1.13 Bubble Coral Fan")));
rewrite(446).repItem(new Item((short) 103, (byte) 1, (short) -1, getNamedTag("1.13 Fire Coral Fan")));
rewrite(447).repItem(new Item((short) 98, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral Fan")));
rewrite(443).repItem(new Item(100, (byte) 1, (short) -1, getNamedTag("1.13 Tube Coral Fan")));
rewrite(444).repItem(new Item(106, (byte) 1, (short) -1, getNamedTag("1.13 Brain Coral Fan")));
rewrite(445).repItem(new Item(101, (byte) 1, (short) -1, getNamedTag("1.13 Bubble Coral Fan")));
rewrite(446).repItem(new Item(103, (byte) 1, (short) -1, getNamedTag("1.13 Fire Coral Fan")));
rewrite(447).repItem(new Item(98, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral Fan")));
rewrite(448).repItem(new Item((short) 78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Tube Coral Fan")));
rewrite(449).repItem(new Item((short) 78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Brain Coral Fan")));
rewrite(450).repItem(new Item((short) 78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Bubble Coral Fan")));
rewrite(451).repItem(new Item((short) 78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Fire Coral Fan")));
rewrite(452).repItem(new Item((short) 78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Horn Coral Fan")));
rewrite(448).repItem(new Item(78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Tube Coral Fan")));
rewrite(449).repItem(new Item(78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Brain Coral Fan")));
rewrite(450).repItem(new Item(78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Bubble Coral Fan")));
rewrite(451).repItem(new Item(78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Fire Coral Fan")));
rewrite(452).repItem(new Item(78, (byte) 1, (short) -1, getNamedTag("1.13 Dead Horn Coral Fan")));
rewrite(428).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Tube Coral Block")));
rewrite(429).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Brain Coral Block")));
rewrite(430).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Bubble Coral Block")));
rewrite(431).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Fire Coral Block")));
rewrite(432).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Horn Coral Block")));
rewrite(428).repItem(new Item(90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Tube Coral Block")));
rewrite(429).repItem(new Item(90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Brain Coral Block")));
rewrite(430).repItem(new Item(90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Bubble Coral Block")));
rewrite(431).repItem(new Item(90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Fire Coral Block")));
rewrite(432).repItem(new Item(90, (byte) 1, (short) -1, getNamedTag("1.13 Dead Horn Coral Block")));
rewrite(433).repItem(new Item((short) 93, (byte) 1, (short) -1, getNamedTag("1.13 Tube Coral Block")));
rewrite(434).repItem(new Item((short) 88, (byte) 1, (short) -1, getNamedTag("1.13 Brain Coral Block")));
rewrite(435).repItem(new Item((short) 92, (byte) 1, (short) -1, getNamedTag("1.13 Bubble Coral Block")));
rewrite(436).repItem(new Item((short) 96, (byte) 1, (short) -1, getNamedTag("1.13 Fire Coral Block")));
rewrite(437).repItem(new Item((short) 86, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral Block")));
rewrite(433).repItem(new Item(93, (byte) 1, (short) -1, getNamedTag("1.13 Tube Coral Block")));
rewrite(434).repItem(new Item(88, (byte) 1, (short) -1, getNamedTag("1.13 Brain Coral Block")));
rewrite(435).repItem(new Item(92, (byte) 1, (short) -1, getNamedTag("1.13 Bubble Coral Block")));
rewrite(436).repItem(new Item(96, (byte) 1, (short) -1, getNamedTag("1.13 Fire Coral Block")));
rewrite(437).repItem(new Item(86, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral Block")));
// Coral End
rewrite(131).repItem(new Item((short) 711, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Quartz")));
rewrite(132).repItem(new Item((short) 350, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Red Sandstone")));
rewrite(133).repItem(new Item((short) 68, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Sandstone")));
rewrite(134).repItem(new Item((short) 118, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Stone")));
rewrite(131).repItem(new Item(711, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Quartz")));
rewrite(132).repItem(new Item(350, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Red Sandstone")));
rewrite(133).repItem(new Item(68, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Sandstone")));
rewrite(134).repItem(new Item(118, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Stone")));
rewrite(181).repItem(new Item((short) 182, (byte) 1, (short) -1, getNamedTag("1.13 Carved Pumpkin")));
rewrite(181).repItem(new Item(182, (byte) 1, (short) -1, getNamedTag("1.13 Carved Pumpkin")));
rewrite(205).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Mushroom Stem")));
rewrite(205).repItem(new Item(90, (byte) 1, (short) -1, getNamedTag("1.13 Mushroom Stem")));
enchantmentMappings.put("minecraft:loyalty", "§7Loyalty");
@ -583,14 +607,6 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
enchantmentMappings.put("minecraft:channeling", "§7Channeling");
}
@Override
protected CompoundTag getNamedTag(String text) {
CompoundTag tag = new CompoundTag("");
tag.put(new CompoundTag("display"));
((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatRewriter.legacyTextToJson(text)));
return tag;
}
@Override
public Item handleItemToClient(Item item) {
if (item == null) return null;
@ -855,7 +871,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
}
@Override
protected Item handleItemToServer(Item item) {
public Item handleItemToServer(Item item) {
if (item == null) return null;
CompoundTag tag = item.getTag();

View File

@ -16,11 +16,11 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.api.type.types.version.Types1_12;
import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import java.util.Optional;
@ -108,7 +108,7 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
public void handle(PacketWrapper wrapper) throws Exception {
int type = wrapper.get(Type.VAR_INT, 1);
EntityType entityType = Entity1_13Types.getTypeFromId(type, false);
addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), entityType);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
Optional<Integer> oldId = EntityTypeMapping.getOldId(type);
if (!oldId.isPresent()) {
@ -313,8 +313,6 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
throw RemovedValueException.EX;
});
// TODO REWRITE BLOCKS IN MINECART
}
@Override

View File

@ -15,9 +15,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
import java.nio.charset.StandardCharsets;

View File

@ -1,10 +1,12 @@
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.rewriters.Rewriter;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMapping;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.SoundMapping;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -16,7 +18,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
@Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
//Named Sound Event
// Named Sound Event
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {
@Override
public void registerMap() {
@ -28,13 +30,15 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
String oldSound = NamedSoundMapping.getOldId(newSound);
if (oldSound != null) {
wrapper.set(Type.STRING, 0, oldSound);
} else if (!Via.getConfig().isSuppress1_13ConversionErrors()) {
ViaBackwards.getPlatform().getLogger().warning("Unknown named sound in 1.13->1.12 protocol: " + newSound);
}
}
});
}
});
//Stop Sound
// Stop Sound
protocol.out(State.PLAY, 0x4C, 0x18, new PacketRemapper() {
@Override
public void registerMap() {
@ -58,7 +62,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
}
});
//Sound Effect
// Sound Effect
protocol.out(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
@Override
public void registerMap() {
@ -67,7 +71,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int newSound = wrapper.get(Type.VAR_INT, 0);
int oldSound = SoundMapping.getOldSound(newSound);
int oldSound = BackwardsMappings.soundMappings.getNewId(newSound);
if (oldSound == -1) {
wrapper.cancel();
} else {
@ -81,6 +85,5 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
@Override
protected void registerRewrites() {
}
}

View File

@ -10,8 +10,7 @@ import us.myles.ViaVersion.packets.State;
public class InventoryPackets1_13_2 {
public static void register(Protocol protocol) {
/*
/*
Outgoing packets
*/
@ -118,10 +117,9 @@ public class InventoryPackets1_13_2 {
}
});
/*
Incoming packets
*/
*/
// Click window packet
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
@ -147,5 +145,4 @@ public class InventoryPackets1_13_2 {
}
);
}
}

View File

@ -5,7 +5,6 @@ import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.SoundMapping;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPackets1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
@ -17,16 +16,18 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_13_2To1_14 extends BackwardsProtocol {
private static final Integer[] A = new Integer[0];
private BlockItemPackets1_14 blockItemPackets;
private EntityPackets1_14 entityPackets;
static {
BackwardsMappings.init();
SoundMapping.init();
}
@Override
@ -40,8 +41,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
registerOutgoing(State.PLAY, 0x15, 0x16);
registerOutgoing(State.PLAY, 0x17, 0x18);
registerOutgoing(State.PLAY, 0x18, 0x19);
registerOutgoing(State.PLAY, 0x19, 0x1A);
@ -91,7 +90,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
registerOutgoing(State.PLAY, 0x53, 0x4E); // c
registerOutgoing(State.PLAY, 0x55, 0x4F); // c
registerOutgoing(State.PLAY, 0x56, 0x50); // c
// Update View Position
cancelOutgoing(State.PLAY, 0x40);
@ -143,41 +141,48 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
registerOutgoing(State.PLAY, 0x58, 0x52); // c
registerOutgoing(State.PLAY, 0x59, 0x53); // c
// tags
// Tags
registerOutgoing(State.PLAY, 0x5B, 0x55, new PacketRemapper() {
@Override
public void registerMap() { // c
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int blockTagsSize = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, blockTagsSize); // block tags
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
Integer[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blockIds.length; j++) {
blockIds[j] = getNewBlockStateId(blockIds[j]);
int id = blockIds[j];
// Ignore new blocktags
int blockId = BackwardsMappings.blockMappings.getNewId(id);
blockIds[j] = blockId;
}
}
int itemTagsSize = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, itemTagsSize); // item tags
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < itemTagsSize; i++) {
wrapper.passthrough(Type.STRING);
Integer[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY);
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < itemIds.length; j++) {
itemIds[j] = /*BlockItemPackets1_14.getNewItemId TODO BLOCK IDS*/(itemIds[j]);
int itemId = itemIds[j];
// Ignore new itemtags
Integer oldId = MappingData.oldToNewItems.inverse().get(itemId);
itemIds[j] = oldId != null ? oldId : -1;
}
}
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags
for (int i = 0; i < fluidTagsSize; i++) {
wrapper.passthrough(Type.STRING);
wrapper.passthrough(Type.VAR_INT_ARRAY);
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
}
// Eat entity tags
int entityTagsSize = wrapper.read(Type.VAR_INT);
for (int i = 0; i < entityTagsSize; i++) {
wrapper.read(Type.STRING);
wrapper.read(Type.VAR_INT_ARRAY);
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
}
}
});
@ -202,40 +207,32 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
byte[][] skyLight = new byte[16][];
// we don't need void and +256 light
if (isSet(skyLightMask, 0)) {
wrapper.read(Type.BYTE_ARRAY);
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
for (int i = 0; i < 16; i++) {
if (isSet(skyLightMask, i + 1)) {
Byte[] array = wrapper.read(Type.BYTE_ARRAY);
skyLight[i] = new byte[array.length];
for (int j = 0; j < array.length; j++) {
skyLight[i][j] = array[j];
}
skyLight[i] = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
} else if (isSet(emptySkyLightMask, i + 1)) {
skyLight[i] = ChunkLightStorage.EMPTY_LIGHT;
}
}
if (isSet(skyLightMask, 17)) {
wrapper.read(Type.BYTE_ARRAY);
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
byte[][] blockLight = new byte[16][];
if (isSet(blockLightMask, 0)) {
wrapper.read(Type.BYTE_ARRAY);
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
for (int i = 0; i < 16; i++) {
if (isSet(blockLightMask, i + 1)) {
Byte[] array = wrapper.read(Type.BYTE_ARRAY);
blockLight[i] = new byte[array.length];
for (int j = 0; j < array.length; j++) {
blockLight[i][j] = array[j];
}
blockLight[i] = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
} else if (isSet(emptyBlockLightMask, i + 1)) {
blockLight[i] = ChunkLightStorage.EMPTY_LIGHT;
}
}
if (isSet(blockLightMask, 17)) {
wrapper.read(Type.BYTE_ARRAY);
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z);
@ -296,9 +293,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
}
public static int getNewBlockStateId(int id) {
int newId = BackwardsMappings.blockStateMappings.getNewBlock(id);
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 blockstate id for 1.13.2 block " + id);
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 blockstate id for 1.14 block " + id);
return 0;
}
return newId;
@ -306,9 +303,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
public static int getNewBlockId(int id) {
int newId = BackwardsMappings.blockMappings.getNewBlock(id);
int newId = BackwardsMappings.blockMappings.getNewId(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 block id for 1.13.2 block " + id);
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 block id for 1.14 block " + id);
return id;
}
return newId;

View File

@ -1,101 +1,25 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
import nl.matsv.viabackwards.ViaBackwards;
import us.myles.ViaVersion.api.Via;
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
import nl.matsv.viabackwards.api.data.VBMappings;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.util.GsonUtil;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.viaversion.libs.gson.JsonObject;
import us.myles.viaversion.libs.gson.JsonPrimitive;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Map;
public class BackwardsMappings {
public static BlockMappings blockStateMappings;
public static BlockMappings blockMappings;
public static Mappings blockStateMappings;
public static Mappings blockMappings;
public static Mappings soundMappings;
public static void init() {
JsonObject mapping1_13_2 = MappingDataLoader.loadData("mapping-1.13.2.json");
JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json");
JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json");
JsonObject mapping1_13_2to1_14 = VBMappingDataLoader.loadData("mapping-1.13.2to1.14.json");
ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 block mapping...");
blockStateMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates"));
//blockMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"));
}
private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
String key = entry.getValue().getAsString();
Map.Entry<String, JsonElement> value = findValue(oldIdentifiers, key);
if (value == null) {
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
if (replacement == null && key.contains("[")) {
replacement = mapping.getAsJsonPrimitive(key.substring(0, key.indexOf('[')));
}
if (replacement != null) {
if (replacement.getAsString().startsWith("id:")) {
String id = replacement.getAsString().replace("id:", "");
value = findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString());
} else {
value = findValue(oldIdentifiers, replacement.getAsString());
}
}
if (value == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
if (replacement != null) {
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( ");
} else {
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
}
continue;
}
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString();
if (value.equals(needle)) {
return entry;
}
}
return null;
}
public static JsonObject loadData(String name) {
try (InputStreamReader reader = new InputStreamReader(BackwardsMappings.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name))) {
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
public interface BlockMappings {
int getNewBlock(int old);
}
private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew = new short[11270 + 1];
private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping);
}
@Override
public int getNewBlock(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
}
blockStateMappings = new VBMappings(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates"));
blockMappings = new VBMappings(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"), false);
soundMappings = new VBMappings(mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"), mapping1_13_2to1_14.getAsJsonObject("sounds"));
}
}

View File

@ -0,0 +1,34 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
public class EntityPositionStorage extends EntityStorage {
private double x;
private double y;
private double z;
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public void setCoordinates(double x, double y, double z, boolean relative) {
if (relative) {
this.x += x;
this.y += y;
this.z += z;
} else {
this.x = x;
this.y = y;
this.z = z;
}
}
}

View File

@ -0,0 +1,65 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.type.Type;
public class RecipeRewriter1_14 extends RecipeRewriter {
public RecipeRewriter1_14(final BlockItemRewriter rewriter) {
super(rewriter);
}
public void handle(PacketWrapper wrapper, String type) throws Exception {
switch (type) {
case "crafting_shapeless":
handleCraftingShapeless(wrapper);
break;
case "crafting_shaped":
handleCraftingShaped(wrapper);
break;
case "smelting":
handleSmelting(wrapper);
break;
}
}
public void handleSmelting(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.STRING); // Group
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) {
rewriter.handleItemToClient(item);
}
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
}
public void handleCraftingShaped(PacketWrapper wrapper) throws Exception {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.STRING); // Group
for (int j = 0; j < ingredientsNo; j++) {
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) {
rewriter.handleItemToClient(item);
}
}
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
}
public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.STRING); // Group
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < ingredientsNo; j++) {
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) {
rewriter.handleItemToClient(item);
}
}
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
}
}

View File

@ -1,44 +0,0 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
import us.myles.viaversion.libs.gson.JsonArray;
import us.myles.viaversion.libs.gson.JsonElement;
import us.myles.viaversion.libs.gson.JsonObject;
import java.util.Arrays;
import static us.myles.ViaVersion.api.data.MappingDataLoader.loadData;
public class SoundMapping {
private static final short[] sounds = new short[795];
public static void init() {
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json");
JsonObject mapping1_14 = loadData("mapping-1.14.json");
Arrays.fill(sounds, (short) -1);
mapIdentifiers(sounds, mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"));
}
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) continue; //There will be missing sounds, since we are goind backwards
output[i] = index.shortValue();
}
}
private static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i);
if (v.getAsString().equals(value)) {
return i;
}
}
return null;
}
public static int getOldSound(int newSound) {
return newSound >= sounds.length ? -1 : sounds[newSound];
}
}

View File

@ -5,7 +5,9 @@ import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
@ -145,6 +147,9 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
// Set cooldown
itemRewriter.registerSetCooldown(0x17, 0x18, BlockItemPackets1_14::getOldItemId);
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15);
@ -229,7 +234,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
EntityType entityType = wrapper.user().get(EntityTracker.class).get(getProtocol()).getEntityType(entityId);
if (entityType == null) return; // TODO: Check why there might (?) be an untracked entity
if (entityType == null) return;
if (entityType.isOrHasParent(Entity1_14Types.EntityType.ABSTRACT_HORSE)) {
wrapper.setId(0x3F);
@ -257,8 +262,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
@Override
public void registerMap() {
handler(new PacketHandler() {
private final Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
private final RecipeRewriter recipeHandler = new RecipeRewriter1_14(BlockItemPackets1_14.this);
@Override
public void handle(PacketWrapper wrapper) throws Exception {
@ -291,44 +296,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
wrapper.write(Type.STRING, id);
wrapper.write(Type.STRING, type);
if (type.equals("crafting_shapeless")) {
wrapper.passthrough(Type.STRING); // Group
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < ingredientsNo; j++) {
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (int k = 0; k < items.length; k++) {
items[k] = handleItemToClient(items[k]);
}
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
}
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
} else if (type.equals("crafting_shaped")) {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.STRING); // Group
for (int j = 0; j < ingredientsNo; j++) {
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (int k = 0; k < items.length; k++) {
items[k] = handleItemToClient(items[k]);
}
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
}
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
} else if (type.equals("smelting")) {
wrapper.passthrough(Type.STRING); // Group
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (int k = 0; k < items.length; k++) {
items[k] = handleItemToClient(items[k]);
}
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
}
// Handle the rest of the types
recipeHandler.handle(wrapper, type);
}
wrapper.set(Type.VAR_INT, 0, size - deleted);
}
@ -336,10 +305,9 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}
});
/*
Incoming packets
*/
*/
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x08);
@ -376,7 +344,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))); //TODO proper block id
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockId(wrapper.get(Type.VAR_INT, 0)));
}
});
}
@ -589,105 +557,105 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
@Override
protected void registerRewrites() {
rewrite(247).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Brick Wall")));
rewrite(248).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Prismarine Wall")));
rewrite(249).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Red Sandstone Wall")));
rewrite(250).repItem(new Item((short) 246, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Wall")));
rewrite(251).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Granite Wall")));
rewrite(252).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Stone Brick Wall")));
rewrite(253).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Nether Brick Wall")));
rewrite(254).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Wall")));
rewrite(255).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Wall")));
rewrite(256).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Sandstone Wall")));
rewrite(257).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Wall")));
rewrite(258).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Wall")));
rewrite(247).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Brick Wall")));
rewrite(248).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Prismarine Wall")));
rewrite(249).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Red Sandstone Wall")));
rewrite(250).repItem(new Item(246, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Wall")));
rewrite(251).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Granite Wall")));
rewrite(252).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Stone Brick Wall")));
rewrite(253).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Nether Brick Wall")));
rewrite(254).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Wall")));
rewrite(255).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Wall")));
rewrite(256).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Sandstone Wall")));
rewrite(257).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Wall")));
rewrite(258).repItem(new Item(245, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Wall")));
rewrite(121).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Stone Slab")));
rewrite(124).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 Cut Sandstone Slab")));
rewrite(132).repItem(new Item((short) 131, (byte) 1, (short) -1, getNamedTag("1.14 Cut Red Sandstone Slab")));
rewrite(492).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Slab")));
rewrite(493).repItem(new Item((short) 131, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Slab")));
rewrite(494).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Slab")));
rewrite(495).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Slab")));
rewrite(496).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Slab")));
rewrite(497).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Slab")));
rewrite(498).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Cut Sandstone Slab")));
rewrite(499).repItem(new Item((short) 130, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Slab")));
rewrite(500).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Granite Slab")));
rewrite(501).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Slab")));
rewrite(502).repItem(new Item((short) 129, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Slab")));
rewrite(503).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Slab")));
rewrite(504).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Slab")));
rewrite(121).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Stone Slab")));
rewrite(124).repItem(new Item(123, (byte) 1, (short) -1, getNamedTag("1.14 Cut Sandstone Slab")));
rewrite(132).repItem(new Item(131, (byte) 1, (short) -1, getNamedTag("1.14 Cut Red Sandstone Slab")));
rewrite(492).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Slab")));
rewrite(493).repItem(new Item(131, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Slab")));
rewrite(494).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Slab")));
rewrite(495).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Slab")));
rewrite(496).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Slab")));
rewrite(497).repItem(new Item(123, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Slab")));
rewrite(498).repItem(new Item(123, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Cut Sandstone Slab")));
rewrite(499).repItem(new Item(130, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Slab")));
rewrite(500).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Granite Slab")));
rewrite(501).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Slab")));
rewrite(502).repItem(new Item(129, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Slab")));
rewrite(503).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Slab")));
rewrite(504).repItem(new Item(126, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Slab")));
rewrite(478).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Stairs")));
rewrite(479).repItem(new Item((short) 371, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Stairs")));
rewrite(480).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Stairs")));
rewrite(481).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Stairs")));
rewrite(482).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Stairs")));
rewrite(483).repItem(new Item((short) 235, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Stairs")));
rewrite(484).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Stone Stairs")));
rewrite(485).repItem(new Item((short) 235, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Sandstone Stairs")));
rewrite(486).repItem(new Item((short) 278, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Stairs")));
rewrite(487).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Granite Stairs")));
rewrite(488).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Stairs")));
rewrite(489).repItem(new Item((short) 228, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Stairs")));
rewrite(490).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Stairs")));
rewrite(491).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Stairs")));
rewrite(478).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Stairs")));
rewrite(479).repItem(new Item(371, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Stairs")));
rewrite(480).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Stairs")));
rewrite(481).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Stairs")));
rewrite(482).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Stairs")));
rewrite(483).repItem(new Item(235, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Stairs")));
rewrite(484).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Stone Stairs")));
rewrite(485).repItem(new Item(235, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Sandstone Stairs")));
rewrite(486).repItem(new Item(278, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Stairs")));
rewrite(487).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Granite Stairs")));
rewrite(488).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Stairs")));
rewrite(489).repItem(new Item(228, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Stairs")));
rewrite(490).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Stairs")));
rewrite(491).repItem(new Item(163, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Stairs")));
rewrite(108).repItem(new Item((short) 111, (byte) 1, (short) -1, getNamedTag("1.14 Cornflower")));
rewrite(109).repItem(new Item((short) 105, (byte) 1, (short) -1, getNamedTag("1.14 Lily of the Valley")));
rewrite(110).repItem(new Item((short) 100, (byte) 1, (short) -1, getNamedTag("1.14 Wither Rose")));
rewrite(108).repItem(new Item(111, (byte) 1, (short) -1, getNamedTag("1.14 Cornflower")));
rewrite(109).repItem(new Item(105, (byte) 1, (short) -1, getNamedTag("1.14 Lily of the Valley")));
rewrite(110).repItem(new Item(100, (byte) 1, (short) -1, getNamedTag("1.14 Wither Rose")));
rewrite(614).repItem(new Item((short) 611, (byte) 1, (short) -1, getNamedTag("1.14 Bamboo")));
rewrite(857).repItem(new Item((short) 547, (byte) 1, (short) -1, getNamedTag("1.14 Suspicious Stew")));
rewrite(795).repItem(new Item((short) 793, (byte) 1, (short) -1, getNamedTag("1.14 Leather Horse Armor")));
rewrite(614).repItem(new Item(611, (byte) 1, (short) -1, getNamedTag("1.14 Bamboo")));
rewrite(857).repItem(new Item(547, (byte) 1, (short) -1, getNamedTag("1.14 Suspicious Stew")));
rewrite(795).repItem(new Item(793, (byte) 1, (short) -1, getNamedTag("1.14 Leather Horse Armor")));
rewrite(647).repItem(new Item((short) 635, (byte) 1, (short) -1, getNamedTag("1.14 Blue Dye")));
rewrite(648).repItem(new Item((short) 634, (byte) 1, (short) -1, getNamedTag("1.14 Brown Dye")));
rewrite(649).repItem(new Item((short) 631, (byte) 1, (short) -1, getNamedTag("1.14 Black Dye")));
rewrite(650).repItem(new Item((short) 646, (byte) 1, (short) -1, getNamedTag("1.14 White Dye")));
rewrite(647).repItem(new Item(635, (byte) 1, (short) -1, getNamedTag("1.14 Blue Dye")));
rewrite(648).repItem(new Item(634, (byte) 1, (short) -1, getNamedTag("1.14 Brown Dye")));
rewrite(649).repItem(new Item(631, (byte) 1, (short) -1, getNamedTag("1.14 Black Dye")));
rewrite(650).repItem(new Item(646, (byte) 1, (short) -1, getNamedTag("1.14 White Dye")));
rewrite(505).repItem(new Item((short) 299, (byte) 1, (short) -1, getNamedTag("1.14 Scaffolding")));
rewrite(516).repItem(new Item((short) 515, (byte) 1, (short) -1, getNamedTag("1.14 Jigsaw Block")));
rewrite(517).repItem(new Item((short) 694, (byte) 1, (short) -1, getNamedTag("1.14 Composter")));
rewrite(505).repItem(new Item(299, (byte) 1, (short) -1, getNamedTag("1.14 Scaffolding")));
rewrite(516).repItem(new Item(515, (byte) 1, (short) -1, getNamedTag("1.14 Jigsaw Block")));
rewrite(517).repItem(new Item(694, (byte) 1, (short) -1, getNamedTag("1.14 Composter")));
rewrite(864).repItem(new Item((short) 155, (byte) 1, (short) -1, getNamedTag("1.14 Barrel")));
rewrite(858).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Loom")));
rewrite(865).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.14 Smoker")));
rewrite(866).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.14 Blast Furnace")));
rewrite(867).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Cartography Table")));
rewrite(868).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Fletching Table")));
rewrite(869).repItem(new Item((short) 265, (byte) 1, (short) -1, getNamedTag("1.14 Grindstone")));
rewrite(870).repItem(new Item((short) 143, (byte) 1, (short) -1, getNamedTag("1.14 Lectern")));
rewrite(871).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Smithing Table")));
rewrite(872).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Stonecutter")));
rewrite(864).repItem(new Item(155, (byte) 1, (short) -1, getNamedTag("1.14 Barrel")));
rewrite(858).repItem(new Item(158, (byte) 1, (short) -1, getNamedTag("1.14 Loom")));
rewrite(865).repItem(new Item(160, (byte) 1, (short) -1, getNamedTag("1.14 Smoker")));
rewrite(866).repItem(new Item(160, (byte) 1, (short) -1, getNamedTag("1.14 Blast Furnace")));
rewrite(867).repItem(new Item(158, (byte) 1, (short) -1, getNamedTag("1.14 Cartography Table")));
rewrite(868).repItem(new Item(158, (byte) 1, (short) -1, getNamedTag("1.14 Fletching Table")));
rewrite(869).repItem(new Item(265, (byte) 1, (short) -1, getNamedTag("1.14 Grindstone")));
rewrite(870).repItem(new Item(143, (byte) 1, (short) -1, getNamedTag("1.14 Lectern")));
rewrite(871).repItem(new Item(158, (byte) 1, (short) -1, getNamedTag("1.14 Smithing Table")));
rewrite(872).repItem(new Item(158, (byte) 1, (short) -1, getNamedTag("1.14 Stonecutter")));
rewrite(859).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Flower Banner Pattern")));
rewrite(860).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Creeper Banner Pattern")));
rewrite(861).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Skull Banner Pattern")));
rewrite(862).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Mojang Banner Pattern")));
rewrite(863).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Globe Banner Pattern")));
rewrite(859).repItem(new Item(615, (byte) 1, (short) -1, getNamedTag("1.14 Flower Banner Pattern")));
rewrite(860).repItem(new Item(615, (byte) 1, (short) -1, getNamedTag("1.14 Creeper Banner Pattern")));
rewrite(861).repItem(new Item(615, (byte) 1, (short) -1, getNamedTag("1.14 Skull Banner Pattern")));
rewrite(862).repItem(new Item(615, (byte) 1, (short) -1, getNamedTag("1.14 Mojang Banner Pattern")));
rewrite(863).repItem(new Item(615, (byte) 1, (short) -1, getNamedTag("1.14 Globe Banner Pattern")));
rewrite(873).repItem(new Item((short) 113, (byte) 1, (short) -1, getNamedTag("1.14 Bell")));
rewrite(874).repItem(new Item((short) 234, (byte) 1, (short) -1, getNamedTag("1.14 Lantern")));
rewrite(875).repItem(new Item((short) 820, (byte) 1, (short) -1, getNamedTag("1.14 Sweet Berries")));
rewrite(876).repItem(new Item((short) 146, (byte) 1, (short) -1, getNamedTag("1.14 Campfire")));
rewrite(873).repItem(new Item(113, (byte) 1, (short) -1, getNamedTag("1.14 Bell")));
rewrite(874).repItem(new Item(234, (byte) 1, (short) -1, getNamedTag("1.14 Lantern")));
rewrite(875).repItem(new Item(820, (byte) 1, (short) -1, getNamedTag("1.14 Sweet Berries")));
rewrite(876).repItem(new Item(146, (byte) 1, (short) -1, getNamedTag("1.14 Campfire")));
rewrite(590).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Spruce Sign")));
rewrite(591).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Birch Sign")));
rewrite(592).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Jungle Sign")));
rewrite(593).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Acacia Sign")));
rewrite(594).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Dark Oak Sign")));
rewrite(590).repItem(new Item(589, (byte) 1, (short) -1, getNamedTag("1.14 Spruce Sign")));
rewrite(591).repItem(new Item(589, (byte) 1, (short) -1, getNamedTag("1.14 Birch Sign")));
rewrite(592).repItem(new Item(589, (byte) 1, (short) -1, getNamedTag("1.14 Jungle Sign")));
rewrite(593).repItem(new Item(589, (byte) 1, (short) -1, getNamedTag("1.14 Acacia Sign")));
rewrite(594).repItem(new Item(589, (byte) 1, (short) -1, getNamedTag("1.14 Dark Oak Sign")));
rewrite(856).repItem(new Item((short) 525, (byte) 1, (short) -1, getNamedTag("1.14 Crossbow")));
rewrite(856).repItem(new Item(525, (byte) 1, (short) -1, getNamedTag("1.14 Crossbow")));
rewrite(699).repItem(new Item((short) 721, (byte) 1, (short) -1, getNamedTag("1.14 Cat Spawn Egg")));
rewrite(712).repItem(new Item((short) 725, (byte) 1, (short) -1, getNamedTag("1.14 Fox Spawn Egg")));
rewrite(722).repItem(new Item((short) 735, (byte) 1, (short) -1, getNamedTag("1.14 Panda Spawn Egg")));
rewrite(726).repItem(new Item((short) 754, (byte) 1, (short) -1, getNamedTag("1.14 Pillager Spawn Egg")));
rewrite(730).repItem(new Item((short) 734, (byte) 1, (short) -1, getNamedTag("1.14 Ravager Spawn Egg")));
rewrite(741).repItem(new Item((short) 698, (byte) 1, (short) -1, getNamedTag("1.14 Trader Llama Spawn Egg")));
rewrite(747).repItem(new Item((short) 739, (byte) 1, (short) -1, getNamedTag("1.14 Wandering Trader Spawn Egg")));
rewrite(699).repItem(new Item(721, (byte) 1, (short) -1, getNamedTag("1.14 Cat Spawn Egg")));
rewrite(712).repItem(new Item(725, (byte) 1, (short) -1, getNamedTag("1.14 Fox Spawn Egg")));
rewrite(722).repItem(new Item(735, (byte) 1, (short) -1, getNamedTag("1.14 Panda Spawn Egg")));
rewrite(726).repItem(new Item(754, (byte) 1, (short) -1, getNamedTag("1.14 Pillager Spawn Egg")));
rewrite(730).repItem(new Item(734, (byte) 1, (short) -1, getNamedTag("1.14 Ravager Spawn Egg")));
rewrite(741).repItem(new Item(698, (byte) 1, (short) -1, getNamedTag("1.14 Trader Llama Spawn Egg")));
rewrite(747).repItem(new Item(739, (byte) 1, (short) -1, getNamedTag("1.14 Wandering Trader Spawn Egg")));
enchantmentRewriter = new EnchantmentRewriter(nbtTagName);
enchantmentRewriter.registerEnchantment("minecraft:multishot", "§7Multishot");
@ -772,14 +740,6 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
return item;
}
@Override
protected CompoundTag getNamedTag(String text) {
CompoundTag tag = new CompoundTag("");
tag.put(new CompoundTag("display"));
((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatRewriter.legacyTextToJson(text)));
return tag;
}
public static int getNewItemId(int id) {
Integer newId = MappingData.oldToNewItems.get(id);
@ -790,7 +750,6 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
return newId;
}
public static int getOldItemId(int id) {
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
if (oldId == null) {

View File

@ -3,10 +3,11 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.entities.meta.MetaHandler;
import nl.matsv.viabackwards.api.entities.storage.EntityData;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityPositionStorage;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityTypeMapping;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import us.myles.ViaVersion.api.PacketWrapper;
@ -22,18 +23,67 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.Optional;
public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
private static final double RELATIVE_MOVE_FACTOR = 32 * 128;
@Override
protected void addTrackedEntity(PacketWrapper wrapper, int entityId, EntityType type) throws Exception {
super.addTrackedEntity(wrapper, entityId, type);
// Cache the position for every newly tracked entity
if (type == Entity1_14Types.EntityType.PAINTING) {
final Position position = wrapper.get(Type.POSITION, 0);
cacheEntityPosition(wrapper, position.getX(), position.getY(), position.getZ(), true, false);
} else if (wrapper.getId() != 0x25) { // ignore join game
cacheEntityPosition(wrapper, true, false);
}
}
@Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
// Entity teleport
protocol.registerOutgoing(State.PLAY, 0x56, 0x50, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
map(Type.DOUBLE);
map(Type.DOUBLE);
map(Type.DOUBLE);
handler(wrapper -> cacheEntityPosition(wrapper, false, false));
}
});
// Entity relative move + Entity look and relative move
PacketRemapper relativeMoveHandler = new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
map(Type.SHORT);
map(Type.SHORT);
map(Type.SHORT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
double x = wrapper.get(Type.SHORT, 0) / RELATIVE_MOVE_FACTOR;
double y = wrapper.get(Type.SHORT, 1) / RELATIVE_MOVE_FACTOR;
double z = wrapper.get(Type.SHORT, 2) / RELATIVE_MOVE_FACTOR;
cacheEntityPosition(wrapper, x, y, z, false, true);
}
});
}
};
protocol.registerOutgoing(State.PLAY, 0x28, 0x28, relativeMoveHandler);
protocol.registerOutgoing(State.PLAY, 0x29, 0x29, relativeMoveHandler);
// Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override
@ -128,7 +178,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
public void handle(PacketWrapper wrapper) throws Exception {
int type = wrapper.get(Type.VAR_INT, 1);
Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(type);
addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), entityType);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
Optional<Integer> oldId = EntityTypeMapping.getOldId(type);
if (!oldId.isPresent()) {
@ -151,10 +201,38 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
});
// Spawn Experience Orb
registerExtraTracker(0x01, Entity1_14Types.EntityType.XP_ORB);
getProtocol().registerOutgoing(State.PLAY, 0x01, 0x01, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
map(Type.DOUBLE); // Needs to be mapped for the position cache
map(Type.DOUBLE);
map(Type.DOUBLE);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.XP_ORB);
}
});
}
});
// Spawn Global Object
registerExtraTracker(0x02, Entity1_14Types.EntityType.LIGHTNING_BOLT);
getProtocol().registerOutgoing(State.PLAY, 0x02, 0x02, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
map(Type.DOUBLE); // Needs to be mapped for the position cache
map(Type.DOUBLE);
map(Type.DOUBLE);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.LIGHTNING_BOLT);
}
});
}
});
// Spawn painting
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
@ -170,7 +248,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(wrapper.user(), wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.PAINTING);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EntityType.PAINTING);
}
});
}
@ -190,6 +268,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata
handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, Entity1_14Types.EntityType.PLAYER));
handler(wrapper -> cacheEntityPosition(wrapper, true, false));
}
});
@ -426,6 +505,30 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
});
}
private void cacheEntityPosition(PacketWrapper wrapper, boolean create, boolean relative) throws Exception {
cacheEntityPosition(wrapper,
wrapper.get(Type.DOUBLE, 0), wrapper.get(Type.DOUBLE, 1), wrapper.get(Type.DOUBLE, 2), create, relative);
}
private void cacheEntityPosition(PacketWrapper wrapper, double x, double y, double z, boolean create, boolean relative) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
Optional<EntityTracker.StoredEntity> optStoredEntity = getEntityTracker(wrapper.user()).getEntity(entityId);
if (!optStoredEntity.isPresent()) {
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " not found!");
return;
}
EntityTracker.StoredEntity storedEntity = optStoredEntity.get();
EntityPositionStorage positionStorage = create ? new EntityPositionStorage() : storedEntity.get(EntityPositionStorage.class);
if (positionStorage == null) {
ViaBackwards.getPlatform().getLogger().warning("Stored entity with id " + entityId + " missing entitypositionstorage!");
return;
}
positionStorage.setCoordinates(x, y, z, relative);
storedEntity.put(positionStorage);
}
public int villagerDataToProfession(VillagerData data) {
switch (data.getProfession()) {
case 1: // Armorer

View File

@ -1,14 +1,19 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.rewriters.Rewriter;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.SoundMapping;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityPositionStorage;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import java.util.Optional;
public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
@Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
@ -20,7 +25,55 @@ public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.VAR_INT, 0, SoundMapping.getOldSound(wrapper.get(Type.VAR_INT, 0)));
int newId = BackwardsMappings.soundMappings.getNewId(wrapper.get(Type.VAR_INT, 0));
if (newId == -1) {
wrapper.cancel();
} else {
wrapper.set(Type.VAR_INT, 0, newId);
}
}
});
}
});
// Entity Sound Effect
protocol.registerOutgoing(State.PLAY, 0x50, -1, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
int soundId = wrapper.read(Type.VAR_INT);
int newId = BackwardsMappings.soundMappings.getNewId(soundId);
if (newId == -1) return;
int category = wrapper.read(Type.VAR_INT);
int entityId = wrapper.read(Type.VAR_INT);
Optional<EntityTracker.StoredEntity> optEntity = wrapper.user().get(EntityTracker.class).get(protocol).getEntity(entityId);
EntityPositionStorage storedEntity;
if (!optEntity.isPresent() || (storedEntity = optEntity.get().get(EntityPositionStorage.class)) == null) {
ViaBackwards.getPlatform().getLogger().warning("Untracked entity with id " + entityId);
return;
}
float volume = wrapper.read(Type.FLOAT);
float pitch = wrapper.read(Type.FLOAT);
int x = (int) (storedEntity.getX() * 8D);
int y = (int) (storedEntity.getY() * 8D);
int z = (int) (storedEntity.getZ() * 8D);
PacketWrapper soundPacket = wrapper.create(0x4D);
soundPacket.write(Type.VAR_INT, newId);
soundPacket.write(Type.VAR_INT, category);
soundPacket.write(Type.INT, x);
soundPacket.write(Type.INT, y);
soundPacket.write(Type.INT, z);
soundPacket.write(Type.FLOAT, volume);
soundPacket.write(Type.FLOAT, pitch);
soundPacket.send(Protocol1_13_2To1_14.class);
}
});
}
@ -29,6 +82,5 @@ public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
@Override
protected void registerRewrites() {
}
}

View File

@ -149,7 +149,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
}
});
//Tags
// Tags
registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() {
@Override
public void registerMap() {
@ -159,7 +159,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
Integer[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY);
int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blocks.length; j++) {
blocks[j] = getNewBlockId(blocks[j]);
}
@ -167,7 +167,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags
for (int i = 0; i < itemTagsSize; i++) {
wrapper.passthrough(Type.STRING);
Integer[] items = wrapper.passthrough(Type.VAR_INT_ARRAY);
int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < items.length; j++) {
items[j] = InventoryPackets1_13_1.getOldItemId(items[j]);
}
@ -207,7 +207,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
if (blockId > 565) {
blockId -= 5;
} else if (blockId > 561) {
blockId = 0; //TODO replace new blocks
blockId = 0; // Replacements not needed
}
return blockId;

View File

@ -53,7 +53,7 @@ public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
}
// Track Entity
addTrackedEntity(wrapper.user(), entityId, entType);
addTrackedEntity(wrapper, entityId, entType);
}
});
}

View File

@ -14,6 +14,9 @@ public class InventoryPackets1_13_1 {
public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets1_13_1::toClient, InventoryPackets1_13_1::toServer);
// Set cooldown
itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets1_13_1::getOldItemId);
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_ITEM_ARRAY, 0x15, 0x15);
@ -60,7 +63,6 @@ public class InventoryPackets1_13_1 {
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, 0x42, 0x42);
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_ITEM, 0x08, 0x08);

View File

@ -80,19 +80,11 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
}
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
} else if (type.equals("smelting")) {
wrapper.passthrough(Type.STRING); // Group
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
} else if (type.equals("stonecutting")) {
wrapper.passthrough(Type.STRING); // Group?
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
} else if (type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) {
} else if (type.equals("smelting") || type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) {
wrapper.passthrough(Type.STRING); // Group
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);

View File

@ -0,0 +1,252 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_14_4To1_15 extends BackwardsProtocol {
private static final Integer[] A = new Integer[0];
private BlockItemPackets1_15 blockItemPackets;
@Override
protected void registerPackets() {
BackwardsMappings.init();
blockItemPackets = new BlockItemPackets1_15();
blockItemPackets.register(this);
new EntityPackets1_15().register(this);
// Entity Sound Effect
registerOutgoing(State.PLAY, 0x51, 0x50, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Sound Id
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int newId = BackwardsMappings.soundMappings.getNewId(wrapper.get(Type.VAR_INT, 0));
if (newId == -1) {
wrapper.cancel();
} else {
wrapper.set(Type.VAR_INT, 0, newId);
}
}
});
}
});
// Sound Effect
registerOutgoing(State.PLAY, 0x52, 0x51, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Sound Id
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int newId = BackwardsMappings.soundMappings.getNewId(wrapper.get(Type.VAR_INT, 0));
if (newId == -1) {
wrapper.cancel();
} else {
wrapper.set(Type.VAR_INT, 0, newId);
}
}
});
}
});
// Advancements
registerOutgoing(State.PLAY, 0x58, 0x57, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
int size = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.STRING); // Identifier
// Parent
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING);
}
// Display data
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING); // Title
wrapper.passthrough(Type.STRING); // Description
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) {
wrapper.passthrough(Type.STRING); // Background texture
}
wrapper.passthrough(Type.FLOAT); // X
wrapper.passthrough(Type.FLOAT); // Y
}
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
int arrayLength = wrapper.passthrough(Type.VAR_INT);
for (int array = 0; array < arrayLength; array++) {
wrapper.passthrough(Type.STRING_ARRAY); // String array
}
}
}
});
}
});
// Tags
registerOutgoing(State.PLAY, 0x5C, 0x5B, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blockIds.length; j++) {
int id = blockIds[j];
blockIds[j] = BackwardsMappings.blockMappings.getNewId(id);
}
}
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < itemTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < itemIds.length; j++) {
Integer oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]);
itemIds[j] = oldId != null ? oldId : -1;
}
}
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags
for (int i = 0; i < fluidTagsSize; i++) {
wrapper.passthrough(Type.STRING);
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
}
int entityTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < entityTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < entityIds.length; j++) {
entityIds[j] = EntityTypeMapping.getOldEntityId(entityIds[j]);
}
}
}
});
}
});
registerOutgoing(State.PLAY, 0x09, 0x08);
registerOutgoing(State.PLAY, 0x0A, 0x09);
registerOutgoing(State.PLAY, 0x0D, 0x0C);
registerOutgoing(State.PLAY, 0x0E, 0x0D);
registerOutgoing(State.PLAY, 0x0F, 0x0E);
registerOutgoing(State.PLAY, 0x11, 0x10);
registerOutgoing(State.PLAY, 0x12, 0x11);
registerOutgoing(State.PLAY, 0x13, 0x12);
registerOutgoing(State.PLAY, 0x14, 0x13);
registerOutgoing(State.PLAY, 0x16, 0x15);
registerOutgoing(State.PLAY, 0x19, 0x18);
registerOutgoing(State.PLAY, 0x1A, 0x19);
registerOutgoing(State.PLAY, 0x1B, 0x1A);
registerOutgoing(State.PLAY, 0x1C, 0x1B);
registerOutgoing(State.PLAY, 0x1D, 0x1C);
registerOutgoing(State.PLAY, 0x1E, 0x1D);
registerOutgoing(State.PLAY, 0x1F, 0x1E);
registerOutgoing(State.PLAY, 0x20, 0x1F);
registerOutgoing(State.PLAY, 0x21, 0x20);
registerOutgoing(State.PLAY, 0x25, 0x24);
registerOutgoing(State.PLAY, 0x27, 0x26);
registerOutgoing(State.PLAY, 0x29, 0x28);
registerOutgoing(State.PLAY, 0x2A, 0x29);
registerOutgoing(State.PLAY, 0x2B, 0x2A);
registerOutgoing(State.PLAY, 0x2C, 0x2B);
registerOutgoing(State.PLAY, 0x2D, 0x2C);
registerOutgoing(State.PLAY, 0x2E, 0x2D);
registerOutgoing(State.PLAY, 0x2F, 0x2E);
registerOutgoing(State.PLAY, 0x30, 0x2F);
registerOutgoing(State.PLAY, 0x31, 0x30);
registerOutgoing(State.PLAY, 0x32, 0x31);
registerOutgoing(State.PLAY, 0x33, 0x32);
registerOutgoing(State.PLAY, 0x34, 0x33);
registerOutgoing(State.PLAY, 0x35, 0x34);
registerOutgoing(State.PLAY, 0x36, 0x35);
registerOutgoing(State.PLAY, 0x37, 0x36);
registerOutgoing(State.PLAY, 0x39, 0x38);
registerOutgoing(State.PLAY, 0x3A, 0x39);
registerOutgoing(State.PLAY, 0x3C, 0x3B);
registerOutgoing(State.PLAY, 0x3D, 0x3C);
registerOutgoing(State.PLAY, 0x3E, 0x3D);
registerOutgoing(State.PLAY, 0x3F, 0x3E);
registerOutgoing(State.PLAY, 0x40, 0x3F);
registerOutgoing(State.PLAY, 0x41, 0x40);
registerOutgoing(State.PLAY, 0x42, 0x41);
registerOutgoing(State.PLAY, 0x43, 0x42);
registerOutgoing(State.PLAY, 0x45, 0x44);
registerOutgoing(State.PLAY, 0x46, 0x45);
registerOutgoing(State.PLAY, 0x48, 0x47);
registerOutgoing(State.PLAY, 0x49, 0x48);
registerOutgoing(State.PLAY, 0x4A, 0x49);
registerOutgoing(State.PLAY, 0x4B, 0x4A);
registerOutgoing(State.PLAY, 0x4C, 0x4B);
registerOutgoing(State.PLAY, 0x4D, 0x4C);
registerOutgoing(State.PLAY, 0x4E, 0x4D);
registerOutgoing(State.PLAY, 0x4F, 0x4E);
registerOutgoing(State.PLAY, 0x50, 0x4F);
registerOutgoing(State.PLAY, 0x53, 0x52);
registerOutgoing(State.PLAY, 0x54, 0x53);
registerOutgoing(State.PLAY, 0x55, 0x54);
registerOutgoing(State.PLAY, 0x56, 0x55);
registerOutgoing(State.PLAY, 0x57, 0x56);
registerOutgoing(State.PLAY, 0x5A, 0x59);
registerOutgoing(State.PLAY, 0x08, 0x5C);
}
public static int getNewBlockStateId(int id) {
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 blockstate id for 1.14.4 block " + id);
return 0;
}
return newId;
}
public static int getNewBlockId(int id) {
int newId = BackwardsMappings.blockMappings.getNewId(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 block id for 1.14.4 block " + id);
return id;
}
return newId;
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class))
user.put(new ClientWorld(user));
if (!user.has(EntityTracker.class))
user.put(new EntityTracker(user));
user.get(EntityTracker.class).initProtocol(this);
}
public BlockItemPackets1_15 getBlockItemPackets() {
return blockItemPackets;
}
}

View File

@ -0,0 +1,25 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
import nl.matsv.viabackwards.api.data.VBMappings;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.viaversion.libs.gson.JsonObject;
public class BackwardsMappings {
public static Mappings blockStateMappings;
public static Mappings blockMappings;
public static Mappings soundMappings;
public static void init() {
JsonObject mapping1_14 = MappingDataLoader.loadData("mapping-1.14.json");
JsonObject mapping1_15 = MappingDataLoader.loadData("mapping-1.15.json");
JsonObject mapping1_14to1_15 = VBMappingDataLoader.loadData("mapping-1.14.4to1.15.json");
ViaBackwards.getPlatform().getLogger().info("Loading 1.15 -> 1.14.4 mappings...");
blockStateMappings = new VBMappings(mapping1_15.getAsJsonObject("blockstates"), mapping1_14.getAsJsonObject("blockstates"), mapping1_14to1_15.getAsJsonObject("blockstates"));
blockMappings = new VBMappings(mapping1_15.getAsJsonObject("blocks"), mapping1_14.getAsJsonObject("blocks"), mapping1_14to1_15.getAsJsonObject("blocks"), false);
soundMappings = new VBMappings(mapping1_15.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"), mapping1_14to1_15.getAsJsonObject("sounds"));
}
}

View File

@ -0,0 +1,12 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
import us.myles.ViaVersion.api.entities.Entity1_14Types;
public class EntityTypeMapping {
// There's only the bee, so not much to do here
public static int getOldEntityId(int entityId) {
if (entityId == 4) return Entity1_14Types.EntityType.PUFFER_FISH.getId(); // Flying pufferfish!
return entityId >= 5 ? entityId - 1 : entityId;
}
}

View File

@ -0,0 +1,45 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.type.Type;
public class RecipeRewriter1_15 extends RecipeRewriter1_14 {
public RecipeRewriter1_15(final BlockItemRewriter rewriter) {
super(rewriter);
}
@Override
public void handle(PacketWrapper wrapper, String type) throws Exception {
switch (type) {
case "crafting_shapeless":
handleCraftingShapeless(wrapper);
break;
case "crafting_shaped":
handleCraftingShaped(wrapper);
break;
case "blasting": // new
case "smoking": // new
case "campfire_cooking": // new
case "smelting":
handleSmelting(wrapper);
break;
case "stonecutting": // new
handleStonecutting(wrapper);
break;
}
}
public void handleStonecutting(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.STRING);
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) {
rewriter.handleItemToClient(item);
}
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
}
}

View File

@ -0,0 +1,306 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class BlockItemPackets1_15 extends BlockItemRewriter<Protocol1_14_4To1_15> {
@Override
protected void registerPackets(Protocol1_14_4To1_15 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
// Set cooldown
itemRewriter.registerSetCooldown(0x18, 0x17, BlockItemPackets1_15::getOldItemId);
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14);
// Set slot packet
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16);
// Trade list
protocol.out(State.PLAY, 0x28, 0x27, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
handleItemToClient(input);
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
handleItemToClient(output);
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
// Second Item
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
handleItemToClient(second);
}
wrapper.passthrough(Type.BOOLEAN);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.FLOAT);
}
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.BOOLEAN);
}
});
}
});
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x47, 0x46);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x5B, 0x5A, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
private final RecipeRewriter recipeHandler = new RecipeRewriter1_15(BlockItemPackets1_15.this);
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int size = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < size; i++) {
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
recipeHandler.handle(wrapper, type);
}
}
});
}
});
// Incoming packets
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x26);
// Block Action
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0A, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION1_14); // Location
map(Type.UNSIGNED_BYTE); // Action id
map(Type.UNSIGNED_BYTE); // Action param
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockId(wrapper.get(Type.VAR_INT, 0)));
}
});
}
});
// Block Change
protocol.registerOutgoing(State.PLAY, 0x0C, 0x0B, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION1_14);
map(Type.VAR_INT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.VAR_INT, 0);
wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockStateId(id));
}
});
}
});
// Multi Block Change
protocol.registerOutgoing(State.PLAY, 0x10, 0x0F, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Chunk X
map(Type.INT); // 1 - Chunk Z
map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
int id = record.getBlockId();
record.setBlockId(Protocol1_14_4To1_15.getNewBlockStateId(id));
}
}
});
}
});
// Chunk
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
wrapper.write(new Chunk1_14Type(clientWorld), chunk);
if (chunk.isGroundUp()) {
int[] biomeData = chunk.getBiomeData();
int[] newBiomeData = new int[256];
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
int x = j << 2;
int z = i << 2;
int newIndex = z << 4 | x;
int oldIndex = i << 2 | j;
int biome = biomeData[oldIndex];
for (int k = 0; k < 4; k++) {
int offX = newIndex + (k << 4);
for (int l = 0; l < 4; l++) {
newBiomeData[offX + l] = biome;
}
}
}
}
chunk.setBiomeData(newBiomeData);
}
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null) continue;
for (int j = 0; j < section.getPaletteSize(); j++) {
int old = section.getPaletteEntry(j);
int newId = Protocol1_14_4To1_15.getNewBlockStateId(old);
section.setPaletteEntry(j, newId);
}
}
}
});
}
});
// Effect packet
protocol.registerOutgoing(State.PLAY, 0x23, 0x22, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Effect Id
map(Type.POSITION1_14); // Location
map(Type.INT); // Data
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.INT, 0);
int data = wrapper.get(Type.INT, 1);
if (id == 1010) { // Play record
wrapper.set(Type.INT, 1, BlockItemPackets1_15.getOldItemId(data));
} else if (id == 2001) { // Block break + block break sound
wrapper.set(Type.INT, 1, Protocol1_14_4To1_15.getNewBlockStateId(data));
}
}
});
}
});
// Spawn particle
protocol.registerOutgoing(State.PLAY, 0x24, 0x23, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Particle ID
map(Type.BOOLEAN); // 1 - Long Distance
map(Type.DOUBLE, Type.FLOAT); // 2 - X
map(Type.DOUBLE, Type.FLOAT); // 3 - Y
map(Type.DOUBLE, Type.FLOAT); // 4 - Z
map(Type.FLOAT); // 5 - Offset X
map(Type.FLOAT); // 6 - Offset Y
map(Type.FLOAT); // 7 - Offset Z
map(Type.FLOAT); // 8 - Particle Data
map(Type.INT); // 9 - Particle Count
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.INT, 0);
if (id == 3 || id == 23) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockStateId(data));
} else if (id == 32) {
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
}
}
});
}
});
}
@Override
protected void registerRewrites() {
rewrite(881).repItem(new Item(824, (byte) 1, (short) -1, getNamedTag("1.15 Honey Bottle")));
rewrite(878).repItem(new Item(323, (byte) 1, (short) -1, getNamedTag("1.15 Honeycomb")));
rewrite(883).repItem(new Item(455, (byte) 1, (short) -1, getNamedTag("1.15 Honeycomb Block")));
rewrite(879).repItem(new Item(385, (byte) 1, (short) -1, getNamedTag("1.15 Bee Nest")));
rewrite(880).repItem(new Item(865, (byte) 1, (short) -1, getNamedTag("1.15 Beehive")));
rewrite(882).repItem(new Item(321, (byte) 1, (short) -1, getNamedTag("1.15 Honey Block")));
rewrite(698).repItem(new Item(722, (byte) 1, (short) -1, getNamedTag("1.15 Bee Spawn Egg")));
}
@Override
public Item handleItemToClient(Item i) {
Item item = super.handleItemToClient(i);
if (item == null) return null;
item.setIdentifier(getOldItemId(item.getIdentifier()));
return item;
}
@Override
public Item handleItemToServer(Item item) {
if (item == null) return null;
item.setIdentifier(getNewItemId(item.getIdentifier()));
return super.handleItemToServer(item);
}
public static int getNewItemId(int id) {
Integer newId = MappingData.oldToNewItems.get(id);
if (newId == null) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.14.4 item " + id);
return 1;
}
return newId;
}
public static int getOldItemId(int id) {
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
if (oldId == null) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14.4 item for 1.15 item " + id);
return 1;
}
return oldId;
}
}

View File

@ -0,0 +1,271 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_14Types;
import us.myles.ViaVersion.api.entities.Entity1_15Types;
import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
@Override
protected void registerPackets(Protocol1_14_4To1_15 protocol) {
// Spawn Object
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
map(Type.UUID); // 1 - UUID
map(Type.VAR_INT); // 2 - Type
map(Type.DOUBLE); // 3 - X
map(Type.DOUBLE); // 4 - Y
map(Type.DOUBLE); // 5 - Z
map(Type.BYTE); // 6 - Pitch
map(Type.BYTE); // 7 - Yaw
map(Type.INT); // 8 - Data
handler(getTrackerHandler());
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int typeId = wrapper.get(Type.VAR_INT, 1);
Entity1_14Types.EntityType entityType = Entity1_14Types.getTypeFromId(getOldEntityId(typeId));
wrapper.set(Type.VAR_INT, 1, entityType.getId());
if (entityType == Entity1_14Types.EntityType.FALLING_BLOCK) {
int blockState = wrapper.get(Type.INT, 0);
int combined = Protocol1_14_4To1_15.getNewBlockStateId(blockState);
wrapper.set(Type.INT, 0, combined);
}
}
});
}
});
// Spawn mob packet
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.UUID); // 1 - Entity UUID
map(Type.VAR_INT); // 2 - Entity Type
map(Type.DOUBLE); // 3 - X
map(Type.DOUBLE); // 4 - Y
map(Type.DOUBLE); // 5 - Z
map(Type.BYTE); // 6 - Yaw
map(Type.BYTE); // 7 - Pitch
map(Type.BYTE); // 8 - Head Pitch
map(Type.SHORT); // 9 - Velocity X
map(Type.SHORT); // 10 - Velocity Y
map(Type.SHORT); // 11 - Velocity Z
create(wrapper -> wrapper.write(Type.UNSIGNED_BYTE, (short) 0xff)); // Metadata is no longer sent in 1.15, so we have to send an empty one
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int type = wrapper.get(Type.VAR_INT, 1);
Entity1_15Types.EntityType entityType = Entity1_15Types.getTypeFromId(type);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
wrapper.set(Type.VAR_INT, 1, EntityTypeMapping.getOldEntityId(type));
}
});
}
});
// Respawn
protocol.registerOutgoing(State.PLAY, 0x3B, 0x3A, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT);
map(Type.LONG, Type.NOTHING); // Seed
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
}
});
}
});
// Join Game
protocol.registerOutgoing(State.PLAY, 0x26, 0x25, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension
map(Type.LONG, Type.NOTHING); // Seed
map(Type.UNSIGNED_BYTE); // 3 - Max Players
map(Type.STRING); // 4 - Level Type
map(Type.VAR_INT); // 5 - View Distance
map(Type.BOOLEAN); // 6 - Reduce Debug Info
map(Type.BOOLEAN, Type.NOTHING); // Show death screen
handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.INT));
handler(getDimensionHandler(1));
}
});
// Edit Book
protocol.registerIncoming(State.PLAY, 0x0D, 0x0C, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
getProtocol().getBlockItemPackets().handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
}
});
}
});
// Spawn Experience Orb
registerExtraTracker(0x01, Entity1_15Types.EntityType.XP_ORB);
// Spawn Global Object
registerExtraTracker(0x02, Entity1_15Types.EntityType.LIGHTNING_BOLT);
// Spawn painting
registerExtraTracker(0x04, Entity1_15Types.EntityType.PAINTING);
// Spawn player packet
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.UUID); // 1 - Player UUID
map(Type.DOUBLE); // 2 - X
map(Type.DOUBLE); // 3 - Y
map(Type.DOUBLE); // 4 - Z
map(Type.BYTE); // 5 - Yaw
map(Type.BYTE); // 6 - Pitch
create(wrapper -> wrapper.write(Type.UNSIGNED_BYTE, (short) 0xff)); // Metadata is no longer sent in 1.15, so we have to send an empty one
handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.VAR_INT));
}
});
// Destroy entities
registerEntityDestroy(0x38, 0x37);
// Entity Metadata packet
register1_15MetadataRewriter(0x44, 0x43, Types1_14.METADATA_LIST);
// Attributes (get rid of generic.flyingSpeed for the Bee remap)
protocol.registerOutgoing(State.PLAY, 0x59, 0x58, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
map(Type.INT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
EntityType entityType = getEntityType(wrapper.user(), entityId);
if (entityType != Entity1_15Types.EntityType.BEE) return;
int size = wrapper.get(Type.INT, 0);
for (int i = 0; i < size; i++) {
String key = wrapper.read(Type.STRING);
if (key.equals("generic.flyingSpeed")) {
size--;
wrapper.read(Type.DOUBLE);
int modSize = wrapper.read(Type.VAR_INT);
for (int j = 0; j < modSize; j++) {
wrapper.read(Type.UUID);
wrapper.read(Type.DOUBLE);
wrapper.read(Type.BYTE);
}
} else {
wrapper.write(Type.STRING, key);
wrapper.passthrough(Type.DOUBLE);
int modSize = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < modSize; j++) {
wrapper.passthrough(Type.UUID);
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.BYTE);
}
}
}
wrapper.set(Type.INT, 0, size);
}
});
}
});
}
@Override
protected void registerRewrites() {
setDisplayNameJson(true);
setDisplayNameMetaType(MetaType1_14.OptChat);
registerMetaHandler().handle(e -> {
Metadata meta = e.getData();
MetaType type = meta.getMetaType();
if (type == MetaType1_14.Slot) {
Item item = (Item) meta.getValue();
meta.setValue(getProtocol().getBlockItemPackets().handleItemToClient(item));
} else if (type == MetaType1_14.BlockID) {
int blockstate = (int) meta.getValue();
meta.setValue(Protocol1_14_4To1_15.getNewBlockStateId(blockstate));
}
return meta;
});
registerMetaHandler().filter(Entity1_15Types.EntityType.LIVINGENTITY, true).handle(e -> {
int index = e.getIndex();
if (index == 12) {
throw RemovedValueException.EX;
} else if (index > 12) {
e.getData().setId(index - 1);
}
return e.getData();
});
registerMetaHandler().filter(Entity1_15Types.EntityType.BEE, 15).removed();
registerMetaHandler().filter(Entity1_15Types.EntityType.BEE, 16).removed();
regEntType(Entity1_15Types.EntityType.BEE, Entity1_15Types.EntityType.PUFFER_FISH).mobName("Bee").spawnMetadata(storage -> {
storage.add(new Metadata(14, MetaType1_14.Boolean, false));
storage.add(new Metadata(15, MetaType1_14.VarInt, 2));
});
registerMetaHandler().filter(Entity1_15Types.EntityType.ENDERMAN, 16).removed();
registerMetaHandler().filter(Entity1_15Types.EntityType.TRIDENT, 10).removed();
registerMetaHandler().filter(Entity1_15Types.EntityType.WOLF).handle(e -> {
int index = e.getIndex();
if (index >= 17) {
e.getData().setId(index + 1); // redundant health removed in 1.15
}
return e.getData();
});
}
@Override
protected EntityType getTypeFromId(int typeId) {
return Entity1_15Types.getTypeFromId(typeId);
}
@Override
protected int getOldEntityId(final int newId) {
return EntityTypeMapping.getOldEntityId(newId);
}
}

View File

@ -60,7 +60,7 @@ public class EntityPackets1_14_1 extends EntityRewriter<Protocol1_14To1_14_1> {
int type = wrapper.get(Type.VAR_INT, 1);
// Register Type ID
addTrackedEntity(wrapper.user(), entityId, Entity1_14Types.getTypeFromId(type));
addTrackedEntity(wrapper, entityId, Entity1_14Types.getTypeFromId(type));
MetaStorage storage = new MetaStorage(wrapper.get(Types1_14.METADATA_LIST, 0));
handleMeta(wrapper.user(), entityId, storage);

View File

@ -29,6 +29,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10> {
protected void registerPackets(Protocol1_9_4To1_10 protocol) {
jsonNameFormat = false;
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
// Set slot packet
@ -176,11 +177,11 @@ public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10>
@Override
protected void registerRewrites() {
rewrite(255).repItem(new Item((short) 166, (byte) 1, (short) 0, getNamedTag("1.10 Structure Block"))); // Structure block only item since the structure block is in 1.9
rewrite(217).repItem(new Item((short) 287, (byte) 1, (short) 0, getNamedTag("1.10 Structure Void"))).repBlock(new Block(287, 0)); // Structure void to string
rewrite(213).repItem(new Item((short) 159, (byte) 1, (short) 1, getNamedTag("1.10 Magma Block"))).repBlock(new Block(159, 1)); // Magma block to orange clay
rewrite(214).repItem(new Item((short) 159, (byte) 1, (short) 14, getNamedTag("1.10 Nether Wart Block"))).repBlock(new Block(159, 14)); // Nether wart block to red clay
rewrite(215).repItem(new Item((short) 112, (byte) 1, (short) 0, getNamedTag("1.10 Red Nether Bricks"))).repBlock(new Block(112, 0)); // Red nether brick to nether brick
rewrite(216).repItem(new Item((short) 155, (byte) 1, (short) 0, getNamedTag("1.10 Bone Block"))).repBlock(new Block(155, 0)); // Bone block to quartz
rewrite(255).repItem(new Item(166, (byte) 1, (short) 0, getNamedTag("1.10 Structure Block"))); // Structure block only item since the structure block is in 1.9
rewrite(217).repItem(new Item(287, (byte) 1, (short) 0, getNamedTag("1.10 Structure Void"))).repBlock(new Block(287, 0)); // Structure void to string
rewrite(213).repItem(new Item(159, (byte) 1, (short) 1, getNamedTag("1.10 Magma Block"))).repBlock(new Block(159, 1)); // Magma block to orange clay
rewrite(214).repItem(new Item(159, (byte) 1, (short) 14, getNamedTag("1.10 Nether Wart Block"))).repBlock(new Block(159, 14)); // Nether wart block to red clay
rewrite(215).repItem(new Item(112, (byte) 1, (short) 0, getNamedTag("1.10 Red Nether Bricks"))).repBlock(new Block(112, 0)); // Red nether brick to nether brick
rewrite(216).repItem(new Item(155, (byte) 1, (short) 0, getNamedTag("1.10 Bone Block"))).repBlock(new Block(155, 0)); // Bone block to quartz
}
}

View File

@ -343,7 +343,6 @@
"minecraft:black_bed[facing=east,occupied=false,part=foot]": "minecraft:red_bed[facing=east,occupied=false,part=foot]",
"minecraft:seagrass": "minecraft:grass",
"minecraft:tall_seagrass[half=upper]": "id:2809",
//2809 / 175:9 is the upper half of every flower in 1.12.2, the lower half determines the type
"minecraft:tall_seagrass[half=lower]": "minecraft:tall_grass[half=lower]",
"minecraft:sunflower[half=upper]": "id:2809",
"minecraft:lilac[half=upper]": "id:2809",
@ -5436,5 +5435,120 @@
"minecraft:dragon_head[rotation=13]": "id:2305",
"minecraft:dragon_head[rotation=14]": "id:2305",
"minecraft:dragon_head[rotation=15]": "id:2305"
},
"sounds": {
"ambient.underwater.enter": "block.water.ambient",
"ambient.underwater.exit": "block.water.ambient",
"ambient.underwater.loop": "entity.boat.paddle_water",
"ambient.underwater.loop.additions": "block.water.ambient",
"ambient.underwater.loop.additions.rare": "entity.elder_guardian.death",
"ambient.underwater.loop.additions.ultra_rare": "entity.elder_guardian.death",
"block.beacon.activate": "entity.elder_guardian.curse",
"block.beacon.ambient": "entity.elder_guardian.ambient",
"block.beacon.deactivate": "entity.elder_guardian.death",
"block.beacon.power_select": "entity.elder_guardian.hurt_land",
"block.bubble_column.bubble_pop": "block.lava.pop",
"block.bubble_column.upwards_ambient": "block.water.ambient",
"block.bubble_column.upwards_inside": "block.water.ambient",
"block.bubble_column.whirlpool_ambient": "block.water.ambient",
"block.bubble_column.whirlpool_inside": "block.water.ambient",
"block.conduit.activate": "block.chorus_flower.grow",
"block.conduit.ambient": "block.enchantment_table.use",
"block.conduit.ambient.short": "block.enchantment_table.use",
"block.conduit.attack.target": "block.shulker_box.open",
"block.conduit.deactivate": "enchant.thorns.hit",
"block.wet_grass.break": "block.grass.break",
"block.wet_grass.fall": "block.grass.fall",
"block.wet_grass.hit": "block.grass.hit",
"block.wet_grass.place": "block.grass.place",
"block.wet_grass.step": "block.grass.step",
"block.coral_block.break": "block.metal.break",
"block.coral_block.fall": "block.metal.fall",
"block.coral_block.hit": "block.metal.hit",
"block.coral_block.place": "block.metal.place",
"block.coral_block.step": "block.metal.step",
"block.pumpkin.carve": "block.gravel.break",
"entity.cod.ambient": "entity.elder_guardian.flop",
"entity.cod.death": "entity.elder_guardian.flop",
"entity.cod.flop": "entity.elder_guardian.flop",
"entity.cod.hurt": "entity.elder_guardian.hurt_land",
"entity.dolphin.ambient": "entity.bat.ambient",
"entity.dolphin.ambient_water": "entity.fishing_bobber.splash",
"entity.dolphin.attack": "entity.bat.hurt",
"entity.dolphin.death": "entity.bat.death",
"entity.dolphin.eat": "entity.parrot.eat",
"entity.dolphin.hurt": "entity.bat.hurt",
"entity.dolphin.jump": "entity.fishing_bobber.splash",
"entity.dolphin.play": "entity.fishing_bobber.splash",
"entity.dolphin.splash": "entity.fishing_bobber.splash",
"entity.dolphin.swim": "entity.boat.paddle_water",
"entity.drowned.ambient": "entity.zombie.ambient",
"entity.drowned.ambient_water": "entity.zombie.ambient",
"entity.drowned.death": "entity.zombie.death",
"entity.drowned.death_water": "entity.zombie.death",
"entity.drowned.hurt": "entity.zombie.hurt",
"entity.drowned.hurt_water": "entity.zombie.hurt",
"entity.drowned.shoot": "entity.ender_eye.launch",
"entity.drowned.step": "entity.zombie.step",
"entity.drowned.swim": "entity.boat.paddle_water",
"entity.fish.swim": "entity.boat.paddle_water",
"entity.husk.converted_to_zombie": "entity.zombie_villager.cure",
"entity.parrot.imitate.drowned": "entity.zombie.ambient",
"entity.parrot.imitate.phantom": "entity.blaze.ambient",
"entity.phantom.ambient": "entity.blaze.ambient",
"entity.phantom.bite": "entity.blaze.shoot",
"entity.phantom.death": "entity.blaze.death",
"entity.phantom.flap": "entity.bat.loop",
"entity.phantom.hurt": "entity.blaze.hurt",
"entity.phantom.swoop": "entity.blaze.ambient",
"entity.player.splash.high_speed": "entity.fishing_bobber.splash",
"entity.puffer_fish.ambient": "entity.guardian.flop",
"entity.puffer_fish.blow_out": "block.redstone_torch.burnout",
"entity.puffer_fish.blow_up": "block.lava.extinguish",
"entity.puffer_fish.death": "enchant.thorns.hit",
"entity.puffer_fish.flop": "entity.guardian.flop",
"entity.puffer_fish.hurt": "entity.guardian.hurt_land",
"entity.puffer_fish.sting": "entity.blaze.hurt",
"entity.salmon.ambient": "entity.guardian.flop",
"entity.salmon.death": "entity.guardian.hurt_land",
"entity.salmon.flop": "entity.guardian.flop",
"entity.salmon.hurt": "entity.guardian.flop",
"entity.skeleton_horse.swim": "entity.generic.swim",
"entity.skeleton_horse.ambient_water": "entity.horse.ambient",
"entity.skeleton_horse.gallop_water": "entity.horse.gallop",
"entity.skeleton_horse.jump_water": "entity.horse.jump",
"entity.skeleton_horse.step_water": "entity.horse.step",
"entity.squid.squirt": "entity.squid.ambient",
"entity.tropical_fish.ambient": "entity.guardian.flop",
"entity.tropical_fish.death": "entity.slime.death",
"entity.tropical_fish.flop": "entity.guardian.flop",
"entity.tropical_fish.hurt": "entity.slime.hurt",
"entity.turtle.ambient_land": "block.sand.hit",
"entity.turtle.death": "entity.endermite.death",
"entity.turtle.death_baby": "entity.endermite.death",
"entity.turtle.egg_break": "entity.chicken.egg",
"entity.turtle.egg_crack": "entity.chicken.egg",
"entity.turtle.egg_hatch": "entity.chicken.egg",
"entity.turtle.hurt": "entity.chicken.egg",
"entity.turtle.hurt_baby": "entity.endermite.hurt",
"entity.turtle.lay_egg": "entity.chicken.egg",
"entity.turtle.shamble": "block.sand.step",
"entity.turtle.shamble_baby": "block.sand.step",
"entity.turtle.swim": "item.bucket.empty",
"entity.zombie.converted_to_drowned": "item.bucket.empty",
"entity.zombie.destroy_egg": "entity.chicken.egg",
"item.armor.equip_turtle": "item.armor.equip_generic",
"item.axe.strip": "block.wood.break",
"item.bucket.empty_fish": "item.bucket.empty",
"item.bucket.fill_fish": "item.bottle.fill",
"item.trident.hit": "entity.stray.step",
"item.trident.hit_ground": "entity.arrow.hit",
"item.trident.return": "item.armor.equip_diamond",
"item.trident.riptide_1": "entity.arrow.shoot",
"item.trident.riptide_2": "entity.arrow.shoot",
"item.trident.riptide_3": "entity.arrow.shoot",
"item.trident.throw": "entity.skeleton.shoot",
"item.trident.thunder": "entity.lightning_bolt.thunder",
"music.under_water": "music.creative"
}
}

View File

@ -2658,5 +2658,140 @@
"minecraft:jigsaw[facing=west]": "minecraft:structure_block[mode=corner]",
"minecraft:jigsaw[facing=up]": "minecraft:structure_block[mode=corner]",
"minecraft:jigsaw[facing=down]": "minecraft:structure_block[mode=corner]"
},
"sounds": {
"block.bamboo.break": "block.grass.break",
"block.bamboo.fall": "block.grass.fall",
"block.bamboo.hit": "block.grass.hit",
"block.bamboo.place": "block.grass.place",
"block.bamboo.step": "block.grass.step",
"block.bamboo_sapling.break": "block.grass.break",
"block.bamboo_sapling.hit": "block.sand.break",
"block.bamboo_sapling.place": "block.gravel.place",
"block.barrel.close": "block.wooden_trapdoor.close",
"block.barrel.open": "block.wooden_trapdoor.open",
"block.bell.use": "block.anvil.land",
"block.bell.resonate": "block.enchantment_table.use",
"item.book.page_turn": "",
"item.book.put": "block.wood.step",
"block.blastfurnace.fire_crackle": "block.furnace.fire_crackle",
"block.campfire.crackle": "block.fire.ambient",
"entity.cat.stray_ambient": "entity.cat.ambient",
"entity.cat.eat": "entity.cod.flop",
"entity.cat.beg_for_food": "entity.cat.ambient",
"block.composter.empty": "block.grass.break",
"block.composter.fill": "block.gravel.break",
"block.composter.fill_success": "block.gravel.break",
"block.composter.ready": "block.gravel.break",
"block.crop.break": "block.grass.break",
"item.crop.plant": "block.grass.place",
"item.crossbow.hit": "entity.arrow.hit",
"item.crossbow.loading_end": "block.tripwire.detach",
"item.crossbow.loading_middle": "block.comparator.click",
"item.crossbow.loading_start": "block.comparator.click",
"item.crossbow.quick_charge_1": "block.comparator.click",
"item.crossbow.quick_charge_2": "block.comparator.click",
"item.crossbow.quick_charge_3": "block.comparator.click",
"item.crossbow.shoot": "entity.arrow.shoot",
"entity.evoker.celebrate": "entity.villager.yes",
"entity.fox.aggro": "entity.wolf.growl",
"entity.fox.ambient": "entity.wolf.ambient",
"entity.fox.bite": "entity.dolphin.hurt",
"entity.fox.death": "entity.wolf.death",
"entity.fox.eat": "entity.dolphin.eat",
"entity.fox.hurt": "entity.wolf.hurt",
"entity.fox.screech": "entity.wolf.ambient",
"entity.fox.sleep": "entity.wolf.growl",
"entity.fox.sniff": "entity.wolf.pant",
"entity.fox.spit": "entity.llama.spit",
"block.grindstone.use": "block.iron_door.open",
"entity.ravager.ambient": "entity.polar_bear.ambient",
"entity.ravager.attack": "entity.polar_bear.warning",
"entity.ravager.celebrate": "entity.enderman.ambient",
"entity.ravager.death": "entity.polar_bear.death",
"entity.ravager.hurt": "entity.polar_bear.hurt",
"entity.ravager.step": "entity.polar_bear.step",
"entity.ravager.stunned": "entity.polar_bear.ambient",
"entity.ravager.roar": "entity.polar_bear.warning",
"block.lantern.break": "block.glass.break",
"block.lantern.fall": "block.glass.fall",
"block.lantern.hit": "block.glass.hit",
"block.lantern.place": "block.glass.place",
"block.lantern.step": "block.glass.step",
"entity.mooshroom.convert": "entity.zombie_villager.converted",
"entity.mooshroom.eat": "entity.boat.paddle_land",
"entity.mooshroom.milk": "entity.cow.milk",
"entity.mooshroom.suspicious_milk": "entity.cow.milk",
"block.nether_wart.break": "block.wet_grass.break",
"item.nether_wart.plant": "block.wet_grass.place",
"block.note_block.iron_xylophone": "block.note_block.xylophone",
"block.note_block.cow_bell": "block.note_block.bell",
"block.note_block.didgeridoo": "block.note_block.bass",
"block.note_block.bit": "block.note_block.pling",
"block.note_block.banjo": "block.note_block.chime",
"entity.ocelot.hurt": "entity.cat.hurt",
"entity.ocelot.ambient": "entity.cat.purreow",
"entity.ocelot.death": "entity.cat.death",
"entity.panda.pre_sneeze": "entity.turtle.hurt_baby",
"entity.panda.sneeze": "entity.bat.ambient",
"entity.panda.ambient": "entity.turtle.hurt_baby",
"entity.panda.death": "entity.turtle.death_baby",
"entity.panda.eat": "entity.turtle.egg_crack",
"entity.panda.step": "entity.turtle.shamble",
"entity.panda.cant_breed": "entity.polar_bear.ambient_baby",
"entity.panda.aggressive_ambient": "entity.polar_bear.warning",
"entity.panda.worried_ambient": "entity.polar_bear.ambient_baby",
"entity.panda.hurt": "entity.polar_bear.hurt",
"entity.panda.bite": "entity.polar_bear.step",
"entity.pillager.ambient": "entity.villager.ambient",
"entity.pillager.celebrate": "entity.vindicator.ambient",
"entity.pillager.death": "entity.vindicator.death",
"entity.pillager.hurt": "entity.vindicator.hurt",
"entity.player.hurt_sweet_berry_bush": "block.grass.step",
"event.raid.horn": "entity.wither.death",
"block.scaffolding.break": "block.wood.break",
"block.scaffolding.fall": "block.wood.fall",
"block.scaffolding.hit": "block.wood.hit",
"block.scaffolding.place": "block.wood.place",
"block.scaffolding.step": "block.wood.step",
"block.smoker.smoke": "block.fire.ambient",
"block.sweet_berry_bush.break": "block.gravel.break",
"block.sweet_berry_bush.place": "block.gravel.place",
"item.sweet_berries.pick_from_bush": "block.grass.hit",
"ui.loom.select_pattern": "item.flintandsteel.use",
"ui.loom.take_result": "block.wooden_door.close",
"ui.cartography_table.take_result": "block.enchantment_table.use",
"ui.stonecutter.take_result": "entity.horse.breathe",
"ui.stonecutter.select_recipe": "ui.button.click",
"entity.villager.celebrate": "entity.villager.ambient",
"entity.villager.work_armorer": "entity.villager.ambient",
"entity.villager.work_butcher": "entity.villager.ambient",
"entity.villager.work_cartographer": "entity.villager.ambient",
"entity.villager.work_cleric": "entity.villager.ambient",
"entity.villager.work_farmer": "entity.villager.ambient",
"entity.villager.work_fisherman": "entity.villager.ambient",
"entity.villager.work_fletcher": "entity.villager.ambient",
"entity.villager.work_leatherworker": "entity.villager.ambient",
"entity.villager.work_librarian": "entity.villager.ambient",
"entity.villager.work_mason": "entity.villager.ambient",
"entity.villager.work_shepherd": "entity.villager.ambient",
"entity.villager.work_toolsmith": "entity.villager.ambient",
"entity.villager.work_weaponsmith": "entity.villager.ambient",
"entity.vindicator.celebrate": "entity.villager.no",
"entity.wandering_trader.ambient": "entity.villager.ambient",
"entity.wandering_trader.death": "entity.villager.death",
"entity.wandering_trader.disappeared": "entity.enderman.teleport",
"entity.wandering_trader.drink_milk": "entity.witch.drink",
"entity.wandering_trader.drink_potion": "entity.generic.drink",
"entity.wandering_trader.hurt": "entity.villager.hurt",
"entity.wandering_trader.no": "entity.villager.no",
"entity.wandering_trader.reappeared": "entity.villager.yes",
"entity.wandering_trader.trade": "entity.villager.trade",
"entity.wandering_trader.yes": "entity.villager.yes",
"entity.witch.celebrate": "entity.witch.ambient",
"entity.parrot.imitate.guardian": "",
"entity.parrot.imitate.panda": "",
"entity.parrot.imitate.pillager": "",
"entity.parrot.imitate.ravager": ""
}
}

View File

@ -0,0 +1,62 @@
{
"blockstates": {
"minecraft:bell[attachment=floor,facing=north,powered=true]": "minecraft:bell[attachment=floor,facing=north]",
"minecraft:bell[attachment=floor,facing=north,powered=false]": "minecraft:bell[attachment=floor,facing=north]",
"minecraft:bell[attachment=floor,facing=south,powered=true]": "minecraft:bell[attachment=floor,facing=south]",
"minecraft:bell[attachment=floor,facing=south,powered=false]": "minecraft:bell[attachment=floor,facing=south]",
"minecraft:bell[attachment=floor,facing=west,powered=true]": "minecraft:bell[attachment=floor,facing=west]",
"minecraft:bell[attachment=floor,facing=west,powered=false]": "minecraft:bell[attachment=floor,facing=west]",
"minecraft:bell[attachment=floor,facing=east,powered=true]": "minecraft:bell[attachment=floor,facing=east]",
"minecraft:bell[attachment=floor,facing=east,powered=false]": "minecraft:bell[attachment=floor,facing=east]",
"minecraft:bell[attachment=ceiling,facing=north,powered=true]": "minecraft:bell[attachment=ceiling,facing=north]",
"minecraft:bell[attachment=ceiling,facing=north,powered=false]": "minecraft:bell[attachment=ceiling,facing=north]",
"minecraft:bell[attachment=ceiling,facing=south,powered=true]": "minecraft:bell[attachment=ceiling,facing=south]",
"minecraft:bell[attachment=ceiling,facing=south,powered=false]": "minecraft:bell[attachment=ceiling,facing=south]",
"minecraft:bell[attachment=ceiling,facing=west,powered=true]": "minecraft:bell[attachment=ceiling,facing=west]",
"minecraft:bell[attachment=ceiling,facing=west,powered=false]": "minecraft:bell[attachment=ceiling,facing=west]",
"minecraft:bell[attachment=ceiling,facing=east,powered=true]": "minecraft:bell[attachment=ceiling,facing=east]",
"minecraft:bell[attachment=ceiling,facing=east,powered=false]": "minecraft:bell[attachment=ceiling,facing=east]",
"minecraft:bell[attachment=single_wall,facing=north,powered=true]": "minecraft:bell[attachment=single_wall,facing=north]",
"minecraft:bell[attachment=single_wall,facing=north,powered=false]": "minecraft:bell[attachment=single_wall,facing=north]",
"minecraft:bell[attachment=single_wall,facing=south,powered=true]": "minecraft:bell[attachment=single_wall,facing=south]",
"minecraft:bell[attachment=single_wall,facing=south,powered=false]": "minecraft:bell[attachment=single_wall,facing=south]",
"minecraft:bell[attachment=single_wall,facing=west,powered=true]": "minecraft:bell[attachment=single_wall,facing=west]",
"minecraft:bell[attachment=single_wall,facing=west,powered=false]": "minecraft:bell[attachment=single_wall,facing=west]",
"minecraft:bell[attachment=single_wall,facing=east,powered=true]": "minecraft:bell[attachment=single_wall,facing=east]",
"minecraft:bell[attachment=single_wall,facing=east,powered=false]": "minecraft:bell[attachment=single_wall,facing=east]",
"minecraft:bell[attachment=double_wall,facing=north,powered=true]": "minecraft:bell[attachment=double_wall,facing=north]",
"minecraft:bell[attachment=double_wall,facing=north,powered=false]": "minecraft:bell[attachment=double_wall,facing=north]",
"minecraft:bell[attachment=double_wall,facing=south,powered=true]": "minecraft:bell[attachment=double_wall,facing=south]",
"minecraft:bell[attachment=double_wall,facing=south,powered=false]": "minecraft:bell[attachment=double_wall,facing=south]",
"minecraft:bell[attachment=double_wall,facing=west,powered=true]": "minecraft:bell[attachment=double_wall,facing=west]",
"minecraft:bell[attachment=double_wall,facing=west,powered=false]": "minecraft:bell[attachment=double_wall,facing=west]",
"minecraft:bell[attachment=double_wall,facing=east,powered=true]": "minecraft:bell[attachment=double_wall,facing=east]",
"minecraft:bell[attachment=double_wall,facing=east,powered=false]": "minecraft:bell[attachment=double_wall,facing=east]",
"minecraft:honey_block": "minecraft:slime_block",
"minecraft:honeycomb_block": "minecraft:horn_coral_block",
"minecraft:beehive": "minecraft:barrel[facing=up,open=false]",
"minecraft:bee_nest": "minecraft:yellow_shulker_box[facing=up]"
},
"sounds": {
"entity.bee.death": "entity.creeper.death",
"entity.bee.hurt": "entity.bat.hurt",
"entity.bee.loop_aggressive": "entity.enderman.scream",
"entity.bee.loop": "entity.parrot.fly",
"entity.bee.sting": "entity.phantom.bite",
"entity.bee.pollinate": "entity.parrot.fly",
"block.beehive.drip": "entity.slime.squish",
"block.beehive.enter": "entity.slime.death",
"block.beehive.exit": "entity.slime.death_small",
"block.beehive.shear": "block.wool.hit",
"block.beehive.work": "entity.parrot.fly",
"block.honey_block.break": "block.slime_block.break",
"block.honey_block.fall": "block.slime_block.fall",
"block.honey_block.hit": "block.slime_block.hit",
"block.honey_block.place": "block.slime_block.place",
"block.honey_block.slide": "block.slime_block.fall",
"block.honey_block.step": "block.slime_block.step",
"item.honey_bottle.drink": "entity.generic.drink",
"entity.iron_golem.damage": "entity.item.break",
"entity.iron_golem.repair": "entity.iron_golem.step"
}
}

View File

@ -12,7 +12,7 @@
},
"environment": "*",
"authors": [
"Matsv"
"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1"
],
"entrypoints": {
"viafabric:via_api_initialized": [

View File

@ -21,7 +21,7 @@
<description>Allow newer clients to join older server versions.</description>
<inceptionYear>2016</inceptionYear>
<url>https://www.spigotmc.org/resources/viaversion.19254/</url>
<url>https://github.com/ViaVersion/ViaBackwards</url>
<modules>
<module>core</module>
@ -54,14 +54,14 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<!-- ViaVersion -->
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>2.1.4-19w39a</version>
<version>3.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -28,7 +28,7 @@ import java.util.logging.Logger;
@Plugin(id = "viabackwards",
name = "ViaBackwards",
version = VersionInfo.VERSION,
authors = {"Matsv"},
authors = {"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1"},
description = "Allow older Minecraft versions to connect to a newer server version.",
dependencies = {@Dependency(id = "viaversion")}
)

View File

@ -28,7 +28,7 @@ import java.util.logging.Logger;
@Plugin(id = "viabackwards",
name = "ViaBackwards",
version = VersionInfo.VERSION,
authors = {"Matsv"},
authors = {"Matsv", "KennyTV", "Gerrygames", "creeper123123321", "ForceUpdate1"},
description = "Allow older Minecraft versions to connect to a newer server version.",
dependencies = {@Dependency(id = "viaversion")}
)