mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Update to 23w18a
This commit is contained in:
@@ -134,7 +134,7 @@ static def generateCreativeTabs(List<String> lines, FileSystem fs) {
|
||||
lines.add("# CreativeModeTabs fields")
|
||||
def node = loadClass(fs.getPath("net/minecraft/world/item/CreativeModeTabs.class"))
|
||||
for (def field : node.fields) {
|
||||
if ((field.access & Opcodes.ACC_STATIC) != 0 && field.desc == "Lnet/minecraft/world/item/CreativeModeTab;") {
|
||||
if ((field.access & Opcodes.ACC_STATIC) != 0 && field.desc == "Lnet/minecraft/resources/ResourceKey;") {
|
||||
if ((field.access & Opcodes.ACC_PUBLIC) == 0) {
|
||||
lines.add("transitive-accessible field $node.name $field.name $field.desc")
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package dev.architectury.event.events.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.architectury.event.CompoundEventResult;
|
||||
import dev.architectury.event.Event;
|
||||
import dev.architectury.event.EventFactory;
|
||||
@@ -27,6 +26,7 @@ import dev.architectury.event.EventResult;
|
||||
import dev.architectury.hooks.client.screen.ScreenAccess;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
@Environment(EnvType.CLIENT)
|
||||
public interface ClientGuiEvent {
|
||||
/**
|
||||
* @see RenderHud#renderHud(PoseStack, float)
|
||||
* @see RenderHud#renderHud(GuiGraphics, float)
|
||||
*/
|
||||
Event<RenderHud> RENDER_HUD = EventFactory.createLoop();
|
||||
/**
|
||||
@@ -52,19 +52,19 @@ public interface ClientGuiEvent {
|
||||
*/
|
||||
Event<ScreenInitPost> INIT_POST = EventFactory.createLoop();
|
||||
/**
|
||||
* @see ScreenRenderPre#render(Screen, PoseStack, int, int, float)
|
||||
* @see ScreenRenderPre#render(Screen, GuiGraphics, int, int, float)
|
||||
*/
|
||||
Event<ScreenRenderPre> RENDER_PRE = EventFactory.createEventResult();
|
||||
/**
|
||||
* @see ScreenRenderPost#render(Screen, PoseStack, int, int, float)
|
||||
* @see ScreenRenderPost#render(Screen, GuiGraphics, int, int, float)
|
||||
*/
|
||||
Event<ScreenRenderPost> RENDER_POST = EventFactory.createLoop();
|
||||
/**
|
||||
* @see ContainerScreenRenderBackground#render(AbstractContainerScreen, PoseStack, int, int, float)
|
||||
* @see ContainerScreenRenderBackground#render(AbstractContainerScreen, GuiGraphics, int, int, float)
|
||||
*/
|
||||
Event<ContainerScreenRenderBackground> RENDER_CONTAINER_BACKGROUND = EventFactory.createLoop();
|
||||
/**
|
||||
* @see ContainerScreenRenderForeground#render(AbstractContainerScreen, PoseStack, int, int, float)
|
||||
* @see ContainerScreenRenderForeground#render(AbstractContainerScreen, GuiGraphics, int, int, float)
|
||||
*/
|
||||
Event<ContainerScreenRenderForeground> RENDER_CONTAINER_FOREGROUND = EventFactory.createLoop();
|
||||
/**
|
||||
@@ -78,10 +78,10 @@ public interface ClientGuiEvent {
|
||||
* Invoked after the in-game hud has been rendered.
|
||||
* Equivalent to Forge's {@code RenderGameOverlayEvent.Post@ElementType#ALL} and Fabric's {@code HudRenderCallback}.
|
||||
*
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param tickDelta The tick delta.
|
||||
*/
|
||||
void renderHud(PoseStack matrices, float tickDelta);
|
||||
void renderHud(GuiGraphics graphics, float tickDelta);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -129,14 +129,14 @@ public interface ClientGuiEvent {
|
||||
* Equivalent to Forge's {@code GuiScreenEvent.DrawScreenEvent.Pre} event.
|
||||
*
|
||||
* @param screen The screen.
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param mouseX The scaled x-coordinate of the mouse cursor.
|
||||
* @param mouseY The scaled y-coordinate of the mouse cursor.
|
||||
* @param delta The current tick delta.
|
||||
* @return A {@link EventResult} determining the outcome of the event,
|
||||
* the vanilla render may be cancelled by the result.
|
||||
*/
|
||||
EventResult render(Screen screen, PoseStack matrices, int mouseX, int mouseY, float delta);
|
||||
EventResult render(Screen screen, GuiGraphics graphics, int mouseX, int mouseY, float delta);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -146,12 +146,12 @@ public interface ClientGuiEvent {
|
||||
* Equivalent to Forge's {@code GuiScreenEvent.DrawScreenEvent.Post} event.
|
||||
*
|
||||
* @param screen The screen.
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param mouseX The scaled x-coordinate of the mouse cursor.
|
||||
* @param mouseY The scaled y-coordinate of the mouse cursor.
|
||||
* @param delta The current tick delta.
|
||||
*/
|
||||
void render(Screen screen, PoseStack matrices, int mouseX, int mouseY, float delta);
|
||||
void render(Screen screen, GuiGraphics graphics, int mouseX, int mouseY, float delta);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -161,12 +161,12 @@ public interface ClientGuiEvent {
|
||||
* Equivalent to Forge's {@code ContainerScreenEvent.DrawBackground} event.
|
||||
*
|
||||
* @param screen The screen.
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param mouseX The scaled x-coordinate of the mouse cursor.
|
||||
* @param mouseY The scaled y-coordinate of the mouse cursor.
|
||||
* @param delta The current tick delta.
|
||||
*/
|
||||
void render(AbstractContainerScreen<?> screen, PoseStack matrices, int mouseX, int mouseY, float delta);
|
||||
void render(AbstractContainerScreen<?> screen, GuiGraphics graphics, int mouseX, int mouseY, float delta);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -176,12 +176,12 @@ public interface ClientGuiEvent {
|
||||
* Equivalent to Forge's {@code ContainerScreenEvent.DrawForeground} event.
|
||||
*
|
||||
* @param screen The screen.
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param mouseX The scaled x-coordinate of the mouse cursor.
|
||||
* @param mouseY The scaled y-coordinate of the mouse cursor.
|
||||
* @param delta The current tick delta.
|
||||
*/
|
||||
void render(AbstractContainerScreen<?> screen, PoseStack matrices, int mouseX, int mouseY, float delta);
|
||||
void render(AbstractContainerScreen<?> screen, GuiGraphics graphics, int mouseX, int mouseY, float delta);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
|
||||
package dev.architectury.event.events.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.architectury.event.Event;
|
||||
import dev.architectury.event.EventFactory;
|
||||
import dev.architectury.event.EventResult;
|
||||
import dev.architectury.impl.TooltipAdditionalContextsImpl;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -42,15 +42,15 @@ public interface ClientTooltipEvent {
|
||||
*/
|
||||
Event<Item> ITEM = EventFactory.createLoop();
|
||||
/**
|
||||
* @see Render#renderTooltip(PoseStack, List, int, int)
|
||||
* @see Render#renderTooltip(GuiGraphics, List, int, int)
|
||||
*/
|
||||
Event<Render> RENDER_PRE = EventFactory.createEventResult();
|
||||
/**
|
||||
* @see RenderModifyPosition#renderTooltip(PoseStack, PositionContext)
|
||||
* @see RenderModifyPosition#renderTooltip(GuiGraphics, PositionContext)
|
||||
*/
|
||||
Event<RenderModifyPosition> RENDER_MODIFY_POSITION = EventFactory.createLoop();
|
||||
/**
|
||||
* @see RenderModifyColor#renderTooltip(PoseStack, int, int, ColorContext)
|
||||
* @see RenderModifyColor#renderTooltip(GuiGraphics, int, int, ColorContext)
|
||||
*/
|
||||
// Event<RenderModifyColor> RENDER_MODIFY_COLOR = EventFactory.createLoop();
|
||||
|
||||
@@ -85,14 +85,14 @@ public interface ClientTooltipEvent {
|
||||
/**
|
||||
* Invoked before the tooltip for a tooltip is rendered.
|
||||
*
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param texts The mutable list of components that are rendered.
|
||||
* @param x The x-coordinate of the tooltip.
|
||||
* @param y The y-coordinate of the tooltip.
|
||||
* @return A {@link EventResult} determining the outcome of the event,
|
||||
* the execution of the vanilla tooltip rendering may be cancelled by the result.
|
||||
*/
|
||||
EventResult renderTooltip(PoseStack matrices, List<? extends ClientTooltipComponent> texts, int x, int y);
|
||||
EventResult renderTooltip(GuiGraphics graphics, List<? extends ClientTooltipComponent> texts, int x, int y);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -100,10 +100,10 @@ public interface ClientTooltipEvent {
|
||||
/**
|
||||
* Event to manipulate the position of the tooltip.
|
||||
*
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param context The current position context.
|
||||
*/
|
||||
void renderTooltip(PoseStack matrices, PositionContext context);
|
||||
void renderTooltip(GuiGraphics graphics, PositionContext context);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@@ -111,12 +111,12 @@ public interface ClientTooltipEvent {
|
||||
/**
|
||||
* Event to manipulate the color of the tooltip.
|
||||
*
|
||||
* @param matrices The pose stack.
|
||||
* @param graphics The graphics context.
|
||||
* @param x The x-coordinate of the tooltip.
|
||||
* @param y The y-coordinate of the tooltip.
|
||||
* @param context The current color context.
|
||||
*/
|
||||
void renderTooltip(PoseStack matrices, int x, int y, ColorContext context);
|
||||
void renderTooltip(GuiGraphics graphics, int x, int y, ColorContext context);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
|
||||
@@ -22,8 +22,8 @@ package dev.architectury.event.events.common;
|
||||
import dev.architectury.event.Event;
|
||||
import dev.architectury.event.EventFactory;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.storage.loot.LootDataManager;
|
||||
import net.minecraft.world.level.storage.loot.LootPool;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ public interface LootEvent {
|
||||
* });
|
||||
* }</pre>
|
||||
*
|
||||
* @see ModifyLootTable#modifyLootTable(LootTables, ResourceLocation, LootTableModificationContext, boolean)
|
||||
* @see ModifyLootTable#modifyLootTable(LootDataManager, ResourceLocation, LootTableModificationContext, boolean)
|
||||
*/
|
||||
Event<ModifyLootTable> MODIFY_LOOT_TABLE = EventFactory.createLoop();
|
||||
|
||||
@@ -65,13 +65,13 @@ public interface LootEvent {
|
||||
/**
|
||||
* Modifies a loot table.
|
||||
*
|
||||
* @param lootTables the {@link LootTables} instance containing all loot tables
|
||||
* @param lootDataManager the {@link LootDataManager} instance containing all loot tables
|
||||
* @param id the loot table ID
|
||||
* @param context the context used to modify the loot table
|
||||
* @param builtin if {@code true}, the loot table is built-in;
|
||||
* if {@code false}, it is from a user data pack
|
||||
*/
|
||||
void modifyLootTable(LootTables lootTables, ResourceLocation id, LootTableModificationContext context, boolean builtin);
|
||||
void modifyLootTable(LootDataManager lootDataManager, ResourceLocation id, LootTableModificationContext context, boolean builtin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
package dev.architectury.extensions.injected;
|
||||
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.registries.DeferredSupplier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -31,7 +32,12 @@ public interface InjectedItemPropertiesExtension {
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
default Item.Properties arch$tab(CreativeTabRegistry.TabSupplier tab) {
|
||||
default Item.Properties arch$tab(DeferredSupplier<CreativeModeTab> tab) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
default Item.Properties arch$tab(ResourceKey<CreativeModeTab> tab) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class ItemStackHooks {
|
||||
entity.makeFakeItem();
|
||||
}
|
||||
|
||||
player.level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 0.2F, ((player.getRandom().nextFloat() - player.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.level().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_PICKUP, SoundSource.PLAYERS, 0.2F, ((player.getRandom().nextFloat() - player.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.inventoryMenu.broadcastChanges();
|
||||
} else {
|
||||
var entity = player.drop(stack, false);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
package dev.architectury.impl;
|
||||
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.registries.DeferredSupplier;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,5 +30,5 @@ public interface ItemPropertiesExtensionImpl {
|
||||
CreativeModeTab arch$getTab();
|
||||
|
||||
@Nullable
|
||||
CreativeTabRegistry.TabSupplier arch$getTabSupplier();
|
||||
DeferredSupplier<CreativeModeTab> arch$getTabSupplier();
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ public abstract class MixinLightningBolt extends Entity {
|
||||
by = 1
|
||||
), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void handleLightning(CallbackInfo ci, List<Entity> list) {
|
||||
if (this.isRemoved() || this.level.isClientSide) {
|
||||
if (this.isRemoved() || this.level().isClientSide) {
|
||||
return;
|
||||
}
|
||||
|
||||
LightningEvent.STRIKE.invoker().onStrike((LightningBolt) (Object) this, this.level, this.position(), list);
|
||||
LightningEvent.STRIKE.invoker().onStrike((LightningBolt) (Object) this, this.level(), this.position(), list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package dev.architectury.mixin.inject;
|
||||
import dev.architectury.extensions.injected.InjectedItemExtension;
|
||||
import dev.architectury.impl.ItemPropertiesExtensionImpl;
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.registries.DeferredSupplier;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -35,10 +36,10 @@ public class MixinItem implements InjectedItemExtension {
|
||||
private void init(Item.Properties properties, CallbackInfo ci) {
|
||||
CreativeModeTab tab = ((ItemPropertiesExtensionImpl) properties).arch$getTab();
|
||||
if (tab != null) {
|
||||
CreativeTabRegistry.append(tab, (Item) (Object) this);
|
||||
CreativeTabRegistry.appendBuiltin(tab, (Item) (Object) this);
|
||||
return;
|
||||
}
|
||||
CreativeTabRegistry.TabSupplier tabSupplier = ((ItemPropertiesExtensionImpl) properties).arch$getTabSupplier();
|
||||
DeferredSupplier<CreativeModeTab> tabSupplier = ((ItemPropertiesExtensionImpl) properties).arch$getTabSupplier();
|
||||
if (tabSupplier != null) {
|
||||
CreativeTabRegistry.append(tabSupplier, (Item) (Object) this);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ package dev.architectury.mixin.inject;
|
||||
import dev.architectury.extensions.injected.InjectedItemPropertiesExtension;
|
||||
import dev.architectury.impl.ItemPropertiesExtensionImpl;
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.registries.DeferredSupplier;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -33,7 +35,7 @@ public class MixinItemProperties implements InjectedItemPropertiesExtension, Ite
|
||||
@Unique
|
||||
private CreativeModeTab tab;
|
||||
@Unique
|
||||
private CreativeTabRegistry.TabSupplier tabSupplier;
|
||||
private DeferredSupplier<CreativeModeTab> tabSupplier;
|
||||
|
||||
@Override
|
||||
public Item.Properties arch$tab(CreativeModeTab tab) {
|
||||
@@ -43,12 +45,19 @@ public class MixinItemProperties implements InjectedItemPropertiesExtension, Ite
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties arch$tab(CreativeTabRegistry.TabSupplier tab) {
|
||||
public Item.Properties arch$tab(DeferredSupplier<CreativeModeTab> tab) {
|
||||
this.tab = null;
|
||||
this.tabSupplier = tab;
|
||||
return (Item.Properties) (Object) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item.Properties arch$tab(ResourceKey<CreativeModeTab> tab) {
|
||||
this.tab = null;
|
||||
this.tabSupplier = CreativeTabRegistry.defer(tab);
|
||||
return (Item.Properties) (Object) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CreativeModeTab arch$getTab() {
|
||||
@@ -57,7 +66,7 @@ public class MixinItemProperties implements InjectedItemPropertiesExtension, Ite
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CreativeTabRegistry.TabSupplier arch$getTabSupplier() {
|
||||
public DeferredSupplier<CreativeModeTab> arch$getTabSupplier() {
|
||||
return tabSupplier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ package dev.architectury.registry;
|
||||
|
||||
import dev.architectury.extensions.injected.InjectedItemPropertiesExtension;
|
||||
import dev.architectury.injectables.annotations.ExpectPlatform;
|
||||
import dev.architectury.registry.registries.DeferredSupplier;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
@@ -42,35 +45,31 @@ public final class CreativeTabRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Creates a creative tab, with a custom icon.
|
||||
* This has to be registered manually.
|
||||
*
|
||||
* @param name the name of the creative tab
|
||||
* @param icon the icon of the creative tab
|
||||
* @return the creative tab supplier
|
||||
* @param title the title of the creative tab
|
||||
* @param icon the icon of the creative tab
|
||||
* @return the creative tab
|
||||
*/
|
||||
public static TabSupplier create(ResourceLocation name, Supplier<ItemStack> icon) {
|
||||
return create(name, builder -> {
|
||||
public static CreativeModeTab create(Component title, Supplier<ItemStack> icon) {
|
||||
return create(builder -> {
|
||||
builder.title(title);
|
||||
builder.icon(icon);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Creates a creative tab, with a configurable builder callback.
|
||||
* This has to be registered manually.
|
||||
*
|
||||
* @param name the name of the creative tab
|
||||
* @param callback the builder callback
|
||||
* @return the creative tab supplier
|
||||
* @return the creative tab
|
||||
*/
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier create(ResourceLocation name, Consumer<CreativeModeTab.Builder> callback) {
|
||||
public static CreativeModeTab create(Consumer<CreativeModeTab.Builder> callback) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@@ -82,7 +81,7 @@ public final class CreativeTabRegistry {
|
||||
*/
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier of(CreativeModeTab tab) {
|
||||
public static DeferredSupplier<CreativeModeTab> ofBuiltin(CreativeModeTab tab) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@@ -94,91 +93,117 @@ public final class CreativeTabRegistry {
|
||||
*/
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier defer(ResourceLocation name) {
|
||||
public static DeferredSupplier<CreativeModeTab> defer(ResourceLocation name) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a tab supplier for a tab to be created later.
|
||||
*
|
||||
* @param name the key of the creative tab
|
||||
* @return the tab supplier
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public static void modify(CreativeModeTab tab, ModifyTabCallback filler) {
|
||||
modify(of(tab), filler);
|
||||
public static DeferredSupplier<CreativeModeTab> defer(ResourceKey<CreativeModeTab> name) {
|
||||
return defer(name.location());
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void modifyBuiltin(CreativeModeTab tab, ModifyTabCallback filler) {
|
||||
modify(ofBuiltin(tab), filler);
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void modify(TabSupplier tab, ModifyTabCallback filler) {
|
||||
public static void modify(DeferredSupplier<CreativeModeTab> tab, ModifyTabCallback filler) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void append(CreativeModeTab tab, ItemLike... items) {
|
||||
append(of(tab), items);
|
||||
public static void appendBuiltin(CreativeModeTab tab, ItemLike... items) {
|
||||
append(ofBuiltin(tab), items);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void append(CreativeModeTab tab, T... items) {
|
||||
appendStack(of(tab), Stream.of(items).map(supplier -> () -> new ItemStack(supplier.get())));
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void appendBuiltin(CreativeModeTab tab, T... items) {
|
||||
appendStack(ofBuiltin(tab), Stream.of(items).map(supplier -> () -> new ItemStack(supplier.get())));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(CreativeModeTab tab, ItemStack... items) {
|
||||
appendStack(of(tab), items);
|
||||
public static void appendBuiltinStack(CreativeModeTab tab, ItemStack... items) {
|
||||
appendStack(ofBuiltin(tab), items);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(CreativeModeTab tab, Supplier<ItemStack>... items) {
|
||||
appendStack(of(tab), items);
|
||||
public static void appendBuiltinStack(CreativeModeTab tab, Supplier<ItemStack>... items) {
|
||||
appendStack(ofBuiltin(tab), items);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void append(TabSupplier tab, ItemLike... items) {
|
||||
public static void append(DeferredSupplier<CreativeModeTab> 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) {
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void append(DeferredSupplier<CreativeModeTab> tab, T... items) {
|
||||
appendStack(tab, Stream.of(items).map(supplier -> () -> new ItemStack(supplier.get())));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, ItemStack... items) {
|
||||
public static void appendStack(DeferredSupplier<CreativeModeTab> tab, ItemStack... items) {
|
||||
appendStack(tab, Stream.of(items).map(supplier -> () -> supplier));
|
||||
}
|
||||
|
||||
@ExpectPlatform
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, Supplier<ItemStack> item) {
|
||||
public static void appendStack(DeferredSupplier<CreativeModeTab> tab, Supplier<ItemStack> item) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, Supplier<ItemStack>... items) {
|
||||
public static void appendStack(DeferredSupplier<CreativeModeTab> tab, Supplier<ItemStack>... items) {
|
||||
for (Supplier<ItemStack> item : items) {
|
||||
appendStack(tab, item);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, Stream<Supplier<ItemStack>> items) {
|
||||
public static void appendStack(DeferredSupplier<CreativeModeTab> tab, Stream<Supplier<ItemStack>> items) {
|
||||
items.forEach(item -> appendStack(tab, item));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void append(ResourceKey<CreativeModeTab> tab, ItemLike... items) {
|
||||
appendStack(defer(tab), Stream.of(items).map(item -> () -> new ItemStack(item)));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static <I extends ItemLike, T extends Supplier<I>> void append(ResourceKey<CreativeModeTab> tab, T... items) {
|
||||
appendStack(defer(tab), Stream.of(items).map(supplier -> () -> new ItemStack(supplier.get())));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(ResourceKey<CreativeModeTab> tab, ItemStack... items) {
|
||||
appendStack(defer(tab), Stream.of(items).map(supplier -> () -> supplier));
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(ResourceKey<CreativeModeTab> tab, Supplier<ItemStack> item) {
|
||||
appendStack(defer(tab), item);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(ResourceKey<CreativeModeTab> tab, Supplier<ItemStack>... items) {
|
||||
appendStack(defer(tab), items);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(ResourceKey<CreativeModeTab> tab, Stream<Supplier<ItemStack>> items) {
|
||||
appendStack(defer(tab), items);
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,37 @@
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package dev.architectury.test.tab;
|
||||
package dev.architectury.registry.registries;
|
||||
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.test.TestMod;
|
||||
import dev.architectury.test.registry.TestRegistries;
|
||||
import dev.architectury.utils.OptionalSupplier;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class TestCreativeTabs {
|
||||
public static final CreativeTabRegistry.TabSupplier TEST_TAB = CreativeTabRegistry.create(new ResourceLocation(TestMod.MOD_ID, "test_tab"),
|
||||
() -> new ItemStack(TestRegistries.TEST_ITEM.get()));
|
||||
public interface DeferredSupplier<T> extends OptionalSupplier<T> {
|
||||
/**
|
||||
* @return the identifier of the registry
|
||||
*/
|
||||
ResourceLocation getRegistryId();
|
||||
|
||||
/**
|
||||
* @return the identifier of the registry
|
||||
*/
|
||||
default ResourceKey<Registry<T>> getRegistryKey() {
|
||||
return ResourceKey.createRegistryKey(getRegistryId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the identifier of the entry
|
||||
*/
|
||||
ResourceLocation getId();
|
||||
|
||||
/**
|
||||
* Returns the registry key of the creative tab.
|
||||
*
|
||||
* @return The registry key of the creative tab.
|
||||
*/
|
||||
default ResourceKey<T> getKey() {
|
||||
return ResourceKey.create(getRegistryKey(), getId());
|
||||
}
|
||||
}
|
||||
@@ -19,87 +19,16 @@
|
||||
|
||||
package dev.architectury.registry.registries;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ApiStatus.NonExtendable
|
||||
public interface RegistrySupplier<T> extends Supplier<T> {
|
||||
public interface RegistrySupplier<T> extends DeferredSupplier<T> {
|
||||
RegistrarManager getRegistrarManager();
|
||||
|
||||
Registrar<T> getRegistrar();
|
||||
|
||||
/**
|
||||
* @return the identifier of the registry
|
||||
*/
|
||||
ResourceLocation getRegistryId();
|
||||
|
||||
/**
|
||||
* @return the identifier of the registry
|
||||
*/
|
||||
default ResourceKey<Registry<T>> getRegistryKey() {
|
||||
return ResourceKey.createRegistryKey(getRegistryId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the identifier of the entry
|
||||
*/
|
||||
ResourceLocation getId();
|
||||
|
||||
/**
|
||||
* @return whether the entry has been registered
|
||||
*/
|
||||
boolean isPresent();
|
||||
|
||||
@Nullable
|
||||
default T getOrNull() {
|
||||
if (isPresent()) {
|
||||
return get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
default Optional<T> toOptional() {
|
||||
return Optional.ofNullable(getOrNull());
|
||||
}
|
||||
|
||||
default void ifPresent(Consumer<? super T> action) {
|
||||
if (isPresent()) {
|
||||
action.accept(get());
|
||||
}
|
||||
}
|
||||
|
||||
default void ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction) {
|
||||
if (isPresent()) {
|
||||
action.accept(get());
|
||||
} else {
|
||||
emptyAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
default Stream<T> stream() {
|
||||
if (!isPresent()) {
|
||||
return Stream.empty();
|
||||
} else {
|
||||
return Stream.of(get());
|
||||
}
|
||||
}
|
||||
|
||||
default T orElse(T other) {
|
||||
return isPresent() ? get() : other;
|
||||
}
|
||||
|
||||
default T orElseGet(Supplier<? extends T> supplier) {
|
||||
return isPresent() ? get() : supplier.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens to when the registry entry is registered, and calls the given action.
|
||||
* Evaluates immediately if the entry is already registered.
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.utils;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface OptionalSupplier<T> extends Supplier<T> {
|
||||
/**
|
||||
* @return whether the entry is present.
|
||||
*/
|
||||
boolean isPresent();
|
||||
|
||||
@Nullable
|
||||
default T getOrNull() {
|
||||
if (isPresent()) {
|
||||
return get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
default Optional<T> toOptional() {
|
||||
return Optional.ofNullable(getOrNull());
|
||||
}
|
||||
|
||||
default void ifPresent(Consumer<? super T> action) {
|
||||
if (isPresent()) {
|
||||
action.accept(get());
|
||||
}
|
||||
}
|
||||
|
||||
default void ifPresentOrElse(Consumer<? super T> action, Runnable emptyAction) {
|
||||
if (isPresent()) {
|
||||
action.accept(get());
|
||||
} else {
|
||||
emptyAction.run();
|
||||
}
|
||||
}
|
||||
|
||||
default Stream<T> stream() {
|
||||
if (!isPresent()) {
|
||||
return Stream.empty();
|
||||
} else {
|
||||
return Stream.of(get());
|
||||
}
|
||||
}
|
||||
|
||||
default T orElse(T other) {
|
||||
return isPresent() ? get() : other;
|
||||
}
|
||||
|
||||
default T orElseGet(Supplier<? extends T> supplier) {
|
||||
return isPresent() ? get() : supplier.get();
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,6 @@ accessible field net/minecraft/client/gui/screens/Screen narratables Ljava/util/
|
||||
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;
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties materialColor Ljava/util/function/Function;
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties materialColor Ljava/util/function/Function;
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties hasCollision Z
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties hasCollision Z
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties soundType Lnet/minecraft/world/level/block/SoundType;
|
||||
@@ -50,7 +46,7 @@ accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties emissiveRendering Lnet/minecraft/world/level/block/state/BlockBehaviour$StatePredicate;
|
||||
accessible field net/minecraft/world/level/block/state/BlockBehaviour$Properties dynamicShape Z
|
||||
mutable field net/minecraft/world/level/block/state/BlockBehaviour$Properties dynamicShape Z
|
||||
accessible method net/minecraft/world/level/block/state/BlockBehaviour$Properties <init> (Lnet/minecraft/world/level/material/Material;Ljava/util/function/Function;)V
|
||||
accessible method net/minecraft/world/level/block/state/BlockBehaviour$Properties <init> ()V
|
||||
transitive-accessible method net/minecraft/world/entity/player/Player closeContainer ()V
|
||||
transitive-accessible method net/minecraft/advancements/CriteriaTriggers register (Lnet/minecraft/advancements/CriterionTrigger;)Lnet/minecraft/advancements/CriterionTrigger;
|
||||
transitive-accessible method net/minecraft/world/inventory/MenuType <init> (Lnet/minecraft/world/inventory/MenuType$MenuSupplier;Lnet/minecraft/world/flag/FeatureFlagSet;)V
|
||||
@@ -261,8 +257,6 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard GLINT
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard CRUMBLING_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard TRANSLUCENT_TRANSPARENCY Lnet/minecraft/client/renderer/RenderStateShard$TransparencyStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard BLOCK_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NEW_ENTITY_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_LIGHTMAP_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard POSITION_COLOR_TEX_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
@@ -314,6 +308,10 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDE
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_END_PORTAL_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_END_GATEWAY_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_LINES_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GUI_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GUI_OVERLAY_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GUI_TEXT_HIGHLIGHT_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard RENDERTYPE_GUI_GHOST_RECIPE_OVERLAY_SHADER Lnet/minecraft/client/renderer/RenderStateShard$ShaderStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard BLOCK_SHEET_MIPPED Lnet/minecraft/client/renderer/RenderStateShard$TextureStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard BLOCK_SHEET Lnet/minecraft/client/renderer/RenderStateShard$TextureStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_TEXTURE Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;
|
||||
@@ -329,6 +327,7 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_CU
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_DEPTH_TEST Lnet/minecraft/client/renderer/RenderStateShard$DepthTestStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard EQUAL_DEPTH_TEST Lnet/minecraft/client/renderer/RenderStateShard$DepthTestStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard LEQUAL_DEPTH_TEST Lnet/minecraft/client/renderer/RenderStateShard$DepthTestStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard GREATER_DEPTH_TEST Lnet/minecraft/client/renderer/RenderStateShard$DepthTestStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard COLOR_DEPTH_WRITE Lnet/minecraft/client/renderer/RenderStateShard$WriteMaskStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard COLOR_WRITE Lnet/minecraft/client/renderer/RenderStateShard$WriteMaskStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard DEPTH_WRITE Lnet/minecraft/client/renderer/RenderStateShard$WriteMaskStateShard;
|
||||
@@ -343,6 +342,8 @@ transitive-accessible field net/minecraft/client/renderer/RenderStateShard WEATH
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard CLOUDS_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard ITEM_ENTITY_TARGET Lnet/minecraft/client/renderer/RenderStateShard$OutputStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard DEFAULT_LINE Lnet/minecraft/client/renderer/RenderStateShard$LineStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard NO_COLOR_LOGIC Lnet/minecraft/client/renderer/RenderStateShard$ColorLogicStateShard;
|
||||
transitive-accessible field net/minecraft/client/renderer/RenderStateShard OR_REVERSE_COLOR_LOGIC Lnet/minecraft/client/renderer/RenderStateShard$ColorLogicStateShard;
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$TransparencyStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$ShaderStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$TextureStateShard
|
||||
@@ -356,21 +357,22 @@ transitive-accessible class net/minecraft/client/renderer/RenderStateShard$Write
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$LayeringStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$OutputStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$LineStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$ColorLogicStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$OffsetTexturingStateShard
|
||||
transitive-accessible class net/minecraft/client/renderer/RenderStateShard$MultiTextureStateShard
|
||||
|
||||
# CreativeModeTabs fields
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs BUILDING_BLOCKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs COLORED_BLOCKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs NATURAL_BLOCKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs FUNCTIONAL_BLOCKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs REDSTONE_BLOCKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs HOTBAR Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs SEARCH Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs TOOLS_AND_UTILITIES Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs COMBAT Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs FOOD_AND_DRINKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs INGREDIENTS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs SPAWN_EGGS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs OP_BLOCKS Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs INVENTORY Lnet/minecraft/world/item/CreativeModeTab;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs BUILDING_BLOCKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs COLORED_BLOCKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs NATURAL_BLOCKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs FUNCTIONAL_BLOCKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs REDSTONE_BLOCKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs HOTBAR Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs SEARCH Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs TOOLS_AND_UTILITIES Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs COMBAT Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs FOOD_AND_DRINKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs INGREDIENTS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs SPAWN_EGGS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs OP_BLOCKS Lnet/minecraft/resources/ResourceKey;
|
||||
transitive-accessible field net/minecraft/world/item/CreativeModeTabs INVENTORY Lnet/minecraft/resources/ResourceKey;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class EventHandlerImpl {
|
||||
ClientTickEvents.END_WORLD_TICK.register(instance -> ClientTickEvent.CLIENT_LEVEL_POST.invoker().tick(instance));
|
||||
|
||||
ItemTooltipCallback.EVENT.register((itemStack, tooltipFlag, list) -> ClientTooltipEvent.ITEM.invoker().append(itemStack, list, tooltipFlag));
|
||||
HudRenderCallback.EVENT.register((matrices, tickDelta) -> ClientGuiEvent.RENDER_HUD.invoker().renderHud(matrices, tickDelta));
|
||||
HudRenderCallback.EVENT.register((graphics, tickDelta) -> ClientGuiEvent.RENDER_HUD.invoker().renderHud(graphics, tickDelta));
|
||||
}
|
||||
|
||||
public static void registerCommon() {
|
||||
|
||||
@@ -47,6 +47,6 @@ public abstract class MixinFallingBlockEntity extends Entity {
|
||||
target = "Lnet/minecraft/world/level/block/Fallable;onLand(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/item/FallingBlockEntity;)V"),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void handleLand(CallbackInfo ci, Block block, BlockPos blockPos2, boolean bl, boolean bl2, double d, BlockState blockState) {
|
||||
BlockEvent.FALLING_LAND.invoker().onLand(this.level, blockPos2, this.blockState, blockState, (FallingBlockEntity) (Object) this);
|
||||
BlockEvent.FALLING_LAND.invoker().onLand(this.level(), blockPos2, this.blockState, blockState, (FallingBlockEntity) (Object) this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,6 @@ public class MixinServerPlayer {
|
||||
|
||||
@Inject(method = "triggerDimensionChangeTriggers", at = @At("HEAD"))
|
||||
private void changeDimension(ServerLevel serverLevel, CallbackInfo ci) {
|
||||
PlayerEvent.CHANGE_DIMENSION.invoker().change((ServerPlayer) (Object) this, serverLevel.dimension(), ((ServerPlayer) (Object) this).level.dimension());
|
||||
PlayerEvent.CHANGE_DIMENSION.invoker().change((ServerPlayer) (Object) this, serverLevel.dimension(), ((ServerPlayer) (Object) this).level().dimension());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.architectury.event.events.client.ClientGuiEvent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -36,16 +37,16 @@ public abstract class MixinAbstractContainerScreen extends Screen {
|
||||
}
|
||||
|
||||
@Inject(method = "render",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lcom/mojang/blaze3d/vertex/PoseStack;FII)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lnet/minecraft/client/gui/GuiGraphics;FII)V",
|
||||
ordinal = 0, shift = At.Shift.AFTER))
|
||||
public void renderBackground(PoseStack poseStack, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
ClientGuiEvent.RENDER_CONTAINER_BACKGROUND.invoker().render((AbstractContainerScreen<?>) (Object) this, poseStack, mouseX, mouseY, delta);
|
||||
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
ClientGuiEvent.RENDER_CONTAINER_BACKGROUND.invoker().render((AbstractContainerScreen<?>) (Object) this, graphics, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Inject(method = "render",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderLabels(Lcom/mojang/blaze3d/vertex/PoseStack;II)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lnet/minecraft/client/gui/GuiGraphics;FII)V",
|
||||
ordinal = 0, shift = At.Shift.AFTER))
|
||||
public void renderForeground(PoseStack poseStack, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
ClientGuiEvent.RENDER_CONTAINER_FOREGROUND.invoker().render((AbstractContainerScreen<?>) (Object) this, poseStack, mouseX, mouseY, delta);
|
||||
public void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
ClientGuiEvent.RENDER_CONTAINER_FOREGROUND.invoker().render((AbstractContainerScreen<?>) (Object) this, graphics, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.mojang.datafixers.util.Pair;
|
||||
import dev.architectury.event.events.client.ClientGuiEvent;
|
||||
import dev.architectury.event.events.client.ClientReloadShadersEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
@@ -48,19 +49,19 @@ public abstract class MixinGameRenderer {
|
||||
private Minecraft minecraft;
|
||||
|
||||
@Inject(method = "render(FJZ)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lcom/mojang/blaze3d/vertex/PoseStack;IIF)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V",
|
||||
ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION, cancellable = true)
|
||||
public void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, PoseStack matrices, PoseStack matrices2) {
|
||||
if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, matrices2, mouseX, mouseY, minecraft.getDeltaFrameTime()).isFalse()) {
|
||||
public void renderScreenPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, PoseStack matrices, GuiGraphics graphics) {
|
||||
if (ClientGuiEvent.RENDER_PRE.invoker().render(minecraft.screen, graphics, mouseX, mouseY, minecraft.getDeltaFrameTime()).isFalse()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "render(FJZ)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lcom/mojang/blaze3d/vertex/PoseStack;IIF)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltip(Lnet/minecraft/client/gui/GuiGraphics;IIF)V",
|
||||
shift = At.Shift.AFTER, ordinal = 0), locals = LocalCapture.CAPTURE_FAILEXCEPTION)
|
||||
public void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, PoseStack matrices, PoseStack matrices2) {
|
||||
ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, matrices2, mouseX, mouseY, minecraft.getDeltaFrameTime());
|
||||
public void renderScreenPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int mouseX, int mouseY, Window window, Matrix4f matrix, PoseStack matrices, GuiGraphics graphics) {
|
||||
ClientGuiEvent.RENDER_POST.invoker().render(minecraft.screen, graphics, mouseX, mouseY, minecraft.getDeltaFrameTime());
|
||||
}
|
||||
|
||||
@Inject(method = "reloadShaders",
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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.mixin.fabric.client;
|
||||
|
||||
import dev.architectury.event.events.client.ClientTooltipEvent;
|
||||
import dev.architectury.impl.TooltipEventColorContextImpl;
|
||||
import dev.architectury.impl.TooltipEventPositionContextImpl;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(GuiGraphics.class)
|
||||
public abstract class MixinGuiGraphics {
|
||||
@Unique
|
||||
private static ThreadLocal<TooltipEventPositionContextImpl> tooltipPositionContext = ThreadLocal.withInitial(TooltipEventPositionContextImpl::new);
|
||||
@Unique
|
||||
private static ThreadLocal<TooltipEventColorContextImpl> tooltipColorContext = ThreadLocal.withInitial(TooltipEventColorContextImpl::new);
|
||||
|
||||
@Inject(method = "renderTooltip(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;II)V", at = @At("HEAD"))
|
||||
private void preRenderTooltipItem(Font font, ItemStack stack, int x, int y, CallbackInfo ci) {
|
||||
ClientTooltipEvent.additionalContexts().setItem(stack);
|
||||
}
|
||||
|
||||
@Inject(method = "renderTooltip(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;II)V", at = @At("RETURN"))
|
||||
private void postRenderTooltipItem(Font font, ItemStack stack, int x, int y, CallbackInfo ci) {
|
||||
ClientTooltipEvent.additionalContexts().setItem(null);
|
||||
}
|
||||
|
||||
@Inject(method = "renderTooltipInternal", at = @At("HEAD"), cancellable = true)
|
||||
private void renderTooltip(Font font, List<? extends ClientTooltipComponent> list, int x, int y, ClientTooltipPositioner positioner, CallbackInfo ci) {
|
||||
if (!list.isEmpty()) {
|
||||
var colorContext = tooltipColorContext.get();
|
||||
colorContext.reset();
|
||||
var positionContext = tooltipPositionContext.get();
|
||||
positionContext.reset(x, y);
|
||||
if (ClientTooltipEvent.RENDER_PRE.invoker().renderTooltip((GuiGraphics) (Object) this, list, x, y).isFalse()) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
// ClientTooltipEvent.RENDER_MODIFY_COLOR.invoker().renderTooltip((GuiGraphics) (Object) this, x, y, colorContext);
|
||||
ClientTooltipEvent.RENDER_MODIFY_POSITION.invoker().renderTooltip((GuiGraphics) (Object) this, positionContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V",
|
||||
at = @At(value = "HEAD"), ordinal = 0, argsOnly = true)
|
||||
private int modifyTooltipX(int original) {
|
||||
return tooltipPositionContext.get().getTooltipX();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V",
|
||||
at = @At(value = "HEAD"), ordinal = 1, argsOnly = true)
|
||||
private int modifyTooltipY(int original) {
|
||||
return tooltipPositionContext.get().getTooltipY();
|
||||
}
|
||||
|
||||
// @ModifyConstant(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V", constant = @Constant(intValue = 0xf0100010))
|
||||
// private int modifyTooltipBackgroundColor(int original) {
|
||||
// return tooltipColorContext.get().getBackgroundColor();
|
||||
// }
|
||||
//
|
||||
// @ModifyConstant(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V", constant = @Constant(intValue = 0x505000ff))
|
||||
// private int modifyTooltipOutlineGradientTopColor(int original) {
|
||||
// return tooltipColorContext.get().getOutlineGradientTopColor();
|
||||
// }
|
||||
//
|
||||
// @ModifyConstant(method = "renderTooltipInternal(Lnet/minecraft/client/gui/Font;Ljava/util/List;IILnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;)V", constant = @Constant(intValue = 0x5028007f))
|
||||
// private int modifyTooltipOutlineGradientBottomColor(int original) {
|
||||
// return tooltipColorContext.get().getOutlineGradientBottomColor();
|
||||
// }
|
||||
}
|
||||
@@ -19,34 +19,24 @@
|
||||
|
||||
package dev.architectury.mixin.fabric.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.architectury.event.events.client.ClientGuiEvent;
|
||||
import dev.architectury.event.events.client.ClientTooltipEvent;
|
||||
import dev.architectury.hooks.client.screen.ScreenAccess;
|
||||
import dev.architectury.impl.ScreenAccessImpl;
|
||||
import dev.architectury.impl.TooltipEventColorContextImpl;
|
||||
import dev.architectury.impl.TooltipEventPositionContextImpl;
|
||||
import dev.architectury.impl.fabric.ScreenInputDelegate;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(Screen.class)
|
||||
public abstract class MixinScreen implements ScreenInputDelegate {
|
||||
@Unique
|
||||
private static ThreadLocal<TooltipEventPositionContextImpl> tooltipPositionContext = ThreadLocal.withInitial(TooltipEventPositionContextImpl::new);
|
||||
@Unique
|
||||
private static ThreadLocal<TooltipEventColorContextImpl> tooltipColorContext = ThreadLocal.withInitial(TooltipEventColorContextImpl::new);
|
||||
@Unique
|
||||
private ScreenAccessImpl access;
|
||||
|
||||
@@ -85,57 +75,4 @@ public abstract class MixinScreen implements ScreenInputDelegate {
|
||||
private void postInit(Minecraft minecraft, int i, int j, CallbackInfo ci) {
|
||||
ClientGuiEvent.INIT_POST.invoker().init((Screen) (Object) this, getAccess());
|
||||
}
|
||||
|
||||
@Inject(method = "renderTooltip(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;II)V", at = @At("HEAD"))
|
||||
private void preRenderTooltipItem(PoseStack poseStack, ItemStack stack, int x, int y, CallbackInfo ci) {
|
||||
ClientTooltipEvent.additionalContexts().setItem(stack);
|
||||
}
|
||||
|
||||
@Inject(method = "renderTooltip(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/item/ItemStack;II)V", at = @At("RETURN"))
|
||||
private void postRenderTooltipItem(PoseStack poseStack, ItemStack stack, int x, int y, CallbackInfo ci) {
|
||||
ClientTooltipEvent.additionalContexts().setItem(null);
|
||||
}
|
||||
|
||||
@Inject(method = "renderTooltipInternal", at = @At("HEAD"), cancellable = true)
|
||||
private void renderTooltip(PoseStack poseStack, List<? extends ClientTooltipComponent> list, int x, int y, ClientTooltipPositioner positioner, CallbackInfo ci) {
|
||||
if (!list.isEmpty()) {
|
||||
var colorContext = tooltipColorContext.get();
|
||||
colorContext.reset();
|
||||
var positionContext = tooltipPositionContext.get();
|
||||
positionContext.reset(x, y);
|
||||
if (ClientTooltipEvent.RENDER_PRE.invoker().renderTooltip(poseStack, list, x, y).isFalse()) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
// ClientTooltipEvent.RENDER_MODIFY_COLOR.invoker().renderTooltip(poseStack, x, y, colorContext);
|
||||
ClientTooltipEvent.RENDER_MODIFY_POSITION.invoker().renderTooltip(poseStack, positionContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderTooltipInternal",
|
||||
at = @At(value = "HEAD"), ordinal = 0)
|
||||
private int modifyTooltipX(int original) {
|
||||
return tooltipPositionContext.get().getTooltipX();
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "renderTooltipInternal",
|
||||
at = @At(value = "HEAD"), ordinal = 1)
|
||||
private int modifyTooltipY(int original) {
|
||||
return tooltipPositionContext.get().getTooltipY();
|
||||
}
|
||||
|
||||
// @ModifyConstant(method = "renderTooltipInternal", constant = @Constant(intValue = 0xf0100010))
|
||||
// private int modifyTooltipBackgroundColor(int original) {
|
||||
// return tooltipColorContext.get().getBackgroundColor();
|
||||
// }
|
||||
|
||||
// @ModifyConstant(method = "renderTooltipInternal", constant = @Constant(intValue = 0x505000ff))
|
||||
// private int modifyTooltipOutlineGradientTopColor(int original) {
|
||||
// return tooltipColorContext.get().getOutlineGradientTopColor();
|
||||
// }
|
||||
|
||||
// @ModifyConstant(method = "renderTooltipInternal", constant = @Constant(intValue = 0x5028007f))
|
||||
// private int modifyTooltipOutlineGradientBottomColor(int original) {
|
||||
// return tooltipColorContext.get().getOutlineGradientBottomColor();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SpawnEntityPacket {
|
||||
private static final ResourceLocation PACKET_ID = new ResourceLocation("architectury", "spawn_entity_packet");
|
||||
|
||||
public static Packet<ClientGamePacketListener> create(Entity entity) {
|
||||
if (entity.level.isClientSide()) {
|
||||
if (entity.level().isClientSide()) {
|
||||
throw new IllegalStateException("SpawnPacketUtil.create called on the logical client!");
|
||||
}
|
||||
var buffer = PacketByteBufs.create();
|
||||
|
||||
@@ -23,53 +23,46 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import dev.architectury.registry.CreativeTabOutput;
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.CreativeTabRegistry.TabSupplier;
|
||||
import dev.architectury.registry.registries.DeferredSupplier;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CreativeTabRegistryImpl {
|
||||
private static final Multimap<CreativeModeTab, Supplier<ItemStack>> APPENDS = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
private static final Multimap<ResourceLocation, Supplier<ItemStack>> APPENDS = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier create(ResourceLocation name, Consumer<CreativeModeTab.Builder> callback) {
|
||||
CreativeModeTab.Builder builder = FabricItemGroup.builder(name);
|
||||
public static CreativeModeTab create(Consumer<CreativeModeTab.Builder> callback) {
|
||||
CreativeModeTab.Builder builder = FabricItemGroup.builder();
|
||||
callback.accept(builder);
|
||||
CreativeModeTab tab = builder.build();
|
||||
return new TabSupplier() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab get() {
|
||||
return tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresent() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier of(CreativeModeTab tab) {
|
||||
return new TabSupplier() {
|
||||
public static DeferredSupplier<CreativeModeTab> ofBuiltin(CreativeModeTab tab) {
|
||||
ResourceLocation key = BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab);
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Builtin tab %s is not registered!".formatted(tab));
|
||||
}
|
||||
return new DeferredSupplier<>() {
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return tab.getId();
|
||||
public ResourceLocation getRegistryId() {
|
||||
return Registries.CREATIVE_MODE_TAB.location();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,13 +78,18 @@ public class CreativeTabRegistryImpl {
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier defer(ResourceLocation name) {
|
||||
return new TabSupplier() {
|
||||
public static DeferredSupplier<CreativeModeTab> defer(ResourceLocation name) {
|
||||
return new DeferredSupplier<>() {
|
||||
@Nullable
|
||||
private CreativeModeTab tab;
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
public ResourceLocation getRegistryId() {
|
||||
return Registries.CREATIVE_MODE_TAB.location();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -111,12 +109,7 @@ public class CreativeTabRegistryImpl {
|
||||
|
||||
private void resolve() {
|
||||
if (this.tab == null) {
|
||||
for (CreativeModeTab tab : CreativeModeTabs.allTabs()) {
|
||||
if (Objects.equals(tab.getId(), name)) {
|
||||
this.tab = tab;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.tab = BuiltInRegistries.CREATIVE_MODE_TAB.get(name);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -124,12 +117,12 @@ public class CreativeTabRegistryImpl {
|
||||
|
||||
static {
|
||||
ItemGroupEvents.MODIFY_ENTRIES_ALL.register((tab, output) -> {
|
||||
APPENDS.get(tab).forEach(s -> output.accept(s.get()));
|
||||
APPENDS.get(BuiltInRegistries.CREATIVE_MODE_TAB.getKey(tab)).forEach(s -> output.accept(s.get()));
|
||||
});
|
||||
}
|
||||
|
||||
public static void modify(TabSupplier tab, CreativeTabRegistry.ModifyTabCallback filler) {
|
||||
ItemGroupEvents.modifyEntriesEvent(tab.get()).register(entries -> {
|
||||
public static void modify(DeferredSupplier<CreativeModeTab> tab, CreativeTabRegistry.ModifyTabCallback filler) {
|
||||
ItemGroupEvents.modifyEntriesEvent(tab.getKey()).register(entries -> {
|
||||
filler.accept(entries.getEnabledFeatures(), new CreativeTabOutput() {
|
||||
@Override
|
||||
public void acceptAfter(ItemStack after, ItemStack stack, CreativeModeTab.TabVisibility visibility) {
|
||||
@@ -153,7 +146,7 @@ public class CreativeTabRegistryImpl {
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static void appendStack(TabSupplier tab, Supplier<ItemStack> item) {
|
||||
APPENDS.put(tab.get(), item);
|
||||
public static void appendStack(DeferredSupplier<CreativeModeTab> tab, Supplier<ItemStack> item) {
|
||||
APPENDS.put(tab.getId(), item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"client.MixinDebugScreenOverlay",
|
||||
"client.MixinEffectInstance",
|
||||
"client.MixinGameRenderer",
|
||||
"client.MixinGuiGraphics",
|
||||
"client.MixinIntegratedServer",
|
||||
"client.MixinKeyboardHandler",
|
||||
"client.MixinMinecraft",
|
||||
|
||||
@@ -130,7 +130,7 @@ public class CreativeTabRegistryImpl {
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public static TabSupplier of(CreativeModeTab tab) {
|
||||
public static TabSupplier ofBuiltin(CreativeModeTab tab) {
|
||||
ResourceLocation location = CreativeModeTabRegistry.getName(tab);
|
||||
if (location == null) {
|
||||
throw new IllegalArgumentException("Tab %s is not registered!".formatted(tab));
|
||||
|
||||
@@ -3,8 +3,8 @@ org.gradle.daemon=false
|
||||
|
||||
platforms=fabric
|
||||
|
||||
minecraft_version=23w13a
|
||||
supported_version=23w13a
|
||||
minecraft_version=23w18a
|
||||
supported_version=23w18a
|
||||
|
||||
artifact_type=beta
|
||||
|
||||
@@ -14,7 +14,7 @@ base_version=9.0
|
||||
maven_group=dev.architectury
|
||||
|
||||
fabric_loader_version=0.14.19
|
||||
fabric_api_version=0.76.2+1.20
|
||||
fabric_api_version=0.80.1+1.20
|
||||
mod_menu_version=5.0.2
|
||||
|
||||
forge_version=45.0.24
|
||||
|
||||
@@ -21,14 +21,13 @@ package dev.architectury.test.debug.client;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import dev.architectury.event.events.client.ClientGuiEvent;
|
||||
import dev.architectury.test.debug.ConsoleMessageSink;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
@@ -40,10 +39,10 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink {
|
||||
private final List<Message> messages = Collections.synchronizedList(Lists.newArrayList());
|
||||
|
||||
public ClientOverlayMessageSink() {
|
||||
ClientGuiEvent.RENDER_POST.register((screen, matrices, mouseX, mouseY, delta) -> render(matrices, delta));
|
||||
ClientGuiEvent.RENDER_HUD.register((matrices, tickDelta) -> {
|
||||
ClientGuiEvent.RENDER_POST.register((screen, graphics, mouseX, mouseY, delta) -> render(graphics, delta));
|
||||
ClientGuiEvent.RENDER_HUD.register((graphics, tickDelta) -> {
|
||||
if (Minecraft.getInstance().screen == null && !Minecraft.getInstance().options.renderDebug) {
|
||||
render(matrices, tickDelta);
|
||||
render(graphics, tickDelta);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -54,9 +53,9 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink {
|
||||
messages.add(0, new Message(Component.literal(message), Util.getMillis()));
|
||||
}
|
||||
|
||||
public void render(PoseStack matrices, float delta) {
|
||||
matrices.pushPose();
|
||||
matrices.scale(0.5f, 0.5f, 1f);
|
||||
public void render(GuiGraphics graphics, float delta) {
|
||||
graphics.pose().pushPose();
|
||||
graphics.pose().scale(0.5f, 0.5f, 1f);
|
||||
var minecraft = Minecraft.getInstance();
|
||||
var currentMills = Util.getMillis();
|
||||
var lineHeight = minecraft.font.lineHeight;
|
||||
@@ -77,8 +76,8 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink {
|
||||
if (y - 1 < minecraft.getWindow().getGuiScaledHeight()) {
|
||||
var textWidth = minecraft.font.width(message.text);
|
||||
var alpha = (int) Mth.clamp((5000 - timeExisted) / 5000f * 400f + 8, 0, 255);
|
||||
GuiComponent.fill(matrices, 0, y - 1, 2 + textWidth + 1, y + lineHeight - 1, 0x505050 + ((alpha * 144 / 255) << 24));
|
||||
minecraft.font.draw(matrices, message.text, 1, y, 0xE0E0E0 + (alpha << 24));
|
||||
graphics.fill(0, y - 1, 2 + textWidth + 1, y + lineHeight - 1, 0x505050 + ((alpha * 144 / 255) << 24));
|
||||
graphics.drawString(minecraft.font, message.text, 1, y, 0xE0E0E0 + (alpha << 24));
|
||||
}
|
||||
y += lineHeight;
|
||||
}
|
||||
@@ -86,7 +85,7 @@ public class ClientOverlayMessageSink extends ConsoleMessageSink {
|
||||
}
|
||||
|
||||
RenderSystem.disableBlend();
|
||||
matrices.popPose();
|
||||
graphics.pose().popPose();
|
||||
}
|
||||
|
||||
private record Message(Component text, long created) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class DebugEvents {
|
||||
|
||||
public static void debugEvents() {
|
||||
BlockEvent.BREAK.register((world, pos, state, player, xp) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " breaks " + toShortString(pos) + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " breaks " + toShortString(pos) + logSide(player.level()));
|
||||
return EventResult.pass();
|
||||
});
|
||||
BlockEvent.PLACE.register((world, pos, state, placer) -> {
|
||||
@@ -80,13 +80,13 @@ public class DebugEvents {
|
||||
});
|
||||
EntityEvent.LIVING_DEATH.register((entity, source) -> {
|
||||
if (entity instanceof Player) {
|
||||
TestMod.SINK.accept(entity.getScoreboardName() + " died to " + source.getMsgId() + logSide(entity.level));
|
||||
TestMod.SINK.accept(entity.getScoreboardName() + " died to " + source.getMsgId() + logSide(entity.level()));
|
||||
}
|
||||
return EventResult.pass();
|
||||
});
|
||||
EntityEvent.LIVING_HURT.register((entity, source, amount) -> {
|
||||
if (source.getDirectEntity() instanceof Player) {
|
||||
TestMod.SINK.accept(source.getDirectEntity().getScoreboardName() + " deals %.2f damage" + logSide(entity.level), amount);
|
||||
TestMod.SINK.accept(source.getDirectEntity().getScoreboardName() + " deals %.2f damage" + logSide(entity.level()), amount);
|
||||
}
|
||||
return EventResult.pass();
|
||||
});
|
||||
@@ -131,19 +131,19 @@ public class DebugEvents {
|
||||
TestMod.SINK.accept(world.dimension().location() + " explodes at " + toShortString(ExplosionHooks.getPosition(explosion)) + logSide(world));
|
||||
});
|
||||
InteractionEvent.LEFT_CLICK_BLOCK.register((player, hand, pos, face) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " left clicks " + toShortString(pos) + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " left clicks " + toShortString(pos) + logSide(player.level()));
|
||||
return EventResult.pass();
|
||||
});
|
||||
InteractionEvent.RIGHT_CLICK_BLOCK.register((player, hand, pos, face) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " right clicks " + toShortString(pos) + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " right clicks " + toShortString(pos) + logSide(player.level()));
|
||||
return EventResult.pass();
|
||||
});
|
||||
InteractionEvent.RIGHT_CLICK_ITEM.register((player, hand) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " uses " + (hand == InteractionHand.MAIN_HAND ? "main hand" : "off hand") + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " uses " + (hand == InteractionHand.MAIN_HAND ? "main hand" : "off hand") + logSide(player.level()));
|
||||
return CompoundEventResult.pass();
|
||||
});
|
||||
InteractionEvent.INTERACT_ENTITY.register((player, entity, hand) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " interacts with " + entity.getScoreboardName() + " using " + (hand == InteractionHand.MAIN_HAND ? "main hand" : "off hand") + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " interacts with " + entity.getScoreboardName() + " using " + (hand == InteractionHand.MAIN_HAND ? "main hand" : "off hand") + logSide(player.level()));
|
||||
return EventResult.pass();
|
||||
});
|
||||
InteractionEvent.FARMLAND_TRAMPLE.register((level, pos, state, distance, entity) -> {
|
||||
@@ -178,43 +178,43 @@ public class DebugEvents {
|
||||
TestMod.SINK.accept("Server world saved: " + instance.dimension().location());
|
||||
});
|
||||
PlayerEvent.PLAYER_JOIN.register(player -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " joined" + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " joined" + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.PLAYER_QUIT.register(player -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " quit" + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " quit" + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.PLAYER_RESPAWN.register((player, conqueredEnd) -> {
|
||||
if (!conqueredEnd) {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " respawns " + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " respawns " + logSide(player.level()));
|
||||
}
|
||||
});
|
||||
PlayerEvent.PLAYER_CLONE.register((oldPlayer, newPlayer, wonGame) -> {
|
||||
TestMod.SINK.accept("Player cloned: " + newPlayer.getScoreboardName() + logSide(newPlayer.level));
|
||||
TestMod.SINK.accept("Player cloned: " + newPlayer.getScoreboardName() + logSide(newPlayer.level()));
|
||||
});
|
||||
PlayerEvent.PLAYER_ADVANCEMENT.register((player, advancement) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " was awarded with %s" + logSide(player.level), advancement.getChatComponent().getString());
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " was awarded with %s" + logSide(player.level()), advancement.getChatComponent().getString());
|
||||
});
|
||||
PlayerEvent.CRAFT_ITEM.register((player, constructed, inventory) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " crafts " + Component.translatable(constructed.getDescriptionId()).getString() + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " crafts " + Component.translatable(constructed.getDescriptionId()).getString() + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.SMELT_ITEM.register((player, smelted) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " smelts " + Component.translatable(smelted.getDescriptionId()).getString() + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " smelts " + Component.translatable(smelted.getDescriptionId()).getString() + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.PICKUP_ITEM_POST.register((player, entity, stack) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " picks up " + Component.translatable(stack.getDescriptionId()).getString() + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " picks up " + Component.translatable(stack.getDescriptionId()).getString() + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.DROP_ITEM.register((player, entity) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " drops " + Component.translatable(entity.getItem().getDescriptionId()).getString() + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " drops " + Component.translatable(entity.getItem().getDescriptionId()).getString() + logSide(player.level()));
|
||||
return EventResult.pass();
|
||||
});
|
||||
PlayerEvent.OPEN_MENU.register((player, menu) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " opens " + toSimpleName(menu) + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " opens " + toSimpleName(menu) + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.CLOSE_MENU.register((player, menu) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " closes " + toSimpleName(menu) + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " closes " + toSimpleName(menu) + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.CHANGE_DIMENSION.register((player, oldLevel, newLevel) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " switched from " + oldLevel.location() + " to " + newLevel.location() + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " switched from " + oldLevel.location() + " to " + newLevel.location() + logSide(player.level()));
|
||||
});
|
||||
PlayerEvent.FILL_BUCKET.register(((player, level, stack, target) -> {
|
||||
TestMod.SINK.accept("%s used a bucket (%s) in %s%s while looking at %s", player.getScoreboardName(), stack, level.dimension().location(), logSide(level), target == null ? "nothing" : target.getLocation());
|
||||
@@ -291,10 +291,10 @@ public class DebugEvents {
|
||||
return EventResult.pass();
|
||||
});
|
||||
InteractionEvent.CLIENT_LEFT_CLICK_AIR.register((player, hand) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " left clicks air" + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " left clicks air" + logSide(player.level()));
|
||||
});
|
||||
InteractionEvent.CLIENT_RIGHT_CLICK_AIR.register((player, hand) -> {
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " right clicks air" + logSide(player.level));
|
||||
TestMod.SINK.accept(player.getScoreboardName() + " right clicks air" + logSide(player.level()));
|
||||
});
|
||||
ClientRecipeUpdateEvent.EVENT.register(recipeManager -> {
|
||||
TestMod.SINK.accept("Client recipes received");
|
||||
|
||||
@@ -25,6 +25,7 @@ import dev.architectury.core.item.ArchitecturySpawnEggItem;
|
||||
import dev.architectury.hooks.item.food.FoodPropertiesHooks;
|
||||
import dev.architectury.hooks.level.entity.EntityHooks;
|
||||
import dev.architectury.platform.Platform;
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.level.entity.EntityAttributeRegistry;
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.Registrar;
|
||||
@@ -34,9 +35,9 @@ import dev.architectury.test.TestMod;
|
||||
import dev.architectury.test.entity.TestEntity;
|
||||
import dev.architectury.test.recipes.TestRecipeSerializer;
|
||||
import dev.architectury.test.registry.objects.EquippableTickingItem;
|
||||
import dev.architectury.test.tab.TestCreativeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
@@ -44,7 +45,9 @@ import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.CustomRecipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
@@ -60,7 +63,6 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static dev.architectury.test.TestMod.SINK;
|
||||
@@ -74,13 +76,10 @@ public class TestRegistries {
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Objects.requireNonNull(TestCreativeTabs.TEST_TAB);
|
||||
}
|
||||
|
||||
public static final Registrar<TestInt> INTS = RegistrarManager.get(TestMod.MOD_ID).<TestInt>builder(new ResourceLocation(TestMod.MOD_ID, "ints"))
|
||||
.syncToClients()
|
||||
.build();
|
||||
public static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(TestMod.MOD_ID, Registries.CREATIVE_MODE_TAB);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(TestMod.MOD_ID, Registries.ITEM);
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(TestMod.MOD_ID, Registries.BLOCK);
|
||||
public static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(TestMod.MOD_ID, Registries.FLUID);
|
||||
@@ -89,6 +88,10 @@ public class TestRegistries {
|
||||
public static final DeferredRegister<RecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(TestMod.MOD_ID, Registries.RECIPE_SERIALIZER);
|
||||
public static final DeferredRegister<RecipeType<?>> RECIPE_TYPES = DeferredRegister.create(TestMod.MOD_ID, Registries.RECIPE_TYPE);
|
||||
|
||||
public static final RegistrySupplier<CreativeModeTab> TEST_TAB = TABS.register("test_tab", () ->
|
||||
CreativeTabRegistry.create(Component.translatable("category.architectury_test"),
|
||||
() -> new ItemStack(TestRegistries.TEST_ITEM.get())));
|
||||
|
||||
public static final ArchitecturyFluidAttributes TEST_FLUID_ATTRIBUTES = SimpleArchitecturyFluidAttributes.ofSupplier(() -> TestRegistries.TEST_FLUID_FLOWING, () -> TestRegistries.TEST_FLUID)
|
||||
.convertToSource(true)
|
||||
.flowingTexture(new ResourceLocation("block/water_flow"))
|
||||
@@ -105,27 +108,27 @@ public class TestRegistries {
|
||||
});
|
||||
|
||||
public static final RegistrySupplier<Item> TEST_ITEM = ITEMS.register("test_item", () ->
|
||||
new Item(new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
|
||||
new Item(new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> TEST_EQUIPPABLE = ITEMS.register("test_eqippable", () ->
|
||||
new EquippableTickingItem(new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
|
||||
new EquippableTickingItem(new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> TEST_EDIBLE = ITEMS.register("test_edible", () -> {
|
||||
FoodProperties.Builder fpBuilder = new FoodProperties.Builder().nutrition(8).saturationMod(0.8F).meat();
|
||||
FoodPropertiesHooks.effect(fpBuilder, () -> new MobEffectInstance(TEST_EFFECT.get(), 100), 1);
|
||||
return new Item(new Item.Properties().food(fpBuilder.build()).arch$tab(TestCreativeTabs.TEST_TAB));
|
||||
return new Item(new Item.Properties().food(fpBuilder.build()).arch$tab(TestRegistries.TEST_TAB));
|
||||
});
|
||||
public static final RegistrySupplier<Item> TEST_SPAWN_EGG = ITEMS.register("test_spawn_egg", () ->
|
||||
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY, 0xFF000000, 0xFFFFFFFF,
|
||||
new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
|
||||
new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> TEST_SPAWN_EGG_2 = ITEMS.register("test_spawn_egg_2", () ->
|
||||
new ArchitecturySpawnEggItem(TestRegistries.TEST_ENTITY_2, 0xFFFFFFFF, 0xFF000000,
|
||||
new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
|
||||
new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
|
||||
public static final RegistrySupplier<Item> TEST_FLUID_BUCKET = ITEMS.register("test_fluid_bucket", () -> {
|
||||
try {
|
||||
// In example mod the forge class isn't being replaced, this is not required in mods depending on architectury
|
||||
return (Item) Class.forName(!Platform.isForge() ? "dev.architectury.core.item.ArchitecturyBucketItem" : "dev.architectury.core.item.forge.imitator.ArchitecturyBucketItem")
|
||||
.getDeclaredConstructor(Supplier.class, Item.Properties.class)
|
||||
.newInstance(TestRegistries.TEST_FLUID, new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB));
|
||||
.newInstance(TestRegistries.TEST_FLUID, new Item.Properties().arch$tab(TestRegistries.TEST_TAB));
|
||||
} catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException |
|
||||
IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -180,9 +183,9 @@ public class TestRegistries {
|
||||
});
|
||||
|
||||
public static final RegistrySupplier<Item> TEST_BLOCK_ITEM = ITEMS.register("test_block", () ->
|
||||
new BlockItem(TEST_BLOCK.get(), new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
|
||||
new BlockItem(TEST_BLOCK.get(), new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
public static final RegistrySupplier<Item> COLLISION_BLOCK_ITEM = ITEMS.register("collision_block", () ->
|
||||
new BlockItem(COLLISION_BLOCK.get(), new Item.Properties().arch$tab(TestCreativeTabs.TEST_TAB)));
|
||||
new BlockItem(COLLISION_BLOCK.get(), new Item.Properties().arch$tab(TestRegistries.TEST_TAB)));
|
||||
|
||||
public static final RegistrySupplier<EntityType<TestEntity>> TEST_ENTITY = ENTITY_TYPES.register("test_entity", TestEntity.TYPE);
|
||||
public static final RegistrySupplier<EntityType<TestEntity>> TEST_ENTITY_2 = ENTITY_TYPES.register("test_entity_2", TestEntity.TYPE_2);
|
||||
@@ -197,6 +200,7 @@ public class TestRegistries {
|
||||
});
|
||||
|
||||
public static void initialize() {
|
||||
TABS.register();
|
||||
MOB_EFFECTS.register();
|
||||
FLUIDS.register();
|
||||
BLOCKS.register();
|
||||
|
||||
Reference in New Issue
Block a user