Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
819d7f3d39 | ||
|
|
25404d6c92 | ||
|
|
b340c7246b | ||
|
|
2669967b49 | ||
|
|
e945db8cb6 | ||
|
|
9a09e53572 | ||
|
|
0c040db6f0 | ||
|
|
46c7cab3a4 | ||
|
|
922afc12a5 | ||
|
|
4817bf7e2b | ||
|
|
2a118acf77 | ||
|
|
0b93cd0e09 | ||
|
|
b1af6ad721 | ||
|
|
c6d8a83ac9 | ||
|
|
72a070da3e | ||
|
|
dbe0f7049e | ||
|
|
91b81ebb24 | ||
|
|
897e9545c2 | ||
|
|
947e5c3e07 | ||
|
|
ececd96718 | ||
|
|
e9ace2dd6b | ||
|
|
c72f8f766d | ||
|
|
1b89327d84 | ||
|
|
8a8c1a33a6 | ||
|
|
761249d39f | ||
|
|
e03da34f55 | ||
|
|
03ec04cc8d | ||
|
|
f387899dab | ||
|
|
ce49daa300 | ||
|
|
249a720cee | ||
|
|
fa59cbcc01 | ||
|
|
803c24f4d3 | ||
|
|
5e19a5af33 | ||
|
|
8911f1eb94 | ||
|
|
6f0bd98be2 | ||
|
|
e325a03c0a | ||
|
|
b9317df859 | ||
|
|
11bb1349e9 | ||
|
|
6289e9317d | ||
|
|
2d9d67bcb2 | ||
|
|
62fd868130 | ||
|
|
b2b8c48fd0 | ||
|
|
9f9d05d3c6 | ||
|
|
6e01a0affd | ||
|
|
d6d6307550 | ||
|
|
1afdf0fb81 | ||
|
|
fd529ce967 | ||
|
|
c5ba1864d1 | ||
|
|
831b8ad5ad | ||
|
|
58256b5b64 | ||
|
|
d209e9b768 | ||
|
|
61b1f0d8a4 | ||
|
|
2748624dde | ||
|
|
d5b19b8869 | ||
|
|
650f89e1ce | ||
|
|
00172ee675 | ||
|
|
45aab8f9f2 | ||
|
|
1e455b0391 | ||
|
|
59cb67da6e | ||
|
|
6b96e1a8e2 | ||
|
|
5ef94d94e6 | ||
|
|
a59c384884 | ||
|
|
7638d678bb | ||
|
|
f3c30130d2 | ||
|
|
bb583065f3 | ||
|
|
f5bb30559d | ||
|
|
87afb84a4d | ||
|
|
07078b21f1 | ||
|
|
63d3dcb31b | ||
|
|
478e663506 | ||
|
|
6bb8ae1dfc | ||
|
|
2cea70e643 | ||
|
|
54de77a110 | ||
|
|
e38cb88640 | ||
|
|
8deeda641a | ||
|
|
f75420a642 | ||
|
|
efd435e908 | ||
|
|
875ffb7f2d | ||
|
|
385ca98125 | ||
|
|
c4630039c4 | ||
|
|
cf6df691d2 | ||
|
|
76dfbe030e | ||
|
|
c7a168d3b3 | ||
|
|
b79bf429f7 | ||
|
|
6e1c482e2d | ||
|
|
b506060e48 | ||
|
|
8294f6af4f |
No files matched your search
@@ -5,7 +5,7 @@ about: Create a bug report so we can fix it
|
||||
---
|
||||
|
||||
**Describe the bug, provide any errors**
|
||||
A clear and concise description of what the bug is. Can you https://hastebin.com the error?
|
||||
A clear and concise description of what the bug is. Can you https://paste.gg/ the error?
|
||||
|
||||
**How can we reproduce it?**
|
||||
Steps to reproduce the behavior:
|
||||
@@ -24,3 +24,8 @@ If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional server info**
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
|
||||
**Checklist**
|
||||
- [ ] I have included a ViaVersion dump
|
||||
- [ ] If applicable, I have included a paste (not a screenshot) of the error
|
||||
- [ ] I have tried a build from https://ci.viaversion.com/ and the issue still persists
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
Allows older Minecraft versions on a newer Minecraft server
|
||||
|
||||
Supported versions
|
||||
-
|
||||
**Green** = ViaVersion\
|
||||
**Purple** = ViaBackwards addition
|
||||
|
||||

