mirror of
https://github.com/FabricMC/fabric
synced 2026-08-19 06:26:07 -04:00
parent
46f4589dce
commit
d642763d9f
15 changed files with 20 additions and 20 deletions
|
|
@ -51,7 +51,7 @@ import net.fabricmc.fabric.impl.lookup.block.BlockApiLookupImpl;
|
|||
*
|
||||
* <pre>{@code
|
||||
* public final class MyApi {
|
||||
* public static final BlockApiLookup<FluidContainer, Direction> FLUID_CONTAINER = BlockApiLookup.get(Identifier.of("mymod", "fluid_container"), FluidContainer.class, Direction.class);
|
||||
* public static final BlockApiLookup<FluidContainer, Direction> FLUID_CONTAINER = BlockApiLookup.get(Identifier.fromNamespaceAndPath("modid", "fluid_container"), FluidContainer.class, Direction.class);
|
||||
* }}</pre>
|
||||
* Using that, we can query instances of {@code FluidContainer}:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import net.fabricmc.fabric.impl.lookup.entity.EntityApiLookupImpl;
|
|||
* <p>We need to create the EntityApiLookup. We don't need any context so we use {@link Void}.
|
||||
* <pre>{@code
|
||||
* public class MyApi {
|
||||
* public static final EntityApiLookup<Leveled, Void> LEVELED_ENTITY = EntityApiLookup.get(Identifier.of("mymod", "leveled_entity"), Leveled.class, Void.class);
|
||||
* public static final EntityApiLookup<Leveled, Void> LEVELED_ENTITY = EntityApiLookup.get(Identifier.fromNamespaceAndPath("modid", "leveled_entity"), Leveled.class, Void.class);
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import net.fabricmc.fabric.impl.lookup.item.ItemApiLookupImpl;
|
|||
*
|
||||
* <pre>{@code
|
||||
* public final class MyApi {
|
||||
* public static final ItemApiLookup<FluidContainer, Void> FLUID_CONTAINER_ITEM = ItemApiLookup.get(Identifier.of("mymod", "fluid_container"), FluidContainer.class, Void.class);
|
||||
* public static final ItemApiLookup<FluidContainer, Void> FLUID_CONTAINER_ITEM = ItemApiLookup.get(Identifier.fromNamespaceAndPath("modid", "fluid_container"), FluidContainer.class, Void.class);
|
||||
* }}</pre>
|
||||
* API instances are easy to access:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public final class EntitySelectorOptionRegistry {
|
|||
* {@code example_min_health} and can be used like {@code @e[example_min_health=5]}.
|
||||
* <pre>{@code
|
||||
* EntitySelectorOptionRegistry.register(
|
||||
* Identifier.of("example", "min_health"),
|
||||
* Identifier.fromNamespaceAndPath("modid", "min_health"),
|
||||
* Text.literal("Minimum entity health"),
|
||||
* (reader) -> {
|
||||
* final float minHealth = reader.getReader().readFloat();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import net.fabricmc.fabric.impl.gamerule.rpc.FabricGameRuleType;
|
|||
* <p>To register a game rule, you can use {@link GameRuleBuilder#buildAndRegister(Identifier)}.
|
||||
* For example, to register a game rule that is an integer where the default value is 1 and the acceptable values are between 0 and 10, one would use the following:
|
||||
* <blockquote><pre>
|
||||
* public static final GameRule<Integer> EXAMPLE_INT_RULE = GameRuleBuilder.forInteger(1).clamped(0, 10).buildAndRegister(Identifier.of(MOD_ID, "example_int_rule"));
|
||||
* public static final GameRule<Integer> EXAMPLE_INT_RULE = GameRuleBuilder.forInteger(1).range(0, 10).buildAndRegister(Identifier.fromNamespaceAndPath("modid", "custom_int_gamerule"));
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* <p>To register a game rule in a custom category, call {@link GameRuleBuilder#category(CustomGameRuleCategory)} on the builder.
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public final class FabricItemGroup {
|
|||
* <p>Example:
|
||||
*
|
||||
* <pre>{@code
|
||||
* private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.of(MOD_ID, "test_group"));
|
||||
* private static final RegistryKey<ItemGroup> ITEM_GROUP = RegistryKey.of(RegistryKeys.ITEM_GROUP, Identifier.fromNamespaceAndPath("modid", "custom_group"));
|
||||
*
|
||||
* @Override
|
||||
* public void onInitialize() {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public final class SimpleUnbakedExtraModel<T> implements UnbakedExtraModel<T> {
|
|||
*
|
||||
* <h2>Example</h2>
|
||||
* {@snippet :
|
||||
* public static final Identifier MODEL_ID = Identifier.of("mod_id", "model_path");
|
||||
* public static final Identifier MODEL_ID = Identifier.fromNamespaceAndPath("modid", "model_path");
|
||||
* public static final ExtraModelKey<BlockStateModel> MODEL_KEY = ExtraModelKey.create(MODEL_ID::toString);
|
||||
*
|
||||
* public static void register() {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public final class FabricDefaultAttributeRegistry {
|
|||
*
|
||||
* <p>It can be used in a fashion similar to this:
|
||||
* <blockquote><pre>
|
||||
* EntityAttributeRegistry.INSTANCE.register(type, LivingEntity.createLivingAttributes());
|
||||
* FabricDefaultAttributeRegistry.register(type, LivingEntity.createLivingAttributes());
|
||||
* </pre></blockquote>
|
||||
* </p>
|
||||
*
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public final class TradeOfferHelper {
|
|||
*
|
||||
* <p>Below is an example, of registering a trade offer factory to be added a blacksmith with a profession level of 3:
|
||||
* <blockquote><pre>
|
||||
* TradeOfferHelper.registerVillagerOffers(VillagerProfession.BLACKSMITH, 3, factories -> {
|
||||
* TradeOfferHelper.registerVillagerOffers(VillagerProfession.WEAPONSMITH, 3, factories -> {
|
||||
* factories.add(new CustomTradeFactory(...);
|
||||
* });
|
||||
* </pre></blockquote>
|
||||
|
|
@ -63,7 +63,7 @@ public final class TradeOfferHelper {
|
|||
*
|
||||
* <p>Below is an example, of registering a trade offer factory to be added a blacksmith with a profession level of 3:
|
||||
* <blockquote><pre>
|
||||
* TradeOfferHelper.registerVillagerOffers(VillagerProfession.BLACKSMITH, 3, (factories, rebalanced) -> {
|
||||
* TradeOfferHelper.registerVillagerOffers(VillagerProfession.WEAPONSMITH, 3, (factories, rebalanced) -> {
|
||||
* factories.add(new CustomTradeFactory(...);
|
||||
* });
|
||||
* </pre></blockquote>
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ import net.minecraft.network.codec.StreamCodec;
|
|||
*
|
||||
* {@literal @}Override
|
||||
* public void onInitialize() {
|
||||
* Registry.register(Registries.PARTICLE_TYPE, Identifier.of("testmod", "simple"), SIMPLE_TEST_PARTICLE);
|
||||
* Registry.register(Registries.PARTICLE_TYPE, Identifier.of("testmod", "custom"), CUSTOM_TEST_PARTICLE);
|
||||
* Registry.register(Registries.PARTICLE_TYPE, Identifier.fromNamespaceAndPath("modid", "simple"), SIMPLE_TEST_PARTICLE);
|
||||
* Registry.register(Registries.PARTICLE_TYPE, Identifier.fromNamespaceAndPath("modid", "custom"), CUSTOM_TEST_PARTICLE);
|
||||
* }}
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import net.fabricmc.fabric.impl.registry.sync.DynamicRegistriesImpl;
|
|||
* // @link region substring=RegistryKey target=RegistryKey
|
||||
* // @link region substring=ofRegistry target="RegistryKey#ofRegistry"
|
||||
* // @link region substring=Identifier target="net.minecraft.util.Identifier#Identifier(String, String)"
|
||||
* public static final RegistryKey<Registry<MyData>> MY_DATA_KEY = RegistryKey.ofRegistry(Identifier.of("my_mod", "my_data"));
|
||||
* public static final RegistryKey<Registry<MyData>> MY_DATA_KEY = RegistryKey.ofRegistry(Identifier.fromNamespaceAndPath("modid", "my_data"));
|
||||
* // @end @end @end
|
||||
*
|
||||
* // Option 1: Register a non-synced registry
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import net.fabricmc.fabric.mixin.registry.sync.BuiltInRegistriesAccessor;
|
|||
*
|
||||
* <pre>
|
||||
* {@code
|
||||
* RegistryKey<Registry<String>> registryKey = RegistryKey.ofRegistry(Identifier.of("modid", "registry_name"));
|
||||
* RegistryKey<Registry<String>> registryKey = RegistryKey.ofRegistry(Identifier.fromNamespaceAndPath("modid", "custom_registry"));
|
||||
* Registry<String> registry = FabricRegistryBuilder.createSimple(registryKey)
|
||||
* .attribute(RegistryAttribute.SYNCED)
|
||||
* .buildAndRegister();
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ import net.fabricmc.fabric.api.event.EventFactory;
|
|||
* <p>For example, to register a feature renderer for a player model, the example below may be used:
|
||||
* <blockquote><pre>
|
||||
* LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper) -> {
|
||||
* if (entityRenderer instanceof PlayerEntityModel) {
|
||||
* registrationHelper.register(new MyFeatureRenderer((PlayerEntityModel) entityRenderer));
|
||||
* if (entityRenderer instanceof AvatarRenderer<?> avatarEntityRenderer) {
|
||||
* registrationHelper.register(new MyFeatureRenderer(avatarEntityRenderer, context.getModelSet()));
|
||||
* }
|
||||
* });
|
||||
* </pre></blockquote>
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ import net.minecraft.world.inventory.MenuType;
|
|||
* // Creating and registering the type
|
||||
* public static final ExtendedScreenHandlerType<OvenScreenHandler> OVEN =
|
||||
* new ExtendedScreenHandlerType((syncId, inventory, data) -> ..., OvenData.PACKET_CODEC);
|
||||
* Registry.register(Registry.SCREEN_HANDLER, Identifier.of(...), OVEN);
|
||||
* Registry.register(Registry.MENU, Identifier.fromNamespaceAndPath("modid", "custom_menu"), OVEN);
|
||||
*
|
||||
* // Note: remember to also register the screen using vanilla's HandledScreens!
|
||||
* // Note: remember to also register the screen using vanilla's MenuScreens!
|
||||
*
|
||||
* // Screen handler class
|
||||
* public class OvenScreenHandler extends ScreenHandler {
|
||||
* public class OvenScreenHandler extends AbstractContainerMenu {
|
||||
* public OvenScreenHandler(int syncId) {
|
||||
* super(MyScreenHandlers.OVEN, syncId);
|
||||
* }
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public interface FabricSoundInstance {
|
|||
* class CustomSound extends AbstractSoundInstance {
|
||||
* CustomSound() {
|
||||
* // Use the sound defined in sounds.json
|
||||
* super(Identifier.of("mod_id", "custom_sound"), SoundCategory.BLOCKS, SoundInstance.createRandom());
|
||||
* super(Identifier.fromNamespaceAndPath("modid", "custom_sound"), SoundCategory.BLOCKS, SoundInstance.createRandom());
|
||||
* }
|
||||
*
|
||||
* @Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue