mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Add cancellable ToastAddEvent (#8952)
This commit is contained in:
1 parent
a4f52f4057
commit
6b45999702
3 files changed
+55
No files matched your search
@@ -27,6 +27,7 @@ import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraft.client.gui.components.toasts.Toast;
|
||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
@@ -128,6 +129,7 @@ import net.minecraftforge.client.event.RenderTooltipEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.client.event.ScreenshotEvent;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.event.ToastAddEvent;
|
||||
import net.minecraftforge.client.event.ViewportEvent;
|
||||
import net.minecraftforge.client.event.sound.PlaySoundEvent;
|
||||
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
||||
@@ -1098,6 +1100,11 @@ public class ForgeHooksClient
|
||||
return event;
|
||||
}
|
||||
|
||||
public static boolean onToastAdd(Toast toast)
|
||||
{
|
||||
return MinecraftForge.EVENT_BUS.post(new ToastAddEvent(toast));
|
||||
}
|
||||
|
||||
public static boolean isBlockInSolidLayer(BlockState state)
|
||||
{
|
||||
var model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.gui.components.toasts.Toast;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when the client queues a {@link Toast} message to be shown onscreen.
|
||||
* Toasts are small popups that appear on the top right of the screen, for certain actions such as unlocking Advancements and Recipes.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* Cancelling the event stops the toast from being queued, which means it never renders.</p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class ToastAddEvent extends Event
|
||||
{
|
||||
private final Toast toast;
|
||||
|
||||
public ToastAddEvent(Toast toast)
|
||||
{
|
||||
this.toast = toast;
|
||||
}
|
||||
|
||||
public Toast getToast()
|
||||
{
|
||||
return toast;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user