|
||||
|
||||
Releases / Dev Builds
|
||||
-
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-all</artifactId>
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bukkit</artifactId>
|
||||
@@ -32,7 +32,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -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.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-bungee</artifactId>
|
||||
|
||||
@@ -21,7 +21,6 @@ public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
|
||||
Via.getManager().addEnableListener(() -> this.init(getDataFolder()));
|
||||
}
|
||||
|
||||
// Why is this not a thing in Bungee? O_o
|
||||
@Override
|
||||
public void disable() {
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</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;
|
||||
@@ -10,21 +11,11 @@ public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 ext
|
||||
extends Protocol<C1, C2, S1, S2> {
|
||||
|
||||
protected BackwardsProtocol() {
|
||||
super();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,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();
|
||||
}
|
||||
@@ -30,6 +30,10 @@ import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2.Protocol1_15_1To1_15_2;
|
||||
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;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||
@@ -42,7 +46,7 @@ import static us.myles.ViaVersion.api.protocol.ProtocolRegistry.registerProtocol
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "3.0.0";
|
||||
String MINIMUM_VV_VERSION = "3.2.0";
|
||||
|
||||
/**
|
||||
* Initialize ViaBackwards.
|
||||
@@ -86,6 +90,10 @@ public interface ViaBackwardsPlatform {
|
||||
registerProtocol(new Protocol1_15_1To1_15_2(), ProtocolVersion.v1_15_1, ProtocolVersion.v1_15_2);
|
||||
|
||||
registerProtocol(new Protocol1_15_2To1_16(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +109,7 @@ public interface ViaBackwardsPlatform {
|
||||
getLogger().severe("================================");
|
||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||
getLogger().severe("PLEASE USE VIAVERSION " + MINIMUM_VV_VERSION + " OR NEWER");
|
||||
getLogger().severe("LINK: https://viaversion.com");
|
||||
getLogger().severe("LINK: https://ci.viaversion.com/");
|
||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||
getLogger().severe("================================");
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ public class MappedItem {
|
||||
|
||||
public MappedItem(int id, String name) {
|
||||
this.id = id;
|
||||
this.jsonName = ChatRewriter.legacyTextToJson(ChatColor.RESET + name);
|
||||
this.jsonName = ChatRewriter.legacyTextToJson(ChatColor.RESET + name).toString();
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
public class EntityData {
|
||||
private final int id;
|
||||
private final int replacementId;
|
||||
private String mobName;
|
||||
private Object mobName;
|
||||
private MetaCreator defaultMeta;
|
||||
|
||||
public EntityData(int id, int replacementId) {
|
||||
@@ -47,8 +47,11 @@ public class EntityData {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return custom mobname, can be either a String or a JsonElement
|
||||
*/
|
||||
@Nullable
|
||||
public String getMobName() {
|
||||
public Object getMobName() {
|
||||
return mobName;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class EnchantmentRewriter {
|
||||
Number level = (Number) ((CompoundTag) enchantmentEntry).get("lvl").getValue();
|
||||
String loreValue = enchantmentName + " " + getRomanNumber(level.intValue());
|
||||
if (jsonFormat) {
|
||||
loreValue = ChatRewriter.legacyTextToJson(loreValue);
|
||||
loreValue = ChatRewriter.legacyTextToJson(loreValue).toString();
|
||||
}
|
||||
|
||||
lore.add(new StringTag("", loreValue));
|
||||
|
||||
@@ -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,45 +194,21 @@ 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 || ((String) data.getValue()).isEmpty())
|
||||
&& (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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return storage;
|
||||
}
|
||||
|
||||
public void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
|
||||
getEntityTracker(wrapper.user()).trackEntityType(wrapper.get(Type.INT, 0), playerType);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to handle player, painting, or xp orb trackers without meta changes.
|
||||
*/
|
||||
@@ -291,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,28 +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
|
||||
@@ -33,71 +25,79 @@ public abstract class ItemRewriter<T extends BackwardsProtocol> extends ItemRewr
|
||||
public Item handleItemToClient(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag tag = null;
|
||||
boolean textChanged = false;
|
||||
if (translatableRewriter != null
|
||||
&& item.getTag() != null && (tag = 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 = tag.get("Name");
|
||||
StringTag name = display.get("Name");
|
||||
if (name != null) {
|
||||
String newValue = translatableRewriter.processText(name.getValue());
|
||||
if (name.getValue().equals(newValue)) {
|
||||
textChanged = true;
|
||||
String newValue = translatableRewriter.processText(name.getValue()).toString();
|
||||
if (!newValue.equals(name.getValue())) {
|
||||
saveNameTag(display, name);
|
||||
}
|
||||
|
||||
name.setValue(newValue);
|
||||
}
|
||||
|
||||
ListTag lore = tag.get("Lore");
|
||||
ListTag lore = display.get("Lore");
|
||||
if (lore != null) {
|
||||
for (Tag loreEntry : lore) {
|
||||
if (!(loreEntry instanceof StringTag)) continue;
|
||||
ListTag original = null;
|
||||
boolean changed = false;
|
||||
for (Tag loreEntryTag : lore) {
|
||||
if (!(loreEntryTag instanceof StringTag)) continue;
|
||||
|
||||
StringTag stringTag = (StringTag) loreEntry;
|
||||
String newValue = translatableRewriter.processText(stringTag.getValue());
|
||||
if (stringTag.getValue().equals(newValue)) {
|
||||
textChanged = true;
|
||||
StringTag loreEntry = (StringTag) loreEntryTag;
|
||||
String newValue = translatableRewriter.processText(loreEntry.getValue()).toString();
|
||||
if (!changed && !newValue.equals(loreEntry.getValue())) {
|
||||
changed = true;
|
||||
original = lore.clone();
|
||||
}
|
||||
stringTag.setValue(newValue);
|
||||
|
||||
loreEntry.setValue(newValue);
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
saveLoreTag(display, original);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (textChanged) {
|
||||
// Backup data for toServer
|
||||
item.getTag().put(createViaNBT(item));
|
||||
}
|
||||
|
||||
MappedItem data = mappedItemFunction.get(item.getIdentifier());
|
||||
MappedItem data = protocol.getMappingData().getMappedItem(item.getIdentifier());
|
||||
if (data == null) {
|
||||
// Just rewrite the id
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
// Backup data for toServer if not already done above
|
||||
if (!textChanged) {
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
item.getTag().put(createViaNBT(item));
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
|
||||
// Set remapped id
|
||||
// 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 (tag == null) {
|
||||
item.getTag().put(tag = new CompoundTag("display"));
|
||||
if (display == null) {
|
||||
item.getTag().put(display = new CompoundTag("display"));
|
||||
}
|
||||
if (!tag.contains("Name")) {
|
||||
tag.put(new StringTag("Name", data.getJsonName()));
|
||||
if (!display.contains("Name")) {
|
||||
display.put(new StringTag("Name", data.getJsonName()));
|
||||
display.put(new ByteTag(nbtTagName + "|customName"));
|
||||
}
|
||||
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,38 +3,29 @@ 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.ByteTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
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 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,53 +33,42 @@ public abstract class ItemRewriterBase<T extends BackwardsProtocol> extends Rewr
|
||||
@Nullable
|
||||
public Item handleItemToServer(Item item) {
|
||||
if (item == null) return null;
|
||||
|
||||
CompoundTag tag = item.getTag();
|
||||
if (tag == null) {
|
||||
if (toServerRewriter != null) {
|
||||
item.setIdentifier(toServerRewriter.rewrite(item.getIdentifier()));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
CompoundTag viaTag = tag.remove(nbtTagName);
|
||||
if (viaTag != null) {
|
||||
short id = (short) viaTag.get("id").getValue();
|
||||
item.setIdentifier(id);
|
||||
|
||||
Tag dataTag = viaTag.get("data");
|
||||
short data = dataTag != null ? (short) dataTag.getValue() : 0;
|
||||
item.setData(data);
|
||||
|
||||
Tag amountTag = viaTag.get("amount");
|
||||
byte amount = amountTag != null ? (byte) amountTag.getValue() : 1;
|
||||
item.setAmount(amount);
|
||||
|
||||
CompoundTag extras = viaTag.get("extras");
|
||||
if (extras != null) {
|
||||
item.setTag(CONVERTER.convert("", CONVERTER.convert(extras)));
|
||||
}
|
||||
} else {
|
||||
// Rewrite id normally
|
||||
if (toServerRewriter != null) {
|
||||
item.setIdentifier(toServerRewriter.rewrite(item.getIdentifier()));
|
||||
}
|
||||
if (protocol.getMappingData() != null) {
|
||||
item.setIdentifier(protocol.getMappingData().getOldItemId(item.getIdentifier()));
|
||||
}
|
||||
restoreDisplayTag(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected CompoundTag createViaNBT(Item item) {
|
||||
CompoundTag tag = new CompoundTag(nbtTagName);
|
||||
tag.put(new ShortTag("id", (short) item.getIdentifier()));
|
||||
if (item.getAmount() != 1) {
|
||||
tag.put(new ByteTag("amount", item.getAmount()));
|
||||
protected void saveNameTag(CompoundTag displayTag, StringTag original) {
|
||||
displayTag.put(new StringTag(nbtTagName + "|o" + original.getName(), original.getValue()));
|
||||
}
|
||||
|
||||
protected void saveLoreTag(CompoundTag displayTag, ListTag original) {
|
||||
displayTag.put(new ListTag(nbtTagName + "|o" + original.getName(), original.getValue()));
|
||||
}
|
||||
|
||||
protected void restoreDisplayTag(Item item) {
|
||||
if (item.getTag() == null) return;
|
||||
|
||||
CompoundTag display = item.getTag().get("display");
|
||||
if (display != null) {
|
||||
// Remove custom name / restore original name
|
||||
if (display.remove(nbtTagName + "|customName") != null) {
|
||||
display.remove("Name");
|
||||
} else {
|
||||
restoreDisplayTag(display, "Name");
|
||||
}
|
||||
|
||||
// Restore lore
|
||||
restoreDisplayTag(display, "Lore");
|
||||
}
|
||||
if (item.getData() != 0) {
|
||||
tag.put(new ShortTag("data", item.getData()));
|
||||
}
|
||||
|
||||
protected void restoreDisplayTag(CompoundTag displayTag, String tagName) {
|
||||
Tag original = displayTag.remove(nbtTagName + "|o" + tagName);
|
||||
if (original != null) {
|
||||
displayTag.put(original);
|
||||
}
|
||||
if (item.getTag() != null) {
|
||||
tag.put(CONVERTER.convert("extras", CONVERTER.convert(item.getTag())));
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
+16
-21
@@ -20,13 +20,13 @@ 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;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
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.StringTag;
|
||||
@@ -78,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
|
||||
@@ -98,14 +94,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
return super.handleItemToClient(item);
|
||||
}
|
||||
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
|
||||
// Backup data for toServer
|
||||
short originalData = item.getData();
|
||||
item.getTag().put(createViaNBT(item));
|
||||
|
||||
item.setIdentifier(data.getId());
|
||||
// Keep original data if mapped data is set to -1
|
||||
if (data.getData() != -1) {
|
||||
@@ -114,19 +103,25 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
|
||||
// Set display name
|
||||
if (data.getName() != null) {
|
||||
CompoundTag tag = item.getTag().get("display");
|
||||
if (tag == null) {
|
||||
item.getTag().put(tag = new CompoundTag("display"));
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new CompoundTag(""));
|
||||
}
|
||||
StringTag nameTag = tag.get("Name");
|
||||
|
||||
CompoundTag display = item.getTag().get("display");
|
||||
if (display == null) {
|
||||
item.getTag().put(display = new CompoundTag("display"));
|
||||
}
|
||||
|
||||
StringTag nameTag = display.get("Name");
|
||||
if (nameTag == null) {
|
||||
tag.put(nameTag = new StringTag("Name", data.getName()));
|
||||
display.put(nameTag = new StringTag("Name", data.getName()));
|
||||
display.put(new ByteTag(nbtTagName + "|customName"));
|
||||
}
|
||||
|
||||
// Handle colors
|
||||
String value = nameTag.getValue();
|
||||
if (value.contains("%vb_color%")) {
|
||||
tag.put(new StringTag("Name", value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
display.put(new StringTag("Name", value.replace("%vb_color%", BlockColors.get(originalData))));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
@@ -246,7 +241,7 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
CompoundTag tag = new CompoundTag("");
|
||||
tag.put(new CompoundTag("display"));
|
||||
text = ChatColor.RESET + text;
|
||||
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text) : text));
|
||||
((CompoundTag) tag.get("display")).put(new StringTag("Name", jsonNameFormat ? ChatRewriter.legacyTextToJson(text).toString() : text));
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,12 @@ 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;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -24,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) {
|
||||
@@ -42,6 +44,35 @@ public abstract class LegacyEntityRewriter<T extends BackwardsProtocol> extends
|
||||
return objectTypes.get(type);
|
||||
}
|
||||
|
||||
protected void registerRespawn(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
|
||||
getEntityTracker(wrapper.user()).trackEntityType(wrapper.get(Type.INT, 0), playerType);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package nl.matsv.viabackwards.api.rewriters;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public abstract class RecipeRewriter {
|
||||
|
||||
protected final ItemRewriterBase rewriter;
|
||||
|
||||
protected RecipeRewriter(ItemRewriterBase rewriter) {
|
||||
this.rewriter = rewriter;
|
||||
}
|
||||
|
||||
public abstract void handle(PacketWrapper wrapper, String type) throws Exception;
|
||||
|
||||
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
||||
rewriter.getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
handle(wrapper, type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -5,20 +5,18 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TranslatableRewriter {
|
||||
public class TranslatableRewriter extends ComponentRewriter {
|
||||
|
||||
private static final Map<String, Map<String, String>> TRANSLATABLES = new HashMap<>();
|
||||
protected final BackwardsProtocol protocol;
|
||||
protected final Map<String, String> newTranslatables;
|
||||
|
||||
public static void loadTranslatables() {
|
||||
@@ -37,20 +35,21 @@ public class TranslatableRewriter {
|
||||
}
|
||||
|
||||
public TranslatableRewriter(BackwardsProtocol protocol, String sectionIdentifier) {
|
||||
this.protocol = protocol;
|
||||
super(protocol);
|
||||
final Map<String, String> newTranslatables = TRANSLATABLES.get(sectionIdentifier);
|
||||
if (newTranslatables == null) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("Error loading " + sectionIdentifier + " translatables!");
|
||||
this.newTranslatables = new HashMap<>();
|
||||
} else
|
||||
} else {
|
||||
this.newTranslatables = newTranslatables;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.registerOutgoing(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -59,7 +58,7 @@ public class TranslatableRewriter {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -68,23 +67,7 @@ public class TranslatableRewriter {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerBossBar(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -95,7 +78,7 @@ public class TranslatableRewriter {
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -106,36 +89,7 @@ public class TranslatableRewriter {
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatEvent(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.passthrough(Type.VAR_INT) == 2) {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTitle(ClientboundPacketType packetType) {
|
||||
protocol.registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
}
|
||||
});
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -145,84 +99,18 @@ public class TranslatableRewriter {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
wrapper.write(Type.STRING, processText(wrapper.read(Type.STRING)));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String processText(String value) {
|
||||
JsonElement root = GsonUtil.getJsonParser().parse(value);
|
||||
processText(root);
|
||||
return root.toString();
|
||||
}
|
||||
|
||||
protected void processText(JsonElement element) {
|
||||
if (element == null || element.isJsonNull()) return;
|
||||
if (element.isJsonArray()) {
|
||||
processAsArray(element);
|
||||
return;
|
||||
}
|
||||
if (element.isJsonPrimitive()) {
|
||||
handleText(element.getAsJsonPrimitive());
|
||||
return;
|
||||
}
|
||||
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
JsonPrimitive text = object.getAsJsonPrimitive("text");
|
||||
if (text != null) {
|
||||
handleText(text);
|
||||
}
|
||||
|
||||
JsonElement translate = object.get("translate");
|
||||
if (translate != null) {
|
||||
handleTranslate(object, translate.getAsString());
|
||||
|
||||
JsonElement with = object.get("with");
|
||||
if (with != null) {
|
||||
processAsArray(with);
|
||||
}
|
||||
}
|
||||
|
||||
JsonElement extra = object.get("extra");
|
||||
if (extra != null) {
|
||||
processAsArray(extra);
|
||||
}
|
||||
|
||||
JsonObject hoverEvent = object.getAsJsonObject("hoverEvent");
|
||||
if (hoverEvent != null) {
|
||||
handleHoverEvent(hoverEvent);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleText(JsonPrimitive text) {
|
||||
// In case this is needed in the future
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject root, String translate) {
|
||||
String newTranslate = newTranslatables.get(translate);
|
||||
if (newTranslate != null) {
|
||||
root.addProperty("translate", newTranslate);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleHoverEvent(JsonObject hoverEvent) {
|
||||
String action = hoverEvent.getAsJsonPrimitive("action").getAsString();
|
||||
if (action.equals("show_text")) {
|
||||
JsonElement value = hoverEvent.get("value");
|
||||
processText(value != null ? value : hoverEvent.get("contents"));
|
||||
} else if (action.equals("show_entity")) {
|
||||
JsonObject contents = hoverEvent.getAsJsonObject("contents");
|
||||
if (contents != null) {
|
||||
processText(contents.get("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processAsArray(JsonElement element) {
|
||||
for (JsonElement jsonElement : element.getAsJsonArray()) {
|
||||
processText(jsonElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -270,7 +270,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.STRING); // 1 - Window Type
|
||||
map(Type.STRING); // 2 - Title
|
||||
map(Type.COMPONENT); // 2 - Title
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Slots
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@@ -278,8 +278,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = -1;
|
||||
// Passthrough Entity ID
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse"))
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse")) {
|
||||
entityId = wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
// Track Inventory
|
||||
String inventory = wrapper.get(Type.STRING, 0);
|
||||
@@ -288,8 +289,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
windowTracker.setEntityId(entityId);
|
||||
|
||||
// Change llama slotcount to the donkey one
|
||||
if (isLlama(wrapper.user()))
|
||||
if (isLlama(wrapper.user())) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) 17);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-3
@@ -297,9 +297,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
|
||||
Metadata data = e.getData();
|
||||
data.setId(13);
|
||||
data.setMetaType(MetaType1_9.VarInt);
|
||||
|
||||
data.setValue((int) data.getValue() == 1 ? 2 : 4);
|
||||
|
||||
data.setValue(((Number) data.getValue()).intValue() == 1 ? 2 : 4);
|
||||
return data;
|
||||
});
|
||||
|
||||
|
||||
+20
-22
@@ -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_13to1_12_2.ChatRewriter;
|
||||
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,30 +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
|
||||
String msg = wrapper.read(Type.STRING);
|
||||
msg = ChatRewriter.jsonTextToLegacy(msg);
|
||||
msg = "{\"text\":\"" + msg + "\"}";
|
||||
actionbar.write(Type.STRING, 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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+17
@@ -18,11 +18,15 @@ import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPackets1_
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
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_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||
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.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_12, ClientboundPackets1_9_3, ServerboundPackets1_12, ServerboundPackets1_9_3> {
|
||||
|
||||
@@ -40,6 +44,19 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
|
||||
new SoundPackets1_12(this).register();
|
||||
new ChatPackets1_12(this).register();
|
||||
|
||||
registerOutgoing(ClientboundPackets1_12.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
JsonElement component = wrapper.read(Type.COMPONENT);
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(component.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelOutgoing(ClientboundPackets1_12.ADVANCEMENTS);
|
||||
cancelOutgoing(ClientboundPackets1_12.UNLOCK_RECIPES);
|
||||
cancelOutgoing(ClientboundPackets1_12.SELECT_ADVANCEMENTS_TAB);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class ShoulderTracker extends StoredObject {
|
||||
public void update() {
|
||||
PacketWrapper wrapper = new PacketWrapper(0x0F, null, getUser());
|
||||
|
||||
wrapper.write(Type.STRING, Protocol1_9To1_8.fixJson(generateString()));
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(generateString()));
|
||||
wrapper.write(Type.BYTE, (byte) 2);
|
||||
|
||||
try {
|
||||
|
||||
+2
-2
@@ -57,8 +57,8 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<Protocol1_11_1
|
||||
if (columns <= 0) return;
|
||||
|
||||
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.passthrough(Type.BYTE); //X
|
||||
wrapper.passthrough(Type.BYTE); //Z
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
short color = (short) (data[i] & 0xFF);
|
||||
|
||||
+13
-64
@@ -10,22 +10,28 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTranslations;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.ComponentRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
|
||||
private final ComponentRewriter componentRewriter = new ComponentRewriter() {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject object, String translate) {
|
||||
String text = AdvancementTranslations.get(translate);
|
||||
if (text != null) {
|
||||
object.addProperty("translate", text);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public ChatPackets1_12(Protocol1_11_1To1_12 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
@@ -35,68 +41,11 @@ public class ChatPackets1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
||||
protocol.registerOutgoing(ClientboundPackets1_12.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Json Data
|
||||
map(Type.BYTE); // 1 - Position
|
||||
|
||||
handler(wrapper -> {
|
||||
try {
|
||||
JsonObject object = GsonUtil.getJsonParser().parse(wrapper.get(Type.STRING, 0)).getAsJsonObject();
|
||||
// Skip if the root doesn't contain translate
|
||||
if (object.has("translate")) {
|
||||
handleTranslations(object);
|
||||
}
|
||||
|
||||
ChatItemRewriter.toClient(object, wrapper.user());
|
||||
wrapper.set(Type.STRING, 0, object.toString());
|
||||
} catch (Exception e) {
|
||||
// Only print if ViaVer debug is enabled
|
||||
if (Via.getManager().isDebug()) {
|
||||
ViaBackwards.getPlatform().getLogger().severe("Failed to handle translations");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
JsonElement element = wrapper.passthrough(Type.COMPONENT);
|
||||
componentRewriter.processText(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// improve this, not copying will cause ConcurrentModificationException
|
||||
public void handleTranslations(JsonObject object) {
|
||||
JsonObject copiedObj = copy(object);
|
||||
|
||||
if (object.isJsonObject()) {
|
||||
for (Map.Entry<String, JsonElement> entry : copiedObj.entrySet()) {
|
||||
// Get the text that doesn't exist for 1.11 <
|
||||
|
||||
if (entry.getKey().equalsIgnoreCase("translate")) {
|
||||
String translate = entry.getValue().getAsString();
|
||||
String text = AdvancementTranslations.get(translate);
|
||||
if (text != null) {
|
||||
object.addProperty("translate", text);
|
||||
}
|
||||
}
|
||||
// Handle arrays
|
||||
if (entry.getValue().isJsonArray())
|
||||
for (JsonElement element : object.get(entry.getKey()).getAsJsonArray())
|
||||
if (element.isJsonObject())
|
||||
handleTranslations(element.getAsJsonObject());
|
||||
|
||||
// Handle objects
|
||||
if (entry.getValue().isJsonObject())
|
||||
handleTranslations(object.get(entry.getKey()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JsonObject copy(JsonObject object) {
|
||||
JsonObject result = new JsonObject();
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
if (entry.getValue().isJsonObject())
|
||||
result.add(entry.getKey(), copy(entry.getValue().getAsJsonObject()));
|
||||
else
|
||||
result.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+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;
|
||||
|
||||
|
||||
+48
-37
@@ -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");
|
||||
public BackwardsMappings() {
|
||||
super("1.13", "1.12", Protocol1_13To1_12_2.class, true);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for (Map.Entry<String, Integer> entry : StatisticMappings.statistics.entrySet()) {
|
||||
@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;
|
||||
}
|
||||
}
|
||||
+11
-4
@@ -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,13 +34,17 @@ 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;
|
||||
|
||||
return new int[]{type + (meta << 12)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockHandler() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
particles = new ParticleData[]{
|
||||
@@ -148,11 +151,15 @@ public class ParticleMapping {
|
||||
return new ParticleData(replacementId, handler);
|
||||
}
|
||||
|
||||
interface ParticleHandler {
|
||||
public interface ParticleHandler {
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||
|
||||
int[] rewrite(Protocol1_12_2To1_13 protocol, List<Particle.ParticleData> data);
|
||||
|
||||
default boolean isBlockHandler() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class ParticleData {
|
||||
|
||||
+30
-43
@@ -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);
|
||||
@@ -246,9 +232,9 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
int chunkZ = wrapper.get(Type.INT, 1);
|
||||
int block = record.getBlockId();
|
||||
Position position = new Position(
|
||||
(record.getHorizontal() >> 4 & 15) + (chunkX * 16),
|
||||
record.getSectionX() + (chunkX * 16),
|
||||
record.getY(),
|
||||
(record.getHorizontal() & 15) + (chunkZ * 16));
|
||||
record.getSectionZ() + (chunkZ * 16));
|
||||
|
||||
// Store if needed
|
||||
storage.checkAndStore(position, block);
|
||||
@@ -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));
|
||||
@@ -441,7 +427,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
byte z = wrapper.read(Type.BYTE);
|
||||
byte direction = wrapper.read(Type.BYTE);
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.COMPONENT);
|
||||
}
|
||||
if (type > 9) {
|
||||
wrapper.set(Type.VAR_INT, 1, wrapper.get(Type.VAR_INT, 1) - 1);
|
||||
@@ -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()) {
|
||||
@@ -592,8 +575,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
if (display != null) {
|
||||
StringTag name = display.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
StringTag via = display.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.jsonTextToLegacy(name.getValue()));
|
||||
display.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
|
||||
name.setValue(ChatRewriter.jsonTextToLegacy(name.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,6 +608,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
private void rewriteCanPlaceToClient(CompoundTag tag, String tagName) {
|
||||
// The tag was manually created incorrectly so ignore rewriting it
|
||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
||||
ListTag blockTag = tag.get(tagName);
|
||||
if (blockTag == null) return;
|
||||
|
||||
@@ -666,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 (?)
|
||||
@@ -788,8 +773,8 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
CompoundTag displayTag = (CompoundTag) display;
|
||||
StringTag name = displayTag.get("Name");
|
||||
if (name instanceof StringTag) {
|
||||
displayTag.put(new StringTag(extraNbtTag + "|Name", name.getValue()));
|
||||
name.setValue(ChatRewriter.legacyTextToJson(name.getValue()));
|
||||
StringTag via = displayTag.remove(extraNbtTag + "|Name");
|
||||
name.setValue(via != null ? via.getValue() : ChatRewriter.legacyTextToJson(name.getValue()).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,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
|
||||
@@ -845,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()) {
|
||||
@@ -856,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);
|
||||
@@ -865,6 +851,7 @@ public class BlockItemPackets1_13 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
|
||||
private void rewriteCanPlaceToServer(CompoundTag tag, String tagName) {
|
||||
if (!(tag.get(tagName) instanceof ListTag)) return;
|
||||
ListTag blockTag = tag.remove(extraNbtTag + "|" + tagName);
|
||||
if (blockTag != null) {
|
||||
tag.put(ConverterRegistry.convertToTag(tagName, ConverterRegistry.convertToValue(blockTag)));
|
||||
@@ -917,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;
|
||||
}
|
||||
@@ -1001,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
|
||||
|
||||
+7
-2
@@ -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) {
|
||||
@@ -323,7 +323,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
// Rewrite Custom Name from Chat to String
|
||||
registerMetaHandler().filter(Entity1_13Types.EntityType.ENTITY, true, 2).handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
String value = (String) meta.getValue();
|
||||
String value = meta.getValue().toString();
|
||||
if (value.isEmpty()) return meta;
|
||||
meta.setValue(ChatRewriter.jsonTextToLegacy(value));
|
||||
return meta;
|
||||
@@ -382,6 +382,11 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<Protocol1_12_2To1_13
|
||||
int secondArg = 0;
|
||||
int[] particleArgs = data.rewriteMeta(protocol, particle.getArguments());
|
||||
if (particleArgs != null && particleArgs.length != 0) {
|
||||
if (data.getHandler().isBlockHandler() && particleArgs[0] == 0) {
|
||||
// Air doesn't have a break particle for sub 1.13 clients -> glass pane
|
||||
particleArgs[0] = 102;
|
||||
}
|
||||
|
||||
firstArg = particleArgs[0];
|
||||
secondArg = particleArgs.length == 2 ? particleArgs[1] : 0;
|
||||
}
|
||||
|
||||
+27
-13
@@ -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;
|
||||
@@ -21,6 +20,7 @@ import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12
|
||||
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.packets.InventoryPackets;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@@ -138,8 +138,15 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
int[] data = old.rewriteData(protocol, wrapper);
|
||||
if (data != null) {
|
||||
for (int i : data)
|
||||
if (old.getHandler().isBlockHandler() && data[0] == 0) {
|
||||
// Cancel air block particles
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i : data) {
|
||||
wrapper.write(Type.VAR_INT, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -171,7 +178,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 1) { // Update Game Mode
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
@@ -179,7 +186,7 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 3) { // Update Display Name
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 4) { // Remove Player
|
||||
storage.usernames.remove(uuid);
|
||||
@@ -200,9 +207,12 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
byte mode = wrapper.get(Type.BYTE, 0);
|
||||
if (mode == 0 || mode == 2) {
|
||||
String value = wrapper.read(Type.STRING);
|
||||
String value = wrapper.read(Type.COMPONENT).toString();
|
||||
value = ChatRewriter.jsonTextToLegacy(value);
|
||||
if (value.length() > 32) value = value.substring(0, 32);
|
||||
if (value.length() > 32) {
|
||||
value = value.substring(0, 32);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, value);
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.STRING, type == 1 ? "hearts" : "integer");
|
||||
@@ -225,7 +235,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
String displayName = wrapper.read(Type.STRING);
|
||||
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
||||
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
||||
if (displayName.length() > 32) displayName = displayName.substring(0, 32);
|
||||
if (displayName.length() > 32) {
|
||||
displayName = displayName.substring(0, 32);
|
||||
}
|
||||
wrapper.write(Type.STRING, displayName);
|
||||
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
@@ -237,9 +249,10 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
colour = -1;
|
||||
}
|
||||
|
||||
String prefix = wrapper.read(Type.STRING);
|
||||
String suffix = wrapper.read(Type.STRING);
|
||||
prefix = prefix == null || prefix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(prefix);
|
||||
JsonElement prefixComponent = wrapper.read(Type.COMPONENT);
|
||||
JsonElement suffixComponent = wrapper.read(Type.COMPONENT);
|
||||
|
||||
String prefix = prefixComponent == null || prefixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(prefixComponent.toString());
|
||||
if (ViaBackwards.getConfig().addTeamColorTo1_13Prefix()) {
|
||||
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
|
||||
}
|
||||
@@ -248,10 +261,11 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||
|
||||
suffix = suffix == null || suffix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(suffix);
|
||||
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
|
||||
String suffix = suffixComponent == null || suffixComponent.isJsonNull() ? "" : ChatRewriter.jsonTextToLegacy(suffixComponent.toString());
|
||||
suffix = ChatUtil.removeUnusedColor(suffix, '\0'); // Don't remove white coloring
|
||||
if (suffix.length() > 16) suffix = suffix.substring(0, 16);
|
||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||
|
||||
wrapper.write(Type.STRING, prefix);
|
||||
wrapper.write(Type.STRING, suffix);
|
||||
|
||||
@@ -527,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 {
|
||||
|
||||
+2
-2
@@ -49,8 +49,8 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.write(Type.FLAT_ITEM, icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
|
||||
+13
-68
@@ -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;
|
||||
@@ -14,17 +13,18 @@ import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.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;
|
||||
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;
|
||||
|
||||
@@ -34,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);
|
||||
@@ -52,51 +52,12 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
new PlayerPackets1_14(this).register();
|
||||
new SoundPackets1_14(this).register();
|
||||
|
||||
new StatisticsRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_14.STATISTICS);
|
||||
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_POSITION);
|
||||
cancelOutgoing(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
||||
cancelOutgoing(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
|
||||
registerOutgoing(ClientboundPackets1_14.ADVANCEMENTS, new PacketRemapper() { // c
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN))
|
||||
wrapper.passthrough(Type.STRING);
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0)
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_14.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@@ -110,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;
|
||||
}
|
||||
}
|
||||
@@ -122,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;
|
||||
}
|
||||
}
|
||||
@@ -200,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
|
||||
@@ -248,4 +188,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public EntityPackets1_14 getEntityPackets() {
|
||||
return entityPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +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 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"));
|
||||
}
|
||||
}
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_14 extends RecipeRewriter {
|
||||
|
||||
public RecipeRewriter1_14(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmelting(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
|
||||
public void handleCraftingShaped(PacketWrapper wrapper) throws Exception {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
}
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
|
||||
public void handleCraftingShapeless(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
}
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
||||
+32
-52
@@ -4,11 +4,8 @@ import com.google.common.collect.ImmutableSet;
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
|
||||
import nl.matsv.viabackwards.api.rewriters.RecipeRewriter;
|
||||
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.data.RecipeRewriter1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@@ -24,17 +21,19 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
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.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.util.GsonUtil;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
import us.myles.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@@ -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
|
||||
@@ -137,19 +136,19 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
wrapper.write(Type.STRING, stringType);
|
||||
|
||||
String title = wrapper.read(Type.STRING);
|
||||
JsonElement title = wrapper.read(Type.COMPONENT);
|
||||
if (containerTitle != null) {
|
||||
// Don't rewrite renamed, only translatable titles
|
||||
JsonObject object = GsonUtil.getGson().fromJson(title, JsonObject.class);
|
||||
if (object.has("translate")) {
|
||||
JsonObject object;
|
||||
if (title.isJsonObject() && (object = title.getAsJsonObject()).has("translate")) {
|
||||
// Don't rewrite other 9x3 translatable containers
|
||||
if (type != 2 || object.getAsJsonPrimitive("translate").getAsString().equals("container.barrel")) {
|
||||
title = ChatRewriter.legacyTextToJson(containerTitle);
|
||||
}
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.STRING, title);
|
||||
|
||||
wrapper.write(Type.COMPONENT, title);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize);
|
||||
}
|
||||
});
|
||||
@@ -165,7 +164,9 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Window id
|
||||
wrapper.write(Type.STRING, "EntityHorse"); // Type
|
||||
wrapper.write(Type.STRING, "{\"translate\":\"minecraft.horse\"}"); // Title
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("translate", "minecraft.horse");
|
||||
wrapper.write(Type.COMPONENT, object); // Title
|
||||
wrapper.write(Type.UNSIGNED_BYTE, wrapper.read(Type.VAR_INT).shortValue()); // Number of slots
|
||||
wrapper.passthrough(Type.INT); // Entity id
|
||||
}
|
||||
@@ -174,11 +175,12 @@ 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);
|
||||
|
||||
// Trade List -> Plugin Message
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@@ -280,12 +282,12 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() { // c
|
||||
RecipeRewriter recipeHandler = new RecipeRewriter1_13_2(protocol, this::handleItemToClient);
|
||||
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
private final Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
|
||||
private final RecipeRewriter recipeHandler = new RecipeRewriter1_14(BlockItemPackets1_14.this);
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
@@ -355,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;
|
||||
@@ -375,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));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -413,7 +415,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type());
|
||||
wrapper.write(new Chunk1_13Type(clientWorld), chunk);
|
||||
|
||||
ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
|
||||
@@ -440,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);
|
||||
}
|
||||
}
|
||||
@@ -450,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);
|
||||
}
|
||||
}
|
||||
@@ -485,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
|
||||
@@ -535,21 +536,19 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
CompoundTag display = tag.get("display");
|
||||
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
|
||||
ListTag lore = display.get("Lore");
|
||||
ListTag via = display.get(nbtTagName + "|Lore");
|
||||
ListTag via = display.remove(nbtTagName + "|Lore");
|
||||
if (via != null) {
|
||||
display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
|
||||
} else {
|
||||
for (Tag loreEntry : lore) {
|
||||
if (loreEntry instanceof StringTag) {
|
||||
((StringTag) loreEntry).setValue(
|
||||
ChatRewriter.jsonTextToLegacy(
|
||||
((StringTag) loreEntry).getValue()
|
||||
)
|
||||
);
|
||||
if (!(loreEntry instanceof StringTag)) continue;
|
||||
|
||||
String value = ((StringTag) loreEntry).getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
((StringTag) loreEntry).setValue(ChatRewriter.jsonTextToLegacy(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
display.remove(nbtTagName + "|Lore");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,7 +572,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
display.put(ConverterRegistry.convertToTag(nbtTagName + "|Lore", ConverterRegistry.convertToValue(lore)));
|
||||
for (Tag loreEntry : lore) {
|
||||
if (loreEntry instanceof StringTag) {
|
||||
((StringTag) loreEntry).setValue(ChatRewriter.legacyTextToJson(((StringTag) loreEntry).getValue()));
|
||||
((StringTag) loreEntry).setValue(ChatRewriter.legacyTextToJson(((StringTag) loreEntry).getValue()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -583,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);
|
||||
|
||||
+20
-64
@@ -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,19 +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);
|
||||
@@ -103,7 +111,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING)));
|
||||
translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT));
|
||||
if (action == 0) {
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
@@ -136,8 +144,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
wrapper.passthrough(Type.COMPONENT); // Title
|
||||
wrapper.passthrough(Type.COMPONENT); // Description
|
||||
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
InventoryPackets1_13_1.toClient(icon);
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
@@ -160,66 +168,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT); // block tags
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] blocks = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < blocks.length; j++) {
|
||||
blocks[j] = getNewBlockId(blocks[j]);
|
||||
}
|
||||
}
|
||||
int itemTagsSize = wrapper.passthrough(Type.VAR_INT); // item tags
|
||||
for (int i = 0; i < itemTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] items = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < items.length; j++) {
|
||||
items[j] = InventoryPackets1_13_1.getOldItemId(items[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
@@ -231,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);
|
||||
}
|
||||
}
|
||||
-4
@@ -5,8 +5,4 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
|
||||
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_14_1To1_14_2() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
+19
-64
@@ -4,9 +4,11 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
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.rewriters.RecipeRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
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_14to1_13_2.data.RecipeRewriter1_14;
|
||||
|
||||
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
@@ -47,77 +49,30 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
RecipeRewriter recipeHandler = new RecipeRewriter1_14(this, item -> {});
|
||||
registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int deleted = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String fullType = wrapper.read(Type.STRING);
|
||||
String type = fullType.replace("minecraft:", "");
|
||||
String id = wrapper.read(Type.STRING); // id
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int deleted = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String fullType = wrapper.read(Type.STRING);
|
||||
String type = fullType.replace("minecraft:", "");
|
||||
String id = wrapper.read(Type.STRING); // id
|
||||
|
||||
if (type.equals("crafting_special_repairitem")) {
|
||||
deleted++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, fullType);
|
||||
wrapper.write(Type.STRING, id);
|
||||
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
}
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "stonecutting":
|
||||
wrapper.passthrough(Type.STRING); // Group?
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
|
||||
|
||||
break;
|
||||
case "smelting":
|
||||
case "blasting":
|
||||
case "campfire_cooking":
|
||||
case "smoking":
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
|
||||
break;
|
||||
}
|
||||
if (type.equals("crafting_special_repairitem")) {
|
||||
deleted++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||
wrapper.write(Type.STRING, fullType);
|
||||
wrapper.write(Type.STRING, id);
|
||||
|
||||
recipeHandler.handle(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+17
-114
@@ -1,30 +1,28 @@
|
||||
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;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
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;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
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() {
|
||||
@@ -33,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);
|
||||
@@ -48,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);
|
||||
@@ -80,122 +77,28 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_15.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
}
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
new TagRewriter(this, EntityTypeMapping::getOldEntityId).register(ClientboundPackets1_15.TAGS);
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_15.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < blockIds.length; j++) {
|
||||
int id = blockIds[j];
|
||||
blockIds[j] = BackwardsMappings.blockMappings.getNewId(id);
|
||||
}
|
||||
}
|
||||
|
||||
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < itemTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < itemIds.length; j++) {
|
||||
int oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]);
|
||||
itemIds[j] = oldId;
|
||||
}
|
||||
}
|
||||
|
||||
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags
|
||||
for (int i = 0; i < fluidTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
}
|
||||
|
||||
int entityTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < entityTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
for (int j = 0; j < entityIds.length; j++) {
|
||||
entityIds[j] = EntityTypeMapping.getOldEntityId(entityIds[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(ClientWorld.class))
|
||||
user.put(new ClientWorld(user));
|
||||
if (!user.has(ImmediateRespawn.class))
|
||||
if (!user.has(ImmediateRespawn.class)) {
|
||||
user.put(new ImmediateRespawn(user));
|
||||
if (!user.has(EntityTracker.class))
|
||||
}
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
}
|
||||
|
||||
public BlockItemPackets1_15 getBlockItemPackets() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +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 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"));
|
||||
}
|
||||
}
|
||||
-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;
|
||||
}
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.RecipeRewriter1_14;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_15 extends RecipeRewriter1_14 {
|
||||
|
||||
public RecipeRewriter1_15(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "blasting": // new
|
||||
case "smoking": // new
|
||||
case "campfire_cooking": // new
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
case "stonecutting": // new
|
||||
handleStonecutting(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleStonecutting(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
||||
+17
-80
@@ -1,11 +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 nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
@@ -16,24 +12,23 @@ 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_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;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
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_15(this).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_14(protocol, this::handleItemToClient).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
protocol.registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -42,50 +37,12 @@ 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);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_15.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
@@ -100,9 +57,8 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
||||
wrapper.write(new Chunk1_14Type(clientWorld), chunk);
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type());
|
||||
wrapper.write(new Chunk1_14Type(), chunk);
|
||||
|
||||
if (chunk.isFullChunk()) {
|
||||
int[] biomeData = chunk.getBiomeData();
|
||||
@@ -132,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);
|
||||
}
|
||||
}
|
||||
@@ -141,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
|
||||
@@ -160,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
-7
@@ -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
|
||||
@@ -91,7 +90,6 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
map(Type.LONG, Type.NOTHING); // Seed
|
||||
handler(getDimensionHandler(0));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -110,7 +108,6 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||
|
||||
handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.INT));
|
||||
handler(getDimensionHandler(1));
|
||||
|
||||
handler(wrapper -> wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(wrapper.read(Type.BOOLEAN)));
|
||||
}
|
||||
@@ -193,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;
|
||||
});
|
||||
|
||||
-5
@@ -1,13 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_15_1To1_15_2 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_15_1To1_15_2() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
+31
-91
@@ -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;
|
||||
@@ -12,6 +11,7 @@ import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
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.packets.State;
|
||||
@@ -20,13 +20,16 @@ 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;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
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;
|
||||
|
||||
@@ -36,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);
|
||||
@@ -50,10 +53,25 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
EntityPackets1_16 entityPackets = new EntityPackets1_16(this);
|
||||
entityPackets.register();
|
||||
|
||||
registerOutgoing(State.STATUS, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
String original = wrapper.passthrough(Type.STRING);
|
||||
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
|
||||
JsonElement description = object.get("description");
|
||||
if (description == null) return;
|
||||
|
||||
translatableRewriter.processText(description);
|
||||
wrapper.set(Type.STRING, 0, object.toString());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
map(Type.BYTE);
|
||||
map(Type.UUID, Type.NOTHING); // Sender
|
||||
}
|
||||
@@ -64,7 +82,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Window Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> wrapper.write(Type.STRING, translatableRewriter.processText(wrapper.read(Type.STRING))));
|
||||
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
handler(wrapper -> {
|
||||
int windowType = wrapper.get(Type.VAR_INT, 1);
|
||||
if (windowType == 20) { // Smithing table
|
||||
@@ -76,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);
|
||||
@@ -95,73 +112,9 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Identifier
|
||||
// Parent
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
}
|
||||
// Display data
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||
if ((flags & 1) != 0) {
|
||||
wrapper.passthrough(Type.STRING); // Background texture
|
||||
}
|
||||
wrapper.passthrough(Type.FLOAT); // X
|
||||
wrapper.passthrough(Type.FLOAT); // Y
|
||||
}
|
||||
new TagRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
||||
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int array = 0; array < arrayLength; array++) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerOutgoing(ClientboundPackets1_16.STATISTICS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int categoryId = wrapper.read(Type.VAR_INT);
|
||||
int statisticId = wrapper.read(Type.VAR_INT);
|
||||
// New statistics
|
||||
if (statisticId > 49) {
|
||||
wrapper.read(Type.VAR_INT);
|
||||
newSize--;
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, categoryId);
|
||||
wrapper.write(Type.VAR_INT, statisticId);
|
||||
wrapper.passthrough(Type.VAR_INT); // value
|
||||
}
|
||||
|
||||
if (newSize != size) {
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
|
||||
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
|
||||
new StatisticsRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16.STATISTICS);
|
||||
|
||||
registerIncoming(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -218,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)) {
|
||||
@@ -255,4 +190,9 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
public TranslatableRewriter getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
+10
-7
@@ -31,7 +31,7 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
protected void processText(JsonElement value) {
|
||||
public void processText(JsonElement value) {
|
||||
super.processText(value);
|
||||
if (!value.isJsonObject()) return;
|
||||
|
||||
@@ -98,13 +98,16 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter {
|
||||
}
|
||||
|
||||
// Check by the greatest diff of the 3 values
|
||||
int rDiff = Math.abs(color.r - r);
|
||||
int gDiff = Math.abs(color.g - g);
|
||||
int bDiff = Math.abs(color.b - b);
|
||||
int maxDiff = Math.max(Math.max(rDiff, gDiff), bDiff);
|
||||
if (closest == null || maxDiff < smallestDiff) {
|
||||
int rAverage = (color.r + r) / 2;
|
||||
int rDiff = color.r - r;
|
||||
int gDiff = color.g - g;
|
||||
int bDiff = color.b - b;
|
||||
int diff = ((2 + (rAverage >> 8)) * rDiff * rDiff)
|
||||
+ (4 * gDiff * gDiff)
|
||||
+ ((2 + ((255 - rAverage) >> 8)) * bDiff * bDiff);
|
||||
if (closest == null || diff < smallestDiff) {
|
||||
closest = color;
|
||||
smallestDiff = maxDiff;
|
||||
smallestDiff = diff;
|
||||
}
|
||||
}
|
||||
return closest.colorName;
|
||||
|
||||
+13
-25
@@ -1,38 +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 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"));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import us.myles.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public class MapColorRewriter {
|
||||
|
||||
private static final Int2IntMap MAPPINGS = new Int2IntOpenHashMap();
|
||||
|
||||
static {
|
||||
MAPPINGS.put(208, 113);
|
||||
MAPPINGS.put(209, 114);
|
||||
MAPPINGS.put(210, 114);
|
||||
MAPPINGS.put(211, 112);
|
||||
MAPPINGS.put(212, 152);
|
||||
MAPPINGS.put(213, 83);
|
||||
MAPPINGS.put(214, 83);
|
||||
MAPPINGS.put(215, 155);
|
||||
MAPPINGS.put(216, 143);
|
||||
MAPPINGS.put(217, 115);
|
||||
MAPPINGS.put(218, 115);
|
||||
MAPPINGS.put(219, 143);
|
||||
MAPPINGS.put(220, 127);
|
||||
MAPPINGS.put(221, 127);
|
||||
MAPPINGS.put(222, 127);
|
||||
MAPPINGS.put(223, 95);
|
||||
MAPPINGS.put(224, 127);
|
||||
MAPPINGS.put(225, 127);
|
||||
MAPPINGS.put(226, 124);
|
||||
MAPPINGS.put(227, 95);
|
||||
MAPPINGS.put(228, 187);
|
||||
MAPPINGS.put(229, 155);
|
||||
MAPPINGS.put(230, 184);
|
||||
MAPPINGS.put(231, 187);
|
||||
MAPPINGS.put(232, 127);
|
||||
MAPPINGS.put(233, 124);
|
||||
MAPPINGS.put(234, 125);
|
||||
MAPPINGS.put(235, 127);
|
||||
}
|
||||
|
||||
public static int getMappedColor(int color) {
|
||||
return MAPPINGS.getOrDefault(color, -1);
|
||||
}
|
||||
}
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.ItemRewriterBase;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.RecipeRewriter1_15;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class RecipeRewriter1_16 extends RecipeRewriter1_15 {
|
||||
|
||||
public RecipeRewriter1_16(ItemRewriterBase rewriter) {
|
||||
super(rewriter);
|
||||
}
|
||||
|
||||
public void register(ClientboundPacketType packetType) {
|
||||
// Remove new smithing type, only in this handler
|
||||
rewriter.getProtocol().registerOutgoing(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
String originalType = wrapper.read(Type.STRING);
|
||||
String type = originalType.replace("minecraft:", "");
|
||||
if (type.equals("smithing")) {
|
||||
newSize--;
|
||||
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, originalType);
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
handle(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
||||
switch (type) {
|
||||
case "crafting_shapeless":
|
||||
handleCraftingShapeless(wrapper);
|
||||
break;
|
||||
case "crafting_shaped":
|
||||
handleCraftingShaped(wrapper);
|
||||
break;
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting":
|
||||
handleSmelting(wrapper);
|
||||
break;
|
||||
case "stonecutting":
|
||||
handleStonecutting(wrapper);
|
||||
break;
|
||||
case "smithing": // new
|
||||
handleSmithing(wrapper);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmithing(PacketWrapper wrapper) throws Exception {
|
||||
Item[] baseIngredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : baseIngredients) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
Item[] ingredients = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
for (Item item : ingredients) {
|
||||
rewriter.handleItemToClient(item);
|
||||
}
|
||||
rewriter.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
}
|
||||
}
|
||||
+117
-107
@@ -1,12 +1,11 @@
|
||||
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.RecipeRewriter1_16;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.MapColorRewriter;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@@ -16,12 +15,12 @@ import us.myles.ViaVersion.api.rewriters.ItemRewriter;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
||||
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_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.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
@@ -38,57 +37,51 @@ 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);
|
||||
|
||||
new RecipeRewriter1_16(this).register(ClientboundPackets1_16.DECLARE_RECIPES);
|
||||
|
||||
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, BlockItemPackets1_16::getOldItemId);
|
||||
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.TRADE_LIST, new PacketRemapper() {
|
||||
RecipeRewriter1_14 recipeRewriter = new RecipeRewriter1_14(protocol, this::handleItemToClient);
|
||||
// Remove new smithing type, only in this handler
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(input);
|
||||
String originalType = wrapper.read(Type.STRING);
|
||||
String type = originalType.replace("minecraft:", "");
|
||||
if (type.equals("smithing")) {
|
||||
newSize--;
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
handleItemToClient(second);
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT);
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
continue;
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.write(Type.STRING, originalType);
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
recipeRewriter.handle(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
|
||||
@@ -140,16 +133,15 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_16Type(clientWorld));
|
||||
wrapper.write(new Chunk1_15Type(clientWorld), chunk);
|
||||
Chunk chunk = wrapper.read(new Chunk1_16Type());
|
||||
wrapper.write(new Chunk1_15Type(), chunk);
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue;
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int old = section.getPaletteEntry(j);
|
||||
section.setPaletteEntry(j, Protocol1_15_2To1_16.getNewBlockStateId(old));
|
||||
section.setPaletteEntry(j, protocol.getMappingData().getNewBlockStateId(old));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,37 +169,15 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
|
||||
if (chunk.getBlockEntities() == null) return;
|
||||
for (CompoundTag blockEntity : chunk.getBlockEntities()) {
|
||||
String id = ((StringTag) blockEntity.get("id")).getValue();
|
||||
if (id.equals("minecraft:conduit")) {
|
||||
IntArrayTag targetUuidTag = blockEntity.remove("Target");
|
||||
if (targetUuidTag == null) continue;
|
||||
|
||||
// Target -> target_uuid
|
||||
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray(targetUuidTag.getValue());
|
||||
blockEntity.put(new StringTag("target_uuid", targetUuid.toString()));
|
||||
} else if (id.equals("minecraft:skull") && blockEntity.get("SkullOwner") instanceof CompoundTag) {
|
||||
CompoundTag skullOwnerTag = blockEntity.remove("SkullOwner");
|
||||
IntArrayTag ownerUuidTag = skullOwnerTag.remove("Id");
|
||||
if (ownerUuidTag != null) {
|
||||
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray(ownerUuidTag.getValue());
|
||||
skullOwnerTag.put(new StringTag("Id", ownerUuid.toString()));
|
||||
}
|
||||
|
||||
// SkullOwner -> Owner
|
||||
CompoundTag ownerTag = new CompoundTag("Owner");
|
||||
for (Tag tag : skullOwnerTag) {
|
||||
ownerTag.put(tag);
|
||||
}
|
||||
blockEntity.put(ownerTag);
|
||||
}
|
||||
handleBlockEntity(blockEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001, BlockItemPackets1_16::getOldItemId);
|
||||
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 32,
|
||||
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
|
||||
@@ -229,6 +199,55 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Map ID
|
||||
map(Type.BYTE); // Scale
|
||||
map(Type.BOOLEAN); // Tracking Position
|
||||
map(Type.BOOLEAN); // Locked
|
||||
handler(wrapper -> {
|
||||
int iconCount = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
wrapper.passthrough(Type.VAR_INT); // Type
|
||||
wrapper.passthrough(Type.BYTE); // X
|
||||
wrapper.passthrough(Type.BYTE); // Z
|
||||
wrapper.passthrough(Type.BYTE); // Direction
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.COMPONENT); // Display Name
|
||||
}
|
||||
}
|
||||
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns < 1) return;
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Rows
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // X
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Z
|
||||
byte[] data = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int color = data[i] & 0xFF;
|
||||
int mappedColor = MapColorRewriter.getMappedColor(color);
|
||||
if (mappedColor != -1) {
|
||||
data[i] = (byte) mappedColor;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Position position = wrapper.passthrough(Type.POSITION1_14);
|
||||
short action = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
CompoundTag tag = wrapper.passthrough(Type.NBT);
|
||||
handleBlockEntity(tag);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
@@ -240,29 +259,36 @@ 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;
|
||||
private void handleBlockEntity(CompoundTag tag) {
|
||||
StringTag idTag = tag.get("id");
|
||||
if (idTag == null) return;
|
||||
|
||||
String id = idTag.getValue();
|
||||
if (id.equals("minecraft:conduit")) {
|
||||
Tag targetUuidTag = tag.remove("Target");
|
||||
if (!(targetUuidTag instanceof IntArrayTag)) return;
|
||||
|
||||
// Target -> target_uuid
|
||||
UUID targetUuid = UUIDIntArrayType.uuidFromIntArray((int[]) targetUuidTag.getValue());
|
||||
tag.put(new StringTag("target_uuid", targetUuid.toString()));
|
||||
} else if (id.equals("minecraft:skull")) {
|
||||
Tag skullOwnerTag = tag.remove("SkullOwner");
|
||||
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
||||
|
||||
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
|
||||
Tag ownerUuidTag = skullOwnerCompoundTag.remove("Id");
|
||||
if (ownerUuidTag instanceof IntArrayTag) {
|
||||
UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((int[]) ownerUuidTag.getValue());
|
||||
skullOwnerCompoundTag.put(new StringTag("Id", ownerUuid.toString()));
|
||||
}
|
||||
|
||||
// SkullOwner -> Owner
|
||||
CompoundTag ownerTag = new CompoundTag("Owner");
|
||||
for (Tag t : skullOwnerCompoundTag) {
|
||||
ownerTag.put(t);
|
||||
}
|
||||
tag.put(ownerTag);
|
||||
}
|
||||
if (id > 27) {
|
||||
id -= 2;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,6 +316,7 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
}
|
||||
|
||||
InventoryPackets.newToOldAttributes(item);
|
||||
enchantmentRewriter.handleToClient(item);
|
||||
return item;
|
||||
}
|
||||
@@ -314,28 +341,11 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
|
||||
}
|
||||
}
|
||||
|
||||
InventoryPackets.oldToNewAttributes(item);
|
||||
enchantmentRewriter.handleToServer(item);
|
||||
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;
|
||||
|
||||
+60
-10
@@ -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;
|
||||
@@ -17,8 +15,10 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||
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_15to1_14_4.ClientboundPackets1_15;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
|
||||
public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
|
||||
@@ -43,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() {
|
||||
@@ -56,7 +56,19 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
map(Type.BYTE, Type.NOTHING); // Previous gamemode
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
clientWorld.setEnvironment(wrapper.get(Type.INT, 0));
|
||||
int dimension = wrapper.get(Type.INT, 0);
|
||||
|
||||
// Send a dummy respawn with a different dimension if the previous one is equal to the new
|
||||
if (clientWorld.getEnvironment() != null && dimension == clientWorld.getEnvironment().getId()) {
|
||||
PacketWrapper packet = wrapper.create(ClientboundPackets1_15.RESPAWN.ordinal());
|
||||
packet.write(Type.INT, dimension == 0 ? -1 : 0);
|
||||
packet.write(Type.LONG, 0L);
|
||||
packet.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||
packet.write(Type.STRING, "default");
|
||||
packet.send(Protocol1_15_2To1_16.class, true, true);
|
||||
}
|
||||
|
||||
clientWorld.setEnvironment(dimension);
|
||||
|
||||
wrapper.write(Type.STRING, "default"); // Level type
|
||||
wrapper.read(Type.BOOLEAN); // Debug
|
||||
@@ -114,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);
|
||||
@@ -128,6 +140,45 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(packetWrapper -> {
|
||||
int action = packetWrapper.passthrough(Type.VAR_INT);
|
||||
int playerCount = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < playerCount; i++) {
|
||||
packetWrapper.passthrough(Type.UUID);
|
||||
if (action == 0) { // Add
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
int properties = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < properties; j++) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
}
|
||||
}
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
// Display Name
|
||||
protocol.getTranslatableRewriter().processText(packetWrapper.passthrough(Type.COMPONENT));
|
||||
}
|
||||
} else if (action == 1) { // Update Game Mode
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 2) { // Update Ping
|
||||
packetWrapper.passthrough(Type.VAR_INT);
|
||||
} else if (action == 3) { // Update Display Name
|
||||
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||
// Display name
|
||||
protocol.getTranslatableRewriter().processText(packetWrapper.passthrough(Type.COMPONENT));
|
||||
}
|
||||
} // 4 = Remove Player
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,14 +189,13 @@ 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) {
|
||||
String text = meta.getCastedValue();
|
||||
JsonElement text = meta.getCastedValue();
|
||||
if (text != null) {
|
||||
meta.setValue(protocol.getTranslatableRewriter().processText(text));
|
||||
protocol.getTranslatableRewriter().processText(text);
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
|
||||
-5
@@ -1,13 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_15to1_15_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
public class Protocol1_15To1_15_1 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public Protocol1_15To1_15_1() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2;
|
||||
|
||||
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.packets.BlockItemPackets1_16_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.EntityPackets1_16_2;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
|
||||
import us.myles.ViaVersion.api.rewriters.TagRewriter;
|
||||
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_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;
|
||||
|
||||
public Protocol1_16_1To1_16_2() {
|
||||
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, MAPPINGS::load);
|
||||
|
||||
translatableRewriter = new TranslatableRewriter(this);
|
||||
translatableRewriter.registerBossBar(ClientboundPackets1_16_2.BOSSBAR);
|
||||
translatableRewriter.registerCombatEvent(ClientboundPackets1_16_2.COMBAT_EVENT);
|
||||
translatableRewriter.registerDisconnect(ClientboundPackets1_16_2.DISCONNECT);
|
||||
translatableRewriter.registerTabList(ClientboundPackets1_16_2.TAB_LIST);
|
||||
translatableRewriter.registerTitle(ClientboundPackets1_16_2.TITLE);
|
||||
translatableRewriter.registerOpenWindow(ClientboundPackets1_16_2.OPEN_WINDOW);
|
||||
translatableRewriter.registerPing();
|
||||
|
||||
(blockItemPackets = new BlockItemPackets1_16_2(this, translatableRewriter)).register();
|
||||
EntityPackets1_16_2 entityPackets = new EntityPackets1_16_2(this);
|
||||
entityPackets.register();
|
||||
|
||||
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
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
if (type == 0) {
|
||||
// Shown, change to its own packet
|
||||
wrapper.passthrough(Type.STRING); // Recipe
|
||||
wrapper.setId(ServerboundPackets1_16_2.SEEN_RECIPE.ordinal());
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
|
||||
// Settings
|
||||
for (int i = 0; i < 3; i++) {
|
||||
sendSeenRecipePacket(i, wrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
|
||||
boolean open = wrapper.read(Type.BOOLEAN);
|
||||
boolean filter = wrapper.read(Type.BOOLEAN);
|
||||
|
||||
PacketWrapper newPacket = wrapper.create(ServerboundPackets1_16_2.RECIPE_BOOK_DATA.ordinal());
|
||||
newPacket.write(Type.VAR_INT, recipeType);
|
||||
newPacket.write(Type.BOOLEAN, open);
|
||||
newPacket.write(Type.BOOLEAN, filter);
|
||||
newPacket.sendToServer(Protocol1_16_1To1_16_2.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.TAGS);
|
||||
|
||||
new StatisticsRewriter(this, entityPackets::getOldEntityId).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(EntityTracker.class)) {
|
||||
user.put(new EntityTracker(user));
|
||||
}
|
||||
user.get(EntityTracker.class).initProtocol(this);
|
||||
}
|
||||
|
||||
public BlockItemPackets1_16_2 getBlockItemPackets() {
|
||||
return blockItemPackets;
|
||||
}
|
||||
|
||||
public TranslatableRewriter getTranslatableRewriter() {
|
||||
return translatableRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord1_8;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
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.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;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
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 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
|
||||
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);
|
||||
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);
|
||||
itemRewriter.registerTradeList(ClientboundPackets1_16_2.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
|
||||
itemRewriter.registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.UNLOCK_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN); // Open
|
||||
wrapper.passthrough(Type.BOOLEAN); // Filter
|
||||
wrapper.passthrough(Type.BOOLEAN); // Furnace Open
|
||||
wrapper.passthrough(Type.BOOLEAN); // Filter furnace
|
||||
// Blast furnace / smoker
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16_2.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Chunk chunk = wrapper.read(new Chunk1_16_2Type());
|
||||
wrapper.write(new Chunk1_16Type(), chunk);
|
||||
|
||||
chunk.setIgnoreOldLightData(true);
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue;
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int old = section.getPaletteEntry(j);
|
||||
section.setPaletteEntry(j, protocol.getMappingData().getNewBlockStateId(old));
|
||||
}
|
||||
}
|
||||
|
||||
for (CompoundTag blockEntity : chunk.getBlockEntities()) {
|
||||
if (blockEntity == null) continue;
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Position position = wrapper.passthrough(Type.POSITION1_14);
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
handleBlockEntity(wrapper.passthrough(Type.NBT), position);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
long chunkPosition = wrapper.read(Type.LONG);
|
||||
wrapper.read(Type.BOOLEAN); // Ignore old light data
|
||||
|
||||
int chunkX = (int) (chunkPosition >> 42);
|
||||
int chunkY = (int) (chunkPosition << 44 >> 44);
|
||||
int chunkZ = (int) (chunkPosition << 22 >> 42);
|
||||
wrapper.write(Type.INT, chunkX);
|
||||
wrapper.write(Type.INT, chunkZ);
|
||||
|
||||
BlockChangeRecord[] blockChangeRecord = wrapper.read(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY);
|
||||
wrapper.write(Type.BLOCK_CHANGE_RECORD_ARRAY, blockChangeRecord);
|
||||
for (int i = 0; i < blockChangeRecord.length; i++) {
|
||||
BlockChangeRecord record = blockChangeRecord[i];
|
||||
int blockId = protocol.getMappingData().getNewBlockStateId(record.getBlockId());
|
||||
// Relative y -> absolute y
|
||||
blockChangeRecord[i] = new BlockChangeRecord1_8(record.getSectionX(), record.getY(chunkY), record.getSectionZ(), blockId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
protocol.registerIncoming(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void handleBlockEntity(CompoundTag tag, Position position) {
|
||||
StringTag idTag = tag.get("id");
|
||||
if (idTag == null) return;
|
||||
if (idTag.getValue().equals("minecraft:skull")) {
|
||||
// Workaround an old client bug: MC-68487
|
||||
Tag skullOwnerTag = tag.get("SkullOwner");
|
||||
if (!(skullOwnerTag instanceof CompoundTag)) return;
|
||||
|
||||
CompoundTag skullOwnerCompoundTag = (CompoundTag) skullOwnerTag;
|
||||
if (!skullOwnerCompoundTag.contains("Id")) return;
|
||||
|
||||
CompoundTag properties = skullOwnerCompoundTag.get("Properties");
|
||||
if (properties == null) return;
|
||||
|
||||
ListTag textures = properties.get("textures");
|
||||
if (textures == null) return;
|
||||
|
||||
CompoundTag first = textures.size() > 0 ? textures.get(0) : null;
|
||||
if (first == null) return;
|
||||
|
||||
// Make the client cache the skinprofile over this uuid
|
||||
int hashCode = first.get("Value").getValue().hashCode();
|
||||
int[] uuidIntArray = {hashCode, 0, 0, 0}; //TODO split texture in 4 for a lower collision chance
|
||||
skullOwnerCompoundTag.put(new IntArrayTag("Id", uuidIntArray));
|
||||
}
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.api.remapper.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;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2> {
|
||||
|
||||
private final Set<String> oldDimensions = Sets.newHashSet("minecraft:overworld", "minecraft:the_nether", "minecraft:the_end");
|
||||
|
||||
public EntityPackets1_16_2(Protocol1_16_1To1_16_2 protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
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);
|
||||
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER);
|
||||
registerEntityDestroy(ClientboundPackets1_16_2.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Entity ID
|
||||
handler(wrapper -> {
|
||||
boolean hardcore = wrapper.read(Type.BOOLEAN);
|
||||
short gamemode = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
if (hardcore) {
|
||||
gamemode |= 0x08;
|
||||
}
|
||||
wrapper.write(Type.UNSIGNED_BYTE, gamemode);
|
||||
});
|
||||
map(Type.BYTE); // Previous Gamemode
|
||||
map(Type.STRING_ARRAY); // World List
|
||||
handler(wrapper -> {
|
||||
// Just screw the registry and write the defaults for 1.16 and 1.16.1 clients
|
||||
wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.NBT, EntityPackets.DIMENSIONS_TAG);
|
||||
|
||||
CompoundTag dimensionData = wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
|
||||
});
|
||||
map(Type.STRING); // Dimension
|
||||
map(Type.LONG); // Seed
|
||||
handler(wrapper -> {
|
||||
int maxPlayers = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) Math.max(maxPlayers, 255));
|
||||
});
|
||||
// ...
|
||||
handler(getTrackerHandler(Entity1_16_2Types.EntityType.PLAYER, Type.INT));
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerOutgoing(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
CompoundTag dimensionData = wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getDimensionFromData(CompoundTag dimensionData) {
|
||||
// This may technically break other custom dimension settings for 1.16/1.16.1 clients, so those cases are considered semi "unsupported" here
|
||||
StringTag effectsLocation = dimensionData.get("effects");
|
||||
return effectsLocation != null && oldDimensions.contains(effectsLocation.getValue()) ? effectsLocation.getValue() : "minecraft:overworld";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
registerMetaHandler().handle(e -> {
|
||||
Metadata meta = e.getData();
|
||||
MetaType type = meta.getMetaType();
|
||||
if (type == MetaType1_14.Slot) {
|
||||
meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue()));
|
||||
} else if (type == MetaType1_14.BlockID) {
|
||||
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;
|
||||
});
|
||||
|
||||
mapTypes(Entity1_16_2Types.EntityType.values(), Entity1_16Types.EntityType.class);
|
||||
mapEntity(Entity1_16_2Types.EntityType.PIGLIN_BRUTE, Entity1_16_2Types.EntityType.PIGLIN).jsonName("Piglin Brute");
|
||||
|
||||
registerMetaHandler().filter(Entity1_16_2Types.EntityType.ABSTRACT_PIGLIN, true).handle(meta -> {
|
||||
if (meta.getIndex() == 15) {
|
||||
meta.getData().setId(16);
|
||||
} else if (meta.getIndex() == 16) {
|
||||
meta.getData().setId(15);
|
||||
}
|
||||
return meta.getData();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityType getTypeFromId(int typeId) {
|
||||
return Entity1_16_2Types.getTypeFromId(typeId);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16_2to1_16_3;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
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_2To1_16_3 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_16to1_16_1;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
|
||||
public class Protocol1_16To1_16_1 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_16, ServerboundPackets1_16, ServerboundPackets1_16> {
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public class ChatUtil {
|
||||
|
||||
public static String removeUnusedColor(String legacy, char defaultColor, boolean isPrefix) {
|
||||
if (legacy == null) return null;
|
||||
|
||||
Pattern pattern = isPrefix ? UNUSED_COLOR_PATTERN_PREFIX : UNUSED_COLOR_PATTERN;
|
||||
legacy = pattern.matcher(legacy).replaceAll("$1$2");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@@ -22,10 +23,12 @@ public class ChatUtil {
|
||||
builder.append(current);
|
||||
continue;
|
||||
}
|
||||
|
||||
current = legacy.charAt(++i);
|
||||
if (current == last) continue;
|
||||
builder.append('§').append(current);
|
||||
last = current;
|
||||
if (current != last) {
|
||||
builder.append('§').append(current);
|
||||
last = current;
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -5864,39 +5864,39 @@
|
||||
"name": "1.16 Netherite Scrap"
|
||||
},
|
||||
"minecraft:netherite_sword": {
|
||||
"id": "minecraft:iron_sword",
|
||||
"id": "minecraft:diamond_sword",
|
||||
"name": "1.16 Netherite Sword"
|
||||
},
|
||||
"minecraft:netherite_shovel": {
|
||||
"id": "minecraft:iron_shovel",
|
||||
"id": "minecraft:diamond_shovel",
|
||||
"name": "1.16 Netherite Shovel"
|
||||
},
|
||||
"minecraft:netherite_pickaxe": {
|
||||
"id": "minecraft:iron_pickaxe",
|
||||
"id": "minecraft:diamond_pickaxe",
|
||||
"name": "1.16 Netherite Pickaxe"
|
||||
},
|
||||
"minecraft:netherite_axe": {
|
||||
"id": "minecraft:iron_axe",
|
||||
"id": "minecraft:diamond_axe",
|
||||
"name": "1.16 Netherite Axe"
|
||||
},
|
||||
"minecraft:netherite_hoe": {
|
||||
"id": "minecraft:iron_hoe",
|
||||
"id": "minecraft:diamond_hoe",
|
||||
"name": "1.16 Netherite Hoe"
|
||||
},
|
||||
"minecraft:netherite_helmet": {
|
||||
"id": "minecraft:chainmail_helmet",
|
||||
"id": "minecraft:diamond_helmet",
|
||||
"name": "1.16 Netherite Helmet"
|
||||
},
|
||||
"minecraft:netherite_chestplate": {
|
||||
"id": "minecraft:chainmail_chestplate",
|
||||
"id": "minecraft:diamond_chestplate",
|
||||
"name": "1.16 Netherite Chestplate"
|
||||
},
|
||||
"minecraft:netherite_leggings": {
|
||||
"id": "minecraft:chainmail_leggings",
|
||||
"id": "minecraft:diamond_leggings",
|
||||
"name": "1.16 Netherite Leggings"
|
||||
},
|
||||
"minecraft:netherite_boots": {
|
||||
"id": "minecraft:chainmail_boots",
|
||||
"id": "minecraft:diamond_boots",
|
||||
"name": "1.16 Netherite Boots"
|
||||
},
|
||||
"minecraft:crying_obsidian": {
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"blockstates": {
|
||||
"minecraft:lantern[hanging=true,waterlogged=true]": "minecraft:lantern[hanging=true]",
|
||||
"minecraft:lantern[hanging=true,waterlogged=false]": "minecraft:lantern[hanging=true]",
|
||||
"minecraft:lantern[hanging=false,waterlogged=true]": "minecraft:lantern[hanging=false]",
|
||||
"minecraft:lantern[hanging=false,waterlogged=false]": "minecraft:lantern[hanging=false]",
|
||||
"minecraft:soul_lantern[hanging=true,waterlogged=true]": "minecraft:soul_lantern[hanging=true]",
|
||||
"minecraft:soul_lantern[hanging=true,waterlogged=false]": "minecraft:soul_lantern[hanging=true]",
|
||||
"minecraft:soul_lantern[hanging=false,waterlogged=true]": "minecraft:soul_lantern[hanging=false]",
|
||||
"minecraft:soul_lantern[hanging=false,waterlogged=false]": "minecraft:soul_lantern[hanging=false]",
|
||||
"minecraft:chain[axis=x,waterlogged=true]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=x,waterlogged=false]": "minecraft:chain[waterlogged=false]",
|
||||
"minecraft:chain[axis=y,waterlogged=true]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=y,waterlogged=false]": "minecraft:chain[waterlogged=false]",
|
||||
"minecraft:chain[axis=z,waterlogged=true]": "minecraft:chain[waterlogged=true]",
|
||||
"minecraft:chain[axis=z,waterlogged=false]": "minecraft:chain[waterlogged=false]"
|
||||
},
|
||||
"items": {
|
||||
"minecraft:piglin_brute_spawn_egg": {
|
||||
"id": "minecraft:piglin_spawn_egg",
|
||||
"name": "1.16.2 Piglin Brute Spawn Egg"
|
||||
}
|
||||
},
|
||||
"sounds": {
|
||||
"entity.parrot.imitate.piglin_brute": "entity.parrot.imitate.piglin",
|
||||
"entity.piglin_brute.ambient": "entity.piglin.ambient",
|
||||
"entity.piglin_brute.angry": "entity.piglin.angry",
|
||||
"entity.piglin_brute.death": "entity.piglin.death",
|
||||
"entity.piglin_brute.hurt": "entity.piglin.hurt",
|
||||
"entity.piglin_brute.step": "entity.piglin.step",
|
||||
"entity.piglin_brute.converted_to_zombified": "entity.piglin.converted_to_zombified"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,44 @@
|
||||
{
|
||||
"1.16.2": {
|
||||
"multiplayer.disconnect.missing_tags": "Incomplete set of tags received from server.\nPlease contact server operator.",
|
||||
"chat.square_brackets": "[%s]",
|
||||
"disconnect.exceeded_packet_rate": "Kicked for exceeding packet rate limit",
|
||||
"item.minecraft.piglin_brute_spawn_egg": "Piglin Brute Spawn Egg",
|
||||
"entity.minecraft.piglin_brute": "Piglin Brute",
|
||||
"potion.withAmplifier": "%s %s",
|
||||
"potion.withDuration": "%s (%s)",
|
||||
"advancements.sad_label": ":(",
|
||||
"subtitles.entity.parrot.imitate.piglin_brute": "Parrot snorts mightily",
|
||||
"subtitles.entity.piglin_brute.ambient": "Piglin Brute snorts",
|
||||
"subtitles.entity.piglin_brute.angry": "Piglin Brute snorts angrily",
|
||||
"subtitles.entity.piglin_brute.death": "Piglin Brute dies",
|
||||
"subtitles.entity.piglin_brute.hurt": "Piglin Brute hurts",
|
||||
"subtitles.entity.piglin_brute.step": "Piglin Brute steps",
|
||||
"subtitles.entity.piglin_brute.converted_to_zombified": "Piglin Brute converts to Zombified Piglin",
|
||||
"command.context.parse_error": "%s at position %s: %s",
|
||||
"commands.list.nameAndId": "%s (%s)",
|
||||
"argument.angle.incomplete": "Incomplete (expected 1 angle)",
|
||||
"commands.summon.failed.uuid": "Unable to summon entity due to duplicate UUIDs"
|
||||
},
|
||||
"1.16": {
|
||||
"gui.recipebook.search_hint": "Search...",
|
||||
"selectWorld.edit.export_worldgen_settings": "Export World Generation Settings",
|
||||
"selectWorld.edit.export_worldgen_settings.success": "Exported",
|
||||
"selectWorld.edit.export_worldgen_settings.failure": "Export failed",
|
||||
"selectWorld.locked": "Locked by another running instance of Minecraft",
|
||||
"selectWorld.backupQuestion.experimental": "Worlds using Experimental Settings are not supported",
|
||||
"selectWorld.backupWarning.experimental": "This world uses experimental settings that could stop working at any time. We cannot guarantee it will load or work. Here be dragons!",
|
||||
"selectWorld.tooltip.experimental": "This world is using experimental settings",
|
||||
"selectWorld.access_failure": "Failed to access world",
|
||||
"selectWorld.delete_failure": "Failed to delete world",
|
||||
"selectWorld.data_read": "Reading world data...",
|
||||
"createWorld.preparing": "Preparing for world creation...",
|
||||
"datapackFailure.title": "Errors in currently selected datapacks prevented world from loading.\nYou can either try to load only with vanilla datapack (\"safe mode\") or go back to title screen and fix it manually.",
|
||||
"datapackFailure.safeMode": "Safe mode",
|
||||
"editGamerule.title": "Edit game rules",
|
||||
"datapackFailure.safeMode": "Safe Mode",
|
||||
"editGamerule.title": "Edit Game Rules",
|
||||
"editGamerule.default": "Default: %s",
|
||||
"selectWorld.gameRules": "Game Rules",
|
||||
"selectWorld.import_worldgen_settings": "Import settings",
|
||||
"selectWorld.dataPacks": "Data Packs",
|
||||
"selectWorld.import_worldgen_settings": "Import Settings",
|
||||
"selectWorld.import_worldgen_settings.select_file": "Select settings file (.json)",
|
||||
"selectWorld.import_worldgen_settings.failure": "Error importing settings",
|
||||
"selectWorld.import_worldgen_settings.experimental.title": "Warning! These settings are using experimental features",
|
||||
@@ -25,15 +49,46 @@
|
||||
"generator.custom": "Custom",
|
||||
"generator.single_biome_surface": "Single Biome",
|
||||
"generator.single_biome_caves": "Caves",
|
||||
"generator.single_biome_floating_islands": "Floating islands",
|
||||
"generator.single_biome_floating_islands": "Floating Islands",
|
||||
"multiplayer.status.ping": "%s ms",
|
||||
"chat.queue": "[+%s pending lines]",
|
||||
"options.entityDistanceScaling": "Entity Distance",
|
||||
"options.entityDistancePercent": "%s%%",
|
||||
"options.graphics.fabulous.tooltip": "%s graphics uses screen shaders for drawing weather, clouds and particles behind translucent blocks and water.\nThis may severely impact performance for portable devices and 4K displays.",
|
||||
"options.graphics.fabulous": "Fabulous!",
|
||||
"options.graphics.fancy.tooltip": "Fancy graphics balances performance and quality for the majority of machines.\nWeather, clouds and particles may not appear behind translucent blocks or water.",
|
||||
"options.graphics.fast.tooltip": "Fast graphics reduces the amount of visible rain and snow.\nTransparency effects are disabled for various blocks such as tree-leaves.",
|
||||
"options.graphics.warning.title": "Graphics Device Unsupported",
|
||||
"options.graphics.warning.message": "Your graphics device is detected as unsupported for the %s graphics option.\n\nYou may ignore this and continue, however support will not be provided for your device if you choose to use %s graphics.",
|
||||
"options.graphics.warning.renderer": "Renderer detected: [%s]",
|
||||
"options.graphics.warning.vendor": "Vendor detected: [%s]",
|
||||
"options.graphics.warning.version": "OpenGL Version detected: [%s]",
|
||||
"options.graphics.warning.accept": "Continue without support",
|
||||
"options.graphics.warning.cancel": "Take me back",
|
||||
"options.chat.line_spacing": "Line Spacing",
|
||||
"options.chat.delay_none": "Chat Delay: None",
|
||||
"options.chat.delay": "Chat Delay: %s seconds",
|
||||
"title.multiplayer.disabled": "Multiplayer is disabled, please check your launcher settings.",
|
||||
"key.swapOffhand": "Swap Item With Offhand",
|
||||
"pack.available.title": "Available",
|
||||
"pack.selected.title": "Selected",
|
||||
"pack.incompatible": "Incompatible",
|
||||
"pack.incompatible.old": "(Made for an older version of Minecraft)",
|
||||
"pack.incompatible.new": "(Made for a newer version of Minecraft)",
|
||||
"pack.incompatible.confirm.title": "Are you sure you want to load this pack?",
|
||||
"pack.incompatible.confirm.old": "This pack was made for an older version of Minecraft and may no longer work correctly.",
|
||||
"pack.incompatible.confirm.new": "This pack was made for a newer version of Minecraft and may no longer work correctly.",
|
||||
"pack.dropInfo": "Drag and drop files into this window to add packs",
|
||||
"pack.dropConfirm": "Do you want to add following packs to Minecraft?",
|
||||
"pack.copyFailure": "Failed to copy packs",
|
||||
"pack.nameAndSource": "%s (%s)",
|
||||
"pack.openFolder": "Open Pack Folder",
|
||||
"pack.folderInfo": "(Place pack files here)",
|
||||
"dataPack.title": "Select Data Packs",
|
||||
"dataPack.validation.working": "Validating selected data packs...",
|
||||
"dataPack.validation.failed": "Data pack validation failed!",
|
||||
"dataPack.validation.back": "Go Back",
|
||||
"dataPack.validation.reset": "Reset to Default",
|
||||
"block.minecraft.nether_gold_ore": "Nether Gold Ore",
|
||||
"block.minecraft.soul_torch": "Soul Torch",
|
||||
"block.minecraft.soul_wall_torch": "Soul Wall Torch",
|
||||
@@ -285,7 +340,7 @@
|
||||
"subtitles.entity.zombie.break_wooden_door": "Door breaks",
|
||||
"subtitles.entity.zombie.destroy_egg": "Turtle Egg stomped",
|
||||
"subtitles.entity.zombified_piglin.ambient": "Zombified Piglin grunts",
|
||||
"subtitles.entity.zombified_piglin.angry": "Zombified Piglin angers",
|
||||
"subtitles.entity.zombified_piglin.angry": "Zombified Piglin grunts angrily",
|
||||
"subtitles.entity.zombified_piglin.death": "Zombified Piglin dies",
|
||||
"subtitles.entity.zombified_piglin.hurt": "Zombified Piglin hurts",
|
||||
"subtitles.item.armor.equip_netherite": "Netherite armor clanks",
|
||||
@@ -298,8 +353,8 @@
|
||||
"subtitles.ui.stonecutter.take_result": "Stonecutter used",
|
||||
"debug.gamemodes.help": "F3 + F4 = Open game mode switcher",
|
||||
"debug.gamemodes.error": "Unable to open game mode switcher, no permission",
|
||||
"debug.gamemodes.press_f4": "F4",
|
||||
"debug.gamemodes.select_next": "Next",
|
||||
"debug.gamemodes.press_f4": "[ F4 ]",
|
||||
"debug.gamemodes.select_next": "%s Next",
|
||||
"advancements.adventure.bullseye.title": "Bullseye",
|
||||
"advancements.adventure.bullseye.description": "Hit the bullseye of a Target block from at least 30 meters away",
|
||||
"advancements.husbandry.netherite_hoe.title": "Serious Dedication",
|
||||
@@ -310,7 +365,7 @@
|
||||
"advancements.nether.netherite_armor.description": "Get a full suit of Netherite armor",
|
||||
"advancements.nether.use_lodestone.title": "Country Lode, Take Me Home",
|
||||
"advancements.nether.use_lodestone.description": "Use a Compass on a Lodestone",
|
||||
"advancements.nether.obtain_crying_obsidian.title": "Who Is Cutting Onions?",
|
||||
"advancements.nether.obtain_crying_obsidian.title": "Who is Cutting Onions?",
|
||||
"advancements.nether.obtain_crying_obsidian.description": "Obtain Crying Obsidian",
|
||||
"advancements.nether.charge_respawn_anchor.title": "Not Quite \"Nine\" Lives",
|
||||
"advancements.nether.charge_respawn_anchor.description": "Charge a Respawn Anchor to the maximum",
|
||||
@@ -338,8 +393,10 @@
|
||||
"commands.locatebiome.success": "The nearest %s is at %s (%s blocks away)",
|
||||
"commands.teleport.invalidPosition": "Invalid position for teleport",
|
||||
"commands.reload.failure": "Reload failed, keeping old data",
|
||||
"commands.locatebiome.notFound": "Could not find a biome of type %s within reasonable distance",
|
||||
"commands.locatebiome.invalid": "There is no biome named %s",
|
||||
"commands.datapack.modify.enable": "Enabling data pack %s",
|
||||
"commands.datapack.modify.disable": "Disabling data pack %s",
|
||||
"commands.locatebiome.notFound": "Could not find a biome of type \"%s\" within reasonable distance",
|
||||
"commands.locatebiome.invalid": "There is no biome with type \"%s\"",
|
||||
"commands.summon.invalidPosition": "Invalid position for summon",
|
||||
"biome.minecraft.nether_wastes": "Nether Wastes",
|
||||
"biome.minecraft.soul_sand_valley": "Soul Sand Valley",
|
||||
@@ -359,17 +416,19 @@
|
||||
"gamerule.doLimitedCrafting": "Require recipe for crafting",
|
||||
"gamerule.doLimitedCrafting.description": "If enabled, players will be able to craft only unlocked recipes",
|
||||
"gamerule.doMobLoot": "Drop mob loot",
|
||||
"gamerule.doMobLoot.description": "Controls resource drops, including experience orbs",
|
||||
"gamerule.doMobLoot.description": "Controls resource drops from mobs, including experience orbs",
|
||||
"gamerule.doMobSpawning": "Spawn mobs",
|
||||
"gamerule.doMobSpawning.description": "Some entities might have separate rules",
|
||||
"gamerule.doPatrolSpawning": "Spawn pillager patrols",
|
||||
"gamerule.doTileDrops": "Drop blocks",
|
||||
"gamerule.doTileDrops.description": "Controls resource drops, including experience orbs",
|
||||
"gamerule.doTileDrops.description": "Controls resource drops from blocks, including experience orbs",
|
||||
"gamerule.doTraderSpawning": "Spawn wandering traders",
|
||||
"gamerule.doWeatherCycle": "Update weather",
|
||||
"gamerule.drowningDamage": "Deal drowning damage",
|
||||
"gamerule.fallDamage": "Deal fall damage",
|
||||
"gamerule.fireDamage": "Deal fire damage",
|
||||
"gamerule.forgiveDeadPlayers": "Forgive dead players",
|
||||
"gamerule.forgiveDeadPlayers.description": "Angered neutral mobs stop being angry when the targeted player dies nearby.",
|
||||
"gamerule.keepInventory": "Keep inventory after death",
|
||||
"gamerule.logAdminCommands": "Broadcast admin commands",
|
||||
"gamerule.maxCommandChainLength": "Command chain size limit",
|
||||
@@ -384,13 +443,19 @@
|
||||
"gamerule.showDeathMessages": "Show death messages",
|
||||
"gamerule.spawnRadius": "Respawn location radius",
|
||||
"gamerule.spectatorsGenerateChunks": "Allow spectators to generate terrain",
|
||||
"gamerule.universalAnger": "Universal anger",
|
||||
"gamerule.universalAnger.description": "Angered neutral mobs attack any nearby player, not just the player that angered them. Works best if forgiveDeadPlayers is disabled.",
|
||||
"gamerule.category.chat": "Chat",
|
||||
"gamerule.category.spawning": "Spawning",
|
||||
"gamerule.category.updates": "World updates",
|
||||
"gamerule.category.drops": "Drops",
|
||||
"gamerule.category.mobs": "Mobs",
|
||||
"gamerule.category.player": "Player",
|
||||
"gamerule.category.misc": "Miscellaneous"
|
||||
"gamerule.category.misc": "Miscellaneous",
|
||||
"pack.source.builtin": "built-in",
|
||||
"pack.source.world": "world",
|
||||
"pack.source.local": "local",
|
||||
"pack.source.server": "server"
|
||||
},
|
||||
"1.15": {
|
||||
"narration.suggestion.tooltip": "Selected suggestion %d out of %d: %s (%s)",
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</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.0.0</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.0.0-SNAPSHOT</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.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-sponge</artifactId>
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.spongepowered.api.event.Order;
|
||||
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||
import org.spongepowered.api.plugin.Dependency;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||
|
||||
import java.io.File;
|
||||
@@ -45,7 +46,7 @@ public class SpongePlugin implements ViaBackwardsPlatform {
|
||||
// Setup Logger
|
||||
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||
// Init!
|
||||
this.init(configPath.resolve("config.yml").toFile());
|
||||
Via.getManager().addEnableListener(() -> this.init(configPath.resolve("config.yml").toFile()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
<parent>
|
||||
<artifactId>viabackwards-parent</artifactId>
|
||||
<groupId>nl.matsv</groupId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>viabackwards-velocity</artifactId>
|
||||
|
||||
Reference in new issue
Block a user