mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +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
@@ -14,7 +14,6 @@ import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
@@ -22,12 +21,7 @@ import net.minecraft.commands.CommandRuntimeException;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.synchronization.SuggestionProviders;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraftforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -79,11 +73,6 @@ public class ClientCommandHandler
|
||||
CommandDispatcher<SharedSuggestionProvider> newServerCommands = new CommandDispatcher<>();
|
||||
copy(serverCommandsRoot, newServerCommands.getRoot());
|
||||
|
||||
// Copies the server side commands into a temporary server side commands root node to be used later without the client commands
|
||||
RootCommandNode<SharedSuggestionProvider> serverCommandsCopy = new RootCommandNode<>();
|
||||
CommandHelper.mergeCommandNode(newServerCommands.getRoot(), serverCommandsCopy, new IdentityHashMap<>(),
|
||||
Minecraft.getInstance().getConnection().getSuggestionsProvider(), (context) -> 0, (suggestions) -> null);
|
||||
|
||||
// Copies the client side commands into the server side commands to be used for suggestions
|
||||
CommandHelper.mergeCommandNode(commands.getRoot(), newServerCommands.getRoot(), new IdentityHashMap<>(), getSource(), (context) -> 0, (suggestions) -> {
|
||||
SuggestionProvider<SharedSuggestionProvider> suggestionProvider = SuggestionProviders
|
||||
@@ -105,12 +94,6 @@ public class ClientCommandHandler
|
||||
return suggestionProvider;
|
||||
});
|
||||
|
||||
// Copies the server side commands into the client side commands so that they can be sent to the server as a chat message
|
||||
CommandHelper.mergeCommandNode(serverCommandsCopy, commands.getRoot(), new IdentityHashMap<>(), Minecraft.getInstance().getConnection().getSuggestionsProvider(),
|
||||
(context) -> {
|
||||
Minecraft.getInstance().player.chat((context.getInput().startsWith("/") ? "" : "/") + context.getInput());
|
||||
return 0;
|
||||
}, (suggestions) -> null);
|
||||
return newServerCommands;
|
||||
}
|
||||
|
||||
@@ -159,23 +142,17 @@ public class ClientCommandHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Always try to execute the cached parsing of client message as a command. Requires that the execute field of the commands to be set to send to server so that they aren't
|
||||
* Always try to execute the cached parsing of a typed command as a clientside command. Requires that the execute field of the commands to be set to send to server so that they aren't\
|
||||
* treated as client command's that do nothing.
|
||||
*
|
||||
* {@link net.minecraft.commands.Commands#performCommand(CommandSourceStack, String)} for reference
|
||||
*
|
||||
* @param sendMessage
|
||||
* the chat message
|
||||
* @return false leaves the message to be sent to the server, true means it should be caught before {@link LocalPlayer#chat(String)}
|
||||
* @param command the full command to execute, no preceding slash
|
||||
* @return {@code false} leaves the message to be sent to the server, while {@code true} means it should be caught before LocalPlayer#sendCommand
|
||||
*/
|
||||
public static boolean sendMessage(String sendMessage)
|
||||
public static boolean runCommand(String command)
|
||||
{
|
||||
StringReader reader = new StringReader(sendMessage);
|
||||
|
||||
if (!reader.canRead() || reader.read() != '/')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
StringReader reader = new StringReader(command);
|
||||
|
||||
ClientCommandSourceStack source = getSource();
|
||||
|
||||
@@ -185,7 +162,7 @@ public class ClientCommandHandler
|
||||
}
|
||||
catch (CommandRuntimeException execution)// Probably thrown by the command
|
||||
{
|
||||
Minecraft.getInstance().player.sendMessage(new TextComponent("").append(execution.getComponent()).withStyle(ChatFormatting.RED), Util.NIL_UUID);
|
||||
Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(execution.getComponent()).withStyle(ChatFormatting.RED));
|
||||
}
|
||||
catch (CommandSyntaxException syntax)// Usually thrown by the CommandDispatcher
|
||||
{
|
||||
@@ -194,12 +171,12 @@ public class ClientCommandHandler
|
||||
// in case of unknown command, let the server try and handle it
|
||||
return false;
|
||||
}
|
||||
Minecraft.getInstance().player.sendMessage(
|
||||
new TextComponent("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED), Util.NIL_UUID);
|
||||
Minecraft.getInstance().player.sendSystemMessage(
|
||||
Component.literal("").append(ComponentUtils.fromMessage(syntax.getRawMessage())).withStyle(ChatFormatting.RED));
|
||||
if (syntax.getInput() != null && syntax.getCursor() >= 0)
|
||||
{
|
||||
int position = Math.min(syntax.getInput().length(), syntax.getCursor());
|
||||
MutableComponent details = new TextComponent("")
|
||||
MutableComponent details = Component.literal("")
|
||||
.withStyle(ChatFormatting.GRAY)
|
||||
.withStyle((style) -> style
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, reader.getString())));
|
||||
@@ -210,21 +187,20 @@ public class ClientCommandHandler
|
||||
details.append(syntax.getInput().substring(Math.max(0, position - 10), position));
|
||||
if (position < syntax.getInput().length())
|
||||
{
|
||||
details.append(new TextComponent(syntax.getInput().substring(position)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE));
|
||||
details.append(Component.literal(syntax.getInput().substring(position)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE));
|
||||
}
|
||||
details.append(new TranslatableComponent("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
|
||||
Minecraft.getInstance().player.sendMessage(new TextComponent("").append(details).withStyle(ChatFormatting.RED), Util.NIL_UUID);
|
||||
details.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
|
||||
Minecraft.getInstance().player.sendSystemMessage(Component.literal("").append(details).withStyle(ChatFormatting.RED));
|
||||
}
|
||||
}
|
||||
catch (Exception generic)// Probably thrown by the command
|
||||
{
|
||||
TextComponent message = new TextComponent(generic.getMessage() == null ? generic.getClass().getName() : generic.getMessage());
|
||||
Minecraft.getInstance().player.sendMessage(new TranslatableComponent("command.failed")
|
||||
MutableComponent message = Component.literal(generic.getMessage() == null ? generic.getClass().getName() : generic.getMessage());
|
||||
Minecraft.getInstance().player.sendSystemMessage(Component.translatable("command.failed")
|
||||
.withStyle(ChatFormatting.RED)
|
||||
.withStyle((style) -> style
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message))),
|
||||
Util.NIL_UUID);
|
||||
LOGGER.error("Error executing client command \"{}\"", sendMessage, generic);
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, message))));
|
||||
LOGGER.error("Error executing client command \"{}\"", command, generic);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user