Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
113bf1e275 | ||
|
|
2aec3ce6d1 | ||
|
|
f60e31ac78 | ||
|
|
8c4ff7ebfc | ||
|
|
4c7729e602 | ||
|
|
3dfc3bb15b | ||
|
|
69b33dc2d2 | ||
|
|
c24169c410 | ||
|
|
31211c2214 | ||
|
|
cb5fc9fb08 | ||
|
|
a8d7ab62e3 | ||
|
|
71313b4753 | ||
|
|
994bc8eefc | ||
|
|
7d35826637 |
No files matched your search
+8
-3
@@ -39,6 +39,8 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
@@ -170,9 +172,11 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
EntityPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT)));
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
|
||||
componentRewriter.processText(wrapper.user(), wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
|
||||
registerClientbound(State.STATUS, 0x00, 0x00, new PacketHandlers() {
|
||||
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.STRING);
|
||||
@@ -840,7 +844,6 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
ConnectionData.init();
|
||||
RecipeData.init();
|
||||
BlockIdData.init();
|
||||
@@ -854,6 +857,8 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
if (Via.getConfig().isServersideBlockConnections() && Via.getManager().getProviders().get(BlockConnectionProvider.class) instanceof PacketBlockConnectionProvider) {
|
||||
BlockConnectionStorage.init();
|
||||
}
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -141,7 +141,6 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
WorldPackets.air = MAPPINGS.getBlockStateMappings().getNewId(0);
|
||||
WorldPackets.voidAir = MAPPINGS.getBlockStateMappings().getNewId(8591);
|
||||
WorldPackets.caveAir = MAPPINGS.getBlockStateMappings().getNewId(8592);
|
||||
@@ -157,6 +156,8 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.ITEM1_13_2);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-11
@@ -59,7 +59,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
|
||||
EntityTracker1_14 tracker = tracker(event.user());
|
||||
int entityId = event.entityId();
|
||||
tracker.setInsentientData(entityId, (byte) ((((Number) meta.getValue()).byteValue() & ~0x4)
|
||||
| (tracker.getInsentientData(entityId) & 0x4))); // New attacking metadata
|
||||
| (tracker.getInsentientData(entityId) & 0x4))); // New attacking metadata
|
||||
meta.setValue(tracker.getInsentientData(entityId));
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
|
||||
EntityTracker1_14 tracker = tracker(event.user());
|
||||
int entityId = event.entityId();
|
||||
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
|
||||
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
|
||||
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
|
||||
event.createExtraMeta(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
|
||||
event.cancel(); // "Are hands held up"
|
||||
} else if (meta.id() > 16) {
|
||||
@@ -143,7 +143,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
|
||||
EntityTracker1_14 tracker = tracker(event.user());
|
||||
int entityId = event.entityId();
|
||||
tracker.setInsentientData(entityId, (byte) ((tracker.getInsentientData(entityId) & ~0x4)
|
||||
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
|
||||
| ((boolean) meta.getValue() ? 0x4 : 0))); // New attacking
|
||||
event.createExtraMeta(new Metadata(13, Types1_14.META_TYPES.byteType, tracker.getInsentientData(entityId)));
|
||||
event.cancel(); // "Is swinging arms"
|
||||
});
|
||||
@@ -167,14 +167,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
|
||||
filter().type(EntityTypes1_14.OCELOT).removeIndex(16); // owner uuid
|
||||
filter().type(EntityTypes1_14.OCELOT).removeIndex(15); // data
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
EntityType type = event.entityType();
|
||||
if (type.is(EntityTypes1_14.WITCH) || type.is(EntityTypes1_14.RAVAGER) || type.isOrHasParent(EntityTypes1_14.ABSTRACT_ILLAGER_BASE)) {
|
||||
if (meta.id() >= 14) { // 19w13 added a new boolean (raid participant - is celebrating) with id 14
|
||||
meta.setId(meta.id() + 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
filter().type(EntityTypes1_14.ABSTRACT_RAIDER).addIndex(14); // celebrating
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -66,8 +66,6 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
EntityTypes1_15.initialize(this);
|
||||
|
||||
int[] shulkerBoxes = new int[17];
|
||||
@@ -76,6 +74,8 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
shulkerBoxes[i] = shulkerBoxOffset + i;
|
||||
}
|
||||
tagRewriter.addTag(RegistryType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -84,8 +84,6 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
EntityTypes1_16_2.initialize(this);
|
||||
|
||||
tagRewriter.addTag(RegistryType.ITEM, "minecraft:stone_crafting_materials", 14, 962);
|
||||
@@ -101,6 +99,8 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
"minecraft:stone_pressure_plates", "minecraft:nylium", "minecraft:gold_ores", "minecraft:pressure_plates",
|
||||
"minecraft:logs_that_burn", "minecraft:strider_warm_blocks", "minecraft:warped_stems", "minecraft:infiniburn_end",
|
||||
"minecraft:base_stone_nether", "minecraft:base_stone_overworld");
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-4
@@ -35,6 +35,8 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundStatusPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.TranslationMappings;
|
||||
@@ -79,14 +81,14 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
|
||||
|
||||
// Login Success
|
||||
registerClientbound(State.LOGIN, 0x02, 0x02, wrapper -> {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), wrapper -> {
|
||||
// Transform string to a uuid
|
||||
UUID uuid = UUID.fromString(wrapper.read(Type.STRING));
|
||||
wrapper.write(Type.UUID, uuid);
|
||||
});
|
||||
|
||||
// Motd Status - line breaks are no longer allowed for player samples
|
||||
registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> {
|
||||
registerClientbound(State.STATUS, ClientboundStatusPackets.STATUS_RESPONSE.getId(), ClientboundStatusPackets.STATUS_RESPONSE.getId(), wrapper -> {
|
||||
String original = wrapper.passthrough(Type.STRING);
|
||||
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
|
||||
JsonObject players = object.getAsJsonObject("players");
|
||||
@@ -212,8 +214,6 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
int[] wallPostOverrideTag = new int[47];
|
||||
int arrayIndex = 0;
|
||||
wallPostOverrideTag[arrayIndex++] = 140;
|
||||
@@ -263,6 +263,8 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.ITEM1_13_2);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -188,8 +188,6 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:candles", "minecraft:ignored_by_piglin_babies", "minecraft:piglin_food", "minecraft:freeze_immune_wearables",
|
||||
"minecraft:axolotl_tempt_items", "minecraft:occludes_vibration_signals", "minecraft:fox_food",
|
||||
"minecraft:diamond_ores", "minecraft:iron_ores", "minecraft:lapis_ores", "minecraft:redstone_ores",
|
||||
@@ -211,6 +209,8 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.ITEM1_13_2)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -85,7 +85,6 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
Types1_18.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
@@ -94,6 +93,8 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.ITEM1_13_2)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -342,7 +342,6 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
Types1_19_3.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
@@ -354,6 +353,8 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);
|
||||
EntityTypes1_19_3.initialize(this);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -93,7 +93,6 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
EntityTypes1_19_4.initialize(this);
|
||||
Types1_19_4.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
@@ -105,6 +104,8 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION1_19)
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -289,7 +289,6 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
Types1_19.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
@@ -301,6 +300,8 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);
|
||||
EntityTypes1_19.initialize(this);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -345,7 +345,6 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
EntityTypes1_20_3.initialize(this);
|
||||
Types1_20_3.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
@@ -357,6 +356,8 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION1_20_3)
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -243,8 +243,6 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
|
||||
EntityTypes1_20_5.initialize(this);
|
||||
Types1_20_5.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
@@ -280,6 +278,8 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
|
||||
.add(StructuredDataKey.ITEM_NAME).add(StructuredDataKey.OMINOUS_BOTTLE_AMPLIFIER);
|
||||
|
||||
tagRewriter.addTag(RegistryType.ITEM, "minecraft:dyeable", 853, 854, 855, 856, 1120);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class BannerPatterns1_20_5 {
|
||||
|
||||
private static final KeyMappings PATTERNS = new KeyMappings(
|
||||
public static final KeyMappings PATTERNS = new KeyMappings(
|
||||
"base",
|
||||
"square_bottom_left",
|
||||
"square_bottom_right",
|
||||
|
||||
+17
-5
@@ -94,6 +94,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMater
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage.BannerPatternStorage;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
@@ -352,10 +353,10 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
if (item == null) return null;
|
||||
|
||||
super.handleItemToServer(connection, item);
|
||||
return toOldItem(item, DATA_CONVERTER);
|
||||
return toOldItem(connection, item, DATA_CONVERTER);
|
||||
}
|
||||
|
||||
public Item toOldItem(final Item item, final StructuredDataConverter dataConverter) {
|
||||
public Item toOldItem(final UserConnection connection, final Item item, final StructuredDataConverter dataConverter) {
|
||||
// Start out with custom data and add the rest on top, or short-curcuit with the original item
|
||||
final StructuredDataContainer data = item.structuredData();
|
||||
data.setIdLookup(protocol, true);
|
||||
@@ -368,7 +369,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
|
||||
for (final StructuredData<?> structuredData : data.data().values()) {
|
||||
dataConverter.writeToTag(structuredData, tag);
|
||||
dataConverter.writeToTag(connection, structuredData, tag);
|
||||
}
|
||||
|
||||
return dataItem;
|
||||
@@ -1339,6 +1340,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
}
|
||||
|
||||
private void addBlockEntityId(final CompoundTag tag, final String id) {
|
||||
if (!tag.contains("id")) {
|
||||
tag.putString("id", id);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBlockEntityTag(final UserConnection connection, @Nullable final StructuredDataContainer data, final CompoundTag tag) {
|
||||
if (tag == null) {
|
||||
return;
|
||||
@@ -1353,6 +1360,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
final ListTag<CompoundTag> beesTag = tag.getListTag("Bees", CompoundTag.class);
|
||||
if (beesTag != null) {
|
||||
updateBees(data, beesTag);
|
||||
addBlockEntityId(tag, "beehive");
|
||||
}
|
||||
|
||||
final ListTag<StringTag> sherdsTag = tag.getListTag("sherds", StringTag.class);
|
||||
@@ -1368,11 +1376,13 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
toMappedItemId(rightSherd),
|
||||
toMappedItemId(frontSherd)
|
||||
));
|
||||
addBlockEntityId(tag, "decorated_pot");
|
||||
}
|
||||
|
||||
final StringTag noteBlockSoundTag = tag.getStringTag("note_block_sound");
|
||||
if (noteBlockSoundTag != null) {
|
||||
data.set(StructuredDataKey.NOTE_BLOCK_SOUND, noteBlockSoundTag.getValue());
|
||||
addBlockEntityId(tag, "player_head");
|
||||
}
|
||||
|
||||
final StringTag lootTableTag = tag.getStringTag("LootTable");
|
||||
@@ -1404,6 +1414,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
|
||||
final ListTag<CompoundTag> patternsTag = tag.getListTag("Patterns", CompoundTag.class);
|
||||
if (patternsTag != null) {
|
||||
final BannerPatternStorage patternStorage = connection.get(BannerPatternStorage.class);
|
||||
final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> {
|
||||
final String pattern = patternTag.getString("Pattern", "");
|
||||
final int color = patternTag.getInt("Color", -1);
|
||||
@@ -1417,11 +1428,12 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
patternTag.putString("pattern", fullPatternIdentifier);
|
||||
patternTag.putString("color", DyeColors.colorById(color));
|
||||
|
||||
final int id = BannerPatterns1_20_5.keyToId(fullPatternIdentifier);
|
||||
return new BannerPatternLayer(Holder.of(id), color);
|
||||
final int id = patternStorage != null ? patternStorage.bannerPatterns().keyToId(fullPatternIdentifier) : BannerPatterns1_20_5.keyToId(fullPatternIdentifier);
|
||||
return id != -1 ? new BannerPatternLayer(Holder.of(id), color) : null;
|
||||
}).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new);
|
||||
tag.remove("Patterns");
|
||||
tag.put("patterns", patternsTag);
|
||||
addBlockEntityId(tag, "banner");
|
||||
|
||||
if (data != null) {
|
||||
data.set(StructuredDataKey.BANNER_PATTERNS, layers);
|
||||
|
||||
+30
-3
@@ -386,6 +386,10 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
}
|
||||
}
|
||||
|
||||
private int withAlpha(final int rgb) {
|
||||
return 255 << 24 | rgb & 0xffffff;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
filter().mapMetaType(typeId -> {
|
||||
@@ -422,8 +426,14 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
|
||||
filter().type(EntityTypes1_20_5.LIVINGENTITY).index(10).handler((event, meta) -> {
|
||||
final int effectColor = meta.value();
|
||||
if (effectColor == 0) {
|
||||
// No effect
|
||||
meta.setTypeAndValue(Types1_20_5.META_TYPES.particlesType, new Particle[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
final Particle particle = new Particle(protocol.getMappingData().getParticleMappings().mappedId("entity_effect"));
|
||||
particle.add(Type.INT, effectColor);
|
||||
particle.add(Type.INT, withAlpha(effectColor));
|
||||
meta.setTypeAndValue(Types1_20_5.META_TYPES.particlesType, new Particle[]{particle});
|
||||
});
|
||||
|
||||
@@ -434,7 +444,17 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
if (metaIndex == 9) {
|
||||
// If the color is found first
|
||||
final Metadata particleData = event.metaAtIndex(11);
|
||||
addColor(particleData, meta.value());
|
||||
final int color = meta.value();
|
||||
if (particleData == null) {
|
||||
if (color != 0) {
|
||||
// Add default particle with data
|
||||
final Particle particle = new Particle(protocol.getMappingData().getParticleMappings().mappedId("entity_effect"));
|
||||
particle.add(Type.INT, withAlpha(color));
|
||||
event.createExtraMeta(new Metadata(10, Types1_20_5.META_TYPES.particleType, particle));
|
||||
}
|
||||
} else {
|
||||
addColor(particleData, color);
|
||||
}
|
||||
|
||||
event.cancel();
|
||||
return;
|
||||
@@ -453,6 +473,13 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_20_5.ARROW).index(10).handler((event, meta) -> {
|
||||
final int color = meta.value();
|
||||
if (color != -1) {
|
||||
meta.setValue(withAlpha(color));
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
|
||||
final int blockState = meta.value();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
|
||||
@@ -466,7 +493,7 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
|
||||
|
||||
final Particle particle = particleMeta.value();
|
||||
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
|
||||
particle.getArgument(0).setValue(color);
|
||||
particle.getArgument(0).setValue(withAlpha(color));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+49
-17
@@ -25,6 +25,7 @@ import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.GameProfile;
|
||||
import com.viaversion.viaversion.api.minecraft.HolderSet;
|
||||
import com.viaversion.viaversion.api.minecraft.SoundEvent;
|
||||
@@ -60,6 +61,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecora
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.PotionEffects1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Potions1_20_5;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMaterials1_20_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage.BannerPatternStorage;
|
||||
import com.viaversion.viaversion.util.ComponentUtil;
|
||||
import com.viaversion.viaversion.util.UUIDUtil;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
@@ -215,8 +217,8 @@ public final class StructuredDataConverter {
|
||||
}
|
||||
});
|
||||
register(StructuredDataKey.BASE_COLOR, (data, tag) -> tag.putInt("Base", data));
|
||||
register(StructuredDataKey.CHARGED_PROJECTILES, (data, tag) -> convertItemList(data, tag, "ChargedProjectiles"));
|
||||
register(StructuredDataKey.BUNDLE_CONTENTS, (data, tag) -> convertItemList(data, tag, "Items"));
|
||||
register(StructuredDataKey.CHARGED_PROJECTILES, (connection, data, tag) -> convertItemList(connection, data, tag, "ChargedProjectiles"));
|
||||
register(StructuredDataKey.BUNDLE_CONTENTS, (connection, data, tag) -> convertItemList(connection, data, tag, "Items"));
|
||||
register(StructuredDataKey.LODESTONE_TRACKER, (data, tag) -> {
|
||||
final CompoundTag positionTag = new CompoundTag();
|
||||
tag.put("LodestonePos", positionTag);
|
||||
@@ -264,6 +266,7 @@ public final class StructuredDataConverter {
|
||||
values.add(propertyTag);
|
||||
propertiesTag.put(property.name(), values);
|
||||
}
|
||||
profileTag.put("Properties", propertiesTag);
|
||||
});
|
||||
register(StructuredDataKey.INSTRUMENT, (data, tag) -> {
|
||||
// Can't do anything with direct values
|
||||
@@ -303,10 +306,10 @@ public final class StructuredDataConverter {
|
||||
beeTag.putInt("MinOccupationTicks", bee.minTicksInHive());
|
||||
bees.add(beeTag);
|
||||
}
|
||||
getBlockEntityTag(tag).put("Bees", bees);
|
||||
getBlockEntityTag(tag, "beehive").put("Bees", bees);
|
||||
});
|
||||
register(StructuredDataKey.LOCK, (data, tag) -> getBlockEntityTag(tag).put("Lock", data));
|
||||
register(StructuredDataKey.NOTE_BLOCK_SOUND, (data, tag) -> getBlockEntityTag(tag).putString("note_block_sound", data));
|
||||
register(StructuredDataKey.NOTE_BLOCK_SOUND, (data, tag) -> getBlockEntityTag(tag, "player_head").putString("note_block_sound", data));
|
||||
register(StructuredDataKey.POT_DECORATIONS, (data, tag) -> {
|
||||
IntArrayTag originalSherds = null;
|
||||
|
||||
@@ -326,7 +329,7 @@ public final class StructuredDataConverter {
|
||||
if (originalSherds != null) {
|
||||
getBackupTag(tag).put("pot_decorations", originalSherds);
|
||||
}
|
||||
getBlockEntityTag(tag).put("sherds", sherds);
|
||||
getBlockEntityTag(tag, "decorated_pot").put("sherds", sherds);
|
||||
});
|
||||
register(StructuredDataKey.CREATIVE_SLOT_LOCK, (data, tag) -> tag.put("CustomCreativeLock", new CompoundTag()));
|
||||
register(StructuredDataKey.DEBUG_STICK_STATE, (data, tag) -> tag.put("DebugProperty", data));
|
||||
@@ -341,7 +344,13 @@ public final class StructuredDataConverter {
|
||||
});
|
||||
register(StructuredDataKey.BLOCK_ENTITY_DATA, (data, tag) -> {
|
||||
// Handling of previously block entity tags is done using the getBlockEntityTag method
|
||||
tag.put("BlockEntityTag", data);
|
||||
// Merge with already added tag if needed
|
||||
final CompoundTag blockEntityTag = tag.getCompoundTag("BlockEntityTag");
|
||||
if (blockEntityTag != null) {
|
||||
blockEntityTag.putAll(data);
|
||||
} else {
|
||||
tag.put("BlockEntityTag", data);
|
||||
}
|
||||
});
|
||||
register(StructuredDataKey.CONTAINER_LOOT, (data, tag) -> {
|
||||
final Tag lootTable = data.get("loot_table");
|
||||
@@ -420,7 +429,8 @@ public final class StructuredDataConverter {
|
||||
}
|
||||
tag.put("effects", effectsTag);
|
||||
});
|
||||
register(StructuredDataKey.BANNER_PATTERNS, (data, tag) -> {
|
||||
register(StructuredDataKey.BANNER_PATTERNS, (connection, data, tag) -> {
|
||||
final BannerPatternStorage patternStorage = connection.get(BannerPatternStorage.class);
|
||||
if (backupInconvertibleData) {
|
||||
// Backup whole data if one of the entries is inconvertible
|
||||
// Since we don't want to break the order of the entries
|
||||
@@ -429,7 +439,8 @@ public final class StructuredDataConverter {
|
||||
return true;
|
||||
}
|
||||
|
||||
final String identifier = BannerPatterns1_20_5.idToKey(layer.pattern().id());
|
||||
final int id = layer.pattern().id();
|
||||
final String identifier = patternStorage != null ? patternStorage.pattern(id) : BannerPatterns1_20_5.idToKey(id);
|
||||
return identifier == null || identifier.equals("flow") || identifier.equals("guster");
|
||||
})) {
|
||||
final ListTag<CompoundTag> originalPatterns = new ListTag<>(CompoundTag.class);
|
||||
@@ -458,7 +469,8 @@ public final class StructuredDataConverter {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String key = BannerPatterns1_20_5.idToKey(layer.pattern().id());
|
||||
final int id = layer.pattern().id();
|
||||
final String key = patternStorage != null ? patternStorage.pattern(id) : BannerPatterns1_20_5.idToKey(id);
|
||||
if (key == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -473,9 +485,9 @@ public final class StructuredDataConverter {
|
||||
patternTag.putInt("Color", layer.dyeColor());
|
||||
patternsTag.add(patternTag);
|
||||
}
|
||||
tag.put("Patterns", patternsTag);
|
||||
getBlockEntityTag(tag, "banner").put("Patterns", patternsTag);
|
||||
});
|
||||
register(StructuredDataKey.CONTAINER, (data, tag) -> convertItemList(data, tag, "Items"));
|
||||
register(StructuredDataKey.CONTAINER, (connection, data, tag) -> convertItemList(connection, data, tag, "Items"));
|
||||
register(StructuredDataKey.CAN_PLACE_ON, (data, tag) -> convertBlockPredicates(tag, data, "CanPlaceOn", HIDE_CAN_PLACE_ON));
|
||||
register(StructuredDataKey.CAN_BREAK, (data, tag) -> convertBlockPredicates(tag, data, "CanDestroy", HIDE_CAN_DESTROY));
|
||||
register(StructuredDataKey.MAP_POST_PROCESSING, (data, tag) -> {
|
||||
@@ -653,6 +665,15 @@ public final class StructuredDataConverter {
|
||||
return getOrCreate(tag, "BlockEntityTag");
|
||||
}
|
||||
|
||||
private CompoundTag getBlockEntityTag(final CompoundTag tag, final String blockEntity) {
|
||||
final CompoundTag blockEntityTag = getOrCreate(tag, "BlockEntityTag");
|
||||
if (!blockEntityTag.contains("id")) {
|
||||
// Add in the assumed (and required) block entity id
|
||||
blockEntityTag.putString("id", blockEntity);
|
||||
}
|
||||
return blockEntityTag;
|
||||
}
|
||||
|
||||
private static CompoundTag getDisplayTag(final CompoundTag tag) {
|
||||
return getOrCreate(tag, "display");
|
||||
}
|
||||
@@ -671,7 +692,7 @@ public final class StructuredDataConverter {
|
||||
return subTag;
|
||||
}
|
||||
|
||||
static @Nullable CompoundTag removeBackupTag(final CompoundTag tag) {
|
||||
public static @Nullable CompoundTag removeBackupTag(final CompoundTag tag) {
|
||||
final CompoundTag backupTag = tag.getCompoundTag(BACKUP_TAG_KEY);
|
||||
if (backupTag != null) {
|
||||
tag.remove(BACKUP_TAG_KEY);
|
||||
@@ -767,7 +788,7 @@ public final class StructuredDataConverter {
|
||||
return effectDataTag;
|
||||
}
|
||||
|
||||
private void convertItemList(final Item[] items, final CompoundTag tag, final String key) {
|
||||
private void convertItemList(final UserConnection connection, final Item[] items, final CompoundTag tag, final String key) {
|
||||
final ListTag<CompoundTag> itemsTag = new ListTag<>(CompoundTag.class);
|
||||
for (final Item item : items) {
|
||||
final CompoundTag savedItem = new CompoundTag();
|
||||
@@ -781,7 +802,7 @@ public final class StructuredDataConverter {
|
||||
|
||||
final CompoundTag itemTag = new CompoundTag();
|
||||
for (final StructuredData<?> data : item.structuredData().data().values()) {
|
||||
writeToTag(data, itemTag);
|
||||
writeToTag(connection, data, itemTag);
|
||||
}
|
||||
savedItem.put("tag", itemTag);
|
||||
} else {
|
||||
@@ -826,7 +847,7 @@ public final class StructuredDataConverter {
|
||||
tag.putInt("HideFlags", tag.getInt("HideFlags") | value);
|
||||
}
|
||||
|
||||
public <T> void writeToTag(final StructuredData<T> data, final CompoundTag tag) {
|
||||
public <T> void writeToTag(final UserConnection connection, final StructuredData<T> data, final CompoundTag tag) {
|
||||
if (data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -834,16 +855,27 @@ public final class StructuredDataConverter {
|
||||
//noinspection unchecked
|
||||
final DataConverter<T> converter = (DataConverter<T>) rewriters.get(data.key());
|
||||
Preconditions.checkNotNull(converter, "No converter for %s found", data.key());
|
||||
converter.convert(data.value(), tag);
|
||||
converter.convert(connection, data.value(), tag);
|
||||
}
|
||||
|
||||
private <T> void register(final StructuredDataKey<T> key, final DataConverter<T> converter) {
|
||||
rewriters.put(key, converter);
|
||||
}
|
||||
|
||||
private <T> void register(final StructuredDataKey<T> key, final SimpleDataConverter<T> converter) {
|
||||
final DataConverter<T> c = (connection, data, tag) -> converter.convert(data, tag);
|
||||
rewriters.put(key, c);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface DataConverter<T> {
|
||||
interface SimpleDataConverter<T> {
|
||||
|
||||
void convert(T data, CompoundTag tag);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface DataConverter<T> {
|
||||
|
||||
void convert(UserConnection connection, T data, CompoundTag tag);
|
||||
}
|
||||
}
|
||||
+19
-6
@@ -18,16 +18,29 @@
|
||||
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
|
||||
import com.viaversion.viaversion.util.KeyMappings;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
//TODO Item rewriting doesn't have user connection context yet. That's a fairly disruptive change, so it'll be done later
|
||||
// Replace BannerPatterns1_20_5.idToKey
|
||||
// Used by VB
|
||||
public final class BannerPatternStorage implements StorableObject {
|
||||
|
||||
private final Int2ObjectMap<String> bannerPatterns = new Int2ObjectOpenHashMap<>();
|
||||
private KeyMappings bannerPatterns = BannerPatterns1_20_5.PATTERNS;
|
||||
|
||||
public Int2ObjectMap<String> bannerPatterns() {
|
||||
public KeyMappings bannerPatterns() {
|
||||
return bannerPatterns;
|
||||
}
|
||||
|
||||
public void setBannerPatterns(final KeyMappings bannerPatterns) {
|
||||
this.bannerPatterns = bannerPatterns;
|
||||
}
|
||||
|
||||
public @Nullable String pattern(final int id) {
|
||||
return bannerPatterns.idToKey(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearOnServerSwitch() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -69,7 +69,6 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded();
|
||||
Types1_20.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
@@ -80,6 +79,8 @@ public final class Protocol1_20To1_19_4 extends AbstractProtocol<ClientboundPack
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION1_19)
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);
|
||||
|
||||
super.onMappingDataLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.base.ClientboundLoginPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||
@@ -86,7 +87,7 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
||||
protected void registerPackets() {
|
||||
super.registerPackets();
|
||||
|
||||
registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), ClientboundLoginPackets.LOGIN_DISCONNECT.getId(), wrapper -> {
|
||||
if (wrapper.isReadable(Type.COMPONENT, 0)) {
|
||||
// Already written as component in the base protocol
|
||||
return;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||
projectVersion=4.10.1
|
||||
projectVersion=4.10.2
|
||||
|
||||
# Smile emoji
|
||||
mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9
|
||||
|
||||
+2
-2
@@ -85,8 +85,6 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
|
||||
@Override
|
||||
protected void onMappingDataLoaded() {
|
||||
super.onMappingDataLoaded(); // Calls load methods on rewriters
|
||||
|
||||
// Uncomment this if the entity types enum has been newly added specifically for this Protocol
|
||||
// EntityTypes1_20_5.initialize(this);
|
||||
|
||||
@@ -101,6 +99,8 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION1_20_3)
|
||||
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
|
||||
.reader("shriek", ParticleType.Readers.SHRIEK);*/
|
||||
|
||||
super.onMappingDataLoaded(); // Calls load methods on rewriters. Last in case the rewriters access the above filled data
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user