Forge 1.19.1

Load natives from classpath
Make command argument types a forge registry
Add `EntityMobGriefingEvent` to `Allay#wantsToPickUp`
Overhaul `ServerChatEvent` to use `ChatDecorator` system
Remove `ClientChatEvent#setMessage` for now
Gradle 7.5

Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
SizableShrimp committed 2022-07-28 00:20:31 -05:00
1 parent 3c1126a7b4
commit 6845c094ab
98 files changed
+1025 -733

No files matched your search

@@ -26,7 +26,6 @@ import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.chat.NarratorChatListener;
import net.minecraft.client.gui.components.LerpingBossEvent;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.Screen;
@@ -74,6 +73,8 @@ import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.MessageSigner;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.network.protocol.status.ServerStatus;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
@@ -217,7 +218,7 @@ public class ForgeHooksClient
guiLayers.push(minecraft.screen);
minecraft.screen = Objects.requireNonNull(screen);
screen.init(minecraft, minecraft.getWindow().getGuiScaledWidth(), minecraft.getWindow().getGuiScaledHeight());
NarratorChatListener.INSTANCE.sayNow(screen.getNarrationMessage());
minecraft.getNarrator().sayNow(screen.getNarrationMessage());
}
public static void popGuiLayer(Minecraft minecraft)
@@ -230,7 +231,7 @@ public class ForgeHooksClient
popGuiLayerInternal(minecraft);
if (minecraft.screen != null)
NarratorChatListener.INSTANCE.sayNow(minecraft.screen.getNarrationMessage());
minecraft.getNarrator().sayNow(minecraft.screen.getNarrationMessage());
}
public static float getGuiFarPlane()
@@ -940,9 +941,9 @@ public class ForgeHooksClient
}
@Nullable
public static Component onClientChat(ChatType type, Component message, ChatSender chatSender)
public static Component onClientChat(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, MessageSigner messageSigner)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message, chatSender);
ClientChatReceivedEvent event = new ClientChatReceivedEvent(boundChatType, message, playerChatMessage, messageSigner);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
}
@@ -16,7 +16,7 @@ import org.jetbrains.annotations.ApiStatus;
* 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>
* If the event is cancelled, the chat message 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>
@@ -24,13 +24,13 @@ import org.jetbrains.annotations.ApiStatus;
@Cancelable
public class ClientChatEvent extends Event
{
private String message;
// private String message;
private final String originalMessage;
@ApiStatus.Internal
public ClientChatEvent(String message)
{
this.setMessage(message);
// this.setMessage(message);
this.originalMessage = Strings.nullToEmpty(message);
}
@@ -39,24 +39,24 @@ public class ClientChatEvent extends Event
*/
public String getMessage()
{
return message;
return this.originalMessage;
}
/**
* 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);
}
// /**
// * 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;
return this.originalMessage;
}
}
@@ -6,9 +6,10 @@
package net.minecraftforge.client.event;
import net.minecraft.Util;
import net.minecraft.network.chat.ChatSender;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MessageSigner;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@@ -31,15 +32,17 @@ import org.jetbrains.annotations.ApiStatus;
public class ClientChatReceivedEvent extends Event
{
private Component message;
private final ChatType type;
private final ChatSender chatSender;
private final ChatType.Bound boundChatType;
private final PlayerChatMessage playerChatMessage;
private final MessageSigner messageSigner;
@ApiStatus.Internal
public ClientChatReceivedEvent(ChatType type, Component message, ChatSender chatSender)
public ClientChatReceivedEvent(ChatType.Bound boundChatType, Component message, PlayerChatMessage playerChatMessage, MessageSigner messageSigner)
{
this.type = type;
this.boundChatType = boundChatType;
this.message = message;
this.chatSender = chatSender;
this.playerChatMessage = playerChatMessage;
this.messageSigner = messageSigner;
}
/**
@@ -53,7 +56,7 @@ public class ClientChatReceivedEvent extends Event
/**
* 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
* @param message the new message to be displayed
*/
public void setMessage(Component message)
{
@@ -61,20 +64,38 @@ public class ClientChatReceivedEvent extends Event
}
/**
* {@return the type of the chat message}
* {@return the bound chat type of the chat message}.
* This contains the chat type, display name of the sender, and nullable target name depending on the chat type.
*/
public ChatType getType()
public ChatType.Bound getBoundChatType()
{
return type;
return this.boundChatType;
}
/**
* {@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}.
* {@return the full player chat message}.
* This contains the sender UUID, various signing data, and the optional unsigned contents.
*/
public ChatSender getChatSender()
public PlayerChatMessage getPlayerChatMessage()
{
return chatSender;
return this.playerChatMessage;
}
/**
* {@return the message signer}.
* This contains the sender UUID, timestamp of message creation, and signature salt.
* The {@linkplain MessageSigner#profileId() sender UUID} will be {@link Util#NIL_UUID} if the message is a system message.
*/
public MessageSigner getMessageSigner()
{
return this.messageSigner;
}
/**
* {@return {@code true} if the message was sent by the system, {@code false} otherwise}
*/
public boolean isSystem()
{
return this.messageSigner.isSystem();
}
}
@@ -16,5 +16,5 @@ import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
@FunctionalInterface
public interface IGuiOverlay
{
void render(ForgeGui gui, PoseStack poseStack, float partialTick, int width, int height);
void render(ForgeGui gui, PoseStack poseStack, float partialTick, int screenWidth, int screenHeight);
}