Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
Merge branch 'dev' into master
Dieser Commit ist enthalten in:
Commit
f636b67dca
@ -11,7 +11,24 @@
|
||||
package nl.matsv.viabackwards.api;
|
||||
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public abstract class BackwardsProtocol extends Protocol {
|
||||
|
||||
public void out(State state, int oldPacketID, int newPacketID) {
|
||||
this.registerOutgoing(state, oldPacketID, newPacketID, null);
|
||||
}
|
||||
|
||||
public void out(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||
this.registerOutgoing(state, oldPacketID, newPacketID, packetRemapper);
|
||||
}
|
||||
|
||||
public void in(State state, int oldPacketID, int newPacketID) {
|
||||
this.registerIncoming(state, oldPacketID, newPacketID, null);
|
||||
}
|
||||
|
||||
public void in(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
||||
this.registerIncoming(state, oldPacketID, newPacketID, packetRemapper);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2.Protocol1_12_1To1_12_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
@ -39,7 +40,8 @@ public interface ViaBackwardsPlatform {
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_11_1To1_12(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_12.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_12To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_1.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_12_1To1_12_2(), Collections.singletonList(ProtocolVersion.v1_12_1.getId()), ProtocolVersion.v1_12_2.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId())
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_12_2To1_13(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_13.getId())
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,9 +57,9 @@ public interface ViaBackwardsPlatform {
|
||||
boolean upToDate = false;
|
||||
try {
|
||||
Class<?> clazz = Class.forName("us.myles.ViaVersion.api.protocol.ProtocolVersion");
|
||||
Field v1_12_2 = clazz.getField("v1_12_2");
|
||||
Field v1_13 = clazz.getField("v1_13");
|
||||
|
||||
upToDate = (v1_12_2 != null);
|
||||
upToDate = (v1_13 != null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException ignored) {
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class KeepAliveTracker extends StoredObject {
|
||||
private long keepAlive = Integer.MAX_VALUE;
|
||||
|
||||
public KeepAliveTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.KeepAliveTracker;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
@ -36,7 +35,8 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol {
|
||||
}
|
||||
});
|
||||
}
|
||||
}); // Keep alive
|
||||
});
|
||||
|
||||
// Incoming
|
||||
// 0xb - Keep alive
|
||||
registerIncoming(State.PLAY, 0xb, 0xb, new PacketRemapper() {
|
||||
@ -53,7 +53,7 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol {
|
||||
}
|
||||
packetWrapper.write(Type.LONG, realKeepAlive);
|
||||
// Reset KeepAliveTracker (to prevent sending same valid value in a row causing a timeout)
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(Long.MIN_VALUE);
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(Integer.MAX_VALUE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,199 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
new BlockItemPackets1_13().register(this);
|
||||
|
||||
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
|
||||
|
||||
|
||||
out(State.PLAY, 0x00, 0x00, cancel());
|
||||
out(State.PLAY, 0x04, 0x04, cancel());// Spawn Painting TODO MODIFIED
|
||||
out(State.PLAY, 0x07, 0x07, cancel()); // Statistics TODO MODIFIED
|
||||
out(State.PLAY, 0x09, 0x09, cancel()); // Update Block Entity TODO MODIFIED
|
||||
out(State.PLAY, 0x0B, 0x0B, cancel()); // Block Change TODO MODIFIED
|
||||
out(State.PLAY, 0x0E, 0x0F); // Chat Message (clientbound)
|
||||
out(State.PLAY, 0x0F, 0x10, cancel()); // Multi Block Change TODO MODIFIED
|
||||
out(State.PLAY, 0x10, 0x0E, cancel()); // Tab-Complete (clientbound) TODO MODIFIED
|
||||
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
|
||||
out(State.PLAY, 0x12, 0x11, cancel()); // Confirm Transaction (clientbound)
|
||||
out(State.PLAY, 0x13, 0x12, cancel()); // Close Window (clientbound)
|
||||
out(State.PLAY, 0x14, 0x13, cancel()); // Open Window
|
||||
out(State.PLAY, 0x15, 0x14, cancel()); // Window Items
|
||||
out(State.PLAY, 0x16, 0x15, cancel()); // Window Property
|
||||
out(State.PLAY, 0x17, 0x16, cancel()); // Set Slot
|
||||
out(State.PLAY, 0x18, 0x17); // Set Cooldown
|
||||
out(State.PLAY, 0x19, 0x18); // Plugin Message (clientbound) TODO MODIFIED
|
||||
out(State.PLAY, 0x1A, 0x19, cancel()); // Named Sound Effect TODO MODIFIED
|
||||
out(State.PLAY, 0x1B, 0x1A); // Disconnect (play)
|
||||
out(State.PLAY, 0x1C, 0x1B); // Entity Status
|
||||
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response TODO NEW
|
||||
out(State.PLAY, 0x1E, 0x1C); // Explosion
|
||||
out(State.PLAY, 0x1F, 0x1D); // Unload Chunk
|
||||
out(State.PLAY, 0x20, 0x1E); // Change Game State
|
||||
out(State.PLAY, 0x21, 0x1F); // Keep Alive (clientbound)
|
||||
|
||||
// Chunk Data -> moved to BlockItemPackets
|
||||
|
||||
|
||||
|
||||
out(State.PLAY, 0x23, 0x21, cancel()); // Effect TODO MODIFIED
|
||||
out(State.PLAY, 0x24, 0x22, cancel()); // Spawn Particle TODO MODIFIED
|
||||
out(State.PLAY, 0x25, 0x23, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
}
|
||||
}); // Join Game
|
||||
out(State.PLAY, 0x26, 0x24, cancel()); // Map TODO MODIFIED
|
||||
out(State.PLAY, 0x27, 0x25); // Entity
|
||||
out(State.PLAY, 0x28, 0x26); // Entity Relative Move
|
||||
out(State.PLAY, 0x29, 0x27); // Entity Look And Relative Move
|
||||
out(State.PLAY, 0x2A, 0x28); // Entity Look
|
||||
out(State.PLAY, 0x2B, 0x29); // Vehicle Move (clientbound)
|
||||
out(State.PLAY, 0x2C, 0x2A); // Open Sign Editor
|
||||
out(State.PLAY, 0x2D, 0x2B, cancel()); // Craft Recipe Response TODO MODIFIED
|
||||
out(State.PLAY, 0x2E, 0x2C); // Player Abilities (clientbound)
|
||||
out(State.PLAY, 0x2F, 0x2D); // Combat Event
|
||||
out(State.PLAY, 0x30, 0x2E); // Player List Item
|
||||
out(State.PLAY, 0x31, -1, cancel()); // Face Player TODO NEW
|
||||
out(State.PLAY, 0x32, 0x2F); // Player Position And Look (clientbound)
|
||||
out(State.PLAY, 0x33, 0x30); // Use Bed
|
||||
out(State.PLAY, 0x34, 0x31, cancel()); // Unlock Recipes TODO MODIFIED
|
||||
out(State.PLAY, 0x35, 0x32); // Destroy Entities
|
||||
out(State.PLAY, 0x36, 0x33); // Remove Entity Effect
|
||||
out(State.PLAY, 0x37, 0x34); // Resource Pack Send
|
||||
out(State.PLAY, 0x38, 0x35); // Respawn
|
||||
out(State.PLAY, 0x39, 0x36); // Entity Head Look
|
||||
out(State.PLAY, 0x3A, 0x37); // Select Advancement Tab
|
||||
out(State.PLAY, 0x3B, 0x38); // World Border
|
||||
out(State.PLAY, 0x3C, 0x39); // Camera
|
||||
out(State.PLAY, 0x3D, 0x3A, cancel()); // Held Item Change (clientbound)
|
||||
out(State.PLAY, 0x3E, 0x3B); // Display Scoreboard
|
||||
out(State.PLAY, 0x3F, 0x3C, cancel()); // Entity Metadata
|
||||
out(State.PLAY, 0x40, 0x3D); // Attach Entity
|
||||
out(State.PLAY, 0x41, 0x3E); // Entity Velocity
|
||||
out(State.PLAY, 0x42, 0x3F, cancel()); // Entity Equipment
|
||||
out(State.PLAY, 0x43, 0x40); // Set Experience
|
||||
out(State.PLAY, 0x44, 0x41); // Update Health
|
||||
out(State.PLAY, 0x45, 0x42, cancel()); // Scoreboard Objective TODO MODIFIED
|
||||
out(State.PLAY, 0x46, 0x43); // Set Passengers
|
||||
out(State.PLAY, 0x47, 0x44, cancel()); // Teams TODO MODIFIED
|
||||
out(State.PLAY, 0x48, 0x45); // Update Score
|
||||
out(State.PLAY, 0x49, 0x46); // Spawn Position
|
||||
out(State.PLAY, 0x4A, 0x47); // Time Update
|
||||
out(State.PLAY, 0x4B, 0x48); // Title
|
||||
out(State.PLAY, 0x4C, -1, cancel()); // Stop Sound TODO NEW
|
||||
out(State.PLAY, 0x4D, 0x49); // Sound Effect
|
||||
out(State.PLAY, 0x4E, 0x4A); // Player List Header And Footer
|
||||
out(State.PLAY, 0x4F, 0x4B, cancel()); // Collect Item
|
||||
out(State.PLAY, 0x50, 0x4C); // Entity Teleport
|
||||
out(State.PLAY, 0x51, 0x4D, cancel()); // Advancements
|
||||
out(State.PLAY, 0x52, 0x4E); // Entity Properties
|
||||
out(State.PLAY, 0x53, 0x4F); // Entity Effect
|
||||
out(State.PLAY, 0x54, -1, cancel()); // Declare Recipes TODO NEW
|
||||
out(State.PLAY, 0x55, -1, cancel()); // Tags TODO NEW
|
||||
|
||||
|
||||
in(State.PLAY, 0x01, -1, cancel()); // Query Block NBT TODO NEW
|
||||
in(State.PLAY, 0x05, 0x01); // Tab-Complete (serverbound) TODO MODIFIED
|
||||
in(State.PLAY, 0x06, 0x05); //Confirm Transaction (serverbound)
|
||||
in(State.PLAY, 0x07, 0x06); // Enchant Item
|
||||
in(State.PLAY, 0x08, 0x07); // Click Window
|
||||
in(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
|
||||
in(State.PLAY, 0x0A, 0x09, cancel()); // Plugin message (serverbound) TODO MODIFIED
|
||||
in(State.PLAY, 0x0B, -1, cancel()); // Edit Book TODO NEW
|
||||
in(State.PLAY, 0x0C, -1, cancel()); // Query Entity NBT TODO NEW
|
||||
in(State.PLAY, 0x0D, 0x0A); // Use Entity
|
||||
in(State.PLAY, 0x0E, 0x0B); // Keep Alive (serverbound)
|
||||
in(State.PLAY, 0x0F, 0x0C); // Player
|
||||
in(State.PLAY, 0x10, 0x0D); // Player Position
|
||||
in(State.PLAY, 0x11, 0x0E); // Player Position And Look (serverbound)
|
||||
in(State.PLAY, 0x12, 0x0F); // Player Look
|
||||
in(State.PLAY, 0x13, 0x10); // Vehicle Move (serverbound)
|
||||
in(State.PLAY, 0x14, 0x11); // Steer Boat
|
||||
in(State.PLAY, 0x15, -1, cancel()); // Pick Item TODO NEW
|
||||
in(State.PLAY, 0x16, 0x12, cancel()); // Craft Recipe Request TODO MODIFIED
|
||||
in(State.PLAY, 0x17, 0x13); // Player Abilities (serverbound)
|
||||
in(State.PLAY, 0x18, 0x14); // Player Digging
|
||||
in(State.PLAY, 0x19, 0x15); // Entity Action
|
||||
in(State.PLAY, 0x1A, 0x16); // Steer Vehicle
|
||||
in(State.PLAY, 0x1B, 0x17); // Recipe Book Data
|
||||
in(State.PLAY, 0x1C, -1, cancel()); // Name Item TODO NEW
|
||||
in(State.PLAY, 0x1D, 0x18); // Resource Pack Status
|
||||
in(State.PLAY, 0x1E, 0x19); // Advancement Tab
|
||||
in(State.PLAY, 0x1F, -1); // Select Trade
|
||||
in(State.PLAY, 0x20, -1); // Set Beacon Effect
|
||||
in(State.PLAY, 0x21, 0x1A); // Held Item Change (serverbound)
|
||||
in(State.PLAY, 0x22, -1, cancel()); // Update Command Block TODO NEW
|
||||
in(State.PLAY, 0x23, -1, cancel()); // Update Command Block Minecart TODO NEW
|
||||
in(State.PLAY, 0x24, 0x1B); // Creative Inventory Action
|
||||
in(State.PLAY, 0x25, -1, cancel()); // Update Structure Block TODO NEW
|
||||
in(State.PLAY, 0x26, 0x1C); // Update Sign
|
||||
in(State.PLAY, 0x27, 0x1D); // Animation (serverbound)
|
||||
in(State.PLAY, 0x28, 0x1E); // Spectate
|
||||
in(State.PLAY, 0x29, 0x1F); // Player Block Placement
|
||||
in(State.PLAY, 0x2A, 0x20); // Use Item
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
// Register ClientWorld
|
||||
if (!user.has(ClientWorld.class))
|
||||
user.put(new ClientWorld(user));
|
||||
|
||||
}
|
||||
|
||||
public PacketRemapper cancel() {
|
||||
return new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
packetWrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static {
|
||||
BackwardsMappings.init();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
||||
|
||||
public class BackwardsMappings {
|
||||
public static BlockMappings blockMappings;
|
||||
|
||||
public static void init() {
|
||||
us.myles.viaversion.libs.gson.JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
||||
us.myles.viaversion.libs.gson.JsonObject mapping1_13 = loadData("mapping-1.13.json");
|
||||
|
||||
Via.getPlatform().getLogger().info("Loading block mapping...");
|
||||
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"));
|
||||
}
|
||||
|
||||
|
||||
private static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
|
||||
if (value == null) {
|
||||
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
|
||||
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||
String value = entry.getValue().getAsString();
|
||||
if (value.equals(needle)) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public interface BlockMappings {
|
||||
int getNewBlock(int old);
|
||||
}
|
||||
|
||||
private static class BlockMappingsShortArray implements BlockMappings {
|
||||
private short[] oldToNew = new short[4084 * 6];
|
||||
|
||||
private BlockMappingsShortArray(JsonObject oldMapping, JsonObject newMapping) {
|
||||
Arrays.fill(oldToNew, (short) -1);
|
||||
mapIdentifiers(oldToNew, oldMapping, newMapping);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewBlock(int old) {
|
||||
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Matsv
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||
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 us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
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;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||
|
||||
// Chunk packet
|
||||
protocol.out(State.PLAY, 0x22, 0x20, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk1_13Type type = new Chunk1_13Type(clientWorld);
|
||||
Chunk chunk = wrapper.read(type);
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int p = 0; p < section.getPalette().size(); p++) {
|
||||
int old = section.getPalette().get(p);
|
||||
if (old != 0) {
|
||||
section.getPalette().set(p, toNewId(old));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite biome id 255 to plains
|
||||
if (chunk.isBiomeData()) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
chunk.getBiomeData()[i] = 1; // Plains
|
||||
}
|
||||
}
|
||||
|
||||
chunk.getBlockEntities().clear();
|
||||
wrapper.write(type_old, chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static int toNewId(int oldId) {
|
||||
if (oldId < 0) {
|
||||
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
|
||||
}
|
||||
int newId = BackwardsMappings.blockMappings.getNewBlock(oldId);
|
||||
if (newId != -1)
|
||||
return newId;
|
||||
|
||||
Via.getPlatform().getLogger().warning("Missing block completely " + oldId);
|
||||
// Default stone
|
||||
return 1 << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapColorMapping {
|
||||
private static Map<Integer, Integer> mapping = new HashMap<>();
|
||||
static {
|
||||
mapping.put(144, 59); // (148, 124, 114) -> (148, 124, 114)
|
||||
mapping.put(145, 56); // (180, 153, 139) -> (180, 153, 139)
|
||||
mapping.put(146, 56); // (209, 177, 161) -> (209, 177, 161)
|
||||
mapping.put(147, 45); // (111, 94, 85) -> (111, 94, 85)
|
||||
mapping.put(148, 63); // (112, 58, 25) -> (112, 58, 25)
|
||||
mapping.put(149, 60); // (137, 71, 31) -> (137, 71, 31)
|
||||
mapping.put(150, 60); // (159, 82, 36) -> (159, 82, 36)
|
||||
mapping.put(151, 136); // (84, 43, 19) -> (84, 43, 19)
|
||||
mapping.put(152, 83); // (105, 61, 76) -> (105, 61, 76)
|
||||
mapping.put(153, 83); // (129, 75, 93) -> (129, 75, 93)
|
||||
mapping.put(154, 80); // (149, 87, 108) -> (149, 87, 108)
|
||||
mapping.put(155, 115); // (79, 46, 57) -> (79, 46, 57)
|
||||
mapping.put(156, 39); // (79, 76, 97) -> (79, 76, 97)
|
||||
mapping.put(157, 39); // (97, 93, 119) -> (97, 93, 119)
|
||||
mapping.put(158, 36); // (112, 108, 138) -> (112, 108, 138)
|
||||
mapping.put(159, 47); // (59, 57, 73) -> (59, 57, 73)
|
||||
mapping.put(160, 60); // (131, 94, 25) -> (131, 94, 25)
|
||||
mapping.put(161, 61); // (160, 115, 31) -> (160, 115, 31)
|
||||
mapping.put(162, 62); // (186, 133, 36) -> (186, 133, 36)
|
||||
mapping.put(163, 137); // (98, 70, 19) -> (98, 70, 19)
|
||||
mapping.put(164, 108); // (73, 83, 37) -> (73, 83, 37)
|
||||
mapping.put(165, 108); // (89, 101, 46) -> (89, 101, 46)
|
||||
mapping.put(166, 109); // (103, 117, 53) -> (103, 117, 53)
|
||||
mapping.put(167, 111); // (55, 62, 28) -> (55, 62, 28)
|
||||
mapping.put(168, 112); // (113, 54, 55) -> (113, 54, 55)
|
||||
mapping.put(169, 113); // (138, 66, 67) -> (138, 66, 67)
|
||||
mapping.put(170, 114); // (160, 77, 78) -> (160, 77, 78)
|
||||
mapping.put(171, 115); // (85, 41, 41) -> (85, 41, 41)
|
||||
mapping.put(172, 118); // (40, 29, 25) -> (40, 29, 25)
|
||||
mapping.put(173, 107); // (49, 35, 30) -> (49, 35, 30)
|
||||
mapping.put(174, 107); // (57, 41, 35) -> (57, 41, 35)
|
||||
mapping.put(175, 118); // (30, 22, 19) -> (30, 22, 19)
|
||||
mapping.put(176, 91); // (95, 76, 69) -> (95, 76, 69)
|
||||
mapping.put(177, 45); // (116, 92, 85) -> (116, 92, 85)
|
||||
mapping.put(178, 46); // (135, 107, 98) -> (135, 107, 98)
|
||||
mapping.put(179, 47); // (71, 57, 52) -> (71, 57, 52)
|
||||
mapping.put(180, 85); // (61, 65, 65) -> (61, 65, 65)
|
||||
mapping.put(181, 44); // (75, 79, 79) -> (75, 79, 79)
|
||||
mapping.put(182, 27); // (87, 92, 92) -> (87, 92, 92)
|
||||
mapping.put(183, 84); // (46, 49, 49) -> (46, 49, 49)
|
||||
mapping.put(184, 83); // (86, 52, 62) -> (86, 52, 62)
|
||||
mapping.put(185, 83); // (105, 63, 76) -> (105, 63, 76)
|
||||
mapping.put(186, 83); // (122, 73, 88) -> (122, 73, 88)
|
||||
mapping.put(187, 84); // (65, 39, 47) -> (65, 39, 47)
|
||||
mapping.put(188, 84); // (54, 44, 65) -> (54, 44, 65)
|
||||
mapping.put(189, 71); // (66, 53, 79) -> (66, 53, 79)
|
||||
mapping.put(190, 71); // (76, 62, 92) -> (76, 62, 92)
|
||||
mapping.put(191, 87); // (40, 33, 49) -> (40, 33, 49)
|
||||
mapping.put(192, 107); // (54, 35, 25) -> (54, 35, 25)
|
||||
mapping.put(193, 139); // (66, 43, 30) -> (66, 43, 30)
|
||||
mapping.put(194, 43); // (76, 50, 35) -> (76, 50, 35)
|
||||
mapping.put(195, 107); // (40, 26, 19) -> (40, 26, 19)
|
||||
mapping.put(196, 111); // (54, 58, 30) -> (54, 58, 30)
|
||||
mapping.put(197, 111); // (66, 71, 36) -> (66, 71, 36)
|
||||
mapping.put(198, 111); // (76, 82, 42) -> (76, 82, 42)
|
||||
mapping.put(199, 107); // (40, 43, 22) -> (40, 43, 22)
|
||||
mapping.put(200, 112); // (100, 42, 32) -> (100, 42, 32)
|
||||
mapping.put(201, 113); // (123, 52, 40) -> (123, 52, 40)
|
||||
mapping.put(202, 113); // (142, 60, 46) -> (142, 60, 46)
|
||||
mapping.put(203, 115); // (75, 32, 24) -> (75, 32, 24)
|
||||
mapping.put(204, 116); // (26, 16, 11) -> (26, 16, 11)
|
||||
mapping.put(205, 117); // (32, 19, 14) -> (32, 19, 14)
|
||||
mapping.put(206, 107); // (37, 22, 16) -> (37, 22, 16)
|
||||
mapping.put(207, 119); // (20, 12, 8) -> (20, 12, 8)
|
||||
}
|
||||
|
||||
public static int getNearestOldColor(int color) {
|
||||
return mapping.getOrDefault(color, color);
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets;
|
||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.MapColorMapping;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -34,6 +35,43 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
|
||||
protected void registerPackets(Protocol1_11_1To1_12 protocol) {
|
||||
/* Item packets */
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int count = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < count * 3; i++) {
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
}
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
short columns = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
if (columns <= 0) return;
|
||||
short rows = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.passthrough(Type.BYTE); //X
|
||||
wrapper.passthrough(Type.BYTE); //Z
|
||||
Byte[] data = wrapper.read(Type.BYTE_ARRAY);
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
short color = (short) (data[i] & 0xFF);
|
||||
if (color > 143) {
|
||||
color = (short) MapColorMapping.getNearestOldColor(color);
|
||||
data[i] = (byte) color;
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.BYTE_ARRAY, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x16, 0x16, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -1,18 +0,0 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_12_1;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class KeepAliveTracker extends StoredObject {
|
||||
private long keepAlive;
|
||||
|
||||
public KeepAliveTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
2
pom.xml
2
pom.xml
@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.6.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren