Skip to content

Commit bbd8849

Browse files
authored
Merge branch '26.1.2' into 26.1.2
2 parents 7c95451 + edfffd8 commit bbd8849

29 files changed

Lines changed: 497 additions & 33 deletions

File tree

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,36 @@ Fabric API makes strong backwards compatibility guarantees, by which contributor
102102
- Avoid exposing java `record`s as public API.
103103
- Records expose more than is necessary for most APIs, which makes them difficult to evolve.
104104
- Prefer to expose an interface that is implemented by an impl record.
105+
- Avoid creating constant interfaces or creating an interface that is never implemented and intended only to hold `static final` fields.
106+
- Constant interfaces confuse users by suggesting they are intended to be implemented.
107+
- This is a common Java anti-pattern.
108+
- Use a utility class instead.
109+
```java
110+
public final class FooEvents {
111+
public static final Event<Allow> ALLOW = ...;
112+
public static final Event<Before> BEFORE = ...;
113+
public static final Event<After> AFTER = ...;
114+
115+
@FunctionalInterface
116+
public interface Allow {
117+
boolean allowFoo(/* relevant parameters */);
118+
}
119+
120+
@FunctionalInterface
121+
public interface Before {
122+
void beforeFoo(/* relevant parameters */);
123+
}
124+
125+
@FunctionalInterface
126+
public interface Two {
127+
void afterFoo(/* relevant parameters */);
128+
}
129+
130+
// Holder class is not meant for instantiation.
131+
private ExampleEvents() {
132+
}
133+
}
134+
```
105135

106136
### API design patterns to consider
107137

fabric-client-gametest-api-v1/src/client/java/net/fabricmc/fabric/api/client/gametest/v1/context/ClientGameTestContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,5 @@ default Vector2i assertScreenshotContains(String templateImage) {
215215
* @param <E> The type of the checked exception that the function throws
216216
* @throws E When the function throws an exception
217217
*/
218-
<T, E extends Throwable> T computeOnClient(FailableFunction<Minecraft, T, E> function) throws E;
218+
<T extends @Nullable Object, E extends Throwable> T computeOnClient(FailableFunction<Minecraft, T, E> function) throws E;
219219
}

fabric-client-gametest-api-v1/src/client/java/net/fabricmc/fabric/api/client/gametest/v1/context/TestServerContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.commons.lang3.function.FailableConsumer;
2020
import org.apache.commons.lang3.function.FailableFunction;
2121
import org.jetbrains.annotations.ApiStatus;
22+
import org.jspecify.annotations.Nullable;
2223

2324
import net.minecraft.server.MinecraftServer;
2425

@@ -55,5 +56,5 @@ public interface TestServerContext {
5556
* @param <E> The type of the checked exception that the function throws
5657
* @throws E When the function throws an exception
5758
*/
58-
<T, E extends Throwable> T computeOnServer(FailableFunction<MinecraftServer, T, E> function) throws E;
59+
<T extends @Nullable Object, E extends Throwable> T computeOnServer(FailableFunction<MinecraftServer, T, E> function) throws E;
5960
}

fabric-client-gametest-api-v1/src/client/java/net/fabricmc/fabric/impl/client/gametest/world/TestWorldBuilderImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,6 @@ private static void setConsistentSettings(WorldCreationUiState creator) {
142142
creator.getGameRules().set(GameRules.ADVANCE_TIME, false, null);
143143
creator.getGameRules().set(GameRules.ADVANCE_WEATHER, false, null);
144144
creator.getGameRules().set(GameRules.SPAWN_MOBS, false, null);
145+
creator.getGameRules().set(GameRules.RESPAWN_RADIUS, 0, null);
145146
}
146147
}

fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/DatagenEntrypoint.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import net.fabricmc.fabric.impl.tag.convention.datagen.generators.EntityTypeTagsGenerator;
2626
import net.fabricmc.fabric.impl.tag.convention.datagen.generators.FluidTagsGenerator;
2727
import net.fabricmc.fabric.impl.tag.convention.datagen.generators.ItemTagsGenerator;
28+
import net.fabricmc.fabric.impl.tag.convention.datagen.generators.PotionTagsGenerator;
2829
import net.fabricmc.fabric.impl.tag.convention.datagen.generators.StructureTagsGenerator;
2930

3031
public class DatagenEntrypoint implements DataGeneratorEntrypoint {
@@ -36,6 +37,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
3637
pack.addProvider((output, registriesFuture) -> new ItemTagsGenerator(output, registriesFuture, blockTags));
3738
pack.addProvider(FluidTagsGenerator::new);
3839
pack.addProvider(EnchantmentTagsGenerator::new);
40+
pack.addProvider(PotionTagsGenerator::new);
3941
pack.addProvider(BiomeTagsGenerator::new);
4042
pack.addProvider(StructureTagsGenerator::new);
4143
pack.addProvider(EntityTypeTagsGenerator::new);

fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/generators/EnchantmentTagsGenerator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ protected void addTags(HolderLookup.Provider registries) {
5858
.add(Enchantments.FIRE_PROTECTION)
5959
.add(Enchantments.RESPIRATION)
6060
.add(Enchantments.FEATHER_FALLING);
61+
builder(ConventionalEnchantmentTags.HIDDEN_FROM_RECIPE_VIEWERS); // Generate tag so others can see it exists through JSON.
6162
}
6263
}

