mirror of
https://github.com/architectury/architectury-api.git
synced 2026-04-02 13:37:43 -05:00
Update to 1.19.3
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.extensions.injected;
|
||||
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -28,4 +29,9 @@ public interface InjectedItemPropertiesExtension {
|
||||
default Item.Properties arch$tab(CreativeModeTab tab) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
default Item.Properties arch$tab(CreativeTabRegistry.TabSupplier tab) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public final class BiomeHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectsProperties.Mutable setAmbientLoopSound(@Nullable SoundEvent sound) {
|
||||
public EffectsProperties.Mutable setAmbientLoopSound(@Nullable Holder<SoundEvent> sound) {
|
||||
effects.ambientLoopSoundEvent = Optional.ofNullable(sound);
|
||||
return this;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public final class BiomeHooks {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<SoundEvent> getAmbientLoopSound() {
|
||||
public Optional<Holder<SoundEvent>> getAmbientLoopSound() {
|
||||
return effects.ambientLoopSoundEvent;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.hooks.level.biome;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.level.biome.AmbientAdditionsSettings;
|
||||
@@ -47,7 +48,7 @@ public interface EffectsProperties {
|
||||
|
||||
Optional<AmbientParticleSettings> getAmbientParticle();
|
||||
|
||||
Optional<SoundEvent> getAmbientLoopSound();
|
||||
Optional<Holder<SoundEvent>> getAmbientLoopSound();
|
||||
|
||||
Optional<AmbientMoodSettings> getAmbientMoodSound();
|
||||
|
||||
@@ -72,7 +73,7 @@ public interface EffectsProperties {
|
||||
|
||||
EffectsProperties.Mutable setAmbientParticle(@Nullable AmbientParticleSettings settings);
|
||||
|
||||
EffectsProperties.Mutable setAmbientLoopSound(@Nullable SoundEvent sound);
|
||||
EffectsProperties.Mutable setAmbientLoopSound(@Nullable Holder<SoundEvent> sound);
|
||||
|
||||
EffectsProperties.Mutable setAmbientMoodSound(@Nullable AmbientMoodSettings settings);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package dev.architectury.impl;
|
||||
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -27,4 +28,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface ItemPropertiesExtensionImpl {
|
||||
@Nullable
|
||||
CreativeModeTab arch$getTab();
|
||||
|
||||
@Nullable
|
||||
CreativeTabRegistry.TabSupplier arch$getTabSupplier();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,11 @@ public class MixinItem implements InjectedItemExtension {
|
||||
CreativeModeTab tab = ((ItemPropertiesExtensionImpl) properties).arch$getTab();
|
||||
if (tab != null) {
|
||||
CreativeTabRegistry.append(tab, (Item) (Object) this);
|
||||
return;
|
||||
}
|
||||
CreativeTabRegistry.TabSupplier tabSupplier = ((ItemPropertiesExtensionImpl) properties).arch$getTabSupplier();
|
||||
if (tabSupplier != null) {
|
||||
CreativeTabRegistry.append(tabSupplier, (Item) (Object) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.architectury.mixin.inject;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedItemPropertiesExtension;
|
||||
import dev.architectury.impl.ItemPropertiesExtensionImpl;
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -31,10 +32,20 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
public class MixinItemProperties implements InjectedItemPropertiesExtension, ItemPropertiesExtensionImpl {
|
||||
@Unique
|
||||
private CreativeModeTab tab;
|
||||
@Unique
|
||||
private CreativeTabRegistry.TabSupplier tabSupplier;
|
||||
|
||||
@Override
|
||||
public Item.Properties arch$tab(CreativeModeTab tab) {
|
||||
this.tab = tab;
|
||||
this.tabSupplier = null;
|
||||
return (Item.Properties) (Object) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties arch$tab(CreativeTabRegistry.TabSupplier tab) {
|
||||
this.tab = null;
|
||||
this.tabSupplier = tab;
|
||||
return (Item.Properties) (Object) this;
|
||||
}
|
||||
|
||||
@@ -43,4 +54,10 @@ public class MixinItemProperties implements InjectedItemPropertiesExtension, Ite
|
||||
public CreativeModeTab arch$getTab() {
|
||||
return tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CreativeTabRegistry.TabSupplier arch$getTabSupplier() {
|
||||
return tabSupplier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* This file is part of architectury.
|
||||
* Copyright (C) 2020, 2021, 2022 architectury
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.registry;
|
||||
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
@ApiStatus.Experimental
|
||||
public interface CreativeTabOutput extends CreativeModeTab.Output {
|
||||
void acceptAfter(ItemStack after, ItemStack stack, CreativeModeTab.TabVisibility visibility);
|
||||
|
||||
void acceptBefore(ItemStack before, ItemStack stack, CreativeModeTab.TabVisibility visibility);
|
||||
|
||||
@Override
|
||||
default void accept(ItemStack stack, CreativeModeTab.TabVisibility visibility) {
|
||||
acceptAfter(ItemStack.EMPTY, stack, visibility);
|
||||
}
|
||||
|
||||
default void acceptAfter(ItemStack after, ItemStack stack) {
|
||||
this.acceptAfter(after, stack, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
|
||||
}
|
||||
|
||||
default void acceptAfter(ItemStack after, ItemLike item, CreativeModeTab.TabVisibility visibility) {
|
||||
this.acceptAfter(after, new ItemStack(item), visibility);
|
||||
}
|
||||
|
||||
default void acceptAfter(ItemStack after, ItemLike item) {
|
||||
this.acceptAfter(after, new ItemStack(item), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
|
||||
}
|
||||
|
||||
default void acceptAllAfter(ItemStack after, Collection<ItemStack> stacks, CreativeModeTab.TabVisibility visibility) {
|
||||
stacks.forEach((stack) -> acceptAfter(after, stack, visibility));
|
||||
}
|
||||
|
||||
default void acceptAllAfter(ItemStack after, Collection<ItemStack> stacks) {
|
||||
this.acceptAllAfter(after, stacks, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
|
||||
}
|
||||
|
||||
default void acceptAfter(ItemLike after, ItemStack stack) {
|
||||
this.acceptAfter(new ItemStack(after), stack);
|
||||
}
|
||||
|
||||
default void acceptAfter(ItemLike after, ItemLike item, CreativeModeTab.TabVisibility visibility) {
|
||||
this.acceptAfter(new ItemStack(after), item, visibility);
|
||||
}
|
||||
|
||||
default void acceptAfter(ItemLike after, ItemLike item) {
|
||||
this.acceptAfter(new ItemStack(after), item);
|
||||
}
|
||||
|
||||
default void acceptAllAfter(ItemLike after, Collection<ItemStack> stacks, CreativeModeTab.TabVisibility visibility) {
|
||||
acceptAllAfter(new ItemStack(after), stacks, visibility);
|
||||
}
|
||||
|
||||
default void acceptAllAfter(ItemLike after, Collection<ItemStack> stacks) {
|
||||
acceptAllAfter(new ItemStack(after), stacks);
|
||||
}
|
||||
|
||||
default void acceptBefore(ItemStack before, ItemStack stack) {
|
||||
this.acceptBefore(before, stack, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
|
||||
}
|
||||
|
||||
default void acceptBefore(ItemStack before, ItemLike item, CreativeModeTab.TabVisibility visibility) {
|
||||
this.acceptBefore(before, new ItemStack(item), visibility);
|
||||
}
|
||||
|
||||
default void acceptBefore(ItemStack before, ItemLike item) {
|
||||
this.acceptBefore(before, new ItemStack(item), CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
|
||||
}
|
||||
|
||||
default void acceptAllBefore(ItemStack before, Collection<ItemStack> stacks, CreativeModeTab.TabVisibility visibility) {
|
||||
stacks.forEach((stack) -> acceptBefore(before, stack, visibility));
|
||||
}
|
||||
|
||||
default void acceptAllBefore(ItemStack before, Collection<ItemStack> stacks) {
|
||||
this.acceptAllBefore(before, stacks, CreativeModeTab.TabVisibility.PARENT_AND_SEARCH_TABS);
|
||||
}
|
||||
|
||||
default void acceptBefore(ItemLike before, ItemStack stack) {
|
||||
this.acceptBefore(new ItemStack(before), stack);
|
||||
}
|
||||
|
||||
default void acceptBefore(ItemLike before, ItemLike item, CreativeModeTab.TabVisibility visibility) {
|
||||
this.acceptBefore(new ItemStack(before), item, visibility);
|
||||
}
|
||||
|
||||
default void acceptBefore(ItemLike before, ItemLike item) {
|
||||
this.acceptBefore(new ItemStack(before), item);
|
||||
}
|
||||
|
||||
default void acceptAllBefore(ItemLike before, Collection<ItemStack> stacks, CreativeModeTab.TabVisibility visibility) {
|
||||
acceptAllBefore(new ItemStack(before), stacks, visibility);
|
||||
}
|
||||
|
||||
default void acceptAllBefore(ItemLike before, Collection<ItemStack> stacks) {
|
||||
acceptAllBefore(new ItemStack(before), stacks);
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,10 @@
|
||||
|
||||
package dev.architectury.registry;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedItemPropertiesExtension;
|
||||
import dev.architectury.injectables.annotations.ExpectPlatform;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
@@ -28,74 +30,155 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Registry for creating or modifying creative tabs.
|
||||
*
|
||||
* @see InjectedItemPropertiesExtension#arch$tab(CreativeModeTab) to add an item to a creative tab easily
|
||||
*/
|
||||
public final class CreativeTabRegistry {
|
||||
private CreativeTabRegistry() {
|
||||
}
|
||||
|
||||
// I am sorry, fabric wants a resource location instead of the translation key for whatever reason
|
||||
public static CreativeModeTab create(ResourceLocation name, Supplier<ItemStack> icon) {
|
||||
return builder(name).icon(icon).build();
|
||||
/**
|
||||
* Creates a deferred creative tab, with a custom icon.
|
||||
* <p>
|
||||
* On fabric, the supplier is always resolvable. On forge, the supplier is only
|
||||
* resolvable after the registration of the creative tab.
|
||||
*
|
||||
* @param name the name of the creative tab
|
||||
* @param icon the icon of the creative tab
|
||||
* @return the creative tab supplier
|
||||
*/
|
||||
public static TabSupplier create(ResourceLocation name, Supplier<ItemStack> icon) {
|
||||
return create(name, builder -> {
|
||||
builder.icon(icon);
|
||||
});
|
||||
}
|
||||
|
||||
// I am sorry, fabric wants a resource location instead of the translation key for whatever reason
|
||||
|
||||
/**
|
||||
* Creates a deferred creative tab, with a configurable builder callback.
|
||||
* <p>
|
||||
* On fabric, the supplier is always resolvable. On forge, the supplier is only
|
||||
* resolvable after the registration of the creative tab.
|
||||
*
|
||||
* @param name the name of the creative tab
|
||||
* @param callback the builder callback
|
||||
* @return the creative tab supplier
|
||||
*/
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static CreativeModeTab.Builder builder(ResourceLocation name) {
|
||||
public static TabSupplier create(ResourceLocation name, Consumer<CreativeModeTab.Builder> callback) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tab supplier for a tab.
|
||||
*
|
||||
* @param tab the tab
|
||||
* @return the tab supplier
|
||||
*/
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier of(CreativeModeTab tab) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tab supplier for a tab to be created later.
|
||||
*
|
||||
* @param name the name of the creative tab
|
||||
* @return the tab supplier
|
||||
*/
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier defer(ResourceLocation name) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void modify(CreativeModeTab tab, ModifyTabCallback filler) {
|
||||
modify(of(tab), filler);
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void modify(CreativeModeTab tab, Consumer<CreativeModeTab.Output> filler) {
|
||||
public static void modify(TabSupplier tab, ModifyTabCallback filler) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void append(CreativeModeTab tab, ItemLike item) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void append(CreativeModeTab tab, ItemLike... items) {
|
||||
throw new AssertionError();
|
||||
append(of(tab), items);
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void append(CreativeModeTab tab, T item) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void append(CreativeModeTab tab, T... items) {
|
||||
throw new AssertionError();
|
||||
appendStack(of(tab), Stream.of(items).map(supplier -> () -> new ItemStack(supplier.get())));
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(CreativeModeTab tab, ItemStack item) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(CreativeModeTab tab, ItemStack... items) {
|
||||
throw new AssertionError();
|
||||
appendStack(of(tab), items);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(CreativeModeTab tab, Supplier<ItemStack>... items) {
|
||||
appendStack(of(tab), items);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void append(TabSupplier tab, ItemLike... items) {
|
||||
appendStack(tab, Stream.of(items).map(item -> () -> new ItemStack(item)));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void append(TabSupplier tab, T... items) {
|
||||
appendStack(tab, Stream.of(items).map(supplier -> () -> new ItemStack(supplier.get())));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, ItemStack... items) {
|
||||
appendStack(tab, Stream.of(items).map(supplier -> () -> supplier));
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemStack, T extends Supplier<I>> void appendStack(CreativeModeTab tab, T item) {
|
||||
public static void appendStack(TabSupplier tab, Supplier<ItemStack> item) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemStack, T extends Supplier<I>> void appendStack(CreativeModeTab tab, T... items) {
|
||||
throw new AssertionError();
|
||||
public static void appendStack(TabSupplier tab, Supplier<ItemStack>... items) {
|
||||
for (Supplier<ItemStack> item : items) {
|
||||
appendStack(tab, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, Stream<Supplier<ItemStack>> items) {
|
||||
items.forEach(item -> appendStack(tab, item));
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ModifyTabCallback {
|
||||
void accept(FeatureFlagSet flags, CreativeTabOutput output, boolean canUseGameMasterBlocks);
|
||||
}
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
public interface TabSupplier extends Supplier<CreativeModeTab> {
|
||||
/**
|
||||
* Returns the name of the creative tab.
|
||||
*
|
||||
* @return The name of the creative tab.
|
||||
*/
|
||||
ResourceLocation getName();
|
||||
|
||||
/**
|
||||
* @return whether the creative tab is registered.
|
||||
*/
|
||||
boolean isPresent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ accessible method net/minecraft/client/gui/screens/Screen addRenderableOnly (Lne
|
||||
accessible method net/minecraft/client/gui/screens/Screen addWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;
|
||||
accessible field net/minecraft/client/gui/screens/Screen narratables Ljava/util/List;
|
||||
accessible field net/minecraft/client/gui/screens/Screen renderables Ljava/util/List;
|
||||
accessible field net/minecraft/world/level/biome/BiomeGenerationSettings$PlainBuilder features Ljava/util/List;
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour properties Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties material Lnet/minecraft/world/level/material/Material;
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties material Lnet/minecraft/world/level/material/Material;
|
||||
|
||||
Reference in New Issue
Block a user