Make static-only classes final and unconstructible ()

The following classes have been made final and unconstructible:

- All convention tags classes
- `FluidVariantAttributes`
- `FluidVariantRendering`

The following classes have been made unconstructible:

- `BiomeModifications`
- `ClientEntityEvents`
- `ClientTickEvents`
- `LootTableEvents`
- `FabricDefaultAttributeRegistry`
- `MinecartComparatorLogicRegistry`
- `StorageUtil`

The following classes have been explicitly marked as final. Note that actually extending such class has always been impossible due to missing public constructor:

- `VillagerInteractionRegistries`
- `VillagerPlantableRegistry`
- `ModelHelper`
- `StoragePreconditions`

While the first two are technically breaking changes, there is no actual or observed usage for any of those.
This commit is contained in:
apple502j 2022-08-07 03:04:11 +09:00 committed by GitHub
parent e6ea5984c7
commit 83a865928d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 53 additions and 14 deletions
fabric-biome-api-v1/src/main/java/net/fabricmc/fabric/api/biome/v1
fabric-content-registries-v0/src/main/java/net/fabricmc/fabric/api/registry
fabric-convention-tags-v1/src/main/java/net/fabricmc/fabric/api/tag/convention/v1
fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/api/client/event/lifecycle/v1
fabric-loot-api-v2/src/main/java/net/fabricmc/fabric/api/loot/v2
fabric-object-builder-api-v1/src/main/java/net/fabricmc/fabric/api/object/builder/v1/entity
fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/model
fabric-transfer-api-v1/src
client/java/net/fabricmc/fabric/api/transfer/v1/client/fluid
main/java/net/fabricmc/fabric/api/transfer/v1

View file

@ -39,6 +39,9 @@ import net.minecraft.world.gen.feature.PlacedFeature;
* <p><b>Experimental feature</b>, may be removed or changed without further notice.
*/
public final class BiomeModifications {
private BiomeModifications() {
}
/**
* Convenience method to add a feature to one or more biomes.
*

View file

@ -40,7 +40,7 @@ import net.fabricmc.fabric.mixin.content.registry.GiveGiftsToHeroTaskAccessor;
* villagers have with the world.
* @see VillagerPlantableRegistry for registering plants that farmers can plant
*/
public class VillagerInteractionRegistries {
public final class VillagerInteractionRegistries {
private static final Logger LOGGER = LoggerFactory.getLogger(VillagerInteractionRegistries.class);
private VillagerInteractionRegistries() {

View file

@ -35,7 +35,7 @@ import net.minecraft.util.registry.Registry;
/**
* Registry of items that farmer villagers can plant on farmland.
*/
public class VillagerPlantableRegistry {
public final class VillagerPlantableRegistry {
private static final Logger LOGGER = LoggerFactory.getLogger(VillagerPlantableRegistry.class);
private static final HashMap<Item, BlockState> PLANTABLES = new HashMap<>();
static {

View file

@ -27,7 +27,10 @@ import net.fabricmc.fabric.impl.tag.convention.TagRegistration;
* and as such certain biome tags exist to mirror vanilla tags, and should be preferred
* over vanilla unless its behavior is desired.
*/
public class ConventionalBiomeTags {
public final class ConventionalBiomeTags {
private ConventionalBiomeTags() {
}
/**
* Biomes that spawn in the Overworld.
*/

View file

@ -26,7 +26,10 @@ import net.fabricmc.fabric.impl.tag.convention.TagRegistration;
* See {@link net.minecraft.tag.BlockTags} for vanilla tags.
* Note that addition to some vanilla tags implies having certain functionality.
*/
public class ConventionalBlockTags {
public final class ConventionalBlockTags {
private ConventionalBlockTags() {
}
public static final TagKey<Block> QUARTZ_ORES = register("quartz_ores");
public static final TagKey<Block> ORES = register("ores");
public static final TagKey<Block> CHESTS = register("chests");

View file

@ -21,7 +21,10 @@ import net.minecraft.tag.TagKey;
import net.fabricmc.fabric.impl.tag.convention.TagRegistration;
public class ConventionalEnchantmentTags {
public final class ConventionalEnchantmentTags {
private ConventionalEnchantmentTags() {
}
/**
* A tag containing enchantments that increase the amount or
* quality of drops from blocks, such as {@link net.minecraft.enchantment.Enchantments#FORTUNE}.

View file

@ -25,7 +25,10 @@ import net.fabricmc.fabric.impl.tag.convention.TagRegistration;
* See {@link net.minecraft.tag.EntityTypeTags} for vanilla tags.
* Note that addition to some vanilla tags implies having certain functionality.
*/
public class ConventionalEntityTypeTags {
public final class ConventionalEntityTypeTags {
private ConventionalEntityTypeTags() {
}
/**
* Tag containing entity types that display a boss health bar.
*/

View file

@ -25,7 +25,10 @@ import net.fabricmc.fabric.impl.tag.convention.TagRegistration;
* See {@link net.minecraft.tag.FluidTags} for vanilla tags.
* Note that addition to some vanilla tags implies having certain functionality.
*/
public class ConventionalFluidTags {
public final class ConventionalFluidTags {
private ConventionalFluidTags() {
}
public static final TagKey<Fluid> LAVA = register("lava");
public static final TagKey<Fluid> WATER = register("water");
public static final TagKey<Fluid> MILK = register("milk");

View file

@ -25,7 +25,10 @@ import net.fabricmc.fabric.impl.tag.convention.TagRegistration;
* See {@link net.minecraft.tag.ItemTags} for vanilla tags.
* Note that addition to some vanilla tags implies having certain functionality.
*/
public class ConventionalItemTags {
public final class ConventionalItemTags {
private ConventionalItemTags() {
}
// Tool tags
public static final TagKey<Item> PICKAXES = register("pickaxes");
public static final TagKey<Item> SHOVELS = register("shovels");

View file

@ -27,7 +27,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
@Environment(EnvType.CLIENT)
public final class ClientEntityEvents {
public ClientEntityEvents() {
private ClientEntityEvents() {
}
/**

View file

@ -27,7 +27,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
@Environment(EnvType.CLIENT)
public final class ClientTickEvents {
public ClientTickEvents() {
private ClientTickEvents() {
}
/**

View file

@ -30,6 +30,9 @@ import net.fabricmc.fabric.api.event.EventFactory;
* Events for manipulating loot tables.
*/
public final class LootTableEvents {
private LootTableEvents() {
}
/**
* This event can be used to replace loot tables.
* If a loot table is replaced, the iteration will stop for that loot table.

View file

@ -45,6 +45,9 @@ public final class FabricDefaultAttributeRegistry {
*/
private static final Logger LOGGER = LoggerFactory.getLogger(FabricDefaultAttributeRegistry.class);
private FabricDefaultAttributeRegistry() {
}
/**
* Registers a default attribute for a type of living entity.
*

View file

@ -34,6 +34,9 @@ public final class MinecartComparatorLogicRegistry {
private static final Logger LOGGER = LoggerFactory.getLogger(MinecartComparatorLogicRegistry.class);
private static final Map<EntityType<?>, MinecartComparatorLogic<?>> logics = new HashMap<>();
private MinecartComparatorLogicRegistry() {
}
/**
* Gets the registered custom comparator logic for the specified minecart entity type.
*

View file

@ -35,7 +35,7 @@ import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
/**
* Collection of utilities for model implementations.
*/
public abstract class ModelHelper {
public final class ModelHelper {
private ModelHelper() { }
/** Result from {@link #toFaceIndex(Direction)} for null values. */

View file

@ -47,10 +47,13 @@ import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
*/
@ApiStatus.Experimental
@Environment(EnvType.CLIENT)
public class FluidVariantRendering {
public final class FluidVariantRendering {
private static final ApiProviderMap<Fluid, FluidVariantRenderHandler> HANDLERS = ApiProviderMap.create();
private static final FluidVariantRenderHandler DEFAULT_HANDLER = new FluidVariantRenderHandler() { };
private FluidVariantRendering () {
}
/**
* Register a render handler for the passed fluid.
*/

View file

@ -39,10 +39,13 @@ import net.fabricmc.fabric.impl.transfer.TransferApiImpl;
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public class FluidVariantAttributes {
public final class FluidVariantAttributes {
private static final ApiProviderMap<Fluid, FluidVariantAttributeHandler> HANDLERS = ApiProviderMap.create();
private static final FluidVariantAttributeHandler DEFAULT_HANDLER = new FluidVariantAttributeHandler() { };
private FluidVariantAttributes() {
}
/**
* Register an attribute handler for the passed fluid.
*/

View file

@ -28,7 +28,7 @@ import org.jetbrains.annotations.ApiStatus;
* The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
*/
@ApiStatus.Experimental
public class StoragePreconditions {
public final class StoragePreconditions {
/**
* Ensure that the passed transfer variant is not blank.
*

View file

@ -43,6 +43,9 @@ import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
*/
@ApiStatus.Experimental
public final class StorageUtil {
private StorageUtil() {
}
/**
* Move resources between two storages, matching the passed filter, and return the amount that was successfully transferred.
*