fabric-convention-tags-v2/src/datagen/java/net/fabricmc/fabric/impl/tag/convention/datagen/generators/EnglishTagLangGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalEntityTypeTags;
2929
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalFluidTags;
3030
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags;
31+
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalPotionTags;
3132
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalStructureTags;
3233

3334
public class EnglishTagLangGenerator extends FabricLanguageProvider {
@@ -437,6 +438,7 @@ public void generateTranslations(HolderLookup.Provider registryLookup, Translati
437438
translationBuilder.add(ConventionalEnchantmentTags.ENTITY_SPEED_ENHANCEMENTS, "Entity Speed Enhancements");
438439
translationBuilder.add(ConventionalEnchantmentTags.ENTITY_AUXILIARY_MOVEMENT_ENHANCEMENTS, "Entity Auxiliary Movement Enhancements");
439440
translationBuilder.add(ConventionalEnchantmentTags.ENTITY_DEFENSE_ENHANCEMENTS, "Entity Defense Enhancements");
441+
translationBuilder.add(ConventionalEnchantmentTags.HIDDEN_FROM_RECIPE_VIEWERS, "Hidden From Recipe Viewers");
440442

441443
// Entity Types
442444
translationBuilder.add(ConventionalEntityTypeTags.BOSSES, "Bosses");
@@ -558,5 +560,8 @@ public void generateTranslations(HolderLookup.Provider registryLookup, Translati
558560
translationBuilder.add(ConventionalBiomeTags.IS_NETHER_FOREST, "Nether Forest");
559561
translationBuilder.add(ConventionalBiomeTags.IS_END, "The End");
560562
translationBuilder.add(ConventionalBiomeTags.IS_OUTER_END_ISLAND, "Outer End Island");
563+
564+
// Potions
565+
translationBuilder.add(ConventionalPotionTags.HIDDEN_FROM_RECIPE_VIEWERS, "Hidden From Recipe Viewers");
561566
}
562567
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package net.fabricmc.fabric.impl.tag.convention.datagen.generators;
18+
19+
import java.util.concurrent.CompletableFuture;
20+
21+
import net.minecraft.core.HolderLookup;
22+
import net.minecraft.core.registries.Registries;
23+
import net.minecraft.world.item.alchemy.Potion;
24+
25+
import net.fabricmc.fabric.api.datagen.v1.FabricPackOutput;
26+
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagsProvider;
27+
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalPotionTags;
28+
29+
public final class PotionTagsGenerator extends FabricTagsProvider<Potion> {
30+
public PotionTagsGenerator(FabricPackOutput output, CompletableFuture<HolderLookup.Provider> registriesFuture) {
31+
super(output, Registries.POTION, registriesFuture);
32+
}
33+
34+
@Override
35+
protected void addTags(HolderLookup.Provider registries) {
36+
builder(ConventionalPotionTags.HIDDEN_FROM_RECIPE_VIEWERS); // Generate tag so others can see it exists through JSON.
37+
}
38+
}

fabric-convention-tags-v2/src/generated/resources/assets/fabric-convention-tags-v2/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"tag.enchantment.c.entity_auxiliary_movement_enhancements": "Entity Auxiliary Movement Enhancements",
129129
"tag.enchantment.c.entity_defense_enhancements": "Entity Defense Enhancements",
130130
"tag.enchantment.c.entity_speed_enhancements": "Entity Speed Enhancements",
131+
"tag.enchantment.c.hidden_from_recipe_viewers": "Hidden From Recipe Viewers",
131132
"tag.enchantment.c.increase_block_drops": "Increases Block Drops",
132133
"tag.enchantment.c.increase_entity_drops": "Increases Entity Drops",
133134
"tag.enchantment.c.weapon_damage_enhancements": "Weapon Damage Enhancements",
@@ -412,6 +413,7 @@
412413
"tag.item.c.tools.trident": "Tridents",
413414
"tag.item.c.tools.wrench": "Wrenches",
414415
"tag.item.c.villager_job_sites": "Villager Job Sites",
416+
"tag.potion.c.hidden_from_recipe_viewers": "Hidden From Recipe Viewers",
415417
"tag.worldgen.biome.c.hidden_from_locator_selection": "Hidden From Locator Selection",
416418
"tag.worldgen.biome.c.is_aquatic": "Aquatic",
417419
"tag.worldgen.biome.c.is_aquatic_icy": "Icy Aquatic",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"values": []
3+
}

0 commit comments

Comments
 (0)