mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2026-11-04 17:00:16 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
819d7f3d39 | ||
|
|
25404d6c92 | ||
|
|
b340c7246b | ||
|
|
2669967b49 | ||
|
|
e945db8cb6 | ||
|
|
9a09e53572 | ||
|
|
0c040db6f0 | ||
|
|
46c7cab3a4 | ||
|
|
922afc12a5 | ||
|
|
4817bf7e2b | ||
|
|
0b93cd0e09 | ||
|
|
b1af6ad721 | ||
|
|
c6d8a83ac9 | ||
|
|
72a070da3e | ||
|
|
dbe0f7049e | ||
|
|
91b81ebb24 | ||
|
|
897e9545c2 | ||
|
|
947e5c3e07 |
No files matched your search
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-all</artifactId>
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bukkit</artifactId>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package nl.matsv.viabackwards;
|
||||
|
||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||
import nl.matsv.viabackwards.listener.FireExtinguishListener;
|
||||
import nl.matsv.viabackwards.listener.LecternInteractListener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@@ -27,8 +28,11 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
|
||||
}
|
||||
|
||||
private void onServerLoaded() {
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getId()) {
|
||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||
BukkitViaLoader loader = (BukkitViaLoader) Via.getManager().getLoader();
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_16.getVersion()) {
|
||||
loader.storeListener(new FireExtinguishListener(this)).register();
|
||||
}
|
||||
if (ProtocolRegistry.SERVER_PROTOCOL >= ProtocolVersion.v1_14.getVersion()) {
|
||||
loader.storeListener(new LecternInteractListener(this)).register();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package nl.matsv.viabackwards.listener;
|
||||
|
||||
import nl.matsv.viabackwards.BukkitPlugin;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener;
|
||||
|
||||
public class FireExtinguishListener extends ViaBukkitListener {
|
||||
|
||||
public FireExtinguishListener(BukkitPlugin plugin) {
|
||||
super(plugin, Protocol1_15_2To1_16.class);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onFireExtinguish(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Block relative = block.getRelative(event.getBlockFace());
|
||||
if (relative.getType() == Material.FIRE) {
|
||||
event.setCancelled(true);
|
||||
relative.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,12 @@ public class LecternInteractListener extends ViaBukkitListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onLecternInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null || block.getType() != Material.LECTERN) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!isOnPipe(player)) return;
|
||||
|
||||
Lectern lectern = (Lectern) block.getState();
|
||||
ItemStack book = lectern.getInventory().getItem(0);
|
||||
if (book == null) return;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bungee</artifactId>
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-core</artifactId>
|
||||
|
||||
@@ -13,6 +13,7 @@ public class ViaBackwardsConfig extends Config implements nl.matsv.viabackwards.
|
||||
private boolean addCustomEnchantsToLore;
|
||||
private boolean addTeamColorToPrefix;
|
||||
private boolean fix1_13FacePlayer;
|
||||
private boolean alwaysShowOriginalMobName;
|
||||
|
||||
public ViaBackwardsConfig(File configFile) {
|
||||
super(configFile);
|
||||
@@ -28,6 +29,7 @@ public class ViaBackwardsConfig extends Config implements nl.matsv.viabackwards.
|
||||
addCustomEnchantsToLore = getBoolean("add-custom-enchants-into-lore", true);
|
||||
addTeamColorToPrefix = getBoolean("add-teamcolor-to-prefix", true);
|
||||
fix1_13FacePlayer = getBoolean("fix-1_13-face-player", false);
|
||||
alwaysShowOriginalMobName = getBoolean("always-show-original-mob-name", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,6 +47,11 @@ public class ViaBackwardsConfig extends Config implements nl.matsv.viabackwards.
|
||||
return fix1_13FacePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alwaysShowOriginalMobName() {
|
||||
return alwaysShowOriginalMobName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDefaultConfigURL() {
|
||||
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package nl.matsv.viabackwards.api;
|
||||
|
||||
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
@@ -12,18 +13,9 @@ public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 ext
|
||||
protected BackwardsProtocol() {
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(boolean hasMappingDataToLoad) {
|
||||
super(hasMappingDataToLoad);
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false);
|
||||
}
|
||||
|
||||
protected BackwardsProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum, boolean hasMappingDatatToLoad) {
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, hasMappingDatatToLoad);
|
||||
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,4 +24,15 @@ public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 ext
|
||||
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
|
||||
ProtocolRegistry.addMappingLoaderFuture(getClass(), protocolClass, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMappingDataToLoad() {
|
||||
// Manually load them later, since they depend on VV's mappings
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,11 @@ public interface ViaBackwardsConfig {
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean isFix1_13FacePlayer();
|
||||
|
||||
/**
|
||||
* Always shows the original mob's name instead of only when hovering over them with the cursor.
|
||||
*
|
||||
* @return true if enabled
|
||||
*/
|
||||
boolean alwaysShowOriginalMobName();
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2.Protocol1_15_1To1_1
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15to1_15_1.Protocol1_15To1_15_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_2to1_16_3.Protocol1_16_2To1_16_3;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_3to1_16_4.Protocol1_16_3To1_16_4;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
@@ -45,7 +46,7 @@ import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "3.1.1";
|
||||
String MINIMUM_VV_VERSION = "3.2.0";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
@@ -92,6 +93,7 @@ public interface ViaBackwardsPlatform {
|
||||
registerProtocol(new Protocol1_16To1_16_1(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
|
||||
registerProtocol(new Protocol1_16_1To1_16_2(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
|
||||
registerProtocol(new Protocol1_16_2To1_16_3(), ProtocolVersion.v1_16_2, ProtocolVersion.v1_16_3);
|
||||
registerProtocol(new Protocol1_16_3To1_16_4(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
package nl.matsv.viabackwards.api.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.MappingData;
|
||||
import us.myles.ViaVersion.api.data.Mappings;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BackwardsMappings extends MappingData {
|
||||
|
||||
private final Class<? extends Protocol> vvProtocolClass;
|
||||
private Int2ObjectMap<MappedItem> backwardsItemMappings;
|
||||
private Map<String, String> backwardsSoundMappings;
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass) {
|
||||
this(oldVersion, newVersion, vvProtocolClass, false);
|
||||
}
|
||||
|
||||
public BackwardsMappings(String oldVersion, String newVersion, @Nullable Class<? extends Protocol> vvProtocolClass, boolean hasDiffFile) {
|
||||
super(oldVersion, newVersion, hasDiffFile);
|
||||
Preconditions.checkArgument(!vvProtocolClass.isAssignableFrom(BackwardsProtocol.class));
|
||||
this.vvProtocolClass = vvProtocolClass;
|
||||
// Just re-use ViaVersion's item id map
|
||||
loadItems = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadExtras(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings) {
|
||||
if (diffMappings != null) {
|
||||
JsonObject diffItems = diffMappings.getAsJsonObject("items");
|
||||
if (diffItems != null) {
|
||||
backwardsItemMappings = VBMappingDataLoader.loadItemMappings(oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"), diffItems);
|
||||
}
|
||||
|
||||
JsonObject diffSounds = diffMappings.getAsJsonObject("sounds");
|
||||
if (diffSounds != null) {
|
||||
backwardsSoundMappings = VBMappingDataLoader.objectToMap(diffSounds);
|
||||
}
|
||||
}
|
||||
|
||||
// Just re-use ViaVersion's item id map
|
||||
if (vvProtocolClass != null) {
|
||||
itemMappings = ProtocolRegistry.getProtocol(vvProtocolClass).getMappingData().getItemMappings().inverse();
|
||||
}
|
||||
|
||||
loadVBExtras(oldMappings, newMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Mappings loadFromArray(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new VBMappings(oldMappings.getAsJsonArray(key), newMappings.getAsJsonArray(key), diff, shouldWarnOnMissing(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (!oldMappings.has(key) || !newMappings.has(key)) return null;
|
||||
|
||||
JsonObject diff = diffMappings != null ? diffMappings.getAsJsonObject(key) : null;
|
||||
return new VBMappings(oldMappings.getAsJsonObject(key), newMappings.getAsJsonObject(key), diff, shouldWarnOnMissing(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject loadDiffFile() {
|
||||
return VBMappingDataLoader.loadFromDataDir("mapping-" + newVersion + "to" + oldVersion + ".json");
|
||||
}
|
||||
|
||||
/**
|
||||
* To be overridden.
|
||||
*/
|
||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
}
|
||||
|
||||
protected boolean shouldWarnOnMissing(String key) {
|
||||
return !key.equals("blocks") && !key.equals("statistics");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getMappedItem(int) for custom backwards mappings
|
||||
*/
|
||||
@Override
|
||||
public int getNewItemId(int id) {
|
||||
// Don't warn on missing here
|
||||
return this.itemMappings.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlockId(int id) {
|
||||
// Don't warn on missing here
|
||||
return this.blockMappings.getNewId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOldItemId(final int id) {
|
||||
// Warn on missing
|
||||
return checkValidity(id, this.itemMappings.inverse().get(id), "item");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MappedItem getMappedItem(int id) {
|
||||
return backwardsItemMappings != null ? backwardsItemMappings.get(id) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMappedNamedSound(String id) {
|
||||
return backwardsSoundMappings != null ? backwardsSoundMappings.get(id) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Int2ObjectMap<MappedItem> getBackwardsItemMappings() {
|
||||
return backwardsItemMappings;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, String> getBackwardsSoundMappings() {
|
||||
return backwardsSoundMappings;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package nl.matsv.viabackwards.api.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Backwards mappings for newly (!) added items.
|
||||
*/
|
||||
public class VBItemMappings {
|
||||
|
||||
private final Int2ObjectMap<MappedItem> itemMapping;
|
||||
|
||||
public VBItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
|
||||
Map<Integer, MappedItem> itemMapping = new HashMap<>();
|
||||
for (Map.Entry<String, JsonElement> entry : diffMapping.entrySet()) {
|
||||
JsonObject object = entry.getValue().getAsJsonObject();
|
||||
String mappedIdName = object.getAsJsonPrimitive("id").getAsString();
|
||||
Map.Entry<String, JsonElement> value = MappingDataLoader.findValue(newMapping, mappedIdName);
|
||||
if (value == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
Map.Entry<String, JsonElement> oldEntry = MappingDataLoader.findValue(oldMapping, entry.getKey());
|
||||
if (oldEntry == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No old entry for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = Integer.parseInt(oldEntry.getKey());
|
||||
int mappedId = Integer.parseInt(value.getKey());
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
itemMapping.put(id, new MappedItem(mappedId, name));
|
||||
}
|
||||
|
||||
this.itemMapping = new Int2ObjectOpenHashMap<>(itemMapping, 1F);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MappedItem getMappedItem(int id) {
|
||||
return itemMapping.get(id);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ 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.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import us.myles.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonIOException;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
@@ -16,6 +18,7 @@ import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class VBMappingDataLoader {
|
||||
@@ -43,6 +46,7 @@ public class VBMappingDataLoader {
|
||||
try (InputStreamReader reader = new InputStreamReader(stream)) {
|
||||
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -52,10 +56,11 @@ public class VBMappingDataLoader {
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
|
||||
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(newIdentifiers);
|
||||
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) {
|
||||
int mappedId = newIdentifierMap.getInt(key);
|
||||
if (mappedId == -1) {
|
||||
if (diffIdentifiers != null) {
|
||||
// Search in diff mappings
|
||||
JsonPrimitive diffValueJson = diffIdentifiers.getAsJsonPrimitive(key);
|
||||
@@ -74,11 +79,11 @@ public class VBMappingDataLoader {
|
||||
}
|
||||
|
||||
if (diffValue != null) {
|
||||
value = MappingDataLoader.findValue(newIdentifiers, diffValue);
|
||||
mappedId = newIdentifierMap.getInt(diffValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
if (mappedId == -1) {
|
||||
// Nothing found :(
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
@@ -87,39 +92,53 @@ public class VBMappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
|
||||
output[Integer.parseInt(entry.getKey())] = (short) mappedId;
|
||||
}
|
||||
}
|
||||
|
||||
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().isSuppressConversionWarnings() || 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().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + key + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
public static Map<String, String> objectToMap(JsonObject object) {
|
||||
Map<String, String> mappings = new HashMap<>();
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.indexOf(':') == -1) {
|
||||
key = "minecraft:" + key;
|
||||
}
|
||||
output[i] = index.shortValue();
|
||||
String value = entry.getValue().getAsString();
|
||||
if (value.indexOf(':') == -1) {
|
||||
value = "minecraft:" + value;
|
||||
}
|
||||
mappings.put(key, value);
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MappedItem> loadItemMappings(JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping) {
|
||||
Int2ObjectMap<MappedItem> itemMapping = new Int2ObjectOpenHashMap<>(diffMapping.size(), 1F);
|
||||
Object2IntMap newIdenfierMap = MappingDataLoader.indexedObjectToMap(newMapping);
|
||||
Object2IntMap oldIdenfierMap = MappingDataLoader.indexedObjectToMap(oldMapping);
|
||||
for (Map.Entry<String, JsonElement> entry : diffMapping.entrySet()) {
|
||||
JsonObject object = entry.getValue().getAsJsonObject();
|
||||
String mappedIdName = object.getAsJsonPrimitive("id").getAsString();
|
||||
int mappedId = newIdenfierMap.getInt(mappedIdName);
|
||||
if (mappedId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
int oldId = oldIdenfierMap.getInt(entry.getKey());
|
||||
if (oldId == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No old entry for " + mappedIdName + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = object.getAsJsonPrimitive("name").getAsString();
|
||||
itemMapping.put(oldId, new MappedItem(mappedId, name));
|
||||
}
|
||||
|
||||
return itemMapping;
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,6 @@ import java.util.Arrays;
|
||||
|
||||
public class VBMappings extends Mappings {
|
||||
|
||||
public VBMappings(JsonObject oldMapping, JsonObject newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -28,8 +16,12 @@ public class VBMappings extends Mappings {
|
||||
super(create(oldMapping.entrySet().size(), oldMapping, newMapping, diffMapping, warnOnMissing));
|
||||
}
|
||||
|
||||
public VBMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
|
||||
super(create(oldMapping, newMapping, diffMapping, true));
|
||||
public VBMappings(JsonObject oldMapping, JsonObject newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping, newMapping, null, warnOnMissing);
|
||||
}
|
||||
|
||||
public VBMappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
super(oldMapping.size(), oldMapping, newMapping, diffMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
private static short[] create(int size, JsonObject oldMapping, JsonObject newMapping, JsonObject diffMapping, boolean warnOnMissing) {
|
||||
@@ -38,11 +30,4 @@ public class VBMappings extends Mappings {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package nl.matsv.viabackwards.api.data;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.data.Mappings;
|
||||
import us.myles.viaversion.libs.gson.JsonArray;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Backwards mappings for sound ids and names.
|
||||
*/
|
||||
public class VBSoundMappings {
|
||||
|
||||
private final Map<String, String> namedSoundMappings = new HashMap<>();
|
||||
private final Mappings idMappings;
|
||||
|
||||
public VBSoundMappings(JsonArray oldSounds, JsonArray newSounds, JsonObject diffMapping) {
|
||||
idMappings = new VBMappings(oldSounds, newSounds, diffMapping);
|
||||
for (Map.Entry<String, JsonElement> entry : diffMapping.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key.indexOf(':') == -1) {
|
||||
key = "minecraft:" + key;
|
||||
}
|
||||
String value = entry.getValue().getAsString();
|
||||
if (value.indexOf(':') == -1) {
|
||||
value = "minecraft:" + value;
|
||||
}
|
||||
namedSoundMappings.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNewId(String oldId) {
|
||||
return namedSoundMappings.get(oldId);
|
||||
}
|
||||
|
||||
public int getNewId(int oldId) {
|
||||
return idMappings.getNewId(oldId);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
@@ -18,14 +17,14 @@ import java.util.List;
|
||||
public abstract class EntityRewriter<T extends BackwardsProtocol> extends EntityRewriterBase<T> {
|
||||
|
||||
protected EntityRewriter(T protocol) {
|
||||
super(protocol, MetaType1_14.OptChat, 2);
|
||||
this(protocol, MetaType1_14.OptChat, MetaType1_14.Boolean);
|
||||
}
|
||||
|
||||
protected EntityRewriter(T protocol, MetaType displayType) {
|
||||
super(protocol, displayType, 2);
|
||||
protected EntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
super(protocol, displayType, 2, displayVisibilityType, 3);
|
||||
}
|
||||
|
||||
public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType, IdRewriteFunction blockStateRewriter) {
|
||||
public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@@ -42,7 +41,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Entity
|
||||
EntityType entityType = setOldEntityId(wrapper);
|
||||
if (entityType == fallingBlockType) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, blockStateRewriter.rewrite(blockState));
|
||||
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,15 +12,16 @@ import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.ParticleMappings;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
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_9;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
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.exception.CancelException;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
@@ -44,17 +45,18 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
private final Map<EntityType, EntityData> entityTypes = new HashMap<>();
|
||||
private final List<MetaHandlerSettings> metaHandlers = new ArrayList<>();
|
||||
private final MetaType displayNameMetaType;
|
||||
private final MetaType displayVisibilityMetaType;
|
||||
private final int displayNameIndex;
|
||||
private final int displayVisibilityIndex;
|
||||
protected Int2IntMap typeMapping;
|
||||
|
||||
EntityRewriterBase(T protocol) {
|
||||
this(protocol, MetaType1_9.String, 2);
|
||||
}
|
||||
|
||||
EntityRewriterBase(T protocol, MetaType displayNameMetaType, int displayNameIndex) {
|
||||
EntityRewriterBase(T protocol, MetaType displayNameMetaType, int displayNameIndex,
|
||||
MetaType displayVisibilityMetaType, int displayVisibilityIndex) {
|
||||
super(protocol);
|
||||
this.displayNameMetaType = displayNameMetaType;
|
||||
this.displayNameIndex = displayNameIndex;
|
||||
this.displayVisibilityMetaType = displayVisibilityMetaType;
|
||||
this.displayVisibilityIndex = displayVisibilityIndex;
|
||||
}
|
||||
|
||||
protected EntityType getEntityType(UserConnection connection, int id) {
|
||||
@@ -192,10 +194,15 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
Metadata data = storage.get(displayNameIndex);
|
||||
if (data != null) {
|
||||
EntityData entityData = getEntityData(type);
|
||||
// Set the name if there is no custom name set already
|
||||
if (entityData != null && entityData.getMobName() != null
|
||||
&& (data.getValue() == null || data.getValue().toString().isEmpty())
|
||||
&& data.getMetaType().getTypeID() == displayNameMetaType.getTypeID()) {
|
||||
data.setValue(entityData.getMobName());
|
||||
if (ViaBackwards.getConfig().alwaysShowOriginalMobName()) {
|
||||
storage.delete(displayVisibilityIndex);
|
||||
storage.add(new Metadata(displayVisibilityIndex, displayVisibilityMetaType, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,6 +269,20 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
|
||||
return user.get(EntityTracker.class).get(getProtocol());
|
||||
}
|
||||
|
||||
protected void rewriteParticle(Particle particle) {
|
||||
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
|
||||
int id = particle.getId();
|
||||
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
|
||||
Particle.ParticleData data = particle.getArguments().get(0);
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
|
||||
} else if (id == mappings.getItemId()) {
|
||||
Particle.ParticleData data = particle.getArguments().get(0);
|
||||
data.setValue(protocol.getMappingData().getNewItemId(data.get()));
|
||||
}
|
||||
|
||||
particle.setId(protocol.getMappingData().getNewParticleId(id));
|
||||
}
|
||||
|
||||
protected abstract EntityType getTypeFromId(int typeId);
|
||||
|
||||
public int getOldEntityId(int newId) {
|
||||
|
||||
@@ -4,29 +4,20 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.MappedItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewriterBase<T> {
|
||||
|
||||
private final MappedItemFunction mappedItemFunction;
|
||||
private final TranslatableRewriter translatableRewriter;
|
||||
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter,
|
||||
@Nullable IdRewriteFunction oldRewriter, @Nullable IdRewriteFunction newRewriter, MappedItemFunction mappedItemFunction) {
|
||||
super(protocol, oldRewriter, newRewriter, true);
|
||||
this.translatableRewriter = translatableRewriter;
|
||||
this.mappedItemFunction = mappedItemFunction;
|
||||
}
|
||||
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter, MappedItemFunction mappedItemFunction) {
|
||||
protected ItemRewriter(T protocol, @Nullable TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, true);
|
||||
this.translatableRewriter = translatableRewriter;
|
||||
this.mappedItemFunction = mappedItemFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,9 +25,8 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag display = null;
|
||||
if (translatableRewriter != null
|
||||
&& item.getTag() != null && (display = item.getTag().get("display")) != null) {
|
||||
CompoundTag display = item.getTag() != null ? item.getTag().get("display") : null;
|
||||
if (translatableRewriter != null && display != null) {
|
||||
// Handle name and lore components
|
||||
StringTag name = display.get("Name");
|
||||
if (name != null) {
|
||||
@@ -71,19 +61,21 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
}
|
||||
}
|
||||
|
||||
MappedItem data = mappedItemFunction.get(item.getIdentifier());
|
||||
MappedItem data = protocol.getMappingData().getMappedItem(item.getIdentifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
// Set remapped id
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
|
||||
// Save original id, set remapped id
|
||||
item.getTag().put(new IntTag(nbtTagName + "|id", item.getIdentifier()));
|
||||
item.setIdentifier(data.getId());
|
||||
|
||||
// Set custom name - only done if there is no original one
|
||||
if (display == null) {
|
||||
item.getTag().put(display = new CompoundTag("display"));
|
||||
}
|
||||
@@ -94,10 +86,18 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
return item;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MappedItemFunction {
|
||||
@Override
|
||||
@Nullable
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
@Nullable
|
||||
MappedItem get(int id);
|
||||
super.handleItemToServer(item);
|
||||
if (item.getTag() != null) {
|
||||
IntTag originalId = item.getTag().remove(nbtTagName + "|id");
|
||||
if (originalId != null) {
|
||||
item.setIdentifier(originalId.getValue());
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package nl.matsv.viabackwards.api.rewriters;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.viaversion.libs.opennbt.conversion.builtin.CompoundTagConverter;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@@ -13,28 +12,20 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewriter<T> {
|
||||
|
||||
protected static final CompoundTagConverter CONVERTER = new CompoundTagConverter();
|
||||
protected final IdRewriteFunction toClientRewriter;
|
||||
protected final IdRewriteFunction toServerRewriter;
|
||||
protected final String nbtTagName;
|
||||
protected final boolean jsonNameFormat;
|
||||
|
||||
protected ItemRewriterBase(T protocol, @Nullable IdRewriteFunction toClientRewriter, @Nullable IdRewriteFunction toServerRewriter, boolean jsonNameFormat) {
|
||||
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
|
||||
super(protocol);
|
||||
this.toClientRewriter = toClientRewriter;
|
||||
this.toServerRewriter = toServerRewriter;
|
||||
this.jsonNameFormat = jsonNameFormat;
|
||||
nbtTagName = "VB|" + protocol.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
protected ItemRewriterBase(T protocol, boolean jsonNameFormat) {
|
||||
this(protocol, null, null, jsonNameFormat);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
if (toClientRewriter != null) {
|
||||
item.setIdentifier(toClientRewriter.rewrite(item.getIdentifier()));
|
||||
if (protocol.getMappingData() != null) {
|
||||
item.setIdentifier(protocol.getMappingData().getNewItemId(item.getIdentifier()));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
@@ -42,8 +33,8 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
|
||||
@Nullable
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
if (toServerRewriter != null) {
|
||||
item.setIdentifier(toServerRewriter.rewrite(item.getIdentifier()));
|
||||
if (protocol.getMappingData() != null) {
|
||||
item.setIdentifier(protocol.getMappingData().getOldItemId(item.getIdentifier()));
|
||||
}
|
||||
restoreDisplayTag(item);
|
||||
return item;
|
||||
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
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.rewriters.IdRewriteFunction;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
@@ -79,13 +78,9 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
}
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol, @Nullable IdRewriteFunction oldRewriter, @Nullable IdRewriteFunction newRewriter) {
|
||||
super(protocol, oldRewriter, newRewriter, false);
|
||||
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
protected LegacyBlockItemRewriter(T protocol) {
|
||||
this(protocol, null, null);
|
||||
super(protocol, false);
|
||||
replacementData = LEGACY_MAPPINGS.get(protocol.getClass().getSimpleName().split("To")[1].replace("_", "."));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@ import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.ObjectType;
|
||||
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_9;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
@@ -25,11 +26,11 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
|
||||
private final Map<ObjectType, EntityData> objectTypes = new HashMap<>();
|
||||
|
||||
protected LegacyEntityRewriter(T protocol) {
|
||||
super(protocol);
|
||||
this(protocol, MetaType1_9.String, MetaType1_9.Boolean);
|
||||
}
|
||||
|
||||
protected LegacyEntityRewriter(T protocol, MetaType displayType) {
|
||||
super(protocol, displayType, 2);
|
||||
protected LegacyEntityRewriter(T protocol, MetaType displayType, MetaType displayVisibilityType) {
|
||||
super(protocol, displayType, 2, displayVisibilityType, 3);
|
||||
}
|
||||
|
||||
protected EntityObjectData mapObjectType(ObjectType oldObjectType, ObjectType replacement, int data) {
|
||||
|
||||
@@ -3,22 +3,15 @@ package nl.matsv.viabackwards.api.rewriters;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.IdRewriteFunction;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewriter {
|
||||
|
||||
private final Function<String, String> stringIdRewriter;
|
||||
private final BackwardsProtocol protocol;
|
||||
|
||||
public SoundRewriter(BackwardsProtocol protocol, IdRewriteFunction idRewriter, Function<String, String> stringIdRewriter) {
|
||||
super(protocol, idRewriter);
|
||||
this.stringIdRewriter = stringIdRewriter;
|
||||
}
|
||||
|
||||
public SoundRewriter(BackwardsProtocol protocol, IdRewriteFunction idRewriter) {
|
||||
this(protocol, idRewriter, null);
|
||||
public SoundRewriter(BackwardsProtocol protocol) {
|
||||
super(protocol);
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void registerNamedSound(ClientboundPacketType packetType) {
|
||||
@@ -28,7 +21,7 @@ public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewrit
|
||||
map(Type.STRING); // Sound identifier
|
||||
handler(wrapper -> {
|
||||
String soundId = wrapper.get(Type.STRING, 0);
|
||||
String mappedId = stringIdRewriter.apply(soundId);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) return;
|
||||
if (!mappedId.isEmpty()) {
|
||||
wrapper.set(Type.STRING, 0, mappedId);
|
||||
@@ -53,7 +46,7 @@ public class SoundRewriter extends us.myles.ViaVersion.api.rewriters.SoundRewrit
|
||||
}
|
||||
|
||||
String soundId = wrapper.read(Type.STRING);
|
||||
String mappedId = stringIdRewriter.apply(soundId);
|
||||
String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
|
||||
if (mappedId == null) {
|
||||
// No mapping found
|
||||
wrapper.write(Type.STRING, soundId);
|
||||
|
||||
+19
-19
@@ -10,15 +10,18 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
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.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
public class PlayerPackets1_11 {
|
||||
private static final ValueTransformer<Short, Float> TO_NEW_FLOAT = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||
@@ -34,28 +37,25 @@ public class PlayerPackets1_11 {
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
// Handle the new ActionBar
|
||||
if (action == 2) {
|
||||
// Convert to the old actionbar way
|
||||
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
||||
JsonElement msg = wrapper.read(Type.COMPONENT);
|
||||
actionbar.write(Type.COMPONENT, msg);
|
||||
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
||||
if (action == 2) { // Handle the new ActionBar
|
||||
JsonElement message = wrapper.read(Type.COMPONENT);
|
||||
|
||||
actionbar.send(Protocol1_10To1_11.class);
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(ClientboundPackets1_9_3.CHAT_MESSAGE.ordinal());
|
||||
|
||||
wrapper.cancel(); // Cancel the title packet
|
||||
return;
|
||||
}
|
||||
// https://bugs.mojang.com/browse/MC-119145to
|
||||
BaseComponent[] parsed = ComponentSerializer.parse(message.toString());
|
||||
String legacy = TextComponent.toLegacyText(parsed);
|
||||
message = new JsonObject();
|
||||
message.getAsJsonObject().addProperty("text", legacy);
|
||||
|
||||
if (action > 2) {
|
||||
wrapper.set(Type.VAR_INT, 0, action - 1); // Move everything one position down
|
||||
}
|
||||
wrapper.write(Type.COMPONENT, message);
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
} else if (action > 2) {
|
||||
wrapper.set(Type.VAR_INT, 0, action - 1); // Move everything one position down
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+8
-2
@@ -36,6 +36,7 @@ import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_12_1, ServerboundPackets1_13, ServerboundPackets1_12_1> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private BlockItemPackets1_13 blockItemPackets;
|
||||
|
||||
public Protocol1_12_2To1_13() {
|
||||
@@ -45,7 +46,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_13To1_12_2.class, () -> {
|
||||
BackwardsMappings.init();
|
||||
MAPPINGS.load();
|
||||
PaintingMapping.init();
|
||||
Via.getManager().getProviders().register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
|
||||
});
|
||||
@@ -54,7 +55,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null || (newTranslate = BackwardsMappings.translateMappings.get(translate)) != null) {
|
||||
if (newTranslate != null || (newTranslate = getMappingData().getTranslateMappings().get(translate)) != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
@@ -117,4 +118,9 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public BlockItemPackets1_13 getBlockItemPackets() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,6 +1,6 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
@@ -40,7 +40,7 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
addEntries(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
JsonObject mappings = MappingDataLoader.getMappingsCache().get("mapping-1.13.json").getAsJsonObject("blocks");
|
||||
JsonObject mappings = MappingDataLoader.getMappingsCache().get("mapping-1.13.json").getAsJsonObject("blockstates");
|
||||
for (Map.Entry<String, JsonElement> blockState : mappings.entrySet()) {
|
||||
String key = blockState.getValue().getAsString();
|
||||
if (!key.contains("piston")) continue;
|
||||
@@ -52,7 +52,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.getNewId(id);
|
||||
id = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(id);
|
||||
pistonIds.put(data, id);
|
||||
|
||||
String substring = data.substring(10);
|
||||
@@ -68,6 +68,8 @@ public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBloc
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
CompoundTag blockState = tag.get("blockState");
|
||||
if (blockState == null) return tag;
|
||||
|
||||
String dataFromTag = getDataFromTag(blockState);
|
||||
if (dataFromTag == null) return tag;
|
||||
|
||||
|
||||
+47
-36
@@ -11,17 +11,16 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.data.VBItemMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.api.data.VBMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBSoundMappings;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
import us.myles.ViaVersion.api.data.Mappings;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import us.myles.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
@@ -30,40 +29,34 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BackwardsMappings {
|
||||
public static final Int2ObjectMap<String> statisticMappings = new Int2ObjectOpenHashMap<>();
|
||||
public static final Map<String, String> translateMappings = new HashMap<>();
|
||||
public static BlockMappingsShortArray blockMappings;
|
||||
public static VBSoundMappings soundMappings;
|
||||
public static VBItemMappings itemMappings;
|
||||
public static Mappings enchantmentMappings;
|
||||
public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsMappings {
|
||||
private final Int2ObjectMap<String> statisticMappings = new Int2ObjectOpenHashMap<>();
|
||||
private final Map<String, String> translateMappings = new HashMap<>();
|
||||
private Mappings enchantmentMappings;
|
||||
|
||||
public static void init() {
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 mappings...");
|
||||
JsonObject mapping1_12 = MappingDataLoader.getMappingsCache().get("mapping-1.12.json");
|
||||
JsonObject mapping1_13 = MappingDataLoader.getMappingsCache().get("mapping-1.13.json");
|
||||
JsonObject mapping1_12_2to1_13 = VBMappingDataLoader.loadFromDataDir("mapping-1.12.2to1.13.json");
|
||||
|
||||
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
|
||||
itemMappings = new VBItemMappings(mapping1_13.getAsJsonObject("items"), mapping1_12.getAsJsonObject("items"), mapping1_12_2to1_13.getAsJsonObject("items"));
|
||||
soundMappings = new VBSoundMappings(mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"), mapping1_12_2to1_13.getAsJsonObject("sounds"));
|
||||
enchantmentMappings = new VBMappings(mapping1_13.getAsJsonObject("enchantments"), mapping1_12.getAsJsonObject("enchantments"), false);
|
||||
public BackwardsMappings() {
|
||||
super("1.13", "1.12", Protocol1_13To1_12_2.class, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
enchantmentMappings = new VBMappings(oldMappings.getAsJsonObject("enchantments"), newMappings.getAsJsonObject("enchantments"), false);
|
||||
for (Map.Entry<String, Integer> entry : StatisticMappings.CUSTOM_STATS.entrySet()) {
|
||||
statisticMappings.put(entry.getValue().intValue(), entry.getKey());
|
||||
}
|
||||
for (Map.Entry<String, String> entry : MappingData.translateMapping.entrySet()) {
|
||||
for (Map.Entry<String, String> entry : Protocol1_13To1_12_2.MAPPINGS.getTranslateMapping().entrySet()) {
|
||||
translateMappings.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
Object2IntMap newIdentifierMap = MappingDataLoader.indexedObjectToMap(oldIdentifiers);
|
||||
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
|
||||
String key = entry.getValue().getAsString();
|
||||
Map.Entry<String, JsonElement> value = MappingDataLoader.findValue(oldIdentifiers, key);
|
||||
int value = newIdentifierMap.getInt(key);
|
||||
short hardId = -1;
|
||||
if (value == null) {
|
||||
if (value == -1) {
|
||||
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
|
||||
int propertyIndex;
|
||||
if (replacement == null && (propertyIndex = key.indexOf('[')) != -1) {
|
||||
@@ -73,12 +66,12 @@ public class BackwardsMappings {
|
||||
if (replacement.getAsString().startsWith("id:")) {
|
||||
String id = replacement.getAsString().replace("id:", "");
|
||||
hardId = Short.parseShort(id);
|
||||
value = MappingDataLoader.findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString());
|
||||
value = newIdentifierMap.getInt(oldIdentifiers.getAsJsonPrimitive(id).getAsString());
|
||||
} else {
|
||||
value = MappingDataLoader.findValue(oldIdentifiers, replacement.getAsString());
|
||||
value = newIdentifierMap.getInt(replacement.getAsString());
|
||||
}
|
||||
}
|
||||
if (value == null) {
|
||||
if (value == -1) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
if (replacement != null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( ");
|
||||
@@ -89,20 +82,38 @@ public class BackwardsMappings {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
output[Integer.parseInt(entry.getKey())] = hardId != -1 ? hardId : Short.parseShort(value.getKey());
|
||||
output[Integer.parseInt(entry.getKey())] = hardId != -1 ? hardId : (short) value;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlockMappingsShortArray {
|
||||
private final short[] oldToNew = new short[8582];
|
||||
|
||||
private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||
@Override
|
||||
@Nullable
|
||||
protected Mappings loadFromObject(JsonObject oldMappings, JsonObject newMappings, @Nullable JsonObject diffMappings, String key) {
|
||||
if (key.equals("blockstates")) {
|
||||
short[] oldToNew = new short[8582];
|
||||
Arrays.fill(oldToNew, (short) -1);
|
||||
mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping);
|
||||
mapIdentifiers(oldToNew, oldMappings.getAsJsonObject("blockstates"), newMappings.getAsJsonObject("blocks"), diffMappings.getAsJsonObject("blockstates"));
|
||||
return new Mappings(oldToNew);
|
||||
} else {
|
||||
return super.loadFromObject(oldMappings, newMappings, diffMappings, key);
|
||||
}
|
||||
}
|
||||
|
||||
public int getNewId(int old) {
|
||||
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
|
||||
}
|
||||
@Override
|
||||
protected int checkValidity(int id, int mappedId, String type) {
|
||||
// Don't warn for missing ids here
|
||||
return mappedId;
|
||||
}
|
||||
|
||||
public Int2ObjectMap<String> getStatisticMappings() {
|
||||
return statisticMappings;
|
||||
}
|
||||
|
||||
public Map<String, String> getTranslateMappings() {
|
||||
return translateMappings;
|
||||
}
|
||||
|
||||
public Mappings getEnchantmentMappings() {
|
||||
return enchantmentMappings;
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -11,7 +11,6 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@@ -35,7 +34,7 @@ public class ParticleMapping {
|
||||
}
|
||||
|
||||
private int[] rewrite(int newType) {
|
||||
int blockType = BlockItemPackets1_13.toOldId(newType);
|
||||
int blockType = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(newType);
|
||||
|
||||
int type = blockType >> 4;
|
||||
int meta = blockType & 15;
|
||||
|
||||
+20
-36
@@ -15,7 +15,6 @@ import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.FlowerPotHandler;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
@@ -33,8 +32,8 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
@@ -61,23 +60,10 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
private final String extraNbtTag;
|
||||
|
||||
public BlockItemPackets1_13(Protocol1_12_2To1_13 protocol) {
|
||||
super(protocol, null, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
super(protocol, null);
|
||||
extraNbtTag = "VB|" + protocol.getClass().getSimpleName() + "|2";
|
||||
}
|
||||
|
||||
public static int toOldId(int oldId) {
|
||||
if (oldId < 0) {
|
||||
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
|
||||
}
|
||||
int newId = BackwardsMappings.blockMappings.getNewId(oldId);
|
||||
if (newId != -1)
|
||||
return newId;
|
||||
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing block completely " + oldId);
|
||||
// Default stone
|
||||
return 1 << 4;
|
||||
}
|
||||
|
||||
public static boolean isDamageable(int id) {
|
||||
return id >= 256 && id <= 259 // iron shovel, pickaxe, axe, flint and steel
|
||||
|| id == 261 // bow
|
||||
@@ -101,7 +87,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int itemId = wrapper.read(Type.VAR_INT);
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
||||
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
|
||||
if (oldId != -1) {
|
||||
Optional<String> eggEntityId = SpawnEggRewriter.getEntityId(oldId);
|
||||
if (eggEntityId.isPresent()) {
|
||||
@@ -220,7 +206,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
storage.checkAndStore(position, blockState);
|
||||
|
||||
wrapper.write(Type.VAR_INT, toOldId(blockState));
|
||||
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
|
||||
// Flower pot special treatment
|
||||
flowerPotSpecialTreatment(wrapper.user(), blockState, position);
|
||||
@@ -257,7 +243,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
flowerPotSpecialTreatment(wrapper.user(), block, position);
|
||||
|
||||
// Change to old id
|
||||
record.setBlockId(toOldId(block));
|
||||
record.setBlockId(protocol.getMappingData().getNewBlockStateId(block));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -357,7 +343,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
for (int p = 0; p < section.getPaletteSize(); p++) {
|
||||
int old = section.getPaletteEntry(p);
|
||||
if (old != 0) {
|
||||
int oldId = toOldId(old);
|
||||
int oldId = protocol.getMappingData().getNewBlockStateId(old);
|
||||
section.setPaletteEntry(p, oldId);
|
||||
}
|
||||
}
|
||||
@@ -413,9 +399,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, MappingData.oldToNewItems.inverse().get(data) >> 4);
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getItemMappings().get(data) >> 4);
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
data = toOldId(data);
|
||||
data = protocol.getMappingData().getNewBlockStateId(data);
|
||||
int blockId = data >> 4;
|
||||
int blockData = data & 0xF;
|
||||
wrapper.set(Type.INT, 1, (blockId & 0xFFF) | (blockData << 12));
|
||||
@@ -478,7 +464,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
// Enchantment table
|
||||
if (property >= 4 && property <= 6) {
|
||||
short oldId = wrapper.get(Type.SHORT, 1);
|
||||
wrapper.set(Type.SHORT, 1, (short) BackwardsMappings.enchantmentMappings.getNewId(oldId));
|
||||
wrapper.set(Type.SHORT, 1, (short) protocol.getMappingData().getEnchantmentMappings().getNewId(oldId));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -541,12 +527,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
// Look for custom mappings
|
||||
super.handleItemToClient(item);
|
||||
|
||||
// No custom mapping found, look at VV mappings
|
||||
if (item.getIdentifier() == originalId) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(item.getIdentifier());
|
||||
if (oldId != -1) {
|
||||
rawId = itemIdToRaw(oldId, item, tag);
|
||||
} else if (item.getIdentifier() == 362) { // base/colorless shulker box
|
||||
// Handle one-way special case
|
||||
if (item.getIdentifier() == -1) {
|
||||
if (originalId == 362) { // base/colorless shulker box
|
||||
rawId = 0xe50000; // purple shulker box
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
@@ -668,7 +651,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
lore.add(new StringTag("", mappedEnchantmentId + " " + EnchantmentRewriter.getRomanNumber(level)));
|
||||
noMapped.add(enchantmentEntry);
|
||||
} else if (!newId.isEmpty()) {
|
||||
Short oldId = MappingData.oldEnchantmentsIds.inverse().get(newId);
|
||||
Short oldId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().inverse().get(newId);
|
||||
if (oldId == null) {
|
||||
if (!newId.startsWith("viaversion:legacy/")) {
|
||||
// Custom enchant (?)
|
||||
@@ -830,14 +813,15 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int identifier = item.getIdentifier();
|
||||
item.setIdentifier(rawId);
|
||||
super.handleItemToServer(item);
|
||||
|
||||
// Mapped with original data, we can return here
|
||||
if (item.getIdentifier() != rawId) return item;
|
||||
if (item.getIdentifier() != rawId && item.getIdentifier() != -1) return item;
|
||||
|
||||
// Set to legacy id again
|
||||
item.setIdentifier(identifier);
|
||||
|
||||
int newId = -1;
|
||||
if (!MappingData.oldToNewItems.containsKey(rawId)) {
|
||||
if (!protocol.getMappingData().getItemMappings().inverse().containsKey(rawId)) {
|
||||
if (!isDamageable(item.getIdentifier()) && item.getIdentifier() != 358) { // Map
|
||||
if (tag == null) item.setTag(tag = new CompoundTag("tag"));
|
||||
tag.put(new IntTag(extraNbtTag, originalId)); // Data will be lost, saving original id
|
||||
@@ -847,7 +831,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
newId = 362; // directly set the new id -> base/colorless shulker box
|
||||
} else if (item.getIdentifier() == 31 && item.getData() == 0) { // Shrub was removed
|
||||
rawId = 32 << 4; // Dead Bush
|
||||
} else if (MappingData.oldToNewItems.containsKey(rawId & ~0xF)) {
|
||||
} else if (protocol.getMappingData().getItemMappings().inverse().containsKey(rawId & ~0xF)) {
|
||||
rawId &= ~0xF; // Remove data
|
||||
} else {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
@@ -858,7 +842,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
if (newId == -1) {
|
||||
newId = MappingData.oldToNewItems.get(rawId);
|
||||
newId = protocol.getMappingData().getItemMappings().inverse().get(rawId);
|
||||
}
|
||||
|
||||
item.setIdentifier(newId);
|
||||
@@ -920,7 +904,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (dummyEnchant && oldId == 0 && level == 0) {
|
||||
continue; //Skip dummy enchatment
|
||||
}
|
||||
String newId = MappingData.oldEnchantmentsIds.get(oldId);
|
||||
String newId = Protocol1_13To1_12_2.MAPPINGS.getOldEnchantmentsIds().get(oldId);
|
||||
if (newId == null) {
|
||||
newId = "viaversion:legacy/" + oldId;
|
||||
}
|
||||
@@ -1004,7 +988,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
// Create the flowerpot
|
||||
PacketWrapper blockCreate = new PacketWrapper(0x0B, null, user);
|
||||
blockCreate.write(Type.POSITION, position);
|
||||
blockCreate.write(Type.VAR_INT, toOldId(blockState));
|
||||
blockCreate.write(Type.VAR_INT, Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState));
|
||||
blockCreate.send(Protocol1_12_2To1_13.class, true);
|
||||
|
||||
// Send a block entity update
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
Entity1_13Types.ObjectType type = optionalType.get();
|
||||
if (type == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
int combined = BlockItemPackets1_13.toOldId(blockState);
|
||||
int combined = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState);
|
||||
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (type == Entity1_13Types.ObjectType.ITEM_FRAME) {
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@ import com.google.common.base.Joiner;
|
||||
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.ParticleMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||
import nl.matsv.viabackwards.utils.ChatUtil;
|
||||
@@ -542,7 +541,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
newSize--;
|
||||
continue;
|
||||
case 8:
|
||||
name = BackwardsMappings.statisticMappings.get(statisticId);
|
||||
name = protocol.getMappingData().getStatisticMappings().get(statisticId);
|
||||
if (name == null) {
|
||||
wrapper.read(Type.VAR_INT);
|
||||
newSize--;
|
||||
|
||||
+3
-4
@@ -3,7 +3,6 @@ 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 us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
@@ -27,7 +26,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
handler(wrapper -> {
|
||||
String newSound = wrapper.get(Type.STRING, 0);
|
||||
String oldSound = NamedSoundMapping.getOldId(newSound);
|
||||
if (oldSound != null || (oldSound = BackwardsMappings.soundMappings.getNewId(newSound)) != null) {
|
||||
if (oldSound != null || (oldSound = protocol.getMappingData().getMappedNamedSound(newSound)) != null) {
|
||||
wrapper.set(Type.STRING, 0, oldSound);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings()) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unknown named sound in 1.13->1.12 protocol: " + newSound);
|
||||
@@ -52,7 +51,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
String sound;
|
||||
if ((flags & 0x02) != 0) {
|
||||
sound = BackwardsMappings.soundMappings.getNewId(wrapper.read(Type.STRING));
|
||||
sound = protocol.getMappingData().getMappedNamedSound(wrapper.read(Type.STRING));
|
||||
if (sound == null) {
|
||||
sound = "";
|
||||
}
|
||||
@@ -72,7 +71,7 @@ public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int newSound = wrapper.get(Type.VAR_INT, 0);
|
||||
int oldSound = BackwardsMappings.soundMappings.getNewId(newSound);
|
||||
int oldSound = protocol.getMappingData().getSoundMappings().getNewId(newSound);
|
||||
if (oldSound == -1) {
|
||||
wrapper.cancel();
|
||||
} else {
|
||||
|
||||
-18
@@ -8,7 +8,6 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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.StatisticsRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
@@ -73,22 +72,5 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new StatisticsRewriter(this, null, null, null, id -> {
|
||||
int newId = id;
|
||||
if (newId > 40) {
|
||||
if (id == 41) return -1;
|
||||
newId--;
|
||||
}
|
||||
if (newId > 25) {
|
||||
if (id <= 28) return -1;
|
||||
newId -= 3;
|
||||
}
|
||||
if (newId > 22) {
|
||||
if (id <= 24) return -1;
|
||||
newId -= 2;
|
||||
}
|
||||
return newId;
|
||||
}).register(ClientboundPackets1_13.STATISTICS);
|
||||
}
|
||||
}
|
||||
+11
-29
@@ -1,10 +1,9 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
|
||||
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;
|
||||
@@ -21,11 +20,11 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_13, ServerboundPackets1_14, ServerboundPackets1_13> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.14", "1.13.2", Protocol1_14To1_13_2.class, true);
|
||||
private BlockItemPackets1_14 blockItemPackets;
|
||||
private EntityPackets1_14 entityPackets;
|
||||
|
||||
@@ -35,7 +34,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_14To1_13_2.class, BackwardsMappings::init);
|
||||
executeAsyncAfterLoaded(Protocol1_14To1_13_2.class, MAPPINGS::load);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
|
||||
@@ -53,8 +52,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
new PlayerPackets1_14(this).register();
|
||||
new SoundPackets1_14(this).register();
|
||||
|
||||
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> MappingData.oldToNewItems.inverse().get(id),
|
||||
entityPackets::getOldEntityId, id -> BackwardsMappings.statisticsMappings.getNewId(id)).register(ClientboundPackets1_14.STATISTICS);
|
||||
new StatisticsRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_14.STATISTICS);
|
||||
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_POSITION);
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
||||
@@ -73,7 +71,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
for (int j = 0; j < blockIds.length; j++) {
|
||||
int id = blockIds[j];
|
||||
// Ignore new blocktags
|
||||
int blockId = BackwardsMappings.blockMappings.getNewId(id);
|
||||
int blockId = getMappingData().getNewBlockId(id);
|
||||
blockIds[j] = blockId;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +83,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
for (int j = 0; j < itemIds.length; j++) {
|
||||
int itemId = itemIds[j];
|
||||
// Ignore new itemtags
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(itemId);
|
||||
int oldId = getMappingData().getItemMappings().get(itemId);
|
||||
itemIds[j] = oldId;
|
||||
}
|
||||
}
|
||||
@@ -163,27 +161,6 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
});
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 blockstate id for 1.14 block " + id);
|
||||
return 0;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
|
||||
public static int getNewBlockId(int id) {
|
||||
if (id == 669) return -1; // Bell
|
||||
|
||||
int newId = BackwardsMappings.blockMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 block id for 1.14 block " + id);
|
||||
return -1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
@@ -211,4 +188,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public EntityPackets1_14 getEntityPackets() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.data.VBItemMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.api.data.VBMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBSoundMappings;
|
||||
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 statisticsMappings;
|
||||
public static VBSoundMappings soundMappings;
|
||||
public static VBItemMappings itemMappings;
|
||||
|
||||
public static void init() {
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 mappings...");
|
||||
JsonObject mapping1_13_2 = MappingDataLoader.getMappingsCache().get("mapping-1.13.2.json");
|
||||
JsonObject mapping1_14 = MappingDataLoader.getMappingsCache().get("mapping-1.14.json");
|
||||
JsonObject mapping1_13_2to1_14 = VBMappingDataLoader.loadFromDataDir("mapping-1.13.2to1.14.json");
|
||||
|
||||
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);
|
||||
itemMappings = new VBItemMappings(mapping1_14.getAsJsonObject("items"), mapping1_13_2.getAsJsonObject("items"), mapping1_13_2to1_14.getAsJsonObject("items"));
|
||||
soundMappings = new VBSoundMappings(mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"), mapping1_13_2to1_14.getAsJsonObject("sounds"));
|
||||
statisticsMappings = new Mappings(mapping1_14.getAsJsonArray("statistics"), mapping1_13_2.getAsJsonArray("statistics"), false);
|
||||
}
|
||||
}
|
||||
+11
-32
@@ -6,7 +6,6 @@ import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@@ -31,7 +30,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
@@ -51,7 +50,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
private EnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public BlockItemPackets1_14(Protocol1_13_2To1_14 protocol, TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, translatableRewriter, BlockItemPackets1_14::getOldItemId, BlockItemPackets1_14::getNewItemId, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
super(protocol, translatableRewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,9 +175,9 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
});
|
||||
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13_2To1_14::getNewBlockStateId, Protocol1_13_2To1_14::getNewBlockId);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION);
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, BlockItemPackets1_14::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
@@ -358,7 +357,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
map(Type.UNSIGNED_BYTE); // Action param
|
||||
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
|
||||
handler(wrapper -> {
|
||||
int mappedId = Protocol1_13_2To1_14.getNewBlockId(wrapper.get(Type.VAR_INT, 0));
|
||||
int mappedId = protocol.getMappingData().getNewBlockId(wrapper.get(Type.VAR_INT, 0));
|
||||
if (mappedId == -1) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
@@ -378,7 +377,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(id));
|
||||
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -443,7 +442,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int id = section.getFlatBlock(x, y, z);
|
||||
if (MappingData.nonFullBlocks.contains(id)) {
|
||||
if (Protocol1_14To1_13_2.MAPPINGS.getNonFullBlocks().contains(id)) {
|
||||
section.getBlockLightNibbleArray().set(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
@@ -453,7 +452,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int old = section.getPaletteEntry(j);
|
||||
int newId = Protocol1_13_2To1_14.getNewBlockStateId(old);
|
||||
int newId = protocol.getMappingData().getNewBlockStateId(old);
|
||||
section.setPaletteEntry(j, newId);
|
||||
}
|
||||
}
|
||||
@@ -488,17 +487,16 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, data = BlockItemPackets1_14.getOldItemId(data));
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(data));
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, data = Protocol1_13_2To1_14.getNewBlockStateId(data));
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, 3, 23, 32,
|
||||
EntityPackets1_14::getOldParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
|
||||
itemRewriter.registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -584,23 +582,4 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public static int getNewItemId(int id) {
|
||||
int newId = MappingData.oldToNewItems.get(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 item for 1.13.2 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getOldItemId(int id) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
if (oldId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 item for 1.14 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return oldId;
|
||||
}
|
||||
}
|
||||
+4
-27
@@ -34,7 +34,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
private EntityPositionHandler positionHandler;
|
||||
|
||||
public EntityPackets1_14(Protocol1_13_2To1_14 protocol) {
|
||||
super(protocol, MetaType1_13_2.OptChat);
|
||||
super(protocol, MetaType1_13_2.OptChat, MetaType1_13_2.Boolean);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,7 +172,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Type.INT, 0);
|
||||
int combined = Protocol1_13_2To1_14.getNewBlockStateId(blockState);
|
||||
int combined = protocol.getMappingData().getNewBlockStateId(blockState);
|
||||
wrapper.set(Type.INT, 0, combined);
|
||||
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
|
||||
wrapper.set(Type.INT, 0, data + 1);
|
||||
@@ -351,7 +351,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
meta.setValue(getProtocol().getBlockItemPackets().handleItemToClient(item));
|
||||
} else if (type == MetaType1_13_2.BlockID) {
|
||||
int blockstate = (Integer) meta.getValue();
|
||||
meta.setValue(Protocol1_13_2To1_14.getNewBlockStateId(blockstate));
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockstate));
|
||||
}
|
||||
|
||||
return meta;
|
||||
@@ -391,8 +391,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
|
||||
registerMetaHandler().filter(Entity1_14Types.EntityType.AREA_EFFECT_CLOUD, 10).handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
particle.setId(getOldParticleId(particle.getId()));
|
||||
rewriteParticle((Particle) meta.getValue());
|
||||
return meta;
|
||||
});
|
||||
|
||||
@@ -549,28 +548,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
}
|
||||
}
|
||||
|
||||
public static int getOldParticleId(int id) {
|
||||
if (id == 56 || id == 57) return 5; // campfire cosy smoke, signal smoke -> cloud
|
||||
if (id >= 45) {
|
||||
id -= 1; // new 39 -> 44
|
||||
}
|
||||
if (id >= 30) {
|
||||
id -= 1; // skip new short happy villager
|
||||
}
|
||||
if (id >= 28) {
|
||||
id -= 1; // new 24 -> 27
|
||||
}
|
||||
if (id >= 13) {
|
||||
id -= 1; // new water drip 11 -> 13
|
||||
}
|
||||
if (id == 10 || id == 11) {
|
||||
id = 9; // set both landing/falling lava to dripping lava
|
||||
} else if (id > 11) {
|
||||
id -= 2;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getTypeFromId(int typeId) {
|
||||
return Entity1_14Types.getTypeFromId(typeId);
|
||||
|
||||
+2
-4
@@ -5,7 +5,6 @@ import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
@@ -20,8 +19,7 @@ public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
SoundRewriter soundRewriter = new SoundRewriter(protocol,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
SoundRewriter soundRewriter = new SoundRewriter(protocol);
|
||||
soundRewriter.registerSound(ClientboundPackets1_14.SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_14.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_14.STOP_SOUND);
|
||||
@@ -34,7 +32,7 @@ public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||
wrapper.cancel();
|
||||
|
||||
int soundId = wrapper.read(Type.VAR_INT);
|
||||
int newId = BackwardsMappings.soundMappings.getNewId(soundId);
|
||||
int newId = protocol.getMappingData().getSoundMappings().getNewId(soundId);
|
||||
if (newId == -1) return;
|
||||
|
||||
int category = wrapper.read(Type.VAR_INT);
|
||||
|
||||
+16
-37
@@ -1,6 +1,7 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
||||
@@ -12,20 +13,26 @@ 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.remapper.ValueTransformer;
|
||||
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.13.2", "1.13", Protocol1_13_1To1_13.class, true);
|
||||
|
||||
public Protocol1_13To1_13_1() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_13_1To1_13.class, MAPPINGS::load);
|
||||
|
||||
new EntityPackets1_13_1(this).register();
|
||||
InventoryPackets1_13_1.register(this);
|
||||
WorldPackets1_13_1.register(this);
|
||||
@@ -161,42 +168,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, Protocol1_13To1_13_1::getNewBlockId,
|
||||
InventoryPackets1_13_1::getOldItemId, null).register(ClientboundPackets1_13.TAGS);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int blockId) {
|
||||
if (blockId > 8590) {
|
||||
blockId -= 17;
|
||||
} else if (blockId > 8588) {
|
||||
blockId = 8573;
|
||||
} else if (blockId > 8479) {
|
||||
blockId -= 16;
|
||||
} else if (blockId > 8469 && blockId % 2 == 0) {
|
||||
if (blockId % 2 == 0) {
|
||||
blockId = 8459 + (blockId - 8470) / 2;
|
||||
} else {
|
||||
blockId = 0; //TODO replace new blocks
|
||||
}
|
||||
} else if (blockId > 8463) {
|
||||
blockId = 0; //TODO replace new blocks
|
||||
} else if (blockId > 1127) {
|
||||
blockId -= 1;
|
||||
} else if (blockId == 1127) {
|
||||
blockId = 1126;
|
||||
}
|
||||
|
||||
return blockId;
|
||||
}
|
||||
|
||||
public static int getNewBlockId(int blockId) {
|
||||
if (blockId > 565) {
|
||||
blockId -= 5;
|
||||
} else if (blockId > 561) {
|
||||
blockId = 0; // Replacements not needed
|
||||
}
|
||||
|
||||
return blockId;
|
||||
new TagRewriter(this, null).register(ClientboundPackets1_13.TAGS);
|
||||
new StatisticsRewriter(this, null).register(ClientboundPackets1_13.STATISTICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,7 +181,13 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
// Init protocol in EntityTracker
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
|
||||
if (!user.has(ClientWorld.class))
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -13,6 +13,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||
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;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
@@ -51,7 +52,7 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
// Rewrite falling block
|
||||
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) {
|
||||
int data = wrapper.get(Type.INT, 0);
|
||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
// Track Entity
|
||||
@@ -128,15 +129,15 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
// Rewrite items & blocks
|
||||
registerMetaHandler().handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
|
||||
if (meta.getMetaType() == MetaType1_13.Slot) {
|
||||
InventoryPackets1_13_1.toClient((Item) meta.getValue());
|
||||
} else if (meta.getMetaType() == MetaType1_13.BlockID) {
|
||||
// Convert to new block id
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (meta.getMetaType() == MetaType1_13.PARTICLE) {
|
||||
rewriteParticle((Particle) meta.getValue());
|
||||
}
|
||||
|
||||
return meta;
|
||||
});
|
||||
|
||||
@@ -160,7 +161,7 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
|
||||
Metadata meta = e.getData();
|
||||
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
|
||||
return meta;
|
||||
});
|
||||
|
||||
+6
-19
@@ -1,5 +1,6 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
@@ -15,7 +16,7 @@ public class InventoryPackets1_13_1 {
|
||||
public static void register(Protocol protocol) {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets1_13_1::toClient, InventoryPackets1_13_1::toServer);
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets1_13_1::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);
|
||||
|
||||
@@ -58,31 +59,17 @@ public class InventoryPackets1_13_1 {
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_ITEM);
|
||||
|
||||
itemRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, Type.FLAT_ITEM, Type.FLOAT);
|
||||
}
|
||||
|
||||
public static void toClient(Item item) {
|
||||
if (item == null) return;
|
||||
item.setIdentifier(getOldItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
// 1.13.1 Item Id
|
||||
public static int getNewItemId(int itemId) {
|
||||
if (itemId >= 443) {
|
||||
return itemId + 5;
|
||||
}
|
||||
return itemId;
|
||||
item.setIdentifier(Protocol1_13To1_13_1.MAPPINGS.getNewItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
public static void toServer(Item item) {
|
||||
if (item == null) return;
|
||||
item.setIdentifier(getNewItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
// 1.13 Item Id
|
||||
public static int getOldItemId(int newId) {
|
||||
if (newId >= 448) {
|
||||
return newId - 5;
|
||||
}
|
||||
return newId;
|
||||
item.setIdentifier(Protocol1_13To1_13_1.MAPPINGS.getOldItemId(item.getIdentifier()));
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -1,6 +1,5 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
@@ -16,7 +15,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
public class WorldPackets1_13_1 {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13To1_13_1::getNewBlockStateId, Protocol1_13To1_13_1::getNewBlockId);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -30,7 +29,7 @@ public class WorldPackets1_13_1 {
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
if (section != null) {
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
section.setPaletteEntry(i, Protocol1_13To1_13_1.getNewBlockStateId(section.getPaletteEntry(i)));
|
||||
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(section.getPaletteEntry(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +41,6 @@ public class WorldPackets1_13_1 {
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets1_13_1::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets1_13_1::toClient, Type.FLAT_ITEM, Type.FLOAT);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001);
|
||||
}
|
||||
}
|
||||
+11
-28
@@ -1,11 +1,10 @@
|
||||
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.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
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.data.ImmediateRespawn;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15;
|
||||
@@ -20,10 +19,10 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
|
||||
public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.15", "1.14", Protocol1_15To1_14_4.class, true);
|
||||
private BlockItemPackets1_15 blockItemPackets;
|
||||
|
||||
public Protocol1_14_4To1_15() {
|
||||
@@ -32,7 +31,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_15To1_14_4.class, BackwardsMappings::init);
|
||||
executeAsyncAfterLoaded(Protocol1_15To1_14_4.class, MAPPINGS::load);
|
||||
|
||||
TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_15.BOSSBAR);
|
||||
@@ -47,8 +46,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
(blockItemPackets = new BlockItemPackets1_15(this, translatableRewriter)).register();
|
||||
new EntityPackets1_15(this).register();
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_15.NAMED_SOUND);
|
||||
@@ -79,29 +77,9 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id),
|
||||
id -> MappingData.oldToNewItems.inverse().get(id), EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.TAGS);
|
||||
new TagRewriter(this, EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.TAGS);
|
||||
|
||||
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> MappingData.oldToNewItems.inverse().get(id),
|
||||
EntityTypeMapping::getOldEntityId, id -> BackwardsMappings.statisticsMappings.getNewId(id)).register(ClientboundPackets1_15.STATISTICS);
|
||||
}
|
||||
|
||||
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;
|
||||
new StatisticsRewriter(this, EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.STATISTICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,4 +96,9 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public BlockItemPackets1_15 getBlockItemPackets() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.data.VBItemMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.api.data.VBMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBSoundMappings;
|
||||
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 statisticsMappings;
|
||||
public static VBSoundMappings soundMappings;
|
||||
public static VBItemMappings itemMappings;
|
||||
|
||||
public static void init() {
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.15 -> 1.14.4 mappings...");
|
||||
JsonObject mapping1_14 = MappingDataLoader.getMappingsCache().get("mapping-1.14.json");
|
||||
JsonObject mapping1_15 = MappingDataLoader.getMappingsCache().get("mapping-1.15.json");
|
||||
JsonObject mapping1_14to1_15 = VBMappingDataLoader.loadFromDataDir("mapping-1.14.4to1.15.json");
|
||||
|
||||
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);
|
||||
itemMappings = new VBItemMappings(mapping1_15.getAsJsonObject("items"), mapping1_14.getAsJsonObject("items"), mapping1_14to1_15.getAsJsonObject("items"));
|
||||
soundMappings = new VBSoundMappings(mapping1_15.getAsJsonArray("sounds"), mapping1_14.getAsJsonArray("sounds"), mapping1_14to1_15.getAsJsonObject("sounds"));
|
||||
statisticsMappings = new Mappings(mapping1_15.getAsJsonArray("statistics"), mapping1_14.getAsJsonArray("statistics"), false);
|
||||
}
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||
|
||||
public class ParticleMapping {
|
||||
|
||||
public static int getOldId(int newId) {
|
||||
switch (newId) {
|
||||
case 58: // dripping honey -> dripping lava
|
||||
return 9;
|
||||
case 59: // falling honey -> falling lava
|
||||
return 10;
|
||||
case 60: // landing honey -> landing lava
|
||||
return 11;
|
||||
case 61: // falling nectar -> falling water
|
||||
return 13;
|
||||
default:
|
||||
return newId;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-34
@@ -1,10 +1,7 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
@@ -18,19 +15,18 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
|
||||
public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.ItemRewriter<Protocol1_14_4To1_15> {
|
||||
|
||||
public BlockItemPackets1_15(Protocol1_14_4To1_15 protocol, TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, translatableRewriter, BlockItemPackets1_15::getOldItemId, BlockItemPackets1_15::getNewItemId, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
super(protocol, translatableRewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_14_4To1_15::getNewBlockStateId, Protocol1_14_4To1_15::getNewBlockId);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
|
||||
new RecipeRewriter1_14(protocol, this::handleItemToClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
@@ -41,7 +37,7 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, BlockItemPackets1_15::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
@@ -92,7 +88,7 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
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);
|
||||
int newId = protocol.getMappingData().getNewBlockStateId(old);
|
||||
section.setPaletteEntry(j, newId);
|
||||
}
|
||||
}
|
||||
@@ -101,7 +97,7 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001, BlockItemPackets1_15::getOldItemId);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -120,40 +116,21 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int mappedId = ParticleMapping.getOldId(id);
|
||||
if (id != mappedId) {
|
||||
wrapper.set(Type.INT, 0, mappedId);
|
||||
}
|
||||
|
||||
if (id == 3 || id == 23) {
|
||||
int data = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_14_4To1_15.getNewBlockStateId(data));
|
||||
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
|
||||
} else if (id == 32) {
|
||||
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
|
||||
}
|
||||
|
||||
int mappedId = protocol.getMappingData().getNewParticleId(id);
|
||||
if (id != mappedId) {
|
||||
wrapper.set(Type.INT, 0, mappedId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int getNewItemId(int id) {
|
||||
int newId = MappingData.oldToNewItems.get(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.14.4 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
|
||||
public static int getOldItemId(int id) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
if (oldId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14.4 item for 1.15 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return oldId;
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -5,7 +5,6 @@ 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 nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
@@ -58,7 +57,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
}
|
||||
});
|
||||
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_14_4To1_15::getNewBlockStateId);
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.SPAWN_MOB, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -191,10 +190,9 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
meta.setValue(protocol.getBlockItemPackets().handleItemToClient(item));
|
||||
} else if (type == MetaType1_14.BlockID) {
|
||||
int blockstate = (int) meta.getValue();
|
||||
meta.setValue(Protocol1_14_4To1_15.getNewBlockStateId(blockstate));
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockstate));
|
||||
} else if (type == MetaType1_14.PARTICLE) {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
particle.setId(ParticleMapping.getOldId(particle.getId()));
|
||||
rewriteParticle((Particle) meta.getValue());
|
||||
}
|
||||
return meta;
|
||||
});
|
||||
|
||||
+10
-27
@@ -1,6 +1,5 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||
@@ -21,7 +20,6 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
@@ -31,6 +29,7 @@ import java.util.UUID;
|
||||
|
||||
public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_15, ServerboundPackets1_16, ServerboundPackets1_14> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings();
|
||||
private BlockItemPackets1_16 blockItemPackets;
|
||||
private TranslatableRewriter translatableRewriter;
|
||||
|
||||
@@ -40,7 +39,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_16To1_15_2.class, BackwardsMappings::init);
|
||||
executeAsyncAfterLoaded(Protocol1_16To1_15_2.class, MAPPINGS::load);
|
||||
|
||||
translatableRewriter = new TranslatableRewriter1_16(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR);
|
||||
@@ -95,8 +94,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_16.NAMED_SOUND);
|
||||
@@ -114,11 +112,9 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
||||
new TagRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
||||
|
||||
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id -> MappingData.oldToNewItems.inverse().get(id),
|
||||
entityPackets::getOldEntityId, id -> BackwardsMappings.statisticsMappings.getNewId(id)).register(ClientboundPackets1_16.STATISTICS);
|
||||
new StatisticsRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16.STATISTICS);
|
||||
|
||||
registerIncoming(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -175,24 +171,6 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
cancelIncoming(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 blockstate id for 1.15 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.16 block id for 1.15 block " + id);
|
||||
return id;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(ClientWorld.class)) {
|
||||
@@ -212,4 +190,9 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public TranslatableRewriter getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
+13
-27
@@ -1,40 +1,26 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.data.VBItemMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.api.data.VBMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBSoundMappings;
|
||||
import us.myles.ViaVersion.api.data.MappingDataLoader;
|
||||
import us.myles.ViaVersion.api.data.Mappings;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BackwardsMappings {
|
||||
public static Mappings blockStateMappings;
|
||||
public static Mappings blockMappings;
|
||||
public static Mappings statisticsMappings;
|
||||
public static VBSoundMappings soundMappings;
|
||||
public static VBItemMappings itemMappings;
|
||||
public static Map<String, String> attributeMappings = new HashMap<>();
|
||||
public class BackwardsMappings extends nl.matsv.viabackwards.api.data.BackwardsMappings {
|
||||
private final Map<String, String> attributeMappings = new HashMap<>();
|
||||
|
||||
public static void init() {
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.16 -> 1.15.2 mappings...");
|
||||
JsonObject mapping1_15 = MappingDataLoader.getMappingsCache().get("mapping-1.15.json");
|
||||
JsonObject mapping1_16 = MappingDataLoader.getMappingsCache().get("mapping-1.16.json");
|
||||
JsonObject mapping1_15to1_16 = VBMappingDataLoader.loadFromDataDir("mapping-1.15to1.16.json");
|
||||
public BackwardsMappings() {
|
||||
super("1.16", "1.15", Protocol1_16To1_15_2.class, true);
|
||||
}
|
||||
|
||||
blockStateMappings = new VBMappings(mapping1_16.getAsJsonObject("blockstates"), mapping1_15.getAsJsonObject("blockstates"), mapping1_15to1_16.getAsJsonObject("blockstates"));
|
||||
blockMappings = new VBMappings(mapping1_16.getAsJsonObject("blocks"), mapping1_15.getAsJsonObject("blocks"), mapping1_15to1_16.getAsJsonObject("blocks"), false);
|
||||
itemMappings = new VBItemMappings(mapping1_16.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items"), mapping1_15to1_16.getAsJsonObject("items"));
|
||||
soundMappings = new VBSoundMappings(mapping1_16.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), mapping1_15to1_16.getAsJsonObject("sounds"));
|
||||
statisticsMappings = new Mappings(mapping1_16.getAsJsonArray("statistics"), mapping1_15.getAsJsonArray("statistics"), false);
|
||||
|
||||
for (Map.Entry<String, String> entry : MappingData.attributeMappings.entrySet()) {
|
||||
@Override
|
||||
protected void loadVBExtras(JsonObject oldMappings, JsonObject newMappings) {
|
||||
for (Map.Entry<String, String> entry : Protocol1_16To1_15_2.MAPPINGS.getAttributeMappings().entrySet()) {
|
||||
attributeMappings.put(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getAttributeMappings() {
|
||||
return attributeMappings;
|
||||
}
|
||||
}
|
||||
+7
-54
@@ -1,10 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.MapColorRewriter;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
@@ -21,7 +19,6 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_1
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||
@@ -40,14 +37,13 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
private EnchantmentRewriter enchantmentRewriter;
|
||||
|
||||
public BlockItemPackets1_16(Protocol1_15_2To1_16 protocol, TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, translatableRewriter,
|
||||
BlockItemPackets1_16::getOldItemId, BlockItemPackets1_16::getNewItemId, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
super(protocol, translatableRewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15_2To1_16::getNewBlockStateId, Protocol1_15_2To1_16::getNewBlockId);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
|
||||
RecipeRewriter1_14 recipeRewriter = new RecipeRewriter1_14(protocol, this::handleItemToClient);
|
||||
// Remove new smithing type, only in this handler
|
||||
@@ -80,7 +76,7 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, BlockItemPackets1_16::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_16.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
@@ -145,7 +141,7 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (section == null) continue;
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int old = section.getPaletteEntry(j);
|
||||
section.setPaletteEntry(j, Protocol1_15_2To1_16.getNewBlockStateId(old));
|
||||
section.setPaletteEntry(j, protocol.getMappingData().getNewBlockStateId(old));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,9 +175,9 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001, BlockItemPackets1_16::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 34,
|
||||
BlockItemPackets1_16::getNewParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001);
|
||||
|
||||
itemRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -295,31 +291,6 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNewParticleId(int id) {
|
||||
switch (id) {
|
||||
case 27: // soul flame -> flame
|
||||
return 26;
|
||||
case 28: // soul -> smoke
|
||||
return 42;
|
||||
case 64: // ash, crimson spore, warped spore -> mycelium
|
||||
case 65:
|
||||
case 66:
|
||||
return 37;
|
||||
case 67: // dripping obsidian tear -> dripping lava
|
||||
return 9;
|
||||
case 68: // falling obsidian tear
|
||||
return 10;
|
||||
case 69: // landing obsidian tear
|
||||
return 11;
|
||||
case 70: // reversed portal -> portal
|
||||
return 40;
|
||||
}
|
||||
if (id > 27) {
|
||||
id -= 2;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
enchantmentRewriter = new EnchantmentRewriter(nbtTagName);
|
||||
@@ -375,24 +346,6 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
return item;
|
||||
}
|
||||
|
||||
public static int getNewItemId(int id) {
|
||||
int newId = MappingData.oldToNewItems.get(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 item for 1.15 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getOldItemId(int id) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
if (oldId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.15 item for 1.16 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return oldId;
|
||||
}
|
||||
|
||||
private static final class EquipmentData {
|
||||
private final int slot;
|
||||
private final Item item;
|
||||
|
||||
+4
-7
@@ -1,9 +1,7 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||
@@ -45,7 +43,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_15_2To1_16::getNewBlockStateId);
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK);
|
||||
registerSpawnTracker(ClientboundPackets1_16.SPAWN_MOB);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {
|
||||
@@ -128,7 +126,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
int size = wrapper.passthrough(Type.INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String attributeIdentifier = wrapper.read(Type.STRING);
|
||||
String oldKey = BackwardsMappings.attributeMappings.get(attributeIdentifier);
|
||||
String oldKey = protocol.getMappingData().getAttributeMappings().get(attributeIdentifier);
|
||||
wrapper.write(Type.STRING, oldKey != null ? oldKey : attributeIdentifier.replace("minecraft:", ""));
|
||||
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
@@ -191,10 +189,9 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
if (type == MetaType1_14.Slot) {
|
||||
meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue()));
|
||||
} else if (type == MetaType1_14.BlockID) {
|
||||
meta.setValue(Protocol1_15_2To1_16.getNewBlockStateId((int) meta.getValue()));
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId((int) meta.getValue()));
|
||||
} else if (type == MetaType1_14.PARTICLE) {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
particle.setId(ParticleMapping.getOldId(particle.getId()));
|
||||
rewriteParticle((Particle) meta.getValue());
|
||||
} else if (type == MetaType1_14.OptChat) {
|
||||
JsonElement text = meta.getCastedValue();
|
||||
if (text != null) {
|
||||
|
||||
+29
-29
@@ -1,11 +1,10 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.BlockItemPackets1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.EntityPackets1_16_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
@@ -18,12 +17,13 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16, ServerboundPackets1_16_2, ServerboundPackets1_16> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.16.2", "1.16", Protocol1_16_2To1_16_1.class, true);
|
||||
private BlockItemPackets1_16_2 blockItemPackets;
|
||||
private TranslatableRewriter translatableRewriter;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, BackwardsMappings::init);
|
||||
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, MAPPINGS::load);
|
||||
|
||||
translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR);
|
||||
@@ -41,7 +41,6 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_16_2.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_16_2.TITLE);
|
||||
translatableRewriter.registerChatMessage(ClientboundPackets1_16_2.CHAT_MESSAGE);
|
||||
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
@@ -49,13 +48,29 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
EntityPackets1_16_2 entityPackets = new EntityPackets1_16_2(this);
|
||||
entityPackets.register();
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this,
|
||||
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_16_2.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_16_2.STOP_SOUND);
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16_2.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
JsonElement message = wrapper.passthrough(Type.COMPONENT);
|
||||
translatableRewriter.processText(message);
|
||||
byte position = wrapper.passthrough(Type.BYTE);
|
||||
if (position == 2) { // https://bugs.mojang.com/browse/MC-119145
|
||||
wrapper.clearPacket();
|
||||
wrapper.setId(ClientboundPackets1_16.TITLE.ordinal());
|
||||
wrapper.write(Type.VAR_INT, 2);
|
||||
wrapper.write(Type.COMPONENT, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Recipe book data has been split into 2 separate packets
|
||||
registerIncoming(ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -92,29 +107,9 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.TAGS);
|
||||
new TagRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.TAGS);
|
||||
|
||||
new StatisticsRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 blockstate id for 1.16.2 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.16 block id for 1.16.2 block " + id);
|
||||
return id;
|
||||
}
|
||||
return newId;
|
||||
new StatisticsRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,4 +127,9 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
public TranslatableRewriter getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.data.VBItemMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import nl.matsv.viabackwards.api.data.VBMappings;
|
||||
import nl.matsv.viabackwards.api.data.VBSoundMappings;
|
||||
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 VBSoundMappings soundMappings;
|
||||
public static VBItemMappings itemMappings;
|
||||
|
||||
public static void init() {
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading 1.16.2 -> 1.16.1 mappings...");
|
||||
JsonObject mapping1_16 = MappingDataLoader.getMappingsCache().get("mapping-1.16.json");
|
||||
JsonObject mapping1_16_2 = MappingDataLoader.getMappingsCache().get("mapping-1.16.2.json");
|
||||
JsonObject mapping1_16to1_16_2 = VBMappingDataLoader.loadFromDataDir("mapping-1.16to1.16.2.json");
|
||||
|
||||
blockStateMappings = new VBMappings(mapping1_16_2.getAsJsonObject("blockstates"), mapping1_16.getAsJsonObject("blockstates"), mapping1_16to1_16_2.getAsJsonObject("blockstates"));
|
||||
blockMappings = new VBMappings(mapping1_16_2.getAsJsonObject("blocks"), mapping1_16.getAsJsonObject("blocks"), mapping1_16to1_16_2.getAsJsonObject("blocks"), false);
|
||||
itemMappings = new VBItemMappings(mapping1_16_2.getAsJsonObject("items"), mapping1_16.getAsJsonObject("items"), mapping1_16to1_16_2.getAsJsonObject("items"));
|
||||
soundMappings = new VBSoundMappings(mapping1_16_2.getAsJsonArray("sounds"), mapping1_16.getAsJsonArray("sounds"), mapping1_16to1_16_2.getAsJsonObject("sounds"));
|
||||
}
|
||||
}
|
||||
+8
-31
@@ -1,9 +1,7 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.BackwardsMappings;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord1_8;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
@@ -14,7 +12,6 @@ import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
@@ -29,18 +26,17 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.ItemRewriter<Protocol1_16_1To1_16_2> {
|
||||
|
||||
public BlockItemPackets1_16_2(Protocol1_16_1To1_16_2 protocol, TranslatableRewriter translatableRewriter) {
|
||||
super(protocol, translatableRewriter,
|
||||
BlockItemPackets1_16_2::getOldItemId, BlockItemPackets1_16_2::getNewItemId, id -> BackwardsMappings.itemMappings.getMappedItem(id));
|
||||
super(protocol, translatableRewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16_1To1_16_2::getNewBlockStateId, Protocol1_16_1To1_16_2::getNewBlockId);
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
|
||||
new RecipeRewriter1_16(protocol, this::handleItemToClient).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES);
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN, BlockItemPackets1_16_2::getOldItemId);
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16_2.COOLDOWN);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16_2.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16_2.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
@@ -82,7 +78,7 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.
|
||||
if (section == null) continue;
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int old = section.getPaletteEntry(j);
|
||||
section.setPaletteEntry(j, Protocol1_16_1To1_16_2.getNewBlockStateId(old));
|
||||
section.setPaletteEntry(j, protocol.getMappingData().getNewBlockStateId(old));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +88,6 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.
|
||||
IntTag x = blockEntity.get("x");
|
||||
IntTag y = blockEntity.get("y");
|
||||
IntTag z = blockEntity.get("z");
|
||||
|
||||
if (x != null && y != null && z != null) {
|
||||
handleBlockEntity(blockEntity, new Position(x.getValue(), y.getValue().shortValue(), z.getValue()));
|
||||
}
|
||||
@@ -129,7 +124,7 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.
|
||||
wrapper.write(Type.BLOCK_CHANGE_RECORD_ARRAY, blockChangeRecord);
|
||||
for (int i = 0; i < blockChangeRecord.length; i++) {
|
||||
BlockChangeRecord record = blockChangeRecord[i];
|
||||
int blockId = Protocol1_16_1To1_16_2.getNewBlockStateId(record.getBlockId());
|
||||
int blockId = protocol.getMappingData().getNewBlockStateId(record.getBlockId());
|
||||
// Relative y -> absolute y
|
||||
blockChangeRecord[i] = new BlockChangeRecord1_8(record.getSectionX(), record.getY(chunkY), record.getSectionZ(), blockId);
|
||||
}
|
||||
@@ -137,9 +132,9 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001, BlockItemPackets1_16_2::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, 3, 23, 34,
|
||||
null, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001);
|
||||
|
||||
itemRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
@@ -177,22 +172,4 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.
|
||||
skullOwnerCompoundTag.put(new IntArrayTag("Id", uuidIntArray));
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNewItemId(int id) {
|
||||
int newId = MappingData.oldToNewItems.get(id);
|
||||
if (newId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16.2 item for 1.16 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getOldItemId(int id) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
if (oldId == -1) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 item for 1.16.2 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return oldId;
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
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_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
||||
@@ -31,7 +32,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK, Protocol1_16_1To1_16_2::getNewBlockStateId);
|
||||
registerSpawnTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK);
|
||||
registerSpawnTracker(ClientboundPackets1_16_2.SPAWN_MOB);
|
||||
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_EXPERIENCE_ORB, Entity1_16_2Types.EntityType.EXPERIENCE_ORB);
|
||||
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_PAINTING, Entity1_16_2Types.EntityType.PAINTING);
|
||||
@@ -97,12 +98,14 @@ public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2>
|
||||
if (type == MetaType1_14.Slot) {
|
||||
meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue()));
|
||||
} else if (type == MetaType1_14.BlockID) {
|
||||
meta.setValue(Protocol1_16_1To1_16_2.getNewBlockStateId((int) meta.getValue()));
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId((int) meta.getValue()));
|
||||
} else if (type == MetaType1_14.OptChat) {
|
||||
JsonElement text = meta.getCastedValue();
|
||||
if (text != null) {
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
}
|
||||
} else if (type == MetaType1_14.PARTICLE) {
|
||||
rewriteParticle((Particle) meta.getValue());
|
||||
}
|
||||
return meta;
|
||||
});
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_3to1_16_4;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_3to1_16_4.storage.PlayerHandStorage;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
|
||||
public class Protocol1_16_3To1_16_4 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
|
||||
|
||||
public Protocol1_16_3To1_16_4() {
|
||||
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16_2.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerIncoming(ServerboundPackets1_16_2.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLAT_VAR_INT_ITEM);
|
||||
map(Type.BOOLEAN);
|
||||
handler(wrapper -> {
|
||||
int slot = wrapper.read(Type.VAR_INT);
|
||||
if (slot == 1) {
|
||||
wrapper.write(Type.VAR_INT, 40); // offhand
|
||||
} else {
|
||||
wrapper.write(Type.VAR_INT, wrapper.user().get(PlayerHandStorage.class).getCurrentHand());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerIncoming(ServerboundPackets1_16_2.HELD_ITEM_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
short slot = wrapper.passthrough(Type.SHORT);
|
||||
wrapper.user().get(PlayerHandStorage.class).setCurrentHand(slot);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
user.put(new PlayerHandStorage(user));
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_3to1_16_4.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
public class PlayerHandStorage extends StoredObject {
|
||||
|
||||
private int currentHand;
|
||||
|
||||
public PlayerHandStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public int getCurrentHand() {
|
||||
return currentHand;
|
||||
}
|
||||
|
||||
public void setCurrentHand(int currentHand) {
|
||||
this.currentHand = currentHand;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
# If you need help, you can join our Discord - https://viaversion.com/discord
|
||||
#
|
||||
# Always shows a mapped mob's original name, and not only when hovering over it with the cursor.
|
||||
always-show-original-mob-name: true
|
||||
#
|
||||
# Writes name and level of custom enchantments into the item's lore.
|
||||
# Set this to false if you see the entries doubled/if the custom-enchant plugin already writes these into the lore manually.
|
||||
add-custom-enchants-into-lore: true
|
||||
|
||||
File renamed without changes.
@@ -998,5 +998,15 @@
|
||||
"entity.parrot.imitate.panda": "",
|
||||
"entity.parrot.imitate.pillager": "",
|
||||
"entity.parrot.imitate.ravager": ""
|
||||
},
|
||||
"particles": {
|
||||
"falling_lava": "dripping_lava",
|
||||
"landing_lava": "dripping_lava",
|
||||
"falling_water": "dripping_water",
|
||||
"composter": "happy_villager",
|
||||
"flash": "explosion",
|
||||
"sneeze": "spit",
|
||||
"campfire_cosy_smoke": "cloud",
|
||||
"campfire_signal_smoke": "cloud"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"blockstates": {
|
||||
"minecraft:tnt[unstable=false]": "minecraft:tnt",
|
||||
"minecraft:tnt[unstable=true]": "minecraft:tnt",
|
||||
"minecraft:oak_sign": "minecraft:sign[",
|
||||
"minecraft:oak_wall_sign": "minecraft:wall_sign[",
|
||||
"minecraft:smooth_stone_slab": "minecraft:stone_slab[",
|
||||
"minecraft:dead_tube_coral": "minecraft:tube_coral",
|
||||
"minecraft:dead_brain_coral": "minecraft:brain_coral",
|
||||
"minecraft:dead_bubble_coral": "minecraft:bubble_coral",
|
||||
"minecraft:dead_fire_coral": "minecraft:fire_coral",
|
||||
"minecraft:dead_horn_coral": "minecraft:horn_coral",
|
||||
"minecraft:tube_coral": "minecraft:tube_coral",
|
||||
"minecraft:brain_coral": "minecraft:brain_coral",
|
||||
"minecraft:bubble_coral": "minecraft:bubble_coral",
|
||||
"minecraft:fire_coral": "minecraft:fire_coral",
|
||||
"minecraft:horn_coral": "minecraft:horn_coral",
|
||||
"minecraft:conduit": "minecraft:conduit"
|
||||
}
|
||||
}
|
||||
+6
@@ -88,5 +88,11 @@
|
||||
"item.honey_bottle.drink": "entity.generic.drink",
|
||||
"entity.iron_golem.damage": "entity.item.break",
|
||||
"entity.iron_golem.repair": "entity.iron_golem.step"
|
||||
},
|
||||
"particles": {
|
||||
"dripping_honey": "dripping_lava",
|
||||
"falling_honey": "falling_lava",
|
||||
"landing_honey": "landing_lava",
|
||||
"falling_nectar": "falling_water"
|
||||
}
|
||||
}
|
||||
@@ -6230,5 +6230,17 @@
|
||||
"entity.parrot.imitate.hoglin": "entity.ravager.ambient",
|
||||
"entity.parrot.imitate.piglin": "entity.zombie_pigman.ambient",
|
||||
"entity.parrot.imitate.zoglin": "entity.ravager.ambient"
|
||||
},
|
||||
"particles": {
|
||||
"soul_fire_flame": "flame",
|
||||
"soul": "smoke",
|
||||
"ash": "mycelium",
|
||||
"crimson_spore": "mycelium",
|
||||
"warped_spore": "mycelium",
|
||||
"dripping_obsidian_tear": "dripping_lava",
|
||||
"falling_obsidian_tear": "falling_lava",
|
||||
"landing_obsidian_tear": "landing_lava",
|
||||
"reverse_portal": "portal",
|
||||
"white_ash": "mycelium"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-fabric</artifactId>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<groupId>nl.matsv</groupId>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>Allow older clients to join newer server versions.</description>
|
||||
@@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>3.1.1-1.16.3-rc1</version>
|
||||
<version>3.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-sponge</artifactId>
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
|
||||
Reference in new issue
Block a user