Skip to content

Commit f52a557

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents df0e2b7 + 037410d commit f52a557

File tree

114 files changed

+3055
-1193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3055
-1193
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
github: kennytv
22
patreon: kennytv
3+
custom: ['https://florianmichael.de/donate']

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ Supported Versions:
2020

2121
**User Docs:** https://docs.viaversion.com/display/VIAVERSION/
2222

23+
Snapshot support
24+
--------
25+
**ViaVersion will only be released a few days *after* a Minecraft update** unless the protocol changes of the update were trivial. If you want early-access, usually days or even weeks before the final release, you can subscribe to either:
26+
- [GitHub Sponsors](https://github.com/sponsors/kennytv/sponsorships?sponsor=kennytv&tier_id=385613&preview=false) (preferred option. Use the `/verify` command on this Discord after), or alternatively
27+
- [Patreon](https://www.patreon.com/kennytv/membership) (see the highest tier and make sure to link Patreon to your Discord account under Settings->Connections)
28+
This also includes access to a private repository with the code, which will be pushed to the public repository after the given delay on a Minecraft update.
29+
2330
Releases/Dev Builds
2431
--------
2532
You can find official releases in the following places:

api/src/main/java/com/viaversion/viaversion/api/configuration/ViaVersionConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,12 @@ public interface ViaVersionConfig extends Config {
478478
* @return true if enabled
479479
*/
480480
boolean fix1_21PlacementRotation();
481+
482+
/**
483+
* If enabled, 1.20.5+ clients will have sword blocking mechanics on 1.8 servers using the consumable item component.
484+
* Note that you won't be able to see the blocking in first person if the client is older than 1.21.4.
485+
*
486+
* @return true if enabled
487+
*/
488+
boolean swordBlockingViaConsumable();
481489
}

api/src/main/java/com/viaversion/viaversion/api/data/FullMappingsBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public String identifier(final int id) {
9595
}
9696

9797
@Override
98-
public String mappedIdentifier(final int mappedId) {
98+
public @Nullable String mappedIdentifier(final int mappedId) {
9999
if (mappedId < 0 || mappedId >= mappedIdToString.length) {
100100
return null;
101101
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/BlockPosition.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public BlockPosition getRelative(BlockFace face) {
3737
return new BlockPosition(x + face.modX(), y + face.modY(), z + face.modZ());
3838
}
3939

40+
public double distanceFromCenterSquared(final double x, final double y, final double z) {
41+
final double dx = this.x + 0.5 - x;
42+
final double dy = this.y + 0.5 - y;
43+
final double dz = this.z + 0.5 - z;
44+
return dx * dx + dy * dy + dz * dz;
45+
}
46+
4047
public int x() {
4148
return x;
4249
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/ChunkPosition.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ public static long chunkKey(final int chunkX, final int chunkZ) {
6666
return (long) chunkX & 0xffffffffL | ((long) chunkZ & 0xffffffffL) << 32;
6767
}
6868

69+
/**
70+
* Returns a long key for the given block coordinates.
71+
*
72+
* @param x the block X coordinate
73+
* @param z the block Z coordinate
74+
* @return the chunk key
75+
*/
76+
public static long chunkKeyForBlock(final int x, final int z) {
77+
return chunkKey(x >> 4, z >> 4);
78+
}
79+
6980
@Override
7081
public boolean equals(final Object o) {
7182
if (this == o) return true;

api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import com.viaversion.viaversion.api.minecraft.item.data.Bee;
3737
import com.viaversion.viaversion.api.minecraft.item.data.BlockStateProperties;
3838
import com.viaversion.viaversion.api.minecraft.item.data.Consumable1_21_2;
39+
import com.viaversion.viaversion.api.minecraft.item.data.CustomModelData1_21_4;
3940
import com.viaversion.viaversion.api.minecraft.item.data.DamageResistant;
4041
import com.viaversion.viaversion.api.minecraft.item.data.DeathProtection;
4142
import com.viaversion.viaversion.api.minecraft.item.data.DyedColor;
@@ -59,9 +60,11 @@
5960
import com.viaversion.viaversion.api.minecraft.item.data.WrittenBook;
6061
import com.viaversion.viaversion.api.type.Type;
6162
import com.viaversion.viaversion.api.type.Types;
63+
import com.viaversion.viaversion.api.type.types.ArrayType;
6264
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
6365
import com.viaversion.viaversion.api.type.types.version.Types1_21;
6466
import com.viaversion.viaversion.api.type.types.version.Types1_21_2;
67+
import com.viaversion.viaversion.api.type.types.version.Types1_21_4;
6568
import com.viaversion.viaversion.util.Unit;
6669

6770
public record StructuredDataKey<T>(String identifier, Type<T> type) {
@@ -74,14 +77,15 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
7477
public static final StructuredDataKey<Tag> CUSTOM_NAME = new StructuredDataKey<>("custom_name", Types.TAG);
7578
public static final StructuredDataKey<Tag> ITEM_NAME = new StructuredDataKey<>("item_name", Types.TAG);
7679
public static final StructuredDataKey<String> ITEM_MODEL = new StructuredDataKey<>("item_model", Types.STRING);
77-
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", Types.TAG_ARRAY);
80+
public static final StructuredDataKey<Tag[]> LORE = new StructuredDataKey<>("lore", new ArrayType<>(Types.TAG, 256));
7881
public static final StructuredDataKey<Integer> RARITY = new StructuredDataKey<>("rarity", Types.VAR_INT);
7982
public static final StructuredDataKey<Enchantments> ENCHANTMENTS = new StructuredDataKey<>("enchantments", Enchantments.TYPE);
8083
public static final StructuredDataKey<AdventureModePredicate> CAN_PLACE_ON = new StructuredDataKey<>("can_place_on", AdventureModePredicate.TYPE);
8184
public static final StructuredDataKey<AdventureModePredicate> CAN_BREAK = new StructuredDataKey<>("can_break", AdventureModePredicate.TYPE);
8285
public static final StructuredDataKey<AttributeModifiers1_20_5> ATTRIBUTE_MODIFIERS1_20_5 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_20_5.TYPE);
8386
public static final StructuredDataKey<AttributeModifiers1_21> ATTRIBUTE_MODIFIERS1_21 = new StructuredDataKey<>("attribute_modifiers", AttributeModifiers1_21.TYPE);
84-
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
87+
public static final StructuredDataKey<Integer> CUSTOM_MODEL_DATA1_20_5 = new StructuredDataKey<>("custom_model_data", Types.VAR_INT);
88+
public static final StructuredDataKey<CustomModelData1_21_4> CUSTOM_MODEL_DATA1_21_4 = new StructuredDataKey<>("custom_model_data", CustomModelData1_21_4.TYPE);
8589
public static final StructuredDataKey<Unit> HIDE_ADDITIONAL_TOOLTIP = new StructuredDataKey<>("hide_additional_tooltip", Types.EMPTY);
8690
public static final StructuredDataKey<Unit> HIDE_TOOLTIP = new StructuredDataKey<>("hide_tooltip", Types.EMPTY);
8791
public static final StructuredDataKey<Integer> REPAIR_COST = new StructuredDataKey<>("repair_cost", Types.VAR_INT);
@@ -92,7 +96,8 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
9296
public static final StructuredDataKey<FoodProperties1_20_5> FOOD1_21 = new StructuredDataKey<>("food", FoodProperties1_20_5.TYPE1_21);
9397
public static final StructuredDataKey<FoodProperties1_21_2> FOOD1_21_2 = new StructuredDataKey<>("food", FoodProperties1_21_2.TYPE);
9498
public static final StructuredDataKey<Consumable1_21_2> CONSUMABLE1_21_2 = new StructuredDataKey<>("consumable", Consumable1_21_2.TYPE);
95-
public static final StructuredDataKey<Item> USE_REMAINDER = new StructuredDataKey<>("use_remainder", Types1_21_2.ITEM);
99+
public static final StructuredDataKey<Item> USE_REMAINDER1_21_2 = new StructuredDataKey<>("use_remainder", Types1_21_2.ITEM);
100+
public static final StructuredDataKey<Item> USE_REMAINDER1_21_4 = new StructuredDataKey<>("use_remainder", Types1_21_4.ITEM);
96101
public static final StructuredDataKey<UseCooldown> USE_COOLDOWN = new StructuredDataKey<>("use_cooldown", UseCooldown.TYPE);
97102
public static final StructuredDataKey<Unit> FIRE_RESISTANT = new StructuredDataKey<>("fire_resistant", Types.EMPTY);
98103
public static final StructuredDataKey<DamageResistant> DAMAGE_RESISTANT = new StructuredDataKey<>("damage_resistant", DamageResistant.TYPE);
@@ -112,15 +117,19 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
112117
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_20_5 = new StructuredDataKey<>("charged_projectiles", Types1_20_5.ITEM_ARRAY);
113118
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21 = new StructuredDataKey<>("charged_projectiles", Types1_21.ITEM_ARRAY);
114119
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_2 = new StructuredDataKey<>("charged_projectiles", Types1_21_2.ITEM_ARRAY);
120+
public static final StructuredDataKey<Item[]> CHARGED_PROJECTILES1_21_4 = new StructuredDataKey<>("charged_projectiles", Types1_21_4.ITEM_ARRAY);
115121
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_20_5 = new StructuredDataKey<>("bundle_contents", Types1_20_5.ITEM_ARRAY);
116122
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21 = new StructuredDataKey<>("bundle_contents", Types1_21.ITEM_ARRAY);
117123
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_2 = new StructuredDataKey<>("bundle_contents", Types1_21_2.ITEM_ARRAY);
124+
public static final StructuredDataKey<Item[]> BUNDLE_CONTENTS1_21_4 = new StructuredDataKey<>("bundle_contents", Types1_21_4.ITEM_ARRAY);
118125
public static final StructuredDataKey<PotionContents> POTION_CONTENTS1_20_5 = new StructuredDataKey<>("potion_contents", PotionContents.TYPE1_20_5);
119126
public static final StructuredDataKey<PotionContents> POTION_CONTENTS1_21_2 = new StructuredDataKey<>("potion_contents", PotionContents.TYPE1_21_2);
120127
public static final StructuredDataKey<SuspiciousStewEffect[]> SUSPICIOUS_STEW_EFFECTS = new StructuredDataKey<>("suspicious_stew_effects", SuspiciousStewEffect.ARRAY_TYPE);
121128
public static final StructuredDataKey<FilterableString[]> WRITABLE_BOOK_CONTENT = new StructuredDataKey<>("writable_book_content", FilterableString.ARRAY_TYPE);
122129
public static final StructuredDataKey<WrittenBook> WRITTEN_BOOK_CONTENT = new StructuredDataKey<>("written_book_content", WrittenBook.TYPE);
123-
public static final StructuredDataKey<ArmorTrim> TRIM = new StructuredDataKey<>("trim", ArmorTrim.TYPE);
130+
public static final StructuredDataKey<ArmorTrim> TRIM1_20_5 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_20_5);
131+
public static final StructuredDataKey<ArmorTrim> TRIM1_21_2 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_2);
132+
public static final StructuredDataKey<ArmorTrim> TRIM1_21_4 = new StructuredDataKey<>("trim", ArmorTrim.TYPE1_21_4);
124133
public static final StructuredDataKey<CompoundTag> DEBUG_STICK_STATE = new StructuredDataKey<>("debug_stick_state", Types.COMPOUND_TAG);
125134
public static final StructuredDataKey<CompoundTag> ENTITY_DATA = new StructuredDataKey<>("entity_data", Types.COMPOUND_TAG);
126135
public static final StructuredDataKey<CompoundTag> BUCKET_ENTITY_DATA = new StructuredDataKey<>("bucket_entity_data", Types.COMPOUND_TAG);
@@ -140,7 +149,8 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
140149
public static final StructuredDataKey<PotDecorations> POT_DECORATIONS = new StructuredDataKey<>("pot_decorations", PotDecorations.TYPE);
141150
public static final StructuredDataKey<Item[]> CONTAINER1_20_5 = new StructuredDataKey<>("container", Types1_20_5.ITEM_ARRAY);
142151
public static final StructuredDataKey<Item[]> CONTAINER1_21 = new StructuredDataKey<>("container", Types1_21.ITEM_ARRAY);
143-
public static final StructuredDataKey<Item[]> CONTAINER1_21_2 = new StructuredDataKey<>("container", Types1_21_2.ITEM_ARRAY);
152+
public static final StructuredDataKey<Item[]> CONTAINER1_21_2 = new StructuredDataKey<>("container", new ArrayType<>(Types1_21_2.ITEM, 256));
153+
public static final StructuredDataKey<Item[]> CONTAINER1_21_4 = new StructuredDataKey<>("container", Types1_21_4.ITEM_ARRAY);
144154
public static final StructuredDataKey<BlockStateProperties> BLOCK_STATE = new StructuredDataKey<>("block_state", BlockStateProperties.TYPE);
145155
public static final StructuredDataKey<Bee[]> BEES = new StructuredDataKey<>("bees", Bee.ARRAY_TYPE);
146156
public static final StructuredDataKey<Tag> LOCK = new StructuredDataKey<>("lock", Types.TAG);

0 commit comments

Comments
 (0)