mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +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
@@ -10,13 +10,12 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.handshake.ClientIntentionPacket;
|
||||
import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket;
|
||||
import net.minecraft.network.protocol.login.ServerboundCustomQueryPacket;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.LogMessageAdapter;
|
||||
@@ -191,7 +190,7 @@ public class HandshakeHandler
|
||||
LOGGER.error(FMLHSMARKER, "Terminating connection with server, mismatched mod list");
|
||||
//Populate the mod mismatch attribute with a new mismatch data instance to indicate that the disconnect happened due to a mod mismatch
|
||||
c.get().getNetworkManager().channel().attr(NetworkConstants.FML_MOD_MISMATCH_DATA).set(ModMismatchData.channel(mismatchedChannels, NetworkHooks.getConnectionData(c.get().getNetworkManager()), true));
|
||||
c.get().getNetworkManager().disconnect(new TextComponent("Connection closed - mismatched mod channel list"));
|
||||
c.get().getNetworkManager().disconnect(Component.literal("Connection closed - mismatched mod channel list"));
|
||||
return;
|
||||
}
|
||||
// Validate synced custom datapack registries, client cannot be missing any present on the server.
|
||||
@@ -208,7 +207,7 @@ public class HandshakeHandler
|
||||
}
|
||||
if (!missingDataPackRegistries.isEmpty())
|
||||
{
|
||||
c.get().getNetworkManager().disconnect(new TranslatableComponent("fml.menu.multiplayer.missingdatapackregistries", String.join(", ", missingDataPackRegistries)));
|
||||
c.get().getNetworkManager().disconnect(Component.translatable("fml.menu.multiplayer.missingdatapackregistries", String.join(", ", missingDataPackRegistries)));
|
||||
return;
|
||||
}
|
||||
NetworkConstants.handshakeChannel.reply(new HandshakeMessages.C2SModListReply(), c.get());
|
||||
@@ -247,7 +246,7 @@ public class HandshakeHandler
|
||||
if (!mismatchedChannels.isEmpty()) {
|
||||
LOGGER.error(FMLHSMARKER, "Terminating connection with client, mismatched mod list");
|
||||
NetworkConstants.handshakeChannel.reply(new HandshakeMessages.S2CChannelMismatchData(mismatchedChannels), c.get());
|
||||
c.get().getNetworkManager().disconnect(new TextComponent("Connection closed - mismatched mod channel list"));
|
||||
c.get().getNetworkManager().disconnect(Component.literal("Connection closed - mismatched mod channel list"));
|
||||
return;
|
||||
}
|
||||
LOGGER.debug(FMLHSMARKER, "Accepted client connection mod list");
|
||||
@@ -263,7 +262,7 @@ public class HandshakeHandler
|
||||
c.get().setPacketHandled(true);
|
||||
//Populate the mod mismatch attribute with a new mismatch data instance to indicate that the disconnect happened due to a mod mismatch
|
||||
c.get().getNetworkManager().channel().attr(NetworkConstants.FML_MOD_MISMATCH_DATA).set(ModMismatchData.channel(modMismatchData.getMismatchedChannelData(), NetworkHooks.getConnectionData(c.get().getNetworkManager()), false));
|
||||
c.get().getNetworkManager().disconnect(new TextComponent("Connection closed - mismatched mod channel list"));
|
||||
c.get().getNetworkManager().disconnect(Component.literal("Connection closed - mismatched mod channel list"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +313,7 @@ public class HandshakeHandler
|
||||
LOGGER.error(FMLHSMARKER, "Failed to load registry, closing connection.");
|
||||
//Populate the mod mismatch attribute with a new mismatch data instance to indicate that the disconnect happened due to a mod mismatch
|
||||
this.manager.channel().attr(NetworkConstants.FML_MOD_MISMATCH_DATA).set(ModMismatchData.registry(registryMismatches.get(), NetworkHooks.getConnectionData(contextSupplier.get().getNetworkManager())));
|
||||
this.manager.disconnect(new TextComponent("Failed to synchronize registry data from server, closing connection"));
|
||||
this.manager.disconnect(Component.literal("Failed to synchronize registry data from server, closing connection"));
|
||||
}
|
||||
return successfulConnection.get();
|
||||
}
|
||||
|
||||
@@ -92,11 +92,7 @@ public class HandshakeMessages
|
||||
for (int x = 0; x < len; x++)
|
||||
registries.add(input.readResourceLocation());
|
||||
|
||||
// Datapack Registries may or may not be sent in 1.18.2 due to netcode changes.
|
||||
// TODO 1.19: Remove optionalness of datapack registry list in the mod list packet.
|
||||
List<ResourceKey<? extends Registry<?>>> dataPackRegistries = input.isReadable()
|
||||
? input.readCollection(ArrayList::new, buf -> ResourceKey.createRegistryKey(buf.readResourceLocation()))
|
||||
: List.of();
|
||||
List<ResourceKey<? extends Registry<?>>> dataPackRegistries = input.readCollection(ArrayList::new, buf -> ResourceKey.createRegistryKey(buf.readResourceLocation()));
|
||||
return new S2CModList(mods, channels, registries, dataPackRegistries);
|
||||
}
|
||||
|
||||
@@ -113,14 +109,9 @@ public class HandshakeMessages
|
||||
|
||||
output.writeVarInt(registries.size());
|
||||
registries.forEach(output::writeResourceLocation);
|
||||
|
||||
// The list of synced datapack registry names is not sent in 1.18.2 if the list is empty.
|
||||
// TODO 1.19: should send an empty list if the list is empty.
|
||||
|
||||
Set<ResourceKey<? extends Registry<?>>> dataPackRegistries = DataPackRegistriesHooks.getSyncedCustomRegistries();
|
||||
if (!dataPackRegistries.isEmpty())
|
||||
{
|
||||
output.writeCollection(dataPackRegistries, (buf,key) -> buf.writeResourceLocation(key.location()));
|
||||
}
|
||||
output.writeCollection(dataPackRegistries, (buf, key) -> buf.writeResourceLocation(key.location()));
|
||||
}
|
||||
|
||||
public List<String> getModList() {
|
||||
@@ -134,7 +125,7 @@ public class HandshakeMessages
|
||||
public Map<ResourceLocation, String> getChannels() {
|
||||
return this.channels;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return list of ids of non-vanilla syncable datapack registries on the server.
|
||||
*/
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package net.minecraftforge.network;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.util.Attribute;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
@@ -20,6 +18,7 @@ import net.minecraft.util.thread.BlockableEventLoop;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.common.util.LogicalSidedProvider;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraftforge.fml.util.thread.EffectiveSide;
|
||||
import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory;
|
||||
import net.minecraftforge.network.ConnectionData.ModMismatchData;
|
||||
@@ -40,8 +40,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
import net.minecraftforge.fml.config.ConfigTracker;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class NetworkHooks
|
||||
{
|
||||
@@ -80,7 +79,7 @@ public class NetworkHooks
|
||||
|
||||
private static boolean validateSideForProcessing(final ICustomPacket<?> packet, final NetworkInstance ni, final Connection manager) {
|
||||
if (packet.getDirection().getReceptionSide() != EffectiveSide.get()) {
|
||||
manager.disconnect(new TextComponent("Illegal packet received, terminating connection"));
|
||||
manager.disconnect(Component.literal("Illegal packet received, terminating connection"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -88,7 +87,7 @@ public class NetworkHooks
|
||||
|
||||
public static void validatePacketDirection(final NetworkDirection packetDirection, final Optional<NetworkDirection> expectedDirection, final Connection connection) {
|
||||
if (packetDirection != expectedDirection.orElse(packetDirection)) {
|
||||
connection.disconnect(new TextComponent("Illegal packet received, terminating connection"));
|
||||
connection.disconnect(Component.literal("Illegal packet received, terminating connection"));
|
||||
throw new IllegalStateException("Invalid packet received, aborting connection");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundAddMobPacket;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
@@ -36,7 +35,7 @@ public class PlayMessages
|
||||
{
|
||||
/**
|
||||
* Used to spawn a custom entity without the same restrictions as
|
||||
* {@link ClientboundAddEntityPacket} or {@link ClientboundAddMobPacket}
|
||||
* {@link ClientboundAddEntityPacket}
|
||||
*
|
||||
* To customize how your entity is created clientside (instead of using the default factory provided to the {@link EntityType})
|
||||
* see {@link EntityType.Builder#setCustomClientFactory}.
|
||||
@@ -143,7 +142,7 @@ public class PlayMessages
|
||||
return;
|
||||
}
|
||||
|
||||
e.setPacketCoordinates(msg.posX, msg.posY, msg.posZ);
|
||||
e.setPos(msg.posX, msg.posY, msg.posZ);
|
||||
e.absMoveTo(msg.posX, msg.posY, msg.posZ, (msg.yaw * 360) / 256.0F, (msg.pitch * 360) / 256.0F);
|
||||
e.setYHeadRot((msg.headYaw * 360) / 256.0F);
|
||||
e.setYBodyRot((msg.headYaw * 360) / 256.0F);
|
||||
|
||||
@@ -9,8 +9,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.Connection;
|
||||
@@ -21,6 +19,7 @@ import net.minecraft.network.protocol.game.ClientboundUpdateTagsPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundUpdateRecipesPacket;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Network filter for forge-forge connections.
|
||||
|
||||
+11
-9
@@ -8,16 +8,14 @@ package net.minecraftforge.network.filters;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypes;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@@ -32,6 +30,7 @@ import net.minecraftforge.network.NetworkHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraftforge.registries.RegistryManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -68,7 +67,7 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter
|
||||
* Filter for SEntityPropertiesPacket. Filters out any entity attributes that are not in the "minecraft" namespace.
|
||||
* A vanilla client would ignore these with an error log.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
private static ClientboundUpdateAttributesPacket filterEntityProperties(ClientboundUpdateAttributesPacket msg)
|
||||
{
|
||||
ClientboundUpdateAttributesPacket newPacket = new ClientboundUpdateAttributesPacket(msg.getEntityId(), Collections.emptyList());
|
||||
@@ -85,12 +84,15 @@ public class VanillaConnectionNetworkFilter extends VanillaPacketFilter
|
||||
* Filter for SCommandListPacket. Uses {@link CommandTreeCleaner} to filter out any ArgumentTypes that are not in the "minecraft" or "brigadier" namespace.
|
||||
* A vanilla client would fail to deserialize the packet and disconnect with an error message if these were sent.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
private static ClientboundCommandsPacket filterCommandList(ClientboundCommandsPacket packet)
|
||||
{
|
||||
RootCommandNode<SharedSuggestionProvider> root = packet.getRoot();
|
||||
CommandBuildContext commandBuildContext = new CommandBuildContext(RegistryAccess.BUILTIN.get());
|
||||
commandBuildContext.missingTagAccessPolicy(CommandBuildContext.MissingTagAccessPolicy.RETURN_EMPTY);
|
||||
RootCommandNode<SharedSuggestionProvider> root = packet.getRoot(commandBuildContext);
|
||||
RootCommandNode<SharedSuggestionProvider> newRoot = CommandTreeCleaner.cleanArgumentTypes(root, argType -> {
|
||||
ResourceLocation id = ArgumentTypes.getId(argType);
|
||||
ArgumentTypeInfo<?, ?> info = ArgumentTypeInfos.byClass(argType);
|
||||
ResourceLocation id = Registry.COMMAND_ARGUMENT_TYPE.getKey(info);
|
||||
return id != null && (id.getNamespace().equals("minecraft") || id.getNamespace().equals("brigadier"));
|
||||
});
|
||||
return new ClientboundCommandsPacket(newRoot);
|
||||
|
||||
@@ -11,12 +11,11 @@ import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.Connection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A filter for vanilla impl packets.
|
||||
@@ -34,7 +33,7 @@ public abstract class VanillaPacketFilter extends MessageToMessageEncoder<Packet
|
||||
/**
|
||||
* Helper function for building the handler map.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected static <T extends Packet<?>> Map.Entry<Class<? extends Packet<?>>, BiConsumer<Packet<?>, List<? super Packet<?>>>> handler(Class<T> cls, Function<T, ? extends Packet<?>> function)
|
||||
{
|
||||
return handler(cls, (pkt, list) -> list.add(function.apply(cls.cast(pkt))));
|
||||
@@ -43,7 +42,7 @@ public abstract class VanillaPacketFilter extends MessageToMessageEncoder<Packet
|
||||
/**
|
||||
* Helper function for building the handler map.
|
||||
*/
|
||||
@Nonnull
|
||||
@NotNull
|
||||
protected static <T extends Packet<?>> Map.Entry<Class<? extends Packet<?>>, BiConsumer<Packet<?>, List<? super Packet<?>>>> handler(Class<T> cls, BiConsumer<Packet<?>, List<? super Packet<?>>> consumer)
|
||||
{
|
||||
return new AbstractMap.SimpleEntry<>(cls, consumer);
|
||||
|
||||
Reference in new issue
Block a user