mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 23:45:44 +00:00
Forge 1.19
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -6,48 +6,58 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* ClientChatEvent is fired whenever the client is about to send a chat message or command to the server. <br>
|
||||
* This event is fired via {@link ForgeEventFactory#onClientSendMessage(String)},
|
||||
* which is executed by {@link Screen#sendMessage(String, boolean)}<br>
|
||||
* <br>
|
||||
* {@link #message} contains the message that will be sent to the server. This can be changed by mods.<br>
|
||||
* {@link #originalMessage} contains the original message that was going to be sent to the server. This cannot be changed by mods.<br>
|
||||
* <br>
|
||||
* This event is {@link Cancelable}. <br>
|
||||
* If this event is canceled, the chat message or command is never sent to the server.<br>
|
||||
* <br>
|
||||
* This event does not have a result. {@link HasResult}<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
* Fired when the client is about to send a chat message to the server.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the chat message or command will not be sent to the server. </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 ClientChatEvent extends Event
|
||||
{
|
||||
private String message;
|
||||
private final String originalMessage;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeEventFactory#onClientSendMessage(String)
|
||||
*/
|
||||
public ClientChatEvent(String message)
|
||||
{
|
||||
this.setMessage(message);
|
||||
this.originalMessage = Strings.nullToEmpty(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the message that will be sent to the server, if the event is not cancelled}
|
||||
*/
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new message to be sent to the server, if the event is not cancelled.
|
||||
*
|
||||
* @param message the new message to be sent
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = Strings.nullToEmpty(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original message that was to be sent to the server}
|
||||
*/
|
||||
public String getOriginalMessage()
|
||||
{
|
||||
return originalMessage;
|
||||
|
||||
@@ -5,56 +5,79 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.network.chat.ChatSender;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired on the client when a chat message is received.<br>
|
||||
* If this event is cancelled, the message is not displayed in the chat message window.<br>
|
||||
* Fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
|
||||
* Fired when a chat message is received on the client.
|
||||
* This can be used for filtering and detecting messages with specific words or phrases, and suppressing them.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, the message is not displayed in the chat message window. </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>
|
||||
*
|
||||
* @see ChatType
|
||||
*/
|
||||
@Cancelable
|
||||
public class ClientChatReceivedEvent extends Event
|
||||
{
|
||||
private Component message;
|
||||
private final ChatType type;
|
||||
@Nullable
|
||||
private final UUID senderUUID;
|
||||
private final ChatSender chatSender;
|
||||
|
||||
public ClientChatReceivedEvent(ChatType type, Component message, @Nullable UUID senderUUID)
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeEventFactory#onClientChat(ChatType, Component, ChatSender)
|
||||
*/
|
||||
public ClientChatReceivedEvent(ChatType type, Component message, ChatSender chatSender)
|
||||
{
|
||||
this.type = type;
|
||||
this.message = message;
|
||||
this.senderUUID = senderUUID;
|
||||
this.chatSender = chatSender;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the message that will be displayed in the chat message window, if the event is not cancelled}
|
||||
*/
|
||||
public Component getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new message to be displayed in the chat message window, if the event is not cancelled.
|
||||
*
|
||||
* @param message the new message to be sent
|
||||
*/
|
||||
public void setMessage(Component message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the type of the chat message}
|
||||
*/
|
||||
public ChatType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* The UUID of the player or entity that sent this message, or null if not known.
|
||||
* This will be equal to {@link net.minecraft.Util#NIL_UUID} for system messages.
|
||||
* {@return the sender of this chat message} This contains the UUID, name, and (optionally) the team name of the
|
||||
* entity which sent the chat message. For system messages, {@link ChatSender#uuid()} will be equal to
|
||||
* {@link Util#NIL_UUID}.
|
||||
*/
|
||||
@Nullable
|
||||
public UUID getSenderUUID()
|
||||
public ChatSender getChatSender()
|
||||
{
|
||||
return senderUUID;
|
||||
return chatSender;
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,19 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.multiplayer.PlayerInfo;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired before the client player is notified of a change in game mode from the server.
|
||||
* Fired when the client player is notified of a change of {@link GameType} from the server.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public class ClientPlayerChangeGameTypeEvent extends Event
|
||||
{
|
||||
@@ -18,6 +27,10 @@ public class ClientPlayerChangeGameTypeEvent extends Event
|
||||
private final GameType currentGameType;
|
||||
private final GameType newGameType;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onClientChangeGameType(PlayerInfo, GameType, GameType)
|
||||
*/
|
||||
public ClientPlayerChangeGameTypeEvent(PlayerInfo info, GameType currentGameType, GameType newGameType)
|
||||
{
|
||||
this.info = info;
|
||||
@@ -25,16 +38,25 @@ public class ClientPlayerChangeGameTypeEvent extends Event
|
||||
this.newGameType = newGameType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the client player information}
|
||||
*/
|
||||
public PlayerInfo getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the current game type of the player}
|
||||
*/
|
||||
public GameType getCurrentGameType()
|
||||
{
|
||||
return currentGameType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the new game type of the player}
|
||||
*/
|
||||
public GameType getNewGameType()
|
||||
{
|
||||
return newGameType;
|
||||
|
||||
@@ -8,42 +8,53 @@ package net.minecraftforge.client.event;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Client side player connectivity events.
|
||||
*/
|
||||
* Fired for different client connectivity events.
|
||||
* See the various subclasses to listen for specific events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ClientPlayerNetworkEvent.LoggedInEvent
|
||||
* @see ClientPlayerNetworkEvent.LoggedOutEvent
|
||||
* @see ClientPlayerNetworkEvent.RespawnEvent
|
||||
**/
|
||||
public class ClientPlayerNetworkEvent extends Event {
|
||||
private final MultiPlayerGameMode multiPlayerGameMode;
|
||||
private final LocalPlayer player;
|
||||
private final Connection connection;
|
||||
|
||||
/**
|
||||
* @return the player controller for the client side
|
||||
* {@return the multiplayer game mode controller for the player}
|
||||
*/
|
||||
@Nullable
|
||||
public MultiPlayerGameMode getMultiPlayerGameMode() {
|
||||
return multiPlayerGameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the player instance (if present - may be null)
|
||||
* {@return the player instance}
|
||||
*/
|
||||
@Nullable
|
||||
public LocalPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the impl connection (if present - may be null)
|
||||
* {@return the network connection for the player}
|
||||
*/
|
||||
@Nullable
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
ClientPlayerNetworkEvent(final MultiPlayerGameMode multiPlayerGameMode, final LocalPlayer player, final Connection connection) {
|
||||
this.multiPlayerGameMode = multiPlayerGameMode;
|
||||
this.player = player;
|
||||
@@ -52,41 +63,121 @@ public class ClientPlayerNetworkEvent extends Event {
|
||||
|
||||
/**
|
||||
* Fired when the client player logs in to the server. The player should be initialized.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class LoggedInEvent extends ClientPlayerNetworkEvent {
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#firePlayerLogin(MultiPlayerGameMode, LocalPlayer, Connection)
|
||||
*/
|
||||
public LoggedInEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
super(controller, player, networkManager);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the player logs out. Note this might also fire when a new integrated server is being created.
|
||||
* Fired when the client player logs out. This event may also fire when a new integrated server is being created.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems") // Shush IntelliJ, we override non-nullables as nullables in this specific event; see later comment
|
||||
public static class LoggedOutEvent extends ClientPlayerNetworkEvent {
|
||||
|
||||
public LoggedOutEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#firePlayerLogout(MultiPlayerGameMode, LocalPlayer)
|
||||
*/
|
||||
public LoggedOutEvent(@Nullable final MultiPlayerGameMode controller, @Nullable final LocalPlayer player, @Nullable final Connection networkManager) {
|
||||
//noinspection ConstantConditions we know these are nullable, but we don't want to annotate the super as nullable since this is the only event with nullables
|
||||
super(controller, player, networkManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the multiplayer game mode controller for the player, may be {@code null}}. This may be {@code null}
|
||||
* in certain situations such as the creating a new integrated server (singleplayer world) or connecting to
|
||||
* a multiplayer server.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public MultiPlayerGameMode getMultiPlayerGameMode()
|
||||
{
|
||||
return super.getMultiPlayerGameMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the player instance, may be {@code null}}. This may be {@code null}
|
||||
* in certain situations such as the creating a new integrated server (singleplayer world) or connecting to
|
||||
* a multiplayer server.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public LocalPlayer getPlayer()
|
||||
{
|
||||
return super.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the network connection for the player, may be {@code null}}. This may be {@code null}
|
||||
* in certain situations such as the creating a new integrated server (singleplayer world) or connecting to
|
||||
* a multiplayer server.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public Connection getConnection()
|
||||
{
|
||||
return super.getConnection();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the player object respawns, such as dimension changes.
|
||||
* Fired when the client player respawns, creating a new player instance to replace the old player instance.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class RespawnEvent extends ClientPlayerNetworkEvent {
|
||||
private final LocalPlayer oldPlayer;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#firePlayerRespawn(MultiPlayerGameMode, LocalPlayer, LocalPlayer, Connection)
|
||||
*/
|
||||
public RespawnEvent(final MultiPlayerGameMode pc, final LocalPlayer oldPlayer, final LocalPlayer newPlayer, final Connection networkManager) {
|
||||
super(pc, newPlayer, networkManager);
|
||||
this.oldPlayer = oldPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the previous player instance}
|
||||
*/
|
||||
public LocalPlayer getOldPlayer() {
|
||||
return oldPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the newly created player instance}
|
||||
*/
|
||||
public LocalPlayer getNewPlayer() {
|
||||
return super.getPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the newly created player instance}
|
||||
* @see #getNewPlayer()
|
||||
*/
|
||||
@Override
|
||||
public LocalPlayer getPlayer() {
|
||||
return super.getPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,48 +5,107 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Use these events to register block/item
|
||||
* color handlers at the appropriate time.
|
||||
* Fired for registering block and item color handlers at the appropriate time.
|
||||
* See the two subclasses for registering block or item color handlers.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ColorHandlerEvent.Block
|
||||
* @see ColorHandlerEvent.Item
|
||||
*/
|
||||
public abstract class ColorHandlerEvent extends Event implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden This should only be invoked by subclasses.
|
||||
*/
|
||||
public ColorHandlerEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for registering block color handlers.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class Block extends ColorHandlerEvent
|
||||
{
|
||||
private final BlockColors blockColors;
|
||||
|
||||
/**
|
||||
* @hidden This should only be invoked by the client hook.
|
||||
* @see ForgeHooksClient#onBlockColorsInit(BlockColors)
|
||||
*/
|
||||
public Block(BlockColors blockColors)
|
||||
{
|
||||
this.blockColors = blockColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block colors registry}
|
||||
* @see BlockColors#register(BlockColor, net.minecraft.world.level.block.Block...)
|
||||
*/
|
||||
public BlockColors getBlockColors()
|
||||
{
|
||||
return blockColors;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for registering item color handlers.
|
||||
*
|
||||
* <p>The block colors should only be used for referencing or delegating item colors to their respective block
|
||||
* colors. Use {@link ColorHandlerEvent.Block} for registering your block color handlers. </p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class Item extends ColorHandlerEvent
|
||||
{
|
||||
private final ItemColors itemColors;
|
||||
private final BlockColors blockColors;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onItemColorsInit(ItemColors, BlockColors)
|
||||
*/
|
||||
public Item(ItemColors itemColors, BlockColors blockColors)
|
||||
{
|
||||
this.itemColors = itemColors;
|
||||
this.blockColors = blockColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the item colors registry}
|
||||
* @see ItemColors#register(ItemColor, ItemLike...)
|
||||
*/
|
||||
public ItemColors getItemColors()
|
||||
{
|
||||
return itemColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block colors registry}
|
||||
* This should only be used for referencing or delegating item colors to their respective block colors.
|
||||
*/
|
||||
public BlockColors getBlockColors()
|
||||
{
|
||||
return blockColors;
|
||||
|
||||
@@ -7,31 +7,53 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Event class for handling GuiContainer specific events.
|
||||
* Fired for hooking into {@link AbstractContainerScreen} rendering.
|
||||
* See the two subclasses to listen for foreground or background rendering.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ContainerScreenEvent.DrawForeground
|
||||
* @see ContainerScreenEvent.DrawBackground
|
||||
*/
|
||||
public class ContainerScreenEvent extends Event
|
||||
{
|
||||
|
||||
private final AbstractContainerScreen<?> containerScreen;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ContainerScreenEvent(AbstractContainerScreen<?> containerScreen)
|
||||
{
|
||||
this.containerScreen = containerScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the container screen}
|
||||
*/
|
||||
public AbstractContainerScreen<?> getContainerScreen()
|
||||
{
|
||||
return containerScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired directly after the GuiContainer has draw any foreground elements,
|
||||
* But before the "dragged" stack, and before any tooltips.
|
||||
* This is useful for any slot / item specific overlays.
|
||||
* Things that need to be on top of All GUI elements but bellow tooltips and dragged stacks.
|
||||
* Fired after the container screen's foreground layer and elements are drawn, but
|
||||
* before rendering the tooltips and the item stack being dragged by the player.
|
||||
*
|
||||
* <p>This can be used for rendering elements that must be above other screen elements, but
|
||||
* below tooltips and the dragged stack, such as slot or item stack specific overlays. </p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class DrawForeground extends ContainerScreenEvent
|
||||
{
|
||||
@@ -40,12 +62,7 @@ public class ContainerScreenEvent extends Event
|
||||
private final int mouseY;
|
||||
|
||||
/**
|
||||
* Called directly after the GuiContainer has drawn any foreground elements.
|
||||
*
|
||||
* @param guiContainer The container.
|
||||
* @param poseStack The pose stack.
|
||||
* @param mouseX The current X position of the players mouse.
|
||||
* @param mouseY The current Y position of the players mouse.
|
||||
* @hidden
|
||||
*/
|
||||
public DrawForeground(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
@@ -55,25 +72,39 @@ public class ContainerScreenEvent extends Event
|
||||
this.mouseY = mouseY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseX()
|
||||
{
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseY()
|
||||
{
|
||||
return mouseY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This event is fired directly after the GuiContainer has draw any background elements,
|
||||
* This is useful for drawing new background elements.
|
||||
* Fired after the container screen's background layer and elements are drawn.
|
||||
* This can be used for rendering new background elements.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class DrawBackground extends ContainerScreenEvent
|
||||
{
|
||||
@@ -82,12 +113,7 @@ public class ContainerScreenEvent extends Event
|
||||
private final int mouseY;
|
||||
|
||||
/**
|
||||
* Called directly after the GuiContainer has drawn any background elements.
|
||||
*
|
||||
* @param guiContainer The container.
|
||||
* @param poseStack The PoseStack.
|
||||
* @param mouseX The current X position of the players mouse.
|
||||
* @param mouseY The current Y position of the players mouse.
|
||||
* @hidden
|
||||
*/
|
||||
public DrawBackground(AbstractContainerScreen<?> guiContainer, PoseStack poseStack, int mouseX, int mouseY)
|
||||
{
|
||||
@@ -97,16 +123,25 @@ public class ContainerScreenEvent extends Event
|
||||
this.mouseY = mouseY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseX()
|
||||
{
|
||||
return mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y coordinate of the mouse pointer}
|
||||
*/
|
||||
public int getMouseY()
|
||||
{
|
||||
return mouseY;
|
||||
|
||||
@@ -9,15 +9,20 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* An event called whenever the selection highlight around a block or entity is about to be rendered.
|
||||
* Canceling this event stops the selection highlight from being rendered.
|
||||
* Fired before a selection highlight is rendered.
|
||||
* See the two subclasses to listen for blocks or entities.
|
||||
*
|
||||
* @see DrawSelectionEvent.HighlightBlock
|
||||
* @see DrawSelectionEvent.HighlightEntity
|
||||
*/
|
||||
@Cancelable
|
||||
public class DrawSelectionEvent extends Event
|
||||
@@ -25,38 +30,72 @@ public class DrawSelectionEvent extends Event
|
||||
private final LevelRenderer levelRenderer;
|
||||
private final Camera camera;
|
||||
private final HitResult target;
|
||||
private final float partialTicks;
|
||||
private final float partialTick;
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
|
||||
public DrawSelectionEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTicks, PoseStack poseStack, MultiBufferSource multiBufferSource)
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#onDrawHighlight(LevelRenderer, Camera, HitResult, float, PoseStack, MultiBufferSource)
|
||||
*/
|
||||
public DrawSelectionEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource)
|
||||
{
|
||||
this.levelRenderer = levelRenderer;
|
||||
this.camera = camera;
|
||||
this.target = target;
|
||||
this.partialTicks = partialTicks;
|
||||
this.partialTick = partialTick;
|
||||
this.poseStack = poseStack;
|
||||
this.multiBufferSource = multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the level renderer}
|
||||
*/
|
||||
public LevelRenderer getLevelRenderer() { return levelRenderer; }
|
||||
/**
|
||||
* {@return the camera information}
|
||||
*/
|
||||
public Camera getCamera() { return camera; }
|
||||
/**
|
||||
* {@return the hit result which triggered the selection highlight}
|
||||
*/
|
||||
public HitResult getTarget() { return target; }
|
||||
public float getPartialTicks() { return partialTicks; }
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick() { return partialTick; }
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() { return multiBufferSource; }
|
||||
|
||||
/**
|
||||
* A variant of the DrawSelectionEvent only called when a block is highlighted.
|
||||
* Fired before a block's selection highlight is rendered.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the selection highlight will not be rendered. </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 static class HighlightBlock extends DrawSelectionEvent
|
||||
{
|
||||
public HighlightBlock(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public HighlightBlock(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
{
|
||||
super(levelRenderer, camera, target, partialTick, poseStack, bufferSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the block hit result}
|
||||
*/
|
||||
@Override
|
||||
public BlockHitResult getTarget()
|
||||
{
|
||||
@@ -65,17 +104,26 @@ public class DrawSelectionEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of the DrawSelectionEvent only called when an entity is highlighted.
|
||||
* Canceling this event has no effect.
|
||||
* Fired before a block's selection highlight is rendered.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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 static class HighlightEntity extends DrawSelectionEvent
|
||||
{
|
||||
public HighlightEntity(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public HighlightEntity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
{
|
||||
super(levelRenderer, camera, target, partialTick, poseStack, bufferSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the entity hit result}
|
||||
*/
|
||||
@Override
|
||||
public EntityHitResult getTarget()
|
||||
{
|
||||
|
||||
@@ -8,9 +8,11 @@ package net.minecraftforge.client.event;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.SkullModel;
|
||||
import net.minecraft.client.model.SkullModelBase;
|
||||
import net.minecraft.client.model.geom.EntityModelSet;
|
||||
import net.minecraft.client.model.geom.ModelLayerLocation;
|
||||
import net.minecraft.client.model.geom.ModelLayers;
|
||||
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
||||
@@ -18,6 +20,7 @@ import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@@ -27,24 +30,62 @@ import net.minecraft.world.level.block.SkullBlock.Type;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fired for on different events/actions relating to {@linkplain EntityRenderer entity renderers}.
|
||||
* See the various subclasses for listening to different events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see EntityRenderersEvent.RegisterLayerDefinitions
|
||||
* @see EntityRenderersEvent.RegisterRenderers
|
||||
* @see EntityRenderersEvent.AddLayers
|
||||
*/
|
||||
public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public EntityRenderersEvent()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired for registering layer definitions at the appropriate time.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class RegisterLayerDefinitions extends EntityRenderersEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RegisterLayerDefinitions()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a layer definition supplier with the given {@link ModelLayerLocation}.
|
||||
* These will be inserted into the main layer definition map for entity model layers at the appropriate time.
|
||||
*
|
||||
* @param layerLocation The model layer location, which should be used in conjunction with {@link EntityRendererProvider.Context#bakeLayer(ModelLayerLocation)}
|
||||
* @param supplier A supplier to create a {@link LayerDefinition}, generally a static method reference in the entity model class
|
||||
* @param layerLocation the model layer location, which should be used in conjunction with
|
||||
* {@link EntityRendererProvider.Context#bakeLayer(ModelLayerLocation)}
|
||||
* @param supplier a supplier to create a {@link LayerDefinition}, generally a static method reference in
|
||||
* the entity model class
|
||||
*/
|
||||
public void registerLayerDefinition(ModelLayerLocation layerLocation, Supplier<LayerDefinition> supplier)
|
||||
{
|
||||
@@ -53,15 +94,29 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a safe place to register entity renderers and layer renderers.
|
||||
* Fired for registering entity and block entity renderers at the appropriate time.
|
||||
* For registering entity renderer layers to existing entity renderers (whether vanilla or registered through this
|
||||
* event), listen for the {@link AddLayers} event instead.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class RegisterRenderers extends EntityRenderersEvent
|
||||
{
|
||||
/**
|
||||
* Registers an entity renderer.
|
||||
* @hidden
|
||||
*/
|
||||
public RegisterRenderers()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an entity renderer for the given entity type.
|
||||
*
|
||||
* @param entityType The EntityType to register a renderer for
|
||||
* @param entityRendererProvider The renderer provider, can be a lambda like MyRenderer::new
|
||||
* @param entityType the entity type to register a renderer for
|
||||
* @param entityRendererProvider the renderer provider
|
||||
*/
|
||||
public <T extends Entity> void registerEntityRenderer(EntityType<? extends T> entityType, EntityRendererProvider<T> entityRendererProvider)
|
||||
{
|
||||
@@ -69,10 +124,10 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a block entity renderer.
|
||||
* Registers a block entity renderer for the given block entity type.
|
||||
*
|
||||
* @param blockEntityType The BlockEntityType to register a renderer for
|
||||
* @param blockEntityRendererProvider The renderer provider, can be a lambda like MyRenderer::new
|
||||
* @param blockEntityType the block entity type to register a renderer for
|
||||
* @param blockEntityRendererProvider the renderer provider
|
||||
*/
|
||||
public <T extends BlockEntity> void registerBlockEntityRenderer(BlockEntityType<? extends T> blockEntityType, BlockEntityRendererProvider<T> blockEntityRendererProvider)
|
||||
{
|
||||
@@ -81,7 +136,13 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a safe place to register entity renderer layers.
|
||||
* Fired for registering entity renderer layers at the appropriate time, after the entity and player renderers maps
|
||||
* have been created.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class AddLayers extends EntityRenderersEvent
|
||||
{
|
||||
@@ -89,6 +150,9 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
private final Map<String, EntityRenderer<? extends Player>> skinMap;
|
||||
private final EntityModelSet entityModels = Minecraft.getInstance().getEntityModels();
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public AddLayers(Map<EntityType<?>, EntityRenderer<?>> renderers, Map<String, EntityRenderer<? extends Player>> playerRenderers)
|
||||
{
|
||||
this.renderers = renderers;
|
||||
@@ -96,7 +160,11 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of skins.
|
||||
* {@return the set of player skin names which have a renderer}
|
||||
*
|
||||
* Minecraft provides two default skin names: {@code default} for the
|
||||
* {@linkplain ModelLayers#PLAYER regular player model} and {@code slim} for the
|
||||
* {@linkplain ModelLayers#PLAYER_SLIM slim player model}.
|
||||
*/
|
||||
public Set<String> getSkins()
|
||||
{
|
||||
@@ -104,10 +172,12 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a player skin renderer. Vanilla skins are "default" and "slim".
|
||||
* @param skinName The name of the skin renderer to return
|
||||
* @param <R> The type of the skin renderer, usually PlayerRenderer
|
||||
* @return The skin renderer, or null if not found
|
||||
* Returns a player skin renderer for the given skin name.
|
||||
*
|
||||
* @param skinName the name of the skin to get the renderer for
|
||||
* @param <R> the type of the skin renderer, usually {@link PlayerRenderer}
|
||||
* @return the skin renderer, or {@code null} if no renderer is registered for that skin name
|
||||
* @see #getSkins()
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -118,10 +188,11 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
|
||||
/**
|
||||
* Returns an entity renderer for the given entity type.
|
||||
* @param entityType The entity to return a renderer for
|
||||
* @param <T> The type of entity the renderer is for
|
||||
* @param <R> The renderer type
|
||||
* @return The renderer
|
||||
*
|
||||
* @param entityType the entity type to return a renderer for
|
||||
* @param <T> the type of entity the renderer is for
|
||||
* @param <R> the type of the renderer
|
||||
* @return the renderer, or {@code null} if no renderer is registered for that entity type
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -129,6 +200,9 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
return (R) renderers.get(entityType);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the set of entity models}
|
||||
*/
|
||||
public EntityModelSet getEntityModels()
|
||||
{
|
||||
return entityModels;
|
||||
@@ -136,19 +210,27 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a safe place to register models for the skull block
|
||||
* Fired for registering additional {@linkplain net.minecraft.client.model.SkullModelBase skull models} at the appropriate time.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class CreateSkullModels extends EntityRenderersEvent
|
||||
{
|
||||
private final ImmutableMap.Builder<Type,SkullModelBase> builder;
|
||||
private final ImmutableMap.Builder<Type, SkullModelBase> builder;
|
||||
private final EntityModelSet entityModelSet;
|
||||
|
||||
public CreateSkullModels(ImmutableMap.Builder<Type,SkullModelBase> builder, EntityModelSet entityModelSet)
|
||||
public CreateSkullModels(ImmutableMap.Builder<Type, SkullModelBase> builder, EntityModelSet entityModelSet)
|
||||
{
|
||||
this.builder = builder;
|
||||
this.entityModelSet = entityModelSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the set of entity models}
|
||||
*/
|
||||
public EntityModelSet getEntityModelSet()
|
||||
{
|
||||
return entityModelSet;
|
||||
@@ -156,10 +238,14 @@ public class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
|
||||
/**
|
||||
* Registers the constructor for a skull block with the given {@link SkullBlock.Type}.
|
||||
* These will be inserted into the maps used by the item, entity, and block model renderers at the appropiate time.
|
||||
* These will be inserted into the maps used by the item, entity, and block model renderers at the appropriate
|
||||
* time.
|
||||
*
|
||||
* @param type Unique skull type. Will cause an exception if multiple mods (including vanilla) register models for the same type
|
||||
* @param model Model instance. A typical implementation will simply do {@code new SkullModel(entityModelSet.bakeLayer(layerLocation))}
|
||||
* @param type a unique skull type; an exception will be thrown later if multiple mods (including vanilla)
|
||||
* register models for the same type
|
||||
* @param model the skull model instance. A typical implementation will simply bake a model using
|
||||
* {@link EntityModelSet#bakeLayer(ModelLayerLocation)} and pass it to the constructor for
|
||||
* {@link SkullModel}.
|
||||
*/
|
||||
public void registerSkullModel(SkullBlock.Type type, SkullModelBase model)
|
||||
{
|
||||
|
||||
@@ -7,162 +7,180 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.renderer.FogRenderer.FogMode;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.world.level.material.FogType;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.FogRenderer;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
import com.mojang.blaze3d.shaders.FogShape;
|
||||
|
||||
/**
|
||||
* Event that hooks into GameRenderer, allowing any feature to customize visual attributes
|
||||
* the player sees.
|
||||
* Fired for hooking into the entity view rendering in {@link GameRenderer}.
|
||||
* These can be used for customizing the visual features visible to the player.
|
||||
* See the various subclasses for listening to different features.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see EntityViewRenderEvent.RenderFogEvent
|
||||
* @see EntityViewRenderEvent.FogColors
|
||||
* @see EntityViewRenderEvent.CameraSetup
|
||||
* @see EntityViewRenderEvent.FieldOfView
|
||||
*/
|
||||
public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final GameRenderer renderer;
|
||||
private final Camera camera;
|
||||
private final double partialTicks;
|
||||
private final double partialTick;
|
||||
|
||||
public EntityViewRenderEvent(GameRenderer renderer, Camera camera, double partialTicks)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public EntityViewRenderEvent(GameRenderer renderer, Camera camera, double partialTick)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
this.camera = camera;
|
||||
this.partialTicks = partialTicks;
|
||||
this.partialTick = partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the game renderer}
|
||||
*/
|
||||
public GameRenderer getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the camera information}
|
||||
*/
|
||||
public Camera getCamera()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
|
||||
public double getPartialTicks()
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public double getPartialTick()
|
||||
{
|
||||
return partialTicks;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.18.2")
|
||||
private static class FogEvent extends EntityViewRenderEvent
|
||||
{
|
||||
private final FogMode mode;
|
||||
@SuppressWarnings("resource")
|
||||
protected FogEvent(FogMode mode, Camera camera, double partialTick)
|
||||
{
|
||||
super(Minecraft.getInstance().gameRenderer, camera, partialTick);
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public FogMode getMode() { return mode; }
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use RenderFogEvent. This event will be removed as the other event has better functionality.
|
||||
* Fired for customizing the <b>rendering</b> of the fog visible to the player. The plane distances are based on
|
||||
* the player's render distance.
|
||||
*
|
||||
* Event that allows any feature to customize the fog density the player sees.
|
||||
* NOTE: In order to make this event have an effect, you must cancel the event
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}. <br/>
|
||||
* The event must be cancelled for any changes to the plane distances to take effect.</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
|
||||
@Deprecated(forRemoval = true, since = "1.18.2")
|
||||
public static class FogDensity extends FogEvent
|
||||
public static class RenderFogEvent extends EntityViewRenderEvent
|
||||
{
|
||||
private float density;
|
||||
|
||||
public FogDensity(FogMode type, Camera camera, float partialTick, float density)
|
||||
{
|
||||
super(type, camera, partialTick);
|
||||
this.setDensity(density);
|
||||
}
|
||||
|
||||
public float getDensity()
|
||||
{
|
||||
return density;
|
||||
}
|
||||
|
||||
public void setDensity(float density)
|
||||
{
|
||||
this.density = density;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event allows for customization of parameters related to fog rendering. The plane distances are based on the player's render distance.
|
||||
* For the event to have an effect, you must cancel it.
|
||||
*
|
||||
* The FogMode is NOT customizable. It describes the type of fog being modified.
|
||||
* A FogMode of FOG_SKY is the skybox's fog.
|
||||
* A FogMode of FOG_TERRAIN is what the fog induced by render distance uses. This works best for reducing the camera's visibility.
|
||||
*/
|
||||
@HasResult // TODO: remove in 1.19. Setting a result for this event has no effect.
|
||||
@Cancelable
|
||||
public static class RenderFogEvent extends FogEvent // TODO: In 1.19, change superclass to EntityViewRenderEvent
|
||||
{
|
||||
private final FogMode type;
|
||||
private final FogType type;
|
||||
private float farPlaneDistance;
|
||||
private float nearPlaneDistance;
|
||||
private FogShape fogShape;
|
||||
|
||||
/**
|
||||
* @deprecated Use other constructor with all the params. Will be removed in 1.19
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onFogRender(FogType, Camera, float, float, float, FogShape)
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.18.2")
|
||||
public RenderFogEvent(FogMode type, Camera camera, float partialTicks, float distance)
|
||||
public RenderFogEvent(FogType type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape)
|
||||
{
|
||||
this(type, camera, partialTicks, -8f, distance, FogShape.SPHERE);
|
||||
}
|
||||
|
||||
public RenderFogEvent(FogMode type, Camera camera, float partialTicks, float nearPlaneDistance, float farPlaneDistance, FogShape fogShape)
|
||||
{
|
||||
super(type, camera, partialTicks);
|
||||
super(Minecraft.getInstance().gameRenderer, camera, partialTicks);
|
||||
this.type = type;
|
||||
setFarPlaneDistance(farPlaneDistance);
|
||||
setNearPlaneDistance(nearPlaneDistance);
|
||||
setFogShape(fogShape);
|
||||
}
|
||||
|
||||
public FogMode getMode()
|
||||
/**
|
||||
* {@return the type of fog being rendered}
|
||||
*/
|
||||
public FogType getMode()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the distance to the far plane where the fog ends}
|
||||
*/
|
||||
public float getFarPlaneDistance()
|
||||
{
|
||||
return farPlaneDistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the distance to the near plane where the fog starts}
|
||||
*/
|
||||
public float getNearPlaneDistance()
|
||||
{
|
||||
return nearPlaneDistance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the shape of the fog being rendered}
|
||||
*/
|
||||
public FogShape getFogShape()
|
||||
{
|
||||
return fogShape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the distance to the far plane of the fog.
|
||||
*
|
||||
* @param distance the new distance to the far place
|
||||
* @see #scaleFarPlaneDistance(float)
|
||||
*/
|
||||
public void setFarPlaneDistance(float distance)
|
||||
{
|
||||
farPlaneDistance = distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the distance to the near plane of the fog.
|
||||
*
|
||||
* @param distance the new distance to the near plane
|
||||
* @see #scaleNearPlaneDistance(float)
|
||||
*/
|
||||
public void setNearPlaneDistance(float distance)
|
||||
{
|
||||
nearPlaneDistance = distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new shape of the fog being rendered. The new shape will only take effect if the event is cancelled.
|
||||
*
|
||||
* @param shape the new shape of the fog
|
||||
*/
|
||||
public void setFogShape(FogShape shape)
|
||||
{
|
||||
fogShape = shape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the distance to the far plane of the fog by a given factor.
|
||||
*
|
||||
* @param factor the factor to scale the far plane distance by
|
||||
*/
|
||||
public void scaleFarPlaneDistance(float factor)
|
||||
{
|
||||
farPlaneDistance *= factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the distance to the near plane of the fog by a given factor.
|
||||
*
|
||||
* @param factor the factor to scale the near plane distance by
|
||||
*/
|
||||
public void scaleNearPlaneDistance(float factor)
|
||||
{
|
||||
nearPlaneDistance *= factor;
|
||||
@@ -170,8 +188,12 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that allows any feature to customize the color of fog the player sees.
|
||||
* NOTE: Any change made to one of the color variables will affect the result seen in-game.
|
||||
* Fired for customizing the <b>color</b> of the fog visible to the player.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class FogColors extends EntityViewRenderEvent
|
||||
{
|
||||
@@ -179,7 +201,10 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float green;
|
||||
private float blue;
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
/**
|
||||
* @hidden
|
||||
* @see FogRenderer#setupColor(Camera, float, ClientLevel, int, float)
|
||||
*/
|
||||
public FogColors(Camera camera, float partialTicks, float red, float green, float blue)
|
||||
{
|
||||
super(Minecraft.getInstance().gameRenderer, camera, partialTicks);
|
||||
@@ -188,16 +213,46 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
this.setBlue(blue);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the red color value of the fog}
|
||||
*/
|
||||
public float getRed() { return red; }
|
||||
/**
|
||||
* Sets the new red color value of the fog.
|
||||
*
|
||||
* @param red the new red color value
|
||||
*/
|
||||
public void setRed(float red) { this.red = red; }
|
||||
/**
|
||||
* {@return the green color value of the fog}
|
||||
*/
|
||||
public float getGreen() { return green; }
|
||||
/**
|
||||
* Sets the new green color value of the fog.
|
||||
*
|
||||
* @param green the new blue color value
|
||||
*/
|
||||
public void setGreen(float green) { this.green = green; }
|
||||
/**
|
||||
* {@return the blue color value of the fog}
|
||||
*/
|
||||
public float getBlue() { return blue; }
|
||||
/**
|
||||
* Sets the new blue color value of the fog.
|
||||
*
|
||||
* @param blue the new blue color value
|
||||
*/
|
||||
public void setBlue(float blue) { this.blue = blue; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that allows mods to alter the angles of the player's camera. Mainly useful for applying roll.
|
||||
* Fired to allow altering the angles of the player's camera.
|
||||
* This can be used to alter the player's view for different effects, such as applying roll.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class CameraSetup extends EntityViewRenderEvent
|
||||
{
|
||||
@@ -205,6 +260,10 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
private float pitch;
|
||||
private float roll;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onCameraSetup(GameRenderer, Camera, float)
|
||||
*/
|
||||
public CameraSetup(GameRenderer renderer, Camera camera, double renderPartialTicks, float yaw, float pitch, float roll)
|
||||
{
|
||||
super(renderer, camera, renderPartialTicks);
|
||||
@@ -213,31 +272,74 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.
|
||||
this.setRoll(roll);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the yaw of the player's camera}
|
||||
*/
|
||||
public float getYaw() { return yaw; }
|
||||
/**
|
||||
* Sets the yaw of the player's camera.
|
||||
*
|
||||
* @param yaw the new yaw
|
||||
*/
|
||||
public void setYaw(float yaw) { this.yaw = yaw; }
|
||||
/**
|
||||
* {@return the pitch of the player's camera}
|
||||
*/
|
||||
public float getPitch() { return pitch; }
|
||||
/**
|
||||
* Sets the pitch of the player's camera.
|
||||
*
|
||||
* @param pitch the new pitch
|
||||
*/
|
||||
public void setPitch(float pitch) { this.pitch = pitch; }
|
||||
/**
|
||||
* {@return the roll of the player's camera}
|
||||
*/
|
||||
public float getRoll() { return roll; }
|
||||
/**
|
||||
* Sets the roll of the player's camera.
|
||||
*
|
||||
* @param roll the new roll
|
||||
*/
|
||||
public void setRoll(float roll) { this.roll = roll; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Event that allows mods to alter the raw FOV itself.
|
||||
* This directly affects to the FOV without being modified.
|
||||
* */
|
||||
* Fired for altering the raw field of view (FOV).
|
||||
* This is after the FOV settings are applied, and before modifiers such as the Nausea effect.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see FOVModifierEvent
|
||||
*/
|
||||
public static class FieldOfView extends EntityViewRenderEvent
|
||||
{
|
||||
private double fov;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#getFieldOfView(GameRenderer, Camera, double, double)
|
||||
*/
|
||||
public FieldOfView(GameRenderer renderer, Camera camera, double renderPartialTicks, double fov) {
|
||||
super(renderer, camera, renderPartialTicks);
|
||||
this.setFOV(fov);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the raw field of view value}
|
||||
*/
|
||||
public double getFOV() {
|
||||
return fov;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the field of view value.
|
||||
*
|
||||
* @param fov the new FOV value
|
||||
*/
|
||||
public void setFOV(double fov) {
|
||||
this.fov = fov;
|
||||
}
|
||||
|
||||
@@ -8,38 +8,71 @@ package net.minecraftforge.client.event;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired after the field of vision (FOV) modifier for the player is calculated.
|
||||
* This can be used to modify the FOV before the FOV settings are applied.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see EntityViewRenderEvent.FieldOfView
|
||||
*/
|
||||
public class FOVModifierEvent extends Event
|
||||
{
|
||||
private final Player entity;
|
||||
private final Player player;
|
||||
private final float fov;
|
||||
private float newfov;
|
||||
private float newFov;
|
||||
|
||||
public FOVModifierEvent(Player entity, float fov)
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#getFieldOfView(Player, float)
|
||||
*/
|
||||
public FOVModifierEvent(Player player, float fov)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.player = player;
|
||||
this.fov = fov;
|
||||
this.setNewfov(Mth.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, fov));
|
||||
this.setNewFov((float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0F, fov));
|
||||
}
|
||||
|
||||
public Player getEntity()
|
||||
/**
|
||||
* {@return the player affected by this event}
|
||||
*/
|
||||
public Player getPlayer()
|
||||
{
|
||||
return entity;
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original field of vision (FOV) of the player, before any modifications or interpolation}
|
||||
*/
|
||||
public float getFov()
|
||||
{
|
||||
return fov;
|
||||
}
|
||||
|
||||
public float getNewfov()
|
||||
/**
|
||||
* {@return the current field of vision (FOV) of the player}
|
||||
*/
|
||||
public float getNewFov()
|
||||
{
|
||||
return newfov;
|
||||
return newFov;
|
||||
}
|
||||
|
||||
public void setNewfov(float newfov)
|
||||
/**
|
||||
* Sets the new field of vision (FOV) of the player.
|
||||
*
|
||||
* @param newFov the new field of vision (FOV)
|
||||
*/
|
||||
public void setNewFov(float newFov)
|
||||
{
|
||||
this.newfov = newfov;
|
||||
this.newFov = newFov;
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,37 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
/**
|
||||
* Fired when an input is detected from the user's input devices.
|
||||
* See the various subclasses to listen for specific devices and inputs.
|
||||
*
|
||||
* @see InputEvent.RawMouseEvent
|
||||
* @see InputEvent.MouseInputEvent
|
||||
* @see InputEvent.MouseScrollEvent
|
||||
* @see InputEvent.KeyInputEvent
|
||||
* @see InputEvent.ClickInputEvent
|
||||
*/
|
||||
public class InputEvent extends Event
|
||||
{
|
||||
/**
|
||||
* A cancellable mouse event fired before key bindings are updated
|
||||
* Fired when a mouse button is clicked, <b>before</b> being processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse event will not be processed by vanilla (e.g. keymappings and screens) </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>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RawMouseEvent extends InputEvent
|
||||
@@ -24,6 +46,10 @@ public class InputEvent extends Event
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onRawMouseClicked(int, int, int)
|
||||
*/
|
||||
public RawMouseEvent(int button, int action, int modifiers)
|
||||
{
|
||||
this.button = button;
|
||||
@@ -32,10 +58,11 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The mouse button that triggered this event.
|
||||
* https://www.glfw.org/docs/latest/group__buttons.html
|
||||
* {@return the mouse button's input code}
|
||||
*
|
||||
* @see GLFW mouse constants starting with "GLFW_MOUSE_BUTTON_"
|
||||
* @see InputConstants input constants starting with {@code MOUSE_BUTTON_}
|
||||
* @see GLFW mouse constants starting with {@code GLFW_MOUSE_BUTTON_}
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__buttons.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getButton()
|
||||
{
|
||||
@@ -43,10 +70,10 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer representing the mouse button's action.
|
||||
* {@return the mouse button's action}
|
||||
*
|
||||
* @see GLFW#GLFW_PRESS
|
||||
* @see GLFW#GLFW_RELEASE
|
||||
* @see InputConstants#PRESS
|
||||
* @see InputConstants#RELEASE
|
||||
*/
|
||||
public int getAction()
|
||||
{
|
||||
@@ -54,13 +81,15 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Bit field representing the modifier keys pressed.
|
||||
* https://www.glfw.org/docs/latest/group__mods.html
|
||||
* {@return a bit field representing the active modifier keys}
|
||||
*
|
||||
* @see GLFW#GLFW_MOD_SHIFT
|
||||
* @see GLFW#GLFW_MOD_CONTROL
|
||||
* @see GLFW#GLFW_MOD_ALT
|
||||
* @see GLFW#GLFW_MOD_SUPER
|
||||
* @see InputConstants#MOD_CONTROL CTRL modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SHIFT SHIFT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_ALT ALT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SUPER SUPER modifier key bit
|
||||
* @see GLFW#GLFW_KEY_CAPS_LOCK CAPS LOCK modifier key bit
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
@@ -69,13 +98,25 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires when a mouse input is detected.
|
||||
* Fired when a mouse button is clicked, <b>after</b> processing.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static class MouseInputEvent extends InputEvent
|
||||
{
|
||||
private final int button;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onRawMouseClicked(int, int, int)
|
||||
*/
|
||||
public MouseInputEvent(int button, int action, int modifiers)
|
||||
{
|
||||
this.button = button;
|
||||
@@ -84,10 +125,10 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The mouse button that triggered this event.
|
||||
* https://www.glfw.org/docs/latest/group__buttons.html
|
||||
* {@return the mouse button's input code}
|
||||
*
|
||||
* @see GLFW mouse constants starting with "GLFW_MOUSE_BUTTON_"
|
||||
* @see GLFW mouse constants starting with 'GLFW_MOUSE_BUTTON_'
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__buttons.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getButton()
|
||||
{
|
||||
@@ -95,10 +136,10 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer representing the mouse button's action.
|
||||
* {@return the mouse button's action}
|
||||
*
|
||||
* @see GLFW#GLFW_PRESS
|
||||
* @see GLFW#GLFW_RELEASE
|
||||
* @see InputConstants#PRESS
|
||||
* @see InputConstants#RELEASE
|
||||
*/
|
||||
public int getAction()
|
||||
{
|
||||
@@ -106,13 +147,15 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Bit field representing the modifier keys pressed.
|
||||
* https://www.glfw.org/docs/latest/group__mods.html
|
||||
* {@return a bit field representing the active modifier keys}
|
||||
*
|
||||
* @see GLFW#GLFW_MOD_SHIFT
|
||||
* @see GLFW#GLFW_MOD_CONTROL
|
||||
* @see GLFW#GLFW_MOD_ALT
|
||||
* @see GLFW#GLFW_MOD_SUPER
|
||||
* @see InputConstants#MOD_CONTROL CTRL modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SHIFT SHIFT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_ALT ALT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SUPER SUPER modifier key bit
|
||||
* @see GLFW#GLFW_KEY_CAPS_LOCK CAPS LOCK modifier key bit
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
@@ -121,7 +164,16 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires when the mouse scroll wheel is used outside of a gui.
|
||||
* Fired when a mouse scroll wheel is used outside of a screen and a player is loaded, <b>before</b> being
|
||||
* processed by vanilla.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the mouse scroll event will not be processed further. </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>
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class MouseScrollEvent extends InputEvent
|
||||
@@ -132,6 +184,11 @@ public class InputEvent extends Event
|
||||
private final boolean leftDown;
|
||||
private final boolean middleDown;
|
||||
private final boolean rightDown;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onMouseScroll(MouseHandler, double)
|
||||
*/
|
||||
public MouseScrollEvent(double scrollDelta, boolean leftDown, boolean middleDown, boolean rightDown, double mouseX, double mouseY)
|
||||
{
|
||||
this.scrollDelta = scrollDelta;
|
||||
@@ -142,31 +199,49 @@ public class InputEvent extends Event
|
||||
this.mouseY = mouseY;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of change / delta of the mouse scroll}
|
||||
*/
|
||||
public double getScrollDelta()
|
||||
{
|
||||
return this.scrollDelta;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the left mouse button is pressed}
|
||||
*/
|
||||
public boolean isLeftDown()
|
||||
{
|
||||
return this.leftDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the right mouse button is pressed}
|
||||
*/
|
||||
public boolean isRightDown()
|
||||
{
|
||||
return this.rightDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the middle mouse button is pressed}
|
||||
*/
|
||||
public boolean isMiddleDown()
|
||||
{
|
||||
return this.middleDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X position of the mouse cursor}
|
||||
*/
|
||||
public double getMouseX()
|
||||
{
|
||||
return this.mouseX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the mouse cursor}
|
||||
*/
|
||||
public double getMouseY()
|
||||
{
|
||||
return this.mouseY;
|
||||
@@ -174,7 +249,12 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires when a keyboard input is detected.
|
||||
* Fired when a keyboard key input occurs, such as pressing, releasing, or repeating a key.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class KeyInputEvent extends InputEvent
|
||||
{
|
||||
@@ -182,6 +262,11 @@ public class InputEvent extends Event
|
||||
private final int scanCode;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#fireKeyInput(int, int, int, int)
|
||||
*/
|
||||
public KeyInputEvent(int key, int scanCode, int action, int modifiers)
|
||||
{
|
||||
this.key = key;
|
||||
@@ -191,10 +276,11 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* The keyboard key that triggered this event.
|
||||
* https://www.glfw.org/docs/latest/group__keys.html
|
||||
* {@return the {@code GLFW} (platform-agnostic) key code}
|
||||
*
|
||||
* @see GLFW key constants starting with "GLFW_KEY_"
|
||||
* @see InputConstants input constants starting with {@code KEY_}
|
||||
* @see GLFW key constants starting with {@code GLFW_KEY_}
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__keys.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getKey()
|
||||
{
|
||||
@@ -202,12 +288,13 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform-specific scan code.
|
||||
* Used for {@link InputConstants#getKey(int, int)}
|
||||
* {@return the platform-specific scan code}
|
||||
*
|
||||
* The scan code is unique for every key, regardless of whether it has a key code.
|
||||
* Scan codes are platform-specific but consistent over time, so keys will have different scan codes depending
|
||||
* on the platform but they are safe to save to disk as custom key bindings.
|
||||
*
|
||||
* @see InputConstants#getKey(int, int)
|
||||
*/
|
||||
public int getScanCode()
|
||||
{
|
||||
@@ -215,11 +302,11 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Integer representing the key's action.
|
||||
* {@return the mouse button's action}
|
||||
*
|
||||
* @see GLFW#GLFW_PRESS
|
||||
* @see GLFW#GLFW_RELEASE
|
||||
* @see GLFW#GLFW_REPEAT
|
||||
* @see InputConstants#PRESS
|
||||
* @see InputConstants#RELEASE
|
||||
* @see InputConstants#REPEAT
|
||||
*/
|
||||
public int getAction()
|
||||
{
|
||||
@@ -227,13 +314,15 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Bit field representing the modifier keys pressed.
|
||||
* https://www.glfw.org/docs/latest/group__mods.html
|
||||
* {@return a bit field representing the active modifier keys}
|
||||
*
|
||||
* @see GLFW#GLFW_MOD_SHIFT
|
||||
* @see GLFW#GLFW_MOD_CONTROL
|
||||
* @see GLFW#GLFW_MOD_ALT
|
||||
* @see GLFW#GLFW_MOD_SUPER
|
||||
* @see InputConstants#MOD_CONTROL CTRL modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SHIFT SHIFT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_ALT ALT modifier key bit
|
||||
* @see GLFW#GLFW_MOD_SUPER SUPER modifier key bit
|
||||
* @see GLFW#GLFW_KEY_CAPS_LOCK CAPS LOCK modifier key bit
|
||||
* @see GLFW#GLFW_KEY_NUM_LOCK NUM LOCK modifier key bit
|
||||
* @see <a href="https://www.glfw.org/docs/latest/group__mods.html" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public int getModifiers()
|
||||
{
|
||||
@@ -242,11 +331,21 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires when one of the keybindings that by default involves clicking the mouse buttons
|
||||
* is triggered.
|
||||
* Fired when a keymapping that by default involves clicking the mouse buttons is triggered.
|
||||
*
|
||||
* These key bindings are use item, pick block and attack keybindings. (right, middle and left mouse click)
|
||||
* In the case that these key bindings are re-bound to a keyboard key the event will still be fired as normal.
|
||||
* <p>The key bindings that trigger this event are:</p>
|
||||
* <ul>
|
||||
* <li><b>Use Item</b> - defaults to <em>left mouse click</em></li>
|
||||
* <li><b>Pick Block</b> - defaults to <em>middle mouse click</em></li>
|
||||
* <li><b>Attack</b> - defaults to <em>right mouse click</em></li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the keymapping's action is not processed further, and the hand will be swung
|
||||
* according to {@link #shouldSwingHand()}. </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 static class ClickInputEvent extends InputEvent
|
||||
@@ -255,6 +354,11 @@ public class InputEvent extends Event
|
||||
private final KeyMapping keyMapping;
|
||||
private final InteractionHand hand;
|
||||
private boolean handSwing = true;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onClickInput(int, KeyMapping, InteractionHand)
|
||||
*/
|
||||
public ClickInputEvent(int button, KeyMapping keyMapping, InteractionHand hand)
|
||||
{
|
||||
this.button = button;
|
||||
@@ -263,45 +367,62 @@ public class InputEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to false to disable the hand swing animation.
|
||||
* Has no effect if this is a pick block input.
|
||||
* Sets whether to swing the hand. This takes effect whether or not the event is cancelled.
|
||||
*
|
||||
* @param value whether to swing the hand
|
||||
*/
|
||||
public void setSwingHand(boolean value)
|
||||
{
|
||||
handSwing = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return whether to swing the hand; always takes effect, regardless of cancellation}
|
||||
*/
|
||||
public boolean shouldSwingHand()
|
||||
{
|
||||
return handSwing;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hand which is causing the event to get triggered.
|
||||
* {@return the hand that caused the input}
|
||||
*
|
||||
* The event will be called for both hands if this is a use item input regardless
|
||||
* of if either gets canceled.
|
||||
* Will always be MAIN_HAND if this is an attack or pick block input.
|
||||
* of both event's cancellation.
|
||||
* Will always be {@link InteractionHand#MAIN_HAND} if this is an attack or pick block input.
|
||||
*/
|
||||
public InteractionHand getHand()
|
||||
{
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the mouse button is the left mouse button}
|
||||
*/
|
||||
public boolean isAttack()
|
||||
{
|
||||
return button == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the mouse button is the right mouse button}
|
||||
*/
|
||||
public boolean isUseItem()
|
||||
{
|
||||
return button == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code true} if the mouse button is the middle mouse button}
|
||||
*/
|
||||
public boolean isPickBlock()
|
||||
{
|
||||
return button == 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the key mapping which triggered this event}
|
||||
*/
|
||||
public KeyMapping getKeyMapping()
|
||||
{
|
||||
return keyMapping;
|
||||
|
||||
@@ -10,13 +10,22 @@ import java.util.Map;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.ForgeModelBakery;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Fired when the ModelManager is notified of the resource manager reloading.
|
||||
* Called after model registry is setup, but before it's passed to BlockModelShapes.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
// TODO: try to merge with ICustomModelLoader
|
||||
public class ModelBakeEvent extends Event implements IModBusEvent
|
||||
@@ -25,6 +34,10 @@ public class ModelBakeEvent extends Event implements IModBusEvent
|
||||
private final Map<ResourceLocation, BakedModel> modelRegistry;
|
||||
private final ForgeModelBakery modelLoader;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onModelBake(ModelManager, Map, ForgeModelBakery)
|
||||
*/
|
||||
public ModelBakeEvent(ModelManager modelManager, Map<ResourceLocation, BakedModel> modelRegistry, ForgeModelBakery modelLoader)
|
||||
{
|
||||
this.modelManager = modelManager;
|
||||
@@ -32,16 +45,25 @@ public class ModelBakeEvent extends Event implements IModBusEvent
|
||||
this.modelLoader = modelLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the model manager}
|
||||
*/
|
||||
public ModelManager getModelManager()
|
||||
{
|
||||
return modelManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the modifiable registry map of models and their model names}
|
||||
*/
|
||||
public Map<ResourceLocation, BakedModel> getModelRegistry()
|
||||
{
|
||||
return modelRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the model loader}
|
||||
*/
|
||||
public ForgeModelBakery getModelLoader()
|
||||
{
|
||||
return modelLoader;
|
||||
|
||||
@@ -8,14 +8,29 @@ package net.minecraftforge.client.event;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Fired when the {@link ModelLoaderRegistry} is ready to register model loaders
|
||||
* Fired when the {@link ModelLoaderRegistry} is ready for model loader registrations.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ModelLoaderRegistry#registerLoader(ResourceLocation, IModelLoader)
|
||||
*/
|
||||
public class ModelRegistryEvent extends Event implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ModelLoaderRegistry#onModelLoadingStart()
|
||||
*/
|
||||
public ModelRegistryEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -7,22 +7,37 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.client.player.Input;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* This event is fired after player movement inputs are updated.<br>
|
||||
* Handlers can freely manipulate {@link Input} to cancel movement.<br>
|
||||
* <p>Fired after the player's movement inputs are updated.</p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public class MovementInputUpdateEvent extends PlayerEvent
|
||||
{
|
||||
private final Input input;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onMovementInputUpdate(Player, Input)
|
||||
*/
|
||||
public MovementInputUpdateEvent(Player player, Input input)
|
||||
{
|
||||
super(player);
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the player's movement inputs}
|
||||
*/
|
||||
public Input getInput()
|
||||
{
|
||||
return input;
|
||||
|
||||
@@ -8,12 +8,31 @@ package net.minecraftforge.client.event;
|
||||
import net.minecraft.client.particle.ParticleEngine;
|
||||
import net.minecraft.client.particle.ParticleProvider;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.RegisterEvent;
|
||||
|
||||
/**
|
||||
* Fired when you should call {@link ParticleEngine#register(ParticleType, ParticleProvider)}.
|
||||
* Note that your {@code ParticleType}s should still be registered during the usual registry events, this
|
||||
* is only for the factories.
|
||||
* Fired for registering particle providers at the appropriate time.
|
||||
*
|
||||
* <p>{@link ParticleType}s must be registered during {@link RegisterEvent} as usual;
|
||||
* this event is only for the {@link ParticleProvider}s. </p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see ParticleEngine#register(ParticleType, ParticleProvider)
|
||||
*/
|
||||
public class ParticleFactoryRegisterEvent extends Event implements IModBusEvent {}
|
||||
public class ParticleFactoryRegisterEvent extends Event implements IModBusEvent {
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ParticleFactoryRegisterEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,36 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired on {@link Dist#CLIENT} when {@link RecipeManager} has all of its recipes synced from the server to the client (just after a client has connected),
|
||||
* Fired when the {@link RecipeManager} has received and synced the recipes from the server to the client.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public class RecipesUpdatedEvent extends Event
|
||||
{
|
||||
|
||||
|
||||
private final RecipeManager mgr;
|
||||
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onRecipesUpdated(RecipeManager)
|
||||
*/
|
||||
public RecipesUpdatedEvent(RecipeManager mgr)
|
||||
{
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The newly-updated recipe manager that now contains all the recipes that were just received.
|
||||
* {@return the recipe manager}
|
||||
*/
|
||||
public RecipeManager getRecipeManager()
|
||||
{
|
||||
|
||||
@@ -9,29 +9,45 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.ObjectiveArgument;
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Register commands to be executed on the client using this event.
|
||||
*
|
||||
* Some arguments behave differently:
|
||||
* Fired to allow mods to register client commands.
|
||||
*
|
||||
* <p>Some command arguments behave differently for the client commands dispatcher:</p>
|
||||
* <ul>
|
||||
* <li>{@link ResourceLocationArgument#getAdvancement(com.mojang.brigadier.context.CommandContext, String)} only returns advancements that are shown on the advancements screen
|
||||
* <li>{@link ObjectiveArgument#getObjective(com.mojang.brigadier.context.CommandContext, String)} only returns objectives that are set to display
|
||||
* <li>{@link ResourceLocationArgument#getAdvancement(com.mojang.brigadier.context.CommandContext, String)} only returns
|
||||
* advancements that are shown on the advancements screen.
|
||||
* <li>{@link ObjectiveArgument#getObjective(com.mojang.brigadier.context.CommandContext, String)} only returns
|
||||
* objectives that are displayed to the player.
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see net.minecraftforge.event.RegisterCommandsEvent
|
||||
*/
|
||||
public class RegisterClientCommandsEvent extends Event
|
||||
{
|
||||
|
||||
private final CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ClientCommandHandler#mergeServerCommands(CommandDispatcher)
|
||||
*/
|
||||
public RegisterClientCommandsEvent(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
this.dispatcher = dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The command dispatcher for registering commands to be executed on the client
|
||||
* {@return the command dispatcher for registering commands to be executed on the client}
|
||||
*/
|
||||
public CommandDispatcher<CommandSourceStack> getDispatcher()
|
||||
{
|
||||
|
||||
@@ -5,20 +5,44 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraftforge.event.AddReloadListenerEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Fired to allow mods to register their reload listeners on the client-side resource manager.
|
||||
* This event is fired once during the construction of the {@link Minecraft} instance.
|
||||
*
|
||||
* <p>For registering reload listeners on the server-side resource manager, see {@link AddReloadListenerEvent}. </p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public class RegisterClientReloadListenersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ReloadableResourceManager resourceManager;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RegisterClientReloadListenersEvent(ReloadableResourceManager resourceManager)
|
||||
{
|
||||
this.resourceManager = resourceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the given reload listener to the client-side resource manager.
|
||||
*
|
||||
* @param reloadListener the reload listener
|
||||
*/
|
||||
public void registerReloadListener(PreparableReloadListener reloadListener)
|
||||
{
|
||||
resourceManager.registerReloadListener(reloadListener);
|
||||
|
||||
@@ -8,28 +8,58 @@ package net.minecraftforge.client.event;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Fired to allow mods to register custom {@linkplain ShaderInstance shaders}.
|
||||
* This event is fired after the default Minecraft shaders have been registered.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public class RegisterShadersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ResourceManager resourceManager;
|
||||
private final List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RegisterShadersEvent(ResourceManager resourceManager, List<Pair<ShaderInstance, Consumer<ShaderInstance>>> shaderList)
|
||||
{
|
||||
this.resourceManager = resourceManager;
|
||||
this.shaderList = shaderList;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the client-side resource manager}
|
||||
*/
|
||||
public ResourceManager getResourceManager()
|
||||
{
|
||||
return resourceManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a shader, and a callback for when the shader is loaded.
|
||||
*
|
||||
* <p>When creating a {@link ShaderInstance}, pass in the {@linkplain #getResourceManager()
|
||||
* client-side resource manager} as the resource provider. </p>
|
||||
*
|
||||
* <p>Mods should not store the shader instance passed into this method. Instead, mods should store the shader
|
||||
* passed into the registered load callback. </p>
|
||||
*
|
||||
* @param shaderInstance a shader
|
||||
* @param onLoaded a callback for when the shader is loaded
|
||||
*/
|
||||
public void registerShader(ShaderInstance shaderInstance, Consumer<ShaderInstance> onLoaded)
|
||||
{
|
||||
shaderList.add(Pair.of(shaderInstance, onLoaded));
|
||||
|
||||
@@ -7,19 +7,24 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.HumanoidArm;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* This is a more targeted version of {@link RenderHandEvent} event that is fired specifically when
|
||||
* a player's arm is being rendered in first person, and should be used instead if the desired
|
||||
* outcome is just to replace the rendering of the arm, such as to make armor render on it or
|
||||
* instead of it.
|
||||
* Fired before the player's arm is rendered in first person. This is a more targeted version of {@link RenderHandEvent},
|
||||
* and can be used to replace the rendering of the player's arm, such as for rendering armor on the arm or outright
|
||||
* replacing the arm with armor.
|
||||
*
|
||||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
|
||||
* Canceling the event causes the arm to not render.
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the arm will not be rendered. </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 RenderArmEvent extends Event
|
||||
@@ -30,6 +35,10 @@ public class RenderArmEvent extends Event
|
||||
private final AbstractClientPlayer player;
|
||||
private final HumanoidArm arm;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#renderSpecificFirstPersonArm(PoseStack, MultiBufferSource, int, AbstractClientPlayer, HumanoidArm)
|
||||
*/
|
||||
public RenderArmEvent(PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, AbstractClientPlayer player, HumanoidArm arm)
|
||||
{
|
||||
this.poseStack = poseStack;
|
||||
@@ -40,30 +49,42 @@ public class RenderArmEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The arm being rendered.
|
||||
* {@return the arm being rendered}
|
||||
*/
|
||||
public HumanoidArm getArm()
|
||||
{
|
||||
return arm;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight()
|
||||
{
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the client player that is having their arm rendered. In general this will be the same as {@link net.minecraft.client.Minecraft#player}.
|
||||
* {@return the client player that is having their arm rendered} In general, this will be the same as
|
||||
* {@link net.minecraft.client.Minecraft#player}.
|
||||
*/
|
||||
public AbstractClientPlayer getPlayer()
|
||||
{
|
||||
|
||||
@@ -10,26 +10,54 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Called when a block's texture is going to be overlaid on the player's HUD. Cancel this event to prevent the overlay.
|
||||
* Fired before a block texture will be overlaid on the player's view.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay will not be rendered. </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 RenderBlockOverlayEvent extends Event
|
||||
{
|
||||
|
||||
public static enum OverlayType {
|
||||
FIRE, BLOCK, WATER
|
||||
/**
|
||||
* The type of the block overlay to be rendered.
|
||||
*
|
||||
* @see RenderBlockOverlayEvent
|
||||
*/
|
||||
public enum OverlayType {
|
||||
/**
|
||||
* The type of the overlay when the player is burning / on fire.
|
||||
*/
|
||||
FIRE,
|
||||
/**
|
||||
* The type of overlay when the player is suffocating inside a solid block.
|
||||
*/
|
||||
BLOCK,
|
||||
/**
|
||||
* The type of overlay when the player is underwater.
|
||||
*/
|
||||
WATER
|
||||
}
|
||||
|
||||
|
||||
private final Player player;
|
||||
private final PoseStack poseStack;
|
||||
private final OverlayType overlayType;
|
||||
private final BlockState blockState;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderBlockOverlayEvent(Player player, PoseStack poseStack, OverlayType type, BlockState block, BlockPos blockPos)
|
||||
{
|
||||
this.player = player;
|
||||
@@ -37,21 +65,27 @@ public class RenderBlockOverlayEvent extends Event
|
||||
this.overlayType = type;
|
||||
this.blockState = block;
|
||||
this.blockPos = blockPos;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The player which the overlay will apply to
|
||||
* {@return the player which the overlay will apply to}
|
||||
*/
|
||||
public Player getPlayer() { return player; }
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
/**
|
||||
* The type of overlay to occur
|
||||
* {@return the type of the overlay}
|
||||
*/
|
||||
public OverlayType getOverlayType() { return overlayType; }
|
||||
/**
|
||||
* If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from
|
||||
* {@return the block which the overlay is gotten from}
|
||||
*/
|
||||
public BlockState getBlockState() { return blockState; }
|
||||
/**
|
||||
* {@return the position of the block which the overlay is gotten from}
|
||||
*/
|
||||
public BlockPos getBlockPos() { return blockPos; }
|
||||
}
|
||||
@@ -8,122 +8,273 @@ package net.minecraftforge.client.event;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
import net.minecraftforge.client.gui.IIngameOverlay;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when an overlay element is rendered to the game window.
|
||||
* See the two subclasses for listening to before and after rendering.
|
||||
*
|
||||
* <p>An overlay that is not normally active cannot be forced to render, and this event will not fire. </p>
|
||||
*
|
||||
* @see RenderGameOverlayEvent.Pre
|
||||
* @see RenderGameOverlayEvent.Post
|
||||
* @see ForgeIngameGui
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderGameOverlayEvent extends Event
|
||||
{
|
||||
public PoseStack getMatrixStack()
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return mStack;
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
public float getPartialTicks()
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTicks;
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@return the game window}
|
||||
*/
|
||||
public Window getWindow()
|
||||
{
|
||||
return window;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the type of the overlay element being rendered}
|
||||
*/
|
||||
public ElementType getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public static enum ElementType
|
||||
/**
|
||||
* The types of the different overlay elements that can be rendered
|
||||
*/
|
||||
public enum ElementType
|
||||
{
|
||||
/**
|
||||
* Represents all of the overlay elements; cancelling the {@link RenderGameOverlayEvent.Pre} with this type
|
||||
* will suppress rendering of all overlay elements.
|
||||
*/
|
||||
ALL,
|
||||
/**
|
||||
* An in-game overlay layer.
|
||||
*
|
||||
* @see IIngameOverlay
|
||||
* @see RenderGameOverlayEvent.PreLayer
|
||||
* @see RenderGameOverlayEvent.PostLayer
|
||||
*/
|
||||
LAYER,
|
||||
BOSSINFO, // Individual boss bar
|
||||
/**
|
||||
* An individual boss event bar.
|
||||
*
|
||||
* @see RenderGameOverlayEvent.BossInfo
|
||||
*/
|
||||
BOSSINFO,
|
||||
/**
|
||||
* For adding text to be rendered on the screen (after the debug screen text, if visible).
|
||||
*
|
||||
* @see RenderGameOverlayEvent.Text
|
||||
*/
|
||||
TEXT,
|
||||
/**
|
||||
* The chat message window overlay.
|
||||
*
|
||||
* @see RenderGameOverlayEvent.Chat
|
||||
*/
|
||||
CHAT,
|
||||
/**
|
||||
* The player list overlay, shown when the <kbd>TAB</kbd> key (or other keybind) is pressed.
|
||||
*
|
||||
* <em>See {@code ForgeIngameGui#renderPlayerList}</em>
|
||||
*/
|
||||
PLAYER_LIST,
|
||||
/**
|
||||
* The debug overlay.
|
||||
*
|
||||
* <em>See {@code ForgeIngameGui#renderHUDText.}</em>
|
||||
*/
|
||||
DEBUG
|
||||
}
|
||||
|
||||
private final PoseStack mStack;
|
||||
private final float partialTicks;
|
||||
private final PoseStack poseStack;
|
||||
private final float partialTick;
|
||||
private final Window window;
|
||||
private final ElementType type;
|
||||
|
||||
public RenderGameOverlayEvent(PoseStack mStack, float partialTicks, Window window)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderGameOverlayEvent(PoseStack poseStack, float partialTick, Window window)
|
||||
{
|
||||
this.mStack = mStack;
|
||||
this.partialTicks = partialTicks;
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = partialTick;
|
||||
this.window = window;
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
private RenderGameOverlayEvent(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
private RenderGameOverlayEvent(PoseStack poseStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
this.mStack = mStack;
|
||||
this.partialTicks = parent.getPartialTicks();
|
||||
this.poseStack = poseStack;
|
||||
this.partialTick = parent.getPartialTick();
|
||||
this.window = parent.getWindow();
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> an active overlay element is rendered to the screen.
|
||||
* <em>See the three sub-classes for specific special overlay elements. </em>
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay corresponding to this event will not be rendered, and the
|
||||
* corresponding {@link RenderGameOverlayEvent.Post} event is not fired. </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>
|
||||
*
|
||||
* @see RenderGameOverlayEvent.PreLayer
|
||||
* @see RenderGameOverlayEvent.BossInfo
|
||||
* @see RenderGameOverlayEvent.Text
|
||||
* @see RenderGameOverlayEvent.Chat
|
||||
*/
|
||||
public static class Pre extends RenderGameOverlayEvent
|
||||
{
|
||||
public Pre(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(PoseStack poseStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
super(poseStack, parent, type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> an active overlay element is rendered to the screen, if the corresponding
|
||||
* {@link RenderGameOverlayEvent.Pre} is not cancelled.
|
||||
* <em>See the specialized {@link RenderGameOverlayEvent.PostLayer} for individual overlay layer.</em>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class Post extends RenderGameOverlayEvent
|
||||
{
|
||||
public Post(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Post(PoseStack poseStack, RenderGameOverlayEvent parent, ElementType type)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
super(poseStack, parent, type);
|
||||
}
|
||||
@Override public boolean isCancelable(){ return false; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> an in-game overlay layer is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the overlay layer in this event will not be rendered, and the
|
||||
* corresponding {@link RenderGameOverlayEvent.PostLayer} event is not fired. </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>
|
||||
*
|
||||
* @see RenderGameOverlayEvent.PostLayer
|
||||
*/
|
||||
public static class PreLayer extends Pre
|
||||
{
|
||||
private final IIngameOverlay overlay;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PreLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay)
|
||||
{
|
||||
super(mStack, parent, ElementType.LAYER);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the in-game overlay layer being rendered}
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> an in-game overlay layer is rendered to the screen, if the corresponding
|
||||
* {@link RenderGameOverlayEvent.PreLayer} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class PostLayer extends Post
|
||||
{
|
||||
private final IIngameOverlay overlay;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PostLayer(PoseStack mStack, RenderGameOverlayEvent parent, IIngameOverlay overlay)
|
||||
{
|
||||
super(mStack, parent, ElementType.LAYER);
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the in-game overlay layer being rendered}
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> a boss health bar is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the boss health bar corresponding to this event will not be rendered, and the
|
||||
* corresponding {@link RenderGameOverlayEvent.Post} is not fired. </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>
|
||||
*
|
||||
* @see ElementType#BOSSINFO
|
||||
*/
|
||||
public static class BossInfo extends Pre
|
||||
{
|
||||
private final LerpingBossEvent bossEvent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
private int increment;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public BossInfo(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type, LerpingBossEvent bossEvent, int x, int y, int increment)
|
||||
{
|
||||
super(mStack, parent, type);
|
||||
@@ -134,7 +285,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link LerpingBossEvent} currently being rendered
|
||||
* {@return the boss health bar currently being rendered}
|
||||
*/
|
||||
public LerpingBossEvent getBossEvent()
|
||||
{
|
||||
@@ -142,7 +293,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current x position we are rendering at
|
||||
* {@return the X position of the boss health bar}
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
@@ -150,7 +301,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The current y position we are rendering at
|
||||
* {@return the Y position of the boss health bar}
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
@@ -158,7 +309,7 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return How much to move down before rendering the next bar
|
||||
* {@return the Y position increment before rendering the next boss health bar}
|
||||
*/
|
||||
public int getIncrement()
|
||||
{
|
||||
@@ -166,8 +317,9 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount to move down before rendering the next bar
|
||||
* @param increment The increment to set
|
||||
* Sets the Y position increment before rendering the next boss health bar.
|
||||
*
|
||||
* @param increment the new Y position increment
|
||||
*/
|
||||
public void setIncrement(int increment)
|
||||
{
|
||||
@@ -175,10 +327,26 @@ public class RenderGameOverlayEvent extends Event
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> textual information is rendered to the debug screen.
|
||||
* This can be used to add or remove text information.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the text will not be rendered; <em>this includes the debug overlay text</em>. </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>
|
||||
*
|
||||
* @see ElementType#TEXT
|
||||
*/
|
||||
public static class Text extends Pre
|
||||
{
|
||||
private final ArrayList<String> left;
|
||||
private final ArrayList<String> right;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Text(PoseStack mStack, RenderGameOverlayEvent parent, ArrayList<String> left, ArrayList<String> right)
|
||||
{
|
||||
super(mStack, parent, ElementType.TEXT);
|
||||
@@ -186,22 +354,42 @@ public class RenderGameOverlayEvent extends Event
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the modifiable list of text to render on the left side}
|
||||
*/
|
||||
public ArrayList<String> getLeft()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the modifiable list of text to render on the right side}
|
||||
*/
|
||||
public ArrayList<String> getRight()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> the chat messages overlay is rendered to the screen.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the chat messages overlay will not be rendered. </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>
|
||||
*
|
||||
* @see ElementType#CHAT
|
||||
*/
|
||||
public static class Chat extends Pre
|
||||
{
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Chat(PoseStack mStack, RenderGameOverlayEvent parent, int posX, int posY)
|
||||
{
|
||||
super(mStack, parent, ElementType.CHAT);
|
||||
@@ -209,21 +397,37 @@ public class RenderGameOverlayEvent extends Event
|
||||
this.setPosY(posY);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the X position of the chat messages overlay}
|
||||
*/
|
||||
public int getPosX()
|
||||
{
|
||||
return posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new X position for rendering the chat messages overlay
|
||||
*
|
||||
* @param posX the new X position
|
||||
*/
|
||||
public void setPosX(int posX)
|
||||
{
|
||||
this.posX = posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the Y position of the chat messages overlay}
|
||||
*/
|
||||
public int getPosY()
|
||||
{
|
||||
return posY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new Y position for rendering the chat messages overlay
|
||||
*
|
||||
* @param posY the new y position
|
||||
*/
|
||||
public void setPosY(int posY)
|
||||
{
|
||||
this.posY = posY;
|
||||
|
||||
@@ -5,20 +5,27 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
|
||||
* whenever a hand is rendered in first person.
|
||||
* Canceling the event causes the hand to not render.
|
||||
* Fired before a hand is rendered in the first person view.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the hand will not be rendered. </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>
|
||||
*
|
||||
* @see RenderArmEvent
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderHandEvent extends Event
|
||||
@@ -27,53 +34,73 @@ public class RenderHandEvent extends Event
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
private final float partialTicks;
|
||||
private final float partialTick;
|
||||
private final float interpolatedPitch;
|
||||
private final float swingProgress;
|
||||
private final float equipProgress;
|
||||
@Nonnull
|
||||
private final ItemStack stack;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#renderSpecificFirstPersonHand(InteractionHand, PoseStack, MultiBufferSource, int, float, float, float, float, ItemStack)
|
||||
*/
|
||||
public RenderHandEvent(InteractionHand hand, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight,
|
||||
float partialTicks, float interpolatedPitch,
|
||||
float swingProgress, float equipProgress, @Nonnull ItemStack stack)
|
||||
float partialTick, float interpolatedPitch,
|
||||
float swingProgress, float equipProgress, ItemStack stack)
|
||||
{
|
||||
this.hand = hand;
|
||||
this.poseStack = poseStack;
|
||||
this.multiBufferSource = multiBufferSource;
|
||||
this.packedLight = packedLight;
|
||||
this.partialTicks = partialTicks;
|
||||
this.partialTick = partialTick;
|
||||
this.interpolatedPitch = interpolatedPitch;
|
||||
this.swingProgress = swingProgress;
|
||||
this.equipProgress = equipProgress;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the hand being rendered}
|
||||
*/
|
||||
public InteractionHand getHand()
|
||||
{
|
||||
return hand;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() {
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() {
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
public float getPartialTicks()
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTicks;
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The interpolated pitch of the player entity
|
||||
* {@return the interpolated pitch of the player entity}
|
||||
*/
|
||||
public float getInterpolatedPitch()
|
||||
{
|
||||
@@ -81,7 +108,7 @@ public class RenderHandEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The swing progress of the hand being rendered
|
||||
* {@return the swing progress of the hand being rendered}
|
||||
*/
|
||||
public float getSwingProgress()
|
||||
{
|
||||
@@ -89,7 +116,7 @@ public class RenderHandEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The progress of the equip animation. 1.0 is fully equipped.
|
||||
* {@return the progress of the equip animation, from {@code 0.0} to {@code 1.0}}
|
||||
*/
|
||||
public float getEquipProgress()
|
||||
{
|
||||
@@ -97,9 +124,8 @@ public class RenderHandEvent extends Event
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ItemStack to be rendered
|
||||
* {@return the item stack to be rendered}
|
||||
*/
|
||||
@Nonnull
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return stack;
|
||||
|
||||
@@ -6,31 +6,43 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.ItemFrameRenderer;
|
||||
import net.minecraft.world.entity.decoration.ItemFrame;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is called when an item is rendered in an item frame.
|
||||
* Fired before an item stack is rendered in an item frame.
|
||||
* This can be used to prevent normal rendering or add custom rendering.
|
||||
*
|
||||
* You can set canceled to do no further vanilla processing.
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If the event is cancelled, then the item stack will not be rendered</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>
|
||||
*
|
||||
* @see ItemFrameRenderer
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderItemInFrameEvent extends Event
|
||||
{
|
||||
private final ItemStack itemStack;
|
||||
private final ItemFrame itemFrameEntity;
|
||||
private final ItemFrameRenderer renderer;
|
||||
private final ItemFrameRenderer<?> renderer;
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack poseStack,
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer<?> renderItemFrame, PoseStack poseStack,
|
||||
MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
itemStack = itemFrame.getItem();
|
||||
@@ -41,30 +53,49 @@ public class RenderItemInFrameEvent extends Event
|
||||
this.packedLight = packedLight;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
/**
|
||||
* {@return the item stack being rendered}
|
||||
*/
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the item frame entity}
|
||||
*/
|
||||
public ItemFrame getItemFrameEntity()
|
||||
{
|
||||
return itemFrameEntity;
|
||||
}
|
||||
|
||||
public ItemFrameRenderer getRenderer()
|
||||
/**
|
||||
* {@return the renderer for the item frame entity}
|
||||
*/
|
||||
public ItemFrameRenderer<?> getRenderer()
|
||||
{
|
||||
return renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() {
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() {
|
||||
return multiBufferSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() {
|
||||
return packedLight;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,26 @@ package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired after all level rendering.
|
||||
* This can be used for custom rendering outside of e.g. a block entity or entity renderer.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see GameRenderer
|
||||
* @see LevelRenderer
|
||||
*/
|
||||
public class RenderLevelLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final LevelRenderer levelRenderer;
|
||||
@@ -18,6 +35,10 @@ public class RenderLevelLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
private final Matrix4f projectionMatrix;
|
||||
private final long startNanos;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#dispatchRenderLast(LevelRenderer, PoseStack, float, Matrix4f, long)
|
||||
*/
|
||||
public RenderLevelLastEvent(LevelRenderer levelRenderer, PoseStack poseStack, float partialTick, Matrix4f projectionMatrix, long startNanos)
|
||||
{
|
||||
this.levelRenderer = levelRenderer;
|
||||
@@ -27,26 +48,41 @@ public class RenderLevelLastEvent extends net.minecraftforge.eventbus.api.Event
|
||||
this.startNanos = startNanos;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the level renderer}
|
||||
*/
|
||||
public LevelRenderer getLevelRenderer()
|
||||
{
|
||||
return levelRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
return poseStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
return partialTick;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the projection matrix}
|
||||
*/
|
||||
public Matrix4f getProjectionMatrix()
|
||||
{
|
||||
return projectionMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the time when rendering started, in nanoseconds}
|
||||
*/
|
||||
public long getStartNanos()
|
||||
{
|
||||
return startNanos;
|
||||
|
||||
@@ -6,13 +6,31 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when a {@link LivingEntity} is rendered.
|
||||
* See the two subclasses to listen for before and after rendering.
|
||||
*
|
||||
* <p>Despite this event's use of generic type parameters, this is not a {@link net.minecraftforge.eventbus.api.GenericEvent},
|
||||
* and should not be treated as such (such as using generic-specific listeners, which may cause a {@link ClassCastException}).</p>
|
||||
*
|
||||
* @param <T> the living entity that is being rendered
|
||||
* @param <M> the model for the living entity
|
||||
*
|
||||
* @see RenderLivingEvent.Pre
|
||||
* @see RenderLivingEvent.Post
|
||||
* @see RenderPlayerEvent
|
||||
* @see LivingEntityRenderer
|
||||
*/
|
||||
public abstract class RenderLivingEvent<T extends LivingEntity, M extends EntityModel<T>> extends Event
|
||||
{
|
||||
|
||||
@@ -23,6 +41,9 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderLivingEvent(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack,
|
||||
MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
@@ -34,23 +55,74 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
this.packedLight = packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the living entity being rendered
|
||||
*/
|
||||
public LivingEntity getEntity() { return entity; }
|
||||
/**
|
||||
* @return the renderer for the living entity
|
||||
*/
|
||||
public LivingEntityRenderer<T, M> getRenderer() { return renderer; }
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick() { return partialTick; }
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() { return multiBufferSource; }
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() { return packedLight; }
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> an entity is rendered.
|
||||
* This can be used to render additional effects or suppress rendering.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the entity will not be rendered and the corresponding
|
||||
* {@link RenderLivingEvent.Post} will not be fired. </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>
|
||||
*
|
||||
* @param <T> the living entity that is being rendered
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> an entity is rendered, if the corresponding {@link RenderLivingEvent.Post} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancelable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @param <T> the living entity that was rendered
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Post(LivingEntity entity, LivingEntityRenderer<T, M> renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(entity, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
|
||||
@@ -12,29 +12,25 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* RenderNameplateEvent is fired whenever the entity renderer attempts to render a name plate/tag of an entity.
|
||||
* <br>
|
||||
* {@link #nameplateContent} contains the content being rendered on the name plate/tag. This can be changed by mods.<br>
|
||||
* {@link #originalContent} contains the original content being rendered on the name plate/tag. This cannot be
|
||||
* changed by mods.<br>
|
||||
* {@link #entityRenderer} contains the entity renderer instance that renders the name plate/tag. This cannot be
|
||||
* changed by mods.<br>
|
||||
* {@link #poseStack} contains the matrix stack instance involved in rendering the name plate/tag. This cannot
|
||||
* be changed by mods.<br>
|
||||
* {@link #multiBufferSource} contains the render type buffer instance involved in rendering the name plate/tag.
|
||||
* This cannot be changed by mods.<br>
|
||||
* {@link #packedLight} contains the sky and block light values used in rendering the name plate/tag.<br>
|
||||
* {@link #partialTick} contains the partial ticks used in rendering the name plate/tag. This cannot be changed by mods.<br>
|
||||
* <br>
|
||||
* This event has a result. {@link HasResult}. <br>
|
||||
* ALLOW will force-render name plate/tag, DEFAULT will ignore the hook and continue using the vanilla check
|
||||
* and DENY will prevent name plate/tag from rendering<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
**/
|
||||
* Fired before an entity renderer renders the nameplate of an entity.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and {@linkplain HasResult has a result}. </p>
|
||||
* <ul>
|
||||
* <li>{@link Result#ALLOW} - the nameplate will be forcibly rendered.</li>
|
||||
* <li>{@link Result#DEFAULT} - the vanilla logic will be used.</li>
|
||||
* <li>{@link Result#DENY} - the nameplate will not be rendered.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see EntityRenderer
|
||||
*/
|
||||
@Event.HasResult
|
||||
public class RenderNameplateEvent extends EntityEvent
|
||||
{
|
||||
@@ -46,7 +42,10 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
private final float partialTick;
|
||||
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderNameplateEvent(Entity entity, Component content, EntityRenderer<?> entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick)
|
||||
{
|
||||
super(entity);
|
||||
@@ -60,7 +59,9 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content that is to be rendered on the name plate/tag
|
||||
* Sets the new text on the nameplate.
|
||||
*
|
||||
* @param contents the new text
|
||||
*/
|
||||
public void setContent(Component contents)
|
||||
{
|
||||
@@ -68,7 +69,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* The content being rendered on the name plate/tag
|
||||
* {@return the text on the nameplate that will be rendered, if the event is not {@link Result#DENY DENIED}}
|
||||
*/
|
||||
public Component getContent()
|
||||
{
|
||||
@@ -76,7 +77,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* The original content being rendered on the name plate/tag
|
||||
* {@return the original text on the nameplate}
|
||||
*/
|
||||
public Component getOriginalContent()
|
||||
{
|
||||
@@ -84,7 +85,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* The entity renderer that renders the name plate/tag, if it was provided
|
||||
* {@return the entity renderer rendering the nameplate}
|
||||
*/
|
||||
public EntityRenderer<?> getEntityRenderer()
|
||||
{
|
||||
@@ -92,7 +93,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* The matrix stack used during the rendering of the name plate/tag
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack()
|
||||
{
|
||||
@@ -100,7 +101,7 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* The render type buffer used during the rendering of the name plate/tag
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource()
|
||||
{
|
||||
@@ -108,15 +109,17 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* The packed values of sky and block light used during the rendering of the name plate/tag
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see net.minecraft.client.renderer.LightTexture
|
||||
*/
|
||||
public int getPackedLight()
|
||||
{
|
||||
return this.packedLight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The partial ticks used during the rendering of the name plate/tag
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick()
|
||||
{
|
||||
|
||||
@@ -6,12 +6,23 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when a player is being rendered.
|
||||
* See the two subclasses for listening for before and after rendering.
|
||||
*
|
||||
* @see RenderPlayerEvent.Pre
|
||||
* @see RenderPlayerEvent.Post
|
||||
* @see PlayerRenderer
|
||||
*/
|
||||
public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
{
|
||||
private final PlayerRenderer renderer;
|
||||
@@ -20,6 +31,9 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight)
|
||||
{
|
||||
super(player);
|
||||
@@ -30,22 +44,64 @@ public abstract class RenderPlayerEvent extends PlayerEvent
|
||||
this.packedLight = packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the player entity renderer}
|
||||
*/
|
||||
public PlayerRenderer getRenderer() { return renderer; }
|
||||
/**
|
||||
* {@return the partial tick}
|
||||
*/
|
||||
public float getPartialTick() { return partialTick; }
|
||||
/**
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
/**
|
||||
* {@return the source of rendering buffers}
|
||||
*/
|
||||
public MultiBufferSource getMultiBufferSource() { return multiBufferSource; }
|
||||
/**
|
||||
* {@return the amount of packed (sky and block) light for rendering}
|
||||
*
|
||||
* @see LightTexture
|
||||
*/
|
||||
public int getPackedLight() { return packedLight; }
|
||||
|
||||
/**
|
||||
* Fired <b>before</b> the player is rendered.
|
||||
* This can be used for rendering additional effects or suppressing rendering.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the player will not be rendered and the corresponding
|
||||
* {@link RenderPlayerEvent.Post} will not be fired. </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 static class Pre extends RenderPlayerEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired <b>after</b> the player is rendered, if the corresponding {@link RenderPlayerEvent.Pre} is not cancelled.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class Post extends RenderPlayerEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Post(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(player, renderer, partialTick, poseStack, multiBufferSource, packedLight);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ package net.minecraftforge.client.event;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.client.gui.Font;
|
||||
@@ -17,24 +15,24 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A set of events which are fired at various points during tooltip rendering.
|
||||
* <p>
|
||||
* Can be used to change the rendering parameters, draw something extra, etc.
|
||||
* <p>
|
||||
* Do not use this event directly, use one of the subclasses:
|
||||
* <ul>
|
||||
* <li>{@link RenderTooltipEvent.Pre}</li>
|
||||
* <li>{@link RenderTooltipEvent.GatherComponents}</li>
|
||||
* <li>{@link RenderTooltipEvent.Color}</li>
|
||||
* </ul>
|
||||
* Fired during tooltip rendering.
|
||||
* See the various subclasses for listening to specific events.
|
||||
*
|
||||
* @see RenderTooltipEvent.GatherComponents
|
||||
* @see RenderTooltipEvent.Pre
|
||||
* @see RenderTooltipEvent.Color
|
||||
*/
|
||||
public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected final ItemStack itemStack;
|
||||
protected final PoseStack poseStack;
|
||||
protected int x;
|
||||
@@ -43,7 +41,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
protected final List<ClientTooltipComponent> components;
|
||||
|
||||
|
||||
public RenderTooltipEvent(@Nonnull ItemStack itemStack, PoseStack poseStack, int x, int y, @Nonnull Font font, @Nonnull List<ClientTooltipComponent> components)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public RenderTooltipEvent(@NotNull ItemStack itemStack, PoseStack poseStack, int x, int y, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
this.poseStack = poseStack;
|
||||
@@ -54,9 +55,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The stack which the tooltip is being rendered for. As tooltips can be drawn without itemstacks, this stack may be empty.
|
||||
* {@return the item stack which the tooltip is being rendered for, or an {@linkplain ItemStack#isEmpty() empty
|
||||
* item stack} if there is no associated item stack}
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
@@ -64,23 +66,23 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
|
||||
|
||||
/**
|
||||
* @return The PoseStack rendering context.
|
||||
* {@return the pose stack used for rendering}
|
||||
*/
|
||||
public PoseStack getPoseStack() { return poseStack; }
|
||||
|
||||
/**
|
||||
* The components to be drawn.
|
||||
* To modify this list use {@link GatherComponents}.
|
||||
* @return an unmodifiable list of tooltip components to be drawn.
|
||||
* {@return the unmodifiable list of tooltip components}
|
||||
*
|
||||
* <p>Use {@link ItemTooltipEvent} or {@link GatherComponents} to modify tooltip contents or components. </p>
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public List<ClientTooltipComponent> getComponents()
|
||||
{
|
||||
return components;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The X position of the tooltip box. By default, the mouse X position.
|
||||
*{@return the X position of the tooltip box} By default, this is the mouse X position.
|
||||
*/
|
||||
public int getX()
|
||||
{
|
||||
@@ -88,27 +90,32 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Y position of the tooltip box. By default, the mouse Y position.
|
||||
* {@return the Y position of the tooltip box} By default, this is the mouse Y position.
|
||||
*/
|
||||
public int getY()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The {@link Font} instance the current render is using.
|
||||
* {@return The font used to render the text}
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
public Font getFont()
|
||||
{
|
||||
return font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires when a tooltip gathers the {@link TooltipComponent}s to render. This event fires before any text wrapping
|
||||
* or text processing.
|
||||
* This event allows modifying the components to be rendered as well as specifying a maximum width for the tooltip.
|
||||
* The maximum width will cause any text components to be wrapped.
|
||||
* Fired when a tooltip gathers the {@link TooltipComponent}s to be rendered, before any text wrapping or processing.
|
||||
* The list of components and the maximum width of the tooltip can be modified through this event.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the list of components will be empty, causing the tooltip to not be rendered and
|
||||
* the corresponding {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Color} to not be fired. </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 static class GatherComponents extends Event
|
||||
@@ -119,6 +126,9 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private final List<Either<FormattedText, TooltipComponent>> tooltipElements;
|
||||
private int maxWidth;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List<Either<FormattedText, TooltipComponent>> tooltipElements, int maxWidth)
|
||||
{
|
||||
this.itemStack = itemStack;
|
||||
@@ -129,7 +139,8 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ItemStack whose tooltip is being rendered or an empty stack if this tooltip is not for a stack
|
||||
* {@return the item stack which the tooltip is being rendered for, or an {@linkplain ItemStack#isEmpty() empty
|
||||
* item stack} if there is no associated item stack}
|
||||
*/
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
@@ -137,7 +148,9 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the width of the screen
|
||||
* {@return the width of the screen}.
|
||||
* The lines of text within the tooltip are wrapped to be within the screen width, and the tooltip box itself
|
||||
* is moved to be within the screen width.
|
||||
*/
|
||||
public int getScreenWidth()
|
||||
{
|
||||
@@ -145,7 +158,8 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the height of the screen
|
||||
* {@return the height of the screen}
|
||||
* The tooltip box is moved to be within the screen height.
|
||||
*/
|
||||
public int getScreenHeight()
|
||||
{
|
||||
@@ -153,8 +167,8 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* The elements to be rendered. These can be either formatted text or custom tooltip components.
|
||||
* This list is modifiable.
|
||||
* {@return the modifiable list of elements to be rendered on the tooltip} These elements can be either
|
||||
* formatted text or custom tooltip components.
|
||||
*/
|
||||
public List<Either<FormattedText, TooltipComponent>> getTooltipElements()
|
||||
{
|
||||
@@ -162,7 +176,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current maximum width for the text components of the tooltip (or -1 for no maximum width)
|
||||
* {@return the maximum width of the tooltip when being rendered}
|
||||
*
|
||||
* <p>A value of {@code -1} means an unlimited maximum width. However, an unlimited maximum width will still
|
||||
* be wrapped to be within the screen bounds.</p>
|
||||
*/
|
||||
public int getMaxWidth()
|
||||
{
|
||||
@@ -170,7 +187,9 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum width for the text components of the tooltip (or -1 for no maximum width)
|
||||
* Sets the maximum width of the tooltip. Use {@code -1} for unlimited maximum width.
|
||||
*
|
||||
* @param maxWidth the new maximum width
|
||||
*/
|
||||
public void setMaxWidth(int maxWidth)
|
||||
{
|
||||
@@ -179,43 +198,65 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired before any tooltip calculations are done. It provides setters for all aspects of the tooltip, so the final render can be modified.
|
||||
* <p>
|
||||
* This event is {@link Cancelable}.
|
||||
* Fired <b>before</b> the tooltip is rendered.
|
||||
* This can be used to modify the positioning and font of the tooltip.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the tooltip will not be rendered and the corresponding
|
||||
* {@link RenderTooltipEvent.Color} will not be fired. </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 static class Pre extends RenderTooltipEvent
|
||||
{
|
||||
private int screenWidth;
|
||||
private int screenHeight;
|
||||
private final int screenWidth;
|
||||
private final int screenHeight;
|
||||
|
||||
public Pre(@Nonnull ItemStack stack, PoseStack poseStack, int x, int y, int screenWidth, int screenHeight, @Nonnull Font font, @Nonnull List<ClientTooltipComponent> components)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Pre(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, int screenWidth, int screenHeight, @NotNull Font font, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
super(stack, poseStack, x, y, font, components);
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the width of the screen}.
|
||||
* The lines of text within the tooltip are wrapped to be within the screen width, and the tooltip box itself
|
||||
* is moved to be within the screen width.
|
||||
*/
|
||||
public int getScreenWidth()
|
||||
{
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the height of the screen}
|
||||
* The tooltip box is moved to be within the screen height.
|
||||
*/
|
||||
public int getScreenHeight()
|
||||
{
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link Font} to be used to render text.
|
||||
* Sets the font to be used to render text.
|
||||
*
|
||||
* @param fr the new font
|
||||
*/
|
||||
public void setFont(@Nonnull Font fr)
|
||||
public void setFont(@NotNull Font fr)
|
||||
{
|
||||
this.font = fr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the X origin of the tooltip.
|
||||
* Sets the X origin of the tooltip.
|
||||
*
|
||||
* @param x the new X origin
|
||||
*/
|
||||
public void setX(int x)
|
||||
{
|
||||
@@ -223,7 +264,9 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Y origin of the tooltip.
|
||||
* Sets the Y origin of the tooltip.
|
||||
*
|
||||
* @param y the new Y origin
|
||||
*/
|
||||
public void setY(int y)
|
||||
{
|
||||
@@ -232,7 +275,13 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired when the colours for the tooltip background are determined.
|
||||
* Fired when the colours for the tooltip background are determined.
|
||||
* This can be used to modify the background color and the border's gradient colors.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*/
|
||||
public static class Color extends RenderTooltipEvent
|
||||
{
|
||||
@@ -244,7 +293,10 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
private int borderStart;
|
||||
private int borderEnd;
|
||||
|
||||
public Color(@Nonnull ItemStack stack, PoseStack poseStack, int x, int y, @Nonnull Font fr, int background, int borderStart, int borderEnd, @Nonnull List<ClientTooltipComponent> components)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public Color(@NotNull ItemStack stack, PoseStack poseStack, int x, int y, @NotNull Font fr, int background, int borderStart, int borderEnd, @NotNull List<ClientTooltipComponent> components)
|
||||
{
|
||||
super(stack, poseStack, x, y, fr, components);
|
||||
this.originalBackground = background;
|
||||
@@ -256,67 +308,118 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api
|
||||
this.borderEnd = borderEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the gradient start color for the tooltip background}
|
||||
*/
|
||||
public int getBackgroundStart()
|
||||
{
|
||||
return backgroundStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the gradient end color for the tooltip background}
|
||||
*/
|
||||
public int getBackgroundEnd()
|
||||
{
|
||||
return backgroundEnd;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the new color for the tooltip background. This sets both the gradient start and end color for the
|
||||
* background to this color.
|
||||
*
|
||||
* @param background the new color for the tooltip background
|
||||
*/
|
||||
public void setBackground(int background)
|
||||
{
|
||||
this.backgroundStart = background;
|
||||
this.backgroundEnd = background;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new start color for the gradient of the tooltip background.
|
||||
*
|
||||
* @param backgroundStart the new start color for the tooltip background
|
||||
*/
|
||||
public void setBackgroundStart(int backgroundStart)
|
||||
{
|
||||
this.backgroundStart = backgroundStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new end color for the gradient of the tooltip background.
|
||||
*
|
||||
* @param backgroundEnd the new end color for the tooltip background
|
||||
*/
|
||||
public void setBackgroundEnd(int backgroundEnd)
|
||||
{
|
||||
this.backgroundEnd = backgroundEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the gradient start color for the tooltip border}
|
||||
*/
|
||||
public int getBorderStart()
|
||||
{
|
||||
return borderStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new start color for the gradient of the tooltip border.
|
||||
*
|
||||
* @param borderStart the new start color for the tooltip border
|
||||
*/
|
||||
public void setBorderStart(int borderStart)
|
||||
{
|
||||
this.borderStart = borderStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the gradient end color for the tooltip border}
|
||||
*/
|
||||
public int getBorderEnd()
|
||||
{
|
||||
return borderEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new end color for the gradient of the tooltip border.
|
||||
*
|
||||
* @param borderEnd the new end color for the tooltip border
|
||||
*/
|
||||
public void setBorderEnd(int borderEnd)
|
||||
{
|
||||
this.borderEnd = borderEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original tooltip background's gradient start color}
|
||||
*/
|
||||
public int getOriginalBackgroundStart()
|
||||
{
|
||||
return originalBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original tooltip background's gradient end color}
|
||||
*/
|
||||
public int getOriginalBackgroundEnd()
|
||||
{
|
||||
return originalBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original tooltip border's gradient start color}
|
||||
*/
|
||||
public int getOriginalBorderStart()
|
||||
{
|
||||
return originalBorderStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original tooltip border's gradient end color}
|
||||
*/
|
||||
public int getOriginalBorderEnd()
|
||||
{
|
||||
return originalBorderEnd;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,30 +5,50 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* This event is called before any Screen will open.
|
||||
* If you don't want this to happen, cancel the event.
|
||||
* If you want to override this Screen, simply set the screen variable to your own Screen.
|
||||
* Fired before any {@link Screen} will be opened, to allow changing or preventing it from being opened. All screen
|
||||
* layers on the screen are closed before this event is fired.
|
||||
*
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the {@code Screen} shall be prevented from opening and any previous screen
|
||||
* will remain open. However, cancelling this event will not prevent the closing of screen layers which happened before
|
||||
* this event fired.</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 ScreenOpenEvent extends Event
|
||||
{
|
||||
private Screen screen;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public ScreenOpenEvent(Screen screen)
|
||||
{
|
||||
this.setScreen(screen);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the screen that will be opened, if the event is not cancelled}
|
||||
*/
|
||||
public Screen getScreen()
|
||||
{
|
||||
return screen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new screen to be opened, if the event is not cancelled.
|
||||
*
|
||||
* @param screen the new screen
|
||||
*/
|
||||
public void setScreen(Screen screen)
|
||||
{
|
||||
this.screen = screen;
|
||||
|
||||
@@ -6,68 +6,105 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.Screenshot;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This event is fired before and after a screenshot is taken
|
||||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
|
||||
* This event is {@link Cancelable}
|
||||
* Fired when a screenshot is taken, but before it is written to disk.
|
||||
*
|
||||
* {@link #screenshotFile} contains the file the screenshot will be/was saved to
|
||||
* {@link #image} contains the {@link NativeImage} that will be saved
|
||||
* {@link #resultMessage} contains the {@link Component} to be returned. If {@code null}, the default vanilla message will be used instead
|
||||
* <p>This event is {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}.
|
||||
* If this event is cancelled, then the screenshot is not written to disk, and the message in the event will be posted
|
||||
* to the player's chat.</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>
|
||||
*
|
||||
* @see Screenshot
|
||||
*/
|
||||
@Cancelable
|
||||
public class ScreenshotEvent extends Event
|
||||
{
|
||||
|
||||
public static final Component DEFAULT_CANCEL_REASON = new TextComponent("Screenshot canceled");
|
||||
public static final Component DEFAULT_CANCEL_REASON = Component.literal("Screenshot canceled");
|
||||
|
||||
private NativeImage image;
|
||||
private final NativeImage image;
|
||||
private File screenshotFile;
|
||||
|
||||
private Component resultMessage = null;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see net.minecraftforge.client.ForgeHooksClient#onScreenshot(NativeImage, File)
|
||||
*/
|
||||
public ScreenshotEvent(NativeImage image, File screenshotFile)
|
||||
{
|
||||
this.image = image;
|
||||
this.screenshotFile = screenshotFile;
|
||||
try {
|
||||
this.screenshotFile = screenshotFile.getCanonicalFile(); // FORGE: Fix errors on Windows with paths that include \.\
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the in-memory image of the screenshot}
|
||||
*/
|
||||
public NativeImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the file where the screenshot will be saved to
|
||||
*/
|
||||
public File getScreenshotFile()
|
||||
{
|
||||
return screenshotFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new file where the screenshot will be saved to.
|
||||
*
|
||||
* @param screenshotFile the new filepath
|
||||
*/
|
||||
public void setScreenshotFile(File screenshotFile)
|
||||
{
|
||||
this.screenshotFile = screenshotFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the custom cancellation message, or {@code null} if no custom message is set}
|
||||
*/
|
||||
public Component getResultMessage()
|
||||
{
|
||||
return resultMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new custom cancellation message used to inform the player.
|
||||
* It may be {@code null}, in which case the {@linkplain #DEFAULT_CANCEL_REASON default cancel reason} will be used.
|
||||
*
|
||||
* @param resultMessage the new result message
|
||||
*/
|
||||
public void setResultMessage(Component resultMessage)
|
||||
{
|
||||
this.resultMessage = resultMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cancellation message to be used in informing the player.
|
||||
*
|
||||
* <p>If there is no custom message given ({@link #getResultMessage()} returns {@code null}), then
|
||||
* the message will be the {@linkplain #DEFAULT_CANCEL_REASON default cancel reason message}.</p>
|
||||
*
|
||||
* @return the cancel message for the player
|
||||
*/
|
||||
public Component getCancelMessage()
|
||||
{
|
||||
return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON;
|
||||
|
||||
@@ -6,35 +6,62 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* Fired before and after a texture atlas stitched together.
|
||||
* See the two subclasses to listen for before and after stitching.
|
||||
*
|
||||
* @see TextureStitchEvent.Pre
|
||||
* @see TextureStitchEvent.Post
|
||||
* @see TextureAtlas
|
||||
*/
|
||||
public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final TextureAtlas atlas;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public TextureStitchEvent(TextureAtlas atlas)
|
||||
{
|
||||
this.atlas = atlas;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the texture atlas}
|
||||
*/
|
||||
public TextureAtlas getAtlas()
|
||||
{
|
||||
return atlas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the TextureMap is told to refresh it's stitched texture.
|
||||
* Called before the {@link net.minecraft.client.renderer.texture.TextureAtlasSprite} are loaded.
|
||||
* <p>Fired <b>before</b> a texture atlas is stitched together.
|
||||
* This can be used to add custom sprites to be stitched into the atlas. </p>
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class Pre extends TextureStitchEvent
|
||||
{
|
||||
private final Set<ResourceLocation> sprites;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onTextureStitchedPre(TextureAtlas, Set)
|
||||
*/
|
||||
public Pre(TextureAtlas map, Set<ResourceLocation> sprites)
|
||||
{
|
||||
super(map);
|
||||
@@ -42,7 +69,12 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a sprite to be stitched into the Texture Atlas.
|
||||
* Adds a sprite to be stitched into the texture atlas.
|
||||
*
|
||||
* <p>Callers should check that the atlas which the event is fired for is the atlas they wish to stitch the
|
||||
* sprite into, as otherwise they would be stitching the sprite into all atlases.</p>
|
||||
*
|
||||
* @param sprite the location of the sprite
|
||||
*/
|
||||
public boolean addSprite(ResourceLocation sprite) {
|
||||
return this.sprites.add(sprite);
|
||||
@@ -50,12 +82,19 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired once the texture map has loaded all textures and
|
||||
* stitched them together. All Icons should have there locations defined
|
||||
* by the time this is fired.
|
||||
* Fired <b>after</b> a texture atlas is stitched together and all textures therein has been loaded.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public static class Post extends TextureStitchEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
* @see ForgeHooksClient#onTextureStitchedPost(TextureAtlas)
|
||||
*/
|
||||
public Post(TextureAtlas map){ super(map); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
/**
|
||||
* Events fired only on the client-side, chiefly related to rendering and user interfaces (screens and input).
|
||||
*/
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.FieldsAreNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -7,19 +7,35 @@ package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/***
|
||||
* Raised when the SoundManager tries to play a normal sound.
|
||||
/**
|
||||
* Fired when a sound is about to be played by the sound engine. This fires before the sound is played and before any
|
||||
* checks on the sound (such as a zeroed volume, an empty {@link net.minecraft.client.resources.sounds.Sound}, and
|
||||
* others). This can be used to change or prevent (by passing {@code null)} a sound from being played through
|
||||
* {@link #setSound(SoundInstance)}).
|
||||
*
|
||||
* If you return null from this function it will prevent the sound from being played,
|
||||
* you can return a different entry if you want to change the sound being played.
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlaySoundEvent extends SoundEvent
|
||||
{
|
||||
private final String name;
|
||||
private final SoundInstance originalSound;
|
||||
@Nullable
|
||||
private SoundInstance sound;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PlaySoundEvent(SoundEngine manager, SoundInstance sound)
|
||||
{
|
||||
super(manager);
|
||||
@@ -28,23 +44,38 @@ public class PlaySoundEvent extends SoundEvent
|
||||
this.setSound(sound);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the name of the original sound} This is equivalent to the path of the location of the original sound.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the original sound that was to be played}
|
||||
*/
|
||||
public SoundInstance getOriginalSound()
|
||||
{
|
||||
return originalSound;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the sound to be played, or {@code null} if no sound will be played}
|
||||
*/
|
||||
@Nullable
|
||||
public SoundInstance getSound()
|
||||
{
|
||||
return sound;
|
||||
}
|
||||
|
||||
public void setSound(SoundInstance result)
|
||||
/**
|
||||
* Sets the sound to be played, which may be {@code null} to prevent any sound from being played.
|
||||
*
|
||||
* @param newSound the new sound to be played, or {@code null} for no sound
|
||||
*/
|
||||
public void setSound(@Nullable SoundInstance newSound)
|
||||
{
|
||||
this.sound = result;
|
||||
this.sound = newSound;
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,29 @@ import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when a <em>non-streaming</em> sound is being played. A non-streaming sound is loaded fully into memory
|
||||
* in a buffer before being played, and used for most sounds of short length such as sound effects for clicking
|
||||
* buttons.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public PlaySoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel source)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
super(manager, sound, source);
|
||||
super(engine, sound, channel);
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,29 @@ import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
/**
|
||||
* Fired when a <em>streaming</em> sound is being played. A streaming sound is streamed directly from its source
|
||||
* (such as a file), and used for sounds of long length which are unsuitable to keep fully loaded in-memory in a buffer
|
||||
* (as is done for regular non-streaming sounds), such as background music or music discs.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </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>
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
public PlayStreamingSourceEvent(SoundEngine manager, SoundInstance sound, Channel source)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
super(manager, sound, source);
|
||||
super(engine, sound, channel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
/**
|
||||
* Fired when the {@link SoundEngine} is constructed or (re)loaded, such as during game initialization or when the sound
|
||||
* output device is changed.
|
||||
*
|
||||
* <p>This event is not {@linkplain Cancelable cancellable}, and does not {@linkplain HasResult have a result}. </p>
|
||||
*
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*/
|
||||
public class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent
|
||||
{
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public SoundEngineLoadEvent(SoundEngine manager)
|
||||
{
|
||||
super(manager);
|
||||
}
|
||||
}
|
||||
@@ -8,44 +8,85 @@ package net.minecraftforge.client.event.sound;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
|
||||
public class SoundEvent extends net.minecraftforge.eventbus.api.Event
|
||||
/**
|
||||
* Superclass for sound related events.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see SoundSourceEvent
|
||||
* @see PlaySoundEvent
|
||||
* @see SoundEngineLoadEvent
|
||||
*/
|
||||
public class SoundEvent extends Event
|
||||
{
|
||||
private final SoundEngine engine;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public SoundEvent(SoundEngine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the sound engine}
|
||||
*/
|
||||
public SoundEngine getEngine()
|
||||
{
|
||||
return engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Superclass for when a sound has started to play on an audio channel.
|
||||
*
|
||||
* <p>These events are fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}. </p>
|
||||
*
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public static class SoundSourceEvent extends SoundEvent
|
||||
{
|
||||
private final SoundInstance sound;
|
||||
private final Channel channel;
|
||||
private final String name;
|
||||
|
||||
public SoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel channel)
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
public SoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
{
|
||||
super(manager);
|
||||
super(engine);
|
||||
this.name = sound.getLocation().getPath();
|
||||
this.sound = sound;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the sound being played}
|
||||
*/
|
||||
public SoundInstance getSound()
|
||||
{
|
||||
return sound;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the audio channel on which the sound is playing on}
|
||||
*/
|
||||
public Channel getChannel()
|
||||
{
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the name of the sound being played} This is equivalent to the path of the location of the original sound.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
|
||||
/**
|
||||
* Raised by the SoundManager.loadSoundSettings, this would be a good place for
|
||||
* adding your custom sounds to the SoundPool.
|
||||
*/
|
||||
public class SoundLoadEvent extends SoundEvent implements IModBusEvent
|
||||
{
|
||||
public SoundLoadEvent(SoundEngine manager)
|
||||
{
|
||||
super(manager);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
|
||||
/**
|
||||
* This event is raised by the SoundManager when it does its first setup of the
|
||||
* SoundSystemConfig's codecs, use this function to add your own codecs.
|
||||
*/
|
||||
public class SoundSetupEvent extends SoundEvent
|
||||
{
|
||||
public SoundSetupEvent(SoundEngine manager)
|
||||
{
|
||||
super(manager);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
/**
|
||||
* Client-only events relating to sounds.
|
||||
*/
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
package net.minecraftforge.client.event.sound;
|
||||
|
||||
import net.minecraft.FieldsAreNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
Reference in new issue
Block a user