3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-20 06:50:10 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2021-10-20 18:58:32 +02:00
Ursprung abb2abe5c9
Commit 9d52fd6212
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 93 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@ plugins {
allprojects { allprojects {
group = "com.viaversion" group = "com.viaversion"
version = "4.1.0-21w41a-SNAPSHOT" version = "4.1.0-21w42a-SNAPSHOT"
description = "Allow older clients to join newer server versions." description = "Allow older clients to join newer server versions."
} }

Datei anzeigen

@ -21,6 +21,7 @@ import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18; import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.data.BlockEntityIds; import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.data.BlockEntityIds;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
@ -34,7 +35,9 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1; import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
@ -46,43 +49,74 @@ import java.util.List;
public final class BlockItemPackets1_18 extends ItemRewriter<Protocol1_17_1To1_18> { public final class BlockItemPackets1_18 extends ItemRewriter<Protocol1_17_1To1_18> {
private static final int WIDTH_BITS = 2;
private static final int HORIZONTAL_MASK = 3;
public BlockItemPackets1_18(final Protocol1_17_1To1_18 protocol, final TranslatableRewriter translatableRewriter) { public BlockItemPackets1_18(final Protocol1_17_1To1_18 protocol, final TranslatableRewriter translatableRewriter) {
super(protocol, translatableRewriter); super(protocol, translatableRewriter);
} }
@Override @Override
protected void registerPackets() { protected void registerPackets() {
/*final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14); //final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES); new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES);
registerSetCooldown(ClientboundPackets1_18.COOLDOWN); registerSetCooldown(ClientboundPackets1_18.COOLDOWN);
registerWindowItems(ClientboundPackets1_18.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY); registerWindowItems1_17_1(ClientboundPackets1_18.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, Type.FLAT_VAR_INT_ITEM);
registerSetSlot(ClientboundPackets1_18.SET_SLOT, Type.FLAT_VAR_INT_ITEM); registerSetSlot1_17_1(ClientboundPackets1_18.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerEntityEquipmentArray(ClientboundPackets1_18.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM); registerEntityEquipmentArray(ClientboundPackets1_18.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
registerTradeList(ClientboundPackets1_18.TRADE_LIST, Type.FLAT_VAR_INT_ITEM); registerTradeList(ClientboundPackets1_18.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM); registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerClickWindow1_17(ClientboundPackets1_18.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM); registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_18.ACKNOWLEDGE_PLAYER_DIGGING); /*blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_18.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_18.BLOCK_ACTION); blockRewriter.registerBlockAction(ClientboundPackets1_18.BLOCK_ACTION);
blockRewriter.registerEffect(ClientboundPackets1_18.EFFECT, 1010, 2001); blockRewriter.registerEffect(ClientboundPackets1_18.EFFECT, 1010, 2001);
blockRewriter.registerBlockChange(ClientboundPackets1_18.BLOCK_CHANGE); blockRewriter.registerBlockChange(ClientboundPackets1_18.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_18.MULTI_BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_18.MULTI_BLOCK_CHANGE);*/
registerCreativeInvAction(ClientboundPackets1_18.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM); registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
protocol.registerServerbound(ClientboundPackets1_18.EDIT_BOOK, new PacketRemapper() {
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); map(Type.INT); // Particle id
map(Type.BOOLEAN); // Override limiter
map(Type.DOUBLE); // X
map(Type.DOUBLE); // Y
map(Type.DOUBLE); // Z
map(Type.FLOAT); // Offset X
map(Type.FLOAT); // Offset Y
map(Type.FLOAT); // Offset Z
map(Type.FLOAT); // Max speed
map(Type.INT); // Particle Count
handler(wrapper -> {
int id = wrapper.get(Type.INT, 0);
if (id == 3) { // Block marker
int blockState = wrapper.read(Type.VAR_INT);
if (blockState == 7786) { // Light block
wrapper.set(Type.INT, 0, 3);
} else {
// Else assume barrier block
wrapper.set(Type.INT, 0, 2);
}
return;
}
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} else if (id == mappings.getItemId()) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
}
int newId = protocol.getMappingData().getNewParticleId(id);
if (newId != id) {
wrapper.set(Type.INT, 0, newId);
}
});
} }
}); });
registerSpawnParticle(ClientboundPackets1_17_1.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);*/
protocol.registerClientbound(ClientboundPackets1_18.BLOCK_ENTITY_DATA, new PacketRemapper() { protocol.registerClientbound(ClientboundPackets1_18.BLOCK_ENTITY_DATA, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {

Datei anzeigen

@ -21,8 +21,14 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18; import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_17;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_18;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper; import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_17;
import com.viaversion.viaversion.api.type.types.version.Types1_18;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.FloatTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
@ -45,8 +51,8 @@ public final class EntityPackets1_18 extends EntityRewriter<Protocol1_17_1To1_18
registerTracker(ClientboundPackets1_18.SPAWN_EXPERIENCE_ORB, Entity1_18Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_18.SPAWN_EXPERIENCE_ORB, Entity1_18Types.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_18.SPAWN_PAINTING, Entity1_18Types.PAINTING); registerTracker(ClientboundPackets1_18.SPAWN_PAINTING, Entity1_18Types.PAINTING);
registerTracker(ClientboundPackets1_18.SPAWN_PLAYER, Entity1_18Types.PLAYER); registerTracker(ClientboundPackets1_18.SPAWN_PLAYER, Entity1_18Types.PLAYER);
registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_17.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_18.REMOVE_ENTITIES);*/ registerRemoveEntities(ClientboundPackets1_18.REMOVE_ENTITIES);*/
registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_18.METADATA_LIST, Types1_17.METADATA_LIST);
protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() { protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
@Override @Override
@ -100,8 +106,30 @@ public final class EntityPackets1_18 extends EntityRewriter<Protocol1_17_1To1_18
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(MetaType1_18.byId(meta.metaType().typeId()));
MetaType type = meta.metaType();
if (type == MetaType1_18.PARTICLE) {
Particle particle = (Particle) meta.getValue();
if (particle.getId() == 3) { // Block marker
Particle.ParticleData data = particle.getArguments().remove(0);
int blockState = (int) data.getValue();
if (blockState == 7786) { // Light block
particle.setId(3);
} else {
// Else assume barrier block
particle.setId(2);
}
return;
}
rewriteParticle(particle);
}
});
// Particles have already been handled // Particles have already been handled
//registerMetaTypeHandler(MetaType1_17.ITEM, MetaType1_17.BLOCK_STATE, null, MetaType1_17.OPT_COMPONENT); //TODO correct types registerMetaTypeHandler(MetaType1_17.ITEM, null, null, null); //TODO
} }
@Override @Override

Datei anzeigen

@ -3,6 +3,18 @@
"item.bundle.drop_contents": "", "item.bundle.drop_contents": "",
"item.bundle.insert": "", "item.bundle.insert": "",
"item.bundle.remove_one": "", "item.bundle.remove_one": "",
"block.growing_plant.crop": "" "block.growing_plant.crop": "",
"music_disc.otherside": "",
"music.overworld.dripstone_caves": "",
"music.overworld.grove": "",
"music.overworld.jagged_peaks": "",
"music.overworld.lush_caves": "",
"music.overworld.meadow": "",
"music.overworld.frozen_peaks": "",
"music.overworld.snowy_slopes": "",
"music.overworld.stony_peaks": ""
},
"particles": {
"block_marker": "barrier"
} }
} }

Datei anzeigen

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions] [versions]
# ViaVersion # ViaVersion
viaver = "4.1.0-21w40a-SNAPSHOT" viaver = "4.1.0-21w42a-SNAPSHOT"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"