Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Merge branch 'dev' of https://github.com/ViaVersion/ViaBackwards into dev
Dieser Commit ist enthalten in:
Commit
04793f41c5
@ -22,6 +22,7 @@ import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14_3to1_14_4.Protocol1_14_3To1_14_4;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||
@ -52,6 +53,7 @@ public interface ViaBackwardsPlatform {
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_14To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_14_1.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_14_1To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14_2.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_14_2To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_3.getId());
|
||||
ProtocolRegistry.registerProtocol(new Protocol1_14_3To1_14_4(), Collections.singletonList(ProtocolVersion.v1_14_3.getId()), ProtocolVersion.v1_14_4.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.BYTE);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
@ -140,7 +140,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.BYTE);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
@ -90,7 +90,7 @@ public class ItemPackets1_11_1 extends BlockItemRewriter<Protocol1_11To1_11_1> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.BYTE);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
@ -125,8 +125,8 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||
in(State.PLAY, 0x1B, 0x17, cancel()); // Recipe Book Data TODO MODIFIED
|
||||
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, 0x1F, -1); // Select Trade (the client won't send this)
|
||||
//in(State.PLAY, 0x20, -1); // Set Beacon Effect (the client won't send this)
|
||||
in(State.PLAY, 0x21, 0x1A); // Held Item Change (serverbound)
|
||||
in(State.PLAY, 0x26, 0x1C); // Update Sign
|
||||
in(State.PLAY, 0x27, 0x1D); // Animation (serverbound)
|
||||
|
@ -0,0 +1,92 @@
|
||||
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.providers.BackwardsBlockEntityProvider;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||
import us.myles.viaversion.libs.gson.JsonElement;
|
||||
import us.myles.viaversion.libs.gson.JsonObject;
|
||||
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;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class PistonHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||
|
||||
private final Map<String, Integer> pistonIds = new HashMap<>();
|
||||
|
||||
public PistonHandler() {
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
Map<String, Integer> keyToId;
|
||||
try {
|
||||
keyToId = (Map<String, Integer>) ConnectionData.class.getDeclaredField("keyToId").get(null);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Integer> entry : keyToId.entrySet()) {
|
||||
if (!entry.getKey().contains("piston")) continue;
|
||||
|
||||
addEntries(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
JsonObject mappings = MappingData.loadData("mapping-1.13.json").getAsJsonObject("blocks");
|
||||
for (Map.Entry<String, JsonElement> blockState : mappings.entrySet()) {
|
||||
String key = blockState.getValue().getAsString();
|
||||
if (!key.contains("piston")) continue;
|
||||
|
||||
addEntries(key, Integer.parseInt(blockState.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There doesn't seem to be a nicer way around it :(
|
||||
private void addEntries(String data, int id) {
|
||||
id = BackwardsMappings.blockMappings.getNewBlock(id);
|
||||
pistonIds.put(data, id);
|
||||
|
||||
String substring = data.substring(10);
|
||||
if (!substring.startsWith("piston") && !substring.startsWith("sticky_piston")) return;
|
||||
|
||||
// Swap properties and add them to the map
|
||||
String[] split = data.substring(0, data.length() - 1).split("\\[");
|
||||
String[] properties = split[1].split(",");
|
||||
data = split[0] + "[" + properties[1] + "," + properties[0] + "]";
|
||||
pistonIds.put(data, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||
CompoundTag blockState = tag.get("blockState");
|
||||
String dataFromTag = getDataFromTag(blockState);
|
||||
if (dataFromTag == null) return tag;
|
||||
|
||||
int id = pistonIds.get(dataFromTag);
|
||||
tag.put(new IntTag("blockId", id >> 4));
|
||||
tag.put(new IntTag("blockData", id & 15));
|
||||
return tag;
|
||||
}
|
||||
|
||||
// The type hasn't actually been updated in the blockstorage, so we need to construct it
|
||||
private String getDataFromTag(CompoundTag tag) {
|
||||
StringTag name = tag.get("Name");
|
||||
if (name == null) return null;
|
||||
|
||||
CompoundTag properties = tag.get("Properties");
|
||||
if (properties == null) return name.getValue();
|
||||
|
||||
StringJoiner joiner = new StringJoiner(",", name.getValue() + "[", "]");
|
||||
for (Tag property : properties) {
|
||||
if (!(property instanceof StringTag)) continue;
|
||||
joiner.add(property.getName() + "=" + ((StringTag) property).getValue());
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
handlers.put("minecraft:banner", new BannerHandler());
|
||||
handlers.put("minecraft:skull", new SkullHandler());
|
||||
handlers.put("minecraft:mob_spawner", new SpawnerHandler());
|
||||
handlers.put("minecraft:piston", new PistonHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,18 +10,18 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.Position;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BackwardsBlockStorage extends StoredObject {
|
||||
// This BlockStorage is very exclusive (;
|
||||
private static final Set<Integer> whitelist = Sets.newConcurrentHashSet();
|
||||
private static final Set<Integer> whitelist = new HashSet<>();
|
||||
|
||||
static {
|
||||
// Flower pots
|
||||
@ -42,6 +42,17 @@ public class BackwardsBlockStorage extends StoredObject {
|
||||
// Skulls
|
||||
for (int i = 5447; i <= 5566; i++)
|
||||
whitelist.add(i);
|
||||
|
||||
// pistons
|
||||
for (int i = 1028; i <= 1039; i++) {
|
||||
whitelist.add(i);
|
||||
}
|
||||
for (int i = 1047; i <= 1082; i++) {
|
||||
whitelist.add(i);
|
||||
}
|
||||
for (int i = 1099; i <= 1110; i++) {
|
||||
whitelist.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,8 +65,7 @@ public class BackwardsBlockStorage extends StoredObject {
|
||||
public void checkAndStore(Position position, int block) {
|
||||
if (!whitelist.contains(block)) {
|
||||
// Remove if not whitelisted
|
||||
if (blocks.containsKey(position))
|
||||
blocks.remove(position);
|
||||
blocks.remove(position);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,6 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.STRING, "minecraft:trader_list");
|
||||
// wrapper.read(Type.STRING); // Remove channel
|
||||
|
||||
int windowId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.INT, windowId);
|
||||
|
@ -70,13 +70,13 @@ public class InventoryPackets1_13_1 {
|
||||
toClient(input);
|
||||
//Output Item
|
||||
Item output = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
toClient(input);
|
||||
toClient(output);
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||
if (secondItem) {
|
||||
//Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_ITEM);
|
||||
toClient(input);
|
||||
toClient(second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
|
||||
|
@ -0,0 +1,60 @@
|
||||
package nl.matsv.viabackwards.protocol.protocol1_14_3to1_14_4;
|
||||
|
||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||
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;
|
||||
|
||||
public class Protocol1_14_3To1_14_4 extends BackwardsProtocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Acknowledge Player Digging - added in pre4
|
||||
registerOutgoing(State.PLAY, 0x5c, -1, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Trade list
|
||||
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
}
|
||||
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.read(Type.INT); // demand value added in pre-5
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
}
|
||||
}
|
@ -96,7 +96,7 @@ public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10>
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.BYTE);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Input Item
|
||||
wrapper.write(Type.ITEM, handleItemToClient(wrapper.read(Type.ITEM))); // Output Item
|
||||
|
2
pom.xml
2
pom.xml
@ -61,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<version>2.1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren