diff --git a/.gitignore b/.gitignore index b03f74fc5d..2872cfca1b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,7 @@ /projects/clean/ /projects/forge/ /projects/fmlonly/ -#/patches/ +#/patches/* #occupational hazards /projects/**/build/ @@ -36,7 +36,7 @@ src/generated/resources/.cache/ #Patch rejects /patches-/ -#*.patch.rej +*.patch.rej /projects/*/rejects/ # FML changelog @@ -44,3 +44,4 @@ changelog.txt *.py *.7z /logs/ + diff --git a/build.gradle b/build.gradle index e30a45caf1..0e01fae44f 100644 --- a/build.gradle +++ b/build.gradle @@ -43,9 +43,9 @@ ext { ] } MAPPING_CHANNEL = 'official' - MAPPING_VERSION = '1.17.1' - MC_VERSION = '1.17.1' - MCP_VERSION = '20210706.113038' + MAPPING_VERSION = '1.18' + MC_VERSION = '1.18' + MCP_VERSION = '20211130.085255' SPI_VERSION = '4.0.10' ACCESSTRANSFORMERS_VERSION = '8.0.4' COREMODS_VERSION = '5.0.1' @@ -63,10 +63,10 @@ ext { FORGE_VERSION = VERSION.substring(MC_VERSION.length() + 1) SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0' - VIGNETTE = 'net.minecraftforge.lex:vignette:0.2.0.16' BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar' INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.7' JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4' + FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.17:all' } println('Version: ' + VERSION + @@ -109,7 +109,7 @@ subprojects { } } - java.toolchain.languageVersion = JavaLanguageVersion.of(16) + java.toolchain.languageVersion = JavaLanguageVersion.of(17) tasks.withType(Javadoc).configureEach { options.tags = [ @@ -285,18 +285,16 @@ def sharedFmlonlyForge = { Project prj -> } } else { prj.task([type: RenameJar, dependsOn: prj.tasks.createMcp2Srg], "create${side}SRG") { - tool = VIGNETTE + tool = FART args = [ - '--jar-in', '{input}', - '--jar-out', '{output}', - '--mapping-format', 'tsrg2', - '--mappings', '{mappings}', - // '--stable', - '--create-inits', '--fix-param-annotations', '--fernflower-meta' + '--input', '{input}', + '--output', '{output}', + '--names', '{mappings}', + '--ann-fix', '--ids-fix', '--src-fix', '--record-fix' ] mappings = prj.tasks.createMcp2Srg.srg input = prj.tasks.getByName("download${side}Slim").output - output = file("build/create${side}SRG/output.jar") + output = prj.file("build/create${side}SRG/output.jar") } } @@ -726,15 +724,13 @@ project(':fmlonly') { '{MC_EXTRA}': '{MC_EXTRA_SHA}' ] ], [ - jar: VIGNETTE, - classpath: getClasspath(project, libs, VIGNETTE), + jar: FART, + classpath: getClasspath(project, libs, FART), args: [ - '--jar-in', '{MC_SLIM}', - '--jar-out', '{MC_SRG}', - '--mapping-format', 'tsrg2', - '--mappings', '{MERGED_MAPPINGS}', - // '--stable', - '--create-inits', '--fix-param-annotations', '--fernflower-meta' + '--input', '{MC_SLIM}', + '--output', '{MC_SRG}', + '--names', '{MERGED_MAPPINGS}', + '--ann-fix', '--ids-fix', '--src-fix', '--record-fix' ]/*, outputs: [ '{MC_SRG}': '{MC_SRG_SHA}' @@ -1250,15 +1246,13 @@ project(':forge') { '{MC_EXTRA}': '{MC_EXTRA_SHA}' ] ], [ - jar: VIGNETTE, - classpath: getClasspath(project, libs, VIGNETTE), + jar: FART, + classpath: getClasspath(project, libs, FART), args: [ - '--jar-in', '{MC_SLIM}', - '--jar-out', '{MC_SRG}', - '--mapping-format', 'tsrg2', - '--mappings', '{MERGED_MAPPINGS}', - // '--stable', - '--create-inits', '--fix-param-annotations', '--fernflower-meta' + '--input', '{MC_SLIM}', + '--output', '{MC_SRG}', + '--names', '{MERGED_MAPPINGS}', + '--ann-fix', '--ids-fix', '--src-fix', '--record-fix' ]/*, outputs: [ '{MC_SRG}': '{MC_SRG_SHA}' @@ -1341,7 +1335,7 @@ project(':forge') { MAPPING_CHANNEL: MAPPING_CHANNEL, MAPPING_VERSION: MAPPING_VERSION, FORGE_SPEC_VERSION: SPEC_VERSION.split("\\.")[0], - MC_NEXT_VERSION: "1."+((MC_VERSION.split("\\.")[1] as int)+1) + MC_NEXT_VERSION: "1."+((MC_VERSION.split("[\\.-]")[1] as int)+1) ]) rename 'gitignore\\.txt', '.gitignore' rename 'gitattributes\\.txt', '.gitattributes' diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java b/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java index c6e300657d..fe99898d9a 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/Bindings.java @@ -1,7 +1,6 @@ package net.minecraftforge.fml; import cpw.mods.modlauncher.util.ServiceLoaderUtils; -import net.minecraftforge.eventbus.api.BusBuilder; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.config.IConfigEvent; import net.minecraftforge.fml.loading.FMLLoader; diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java b/fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java index 3b665b922a..f1cf253ed1 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/IExtensionPoint.java @@ -28,13 +28,13 @@ public interface IExtensionPoint * Compatibility display test for the mod. * Used for displaying compatibility with remote servers with the same mod, and on disk saves. * - * The supplier provides my "local" version for sending across the network or writing to disk - * The predicate tests the version from a remote instance or save for acceptability (Boolean is true for network, false for local save) + * The supplier provides my "local" version for sending across the impl or writing to disk + * The predicate tests the version from a remote instance or save for acceptability (Boolean is true for impl, false for local save) * and returns true if the version is compatible. * - *

Return {@code net.minecraftforge.fmllegacy.network.FMLNetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored + *

Return {@code net.minecraftforge.impl.impl.FMLNetworkConstants#IGNORESERVERONLY} in the supplier, if you wish to be ignored * as a server side only mod.

- *

Return true in the predicate for all values of the input string (when network boolean is true) if you are client side, + *

Return true in the predicate for all values of the input string (when impl boolean is true) if you are client side, * and don't care about matching any potential server version.

* *

diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java index 1c12b49bff..df563b58b3 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModLoader.java @@ -34,7 +34,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java b/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java index 471b1a3b17..79383398d8 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/ModStateManager.java @@ -1,7 +1,6 @@ package net.minecraftforge.fml; import com.google.common.graph.GraphBuilder; -import com.google.common.graph.MutableGraph; import cpw.mods.modlauncher.util.ServiceLoaderUtils; import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.toposort.TopologicalSort; diff --git a/fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java b/fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java index adc9abbb4c..1f2239b54c 100644 --- a/fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java +++ b/fmlcore/src/main/java/net/minecraftforge/fml/VersionChecker.java @@ -43,7 +43,6 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import java.util.zip.GZIPInputStream; diff --git a/fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java b/fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java deleted file mode 100644 index 9c9c8ee12c..0000000000 --- a/fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityInjectDefinalize.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.asm; - -import java.util.EnumSet; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; - -/** - * Removes the final modifier from fields with the @CapabilityInject annotation, prevents the JITer from in lining them so our runtime replacements can work. - */ -@Deprecated(since = "1.18", forRemoval = true) -public class CapabilityInjectDefinalize implements ILaunchPluginService { - - private final String CAP = "Lnet/minecraftforge/common/capabilities/Capability;"; //Don't directly reference this to prevent class loading. - private final String CAP_INJECT = "Lnet/minecraftforge/common/capabilities/CapabilityInject;"; //Don't directly reference this to prevent class loading. - - @Override - public String name() { - return "capability_inject_definalize"; - } - - private static final EnumSet YAY = EnumSet.of(Phase.AFTER); - private static final EnumSet NAY = EnumSet.noneOf(Phase.class); - - @Override - public EnumSet handlesClass(Type classType, boolean isEmpty) - { - return isEmpty ? NAY : YAY; - } - - private boolean hasHolder(List lst) - { - return lst != null && lst.stream().anyMatch(n -> n.desc.equals(CAP_INJECT)); - } - - @Override - public int processClassWithFlags(final Phase phase, final ClassNode classNode, final Type classType, final String reason) - { - final int flags = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL; - final AtomicBoolean changed = new AtomicBoolean(); - classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.equals(CAP) && hasHolder(f.visibleAnnotations)).forEach(f -> - { - int prev = f.access; - f.access &= ~Opcodes.ACC_FINAL; //Strip final - f.access |= Opcodes.ACC_SYNTHETIC; //Add Synthetic so we can check in runtime. - changed.compareAndSet(false, prev != f.access); - }); - - return changed.get() ? ComputeFlags.SIMPLE_REWRITE : ComputeFlags.NO_REWRITE; - } - -} diff --git a/fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityTokenSubclass.java b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/CapabilityTokenSubclass.java similarity index 99% rename from fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityTokenSubclass.java rename to fmlloader/src/main/java/net/minecraftforge/fml/common/asm/CapabilityTokenSubclass.java index d64e8bcd9e..2ead2d4227 100644 --- a/fmlloader/src/main/java/net/minecraftforge/common/asm/CapabilityTokenSubclass.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/CapabilityTokenSubclass.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.common.asm; +package net.minecraftforge.fml.common.asm; import java.util.ArrayDeque; import java.util.Deque; diff --git a/fmlloader/src/main/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java similarity index 98% rename from fmlloader/src/main/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java rename to fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java index db3f2aec4c..67e28983e7 100644 --- a/fmlloader/src/main/java/net/minecraftforge/common/asm/ObjectHolderDefinalize.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/ObjectHolderDefinalize.java @@ -17,9 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.common.asm; +package net.minecraftforge.fml.common.asm; -import java.nio.file.Path; import java.util.EnumSet; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/fmlloader/src/main/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java similarity index 99% rename from fmlloader/src/main/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java rename to fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java index a0f6dd50cb..5d80dd796a 100644 --- a/fmlloader/src/main/java/net/minecraftforge/common/asm/RuntimeEnumExtender.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/common/asm/RuntimeEnumExtender.java @@ -17,9 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.common.asm; +package net.minecraftforge.fml.common.asm; -import java.nio.file.Path; import java.util.EnumSet; import java.util.List; import java.util.stream.Collectors; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java index 88cf4758df..6754518d68 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLConfig.java @@ -24,15 +24,12 @@ import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.core.file.FileNotFoundAction; import com.electronwill.nightconfig.core.io.ParsingException; import com.electronwill.nightconfig.core.io.WritingMode; -import net.minecraftforge.api.distmarker.Dist; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.Objects; -import java.util.stream.Collectors; import static net.minecraftforge.fml.loading.LogMarkers.CORE; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java index 27700cba95..e1da0b58c6 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLLoader.java @@ -23,9 +23,12 @@ import cpw.mods.modlauncher.Launcher; import cpw.mods.modlauncher.api.*; import cpw.mods.modlauncher.serviceapi.ILaunchPluginService; import cpw.mods.modlauncher.util.ServiceLoaderUtils; +import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler; +import net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer; +import net.minecraftforge.fml.loading.moddiscovery.ModFile; +import net.minecraftforge.fml.loading.moddiscovery.ModValidator; import net.minecraftforge.accesstransformer.service.AccessTransformerService; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.loading.moddiscovery.*; import net.minecraftforge.fml.loading.progress.EarlyProgressVisualization; import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.fml.loading.targets.CommonLaunchHandler; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java index ec227d0f84..d1bc534c30 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/FMLServiceProvider.java @@ -78,7 +78,7 @@ public class FMLServiceProvider implements ITransformationService LOGGER.debug(CORE, "Loading configuration"); FMLConfig.load(); LOGGER.debug(CORE, "Preparing ModFile"); - environment.computePropertyIfAbsent(Environment.Keys.MODFILEFACTORY.get(), k->ModFile.buildFactory()); + environment.computePropertyIfAbsent(Environment.Keys.MODFILEFACTORY.get(), k->ModFile::new); arguments = new HashMap<>(); arguments.put("modLists", modListsArgumentList); arguments.put("mods", modsArgumentList); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java index 4992a0c172..f912dd6ae0 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LanguageLoadingProvider.java @@ -32,11 +32,7 @@ import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; -import java.io.File; -import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java index 5bc4235f66..8637b7d0d8 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/LibraryFinder.java @@ -22,14 +22,8 @@ package net.minecraftforge.fml.loading; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; - -import static net.minecraftforge.fml.loading.LogMarkers.CORE; public class LibraryFinder { private static final Logger LOGGER = LogManager.getLogger(); @@ -44,39 +38,9 @@ public class LibraryFinder { return libsPath; } - // Not used anywhere in Forge's codebase, scheduled for deletion unless a good need is expressed. - @Deprecated(forRemoval = true, since = "1.17.1") - public static Path findJarPathFor(final String className, final String jarName) { - final URL resource = LibraryFinder.class.getClassLoader().getResource(className); - return findJarPathFor(className, jarName, resource); - } - - /* - * Only used in ClasspathLocator now, so moved too a private method and depreciated this. - * Scheduled for deletion unless a good need is expressed. - */ - @Deprecated(forRemoval = true, since = "1.17.1") - public static Path findJarPathFor(final String resourceName, final String jarName, final URL resource) { - try { - Path path; - final URI uri = resource.toURI(); - if (uri.getScheme().equals("jar") && uri.getRawSchemeSpecificPart().contains("!/")) { - int lastExcl = uri.getRawSchemeSpecificPart().lastIndexOf("!/"); - path = Paths.get(new URI(uri.getRawSchemeSpecificPart().substring(0, lastExcl))); - } else { - path = Paths.get(new URI("file://"+uri.getRawSchemeSpecificPart().substring(0, uri.getRawSchemeSpecificPart().length()-resourceName.length()))); - } - LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString()); - return path; - } catch (NullPointerException | URISyntaxException e) { - LOGGER.fatal(CORE, "Failed to find JAR for class {} - {}", resourceName, jarName); - throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e); - } - } - static Path getForgeLibraryPath(final String mcVersion, final String forgeVersion, final String forgeGroup) { Path forgePath = findLibsPath().resolve(MavenCoordinateResolver.get(forgeGroup, "forge", "", "universal", mcVersion+"-"+forgeVersion)); - LOGGER.debug(CORE, "Found forge path {} is {}", forgePath, pathStatus(forgePath)); + LOGGER.debug(LogMarkers.CORE, "Found forge path {} is {}", forgePath, pathStatus(forgePath)); return forgePath; } @@ -88,9 +52,9 @@ public class LibraryFinder { Path srgMcPath = findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraft", type, "", "srg", mcVersion+"-"+mcpVersion)); Path mcExtrasPath = findLibsPath().resolve(MavenCoordinateResolver.get("net.minecraft", type, "", "extra", mcVersion+"-"+mcpVersion)); Path patchedBinariesPath = findLibsPath().resolve(MavenCoordinateResolver.get(forgeGroup, "forge", "", type, mcVersion+"-"+forgeVersion)); - LOGGER.debug(CORE,"SRG MC at {} is {}", srgMcPath.toString(), pathStatus(srgMcPath)); - LOGGER.debug(CORE,"MC Extras at {} is {}", mcExtrasPath.toString(), pathStatus(mcExtrasPath)); - LOGGER.debug(CORE,"Forge patches at {} is {}", patchedBinariesPath.toString(), pathStatus(patchedBinariesPath)); + LOGGER.debug(LogMarkers.CORE,"SRG MC at {} is {}", srgMcPath.toString(), pathStatus(srgMcPath)); + LOGGER.debug(LogMarkers.CORE,"MC Extras at {} is {}", mcExtrasPath.toString(), pathStatus(mcExtrasPath)); + LOGGER.debug(LogMarkers.CORE,"Forge patches at {} is {}", patchedBinariesPath.toString(), pathStatus(patchedBinariesPath)); return new Path[] { patchedBinariesPath, mcExtrasPath, srgMcPath }; } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java index 1279980b10..9f3a05e0ed 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/MCPNamingService.java @@ -14,8 +14,6 @@ import java.util.Map; import java.util.function.BiConsumer; import java.util.function.BiFunction; -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - public class MCPNamingService implements INameMappingService { private static final Logger LOGGER = LogManager.getLogger(); private HashMap methods; @@ -58,7 +56,7 @@ public class MCPNamingService implements INameMappingService { HashMap tmpmethods = new HashMap<>(1000); loadMappings("methods.csv", tmpmethods::put); methods = tmpmethods; - LOGGER.debug(CORE, "Loaded {} method mappings from methods.csv", methods.size()); + LOGGER.debug(LogMarkers.CORE, "Loaded {} method mappings from methods.csv", methods.size()); } return methods.getOrDefault(origin, origin); } @@ -68,7 +66,7 @@ public class MCPNamingService implements INameMappingService { HashMap tmpfields = new HashMap<>(1000); loadMappings("fields.csv", tmpfields::put); fields = tmpfields; - LOGGER.debug(CORE, "Loaded {} field mappings from fields.csv", fields.size()); + LOGGER.debug(LogMarkers.CORE, "Loaded {} field mappings from fields.csv", fields.size()); } return fields.getOrDefault(origin, origin); } @@ -81,7 +79,7 @@ public class MCPNamingService implements INameMappingService { try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) { reader.lines().skip(1).map(e -> e.split(",")).forEach(e -> mapStore.accept(e[0], e[1])); } catch (IOException e1) { - LOGGER.error(CORE, "Error reading mappings", e1); + LOGGER.error(LogMarkers.CORE, "Error reading mappings", e1); } } } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java index 08a4c4241c..fcdf26a017 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModDirTransformerDiscoverer.java @@ -30,7 +30,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.stream.Stream; import java.util.zip.ZipFile; public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService { diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java index 3472c95fc3..10df6572b3 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java @@ -32,14 +32,12 @@ import net.minecraftforge.fml.loading.toposort.TopologicalSort; import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.util.StringBuilderFormattable; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; import static java.util.stream.Collectors.*; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java index dc2f98ad3a..ee9344e34b 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/VersionSupportMatrix.java @@ -19,7 +19,6 @@ package net.minecraftforge.fml.loading; -import net.minecraftforge.forgespi.language.MavenVersionAdapter; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.VersionRange; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java index af30082cc0..333b69f187 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractJarFileLocator.java @@ -21,6 +21,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import cpw.mods.jarhandling.SecureJar; import cpw.mods.jarhandling.JarMetadata; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.forgespi.language.IConfigurable; import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModInfo; @@ -42,8 +43,6 @@ import java.util.jar.Manifest; import java.util.stream.Collectors; import java.util.stream.Stream; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - public abstract class AbstractJarFileLocator implements IModLocator { private static final Logger LOGGER = LogManager.getLogger(); protected static final String MODS_TOML = "META-INF/mods.toml"; @@ -51,14 +50,14 @@ public abstract class AbstractJarFileLocator implements IModLocator { @Override public void scanFile(final IModFile file, final Consumer pathConsumer) { - LOGGER.debug(SCAN,"Scan started: {}", file); + LOGGER.debug(LogMarkers.SCAN,"Scan started: {}", file); final Function status = p->file.getSecureJar().verifyPath(p); try (Stream files = Files.find(file.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { file.setSecurityStatus(files.peek(pathConsumer).map(status).reduce((s1, s2)-> SecureJar.Status.values()[Math.min(s1.ordinal(), s2.ordinal())]).orElse(SecureJar.Status.INVALID)); } catch (IOException e) { e.printStackTrace(); } - LOGGER.debug(SCAN,"Scan finished: {}", file); + LOGGER.debug(LogMarkers.SCAN,"Scan finished: {}", file); } @Override @@ -89,10 +88,10 @@ public abstract class AbstractJarFileLocator implements IModLocator { IModFile mod = null; var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE); if (sj.findFile(MODS_TOML).isPresent()) { - LOGGER.debug(SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path); - mod = ModFile.newFMLInstance(this, sj); + LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path); + mod = new ModFile(sj, this, ModFileParser::modsTomlParser); } else if (type != null) { - LOGGER.debug(SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path); + LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path); mod = new ModFile(sj, this, this::manifestParser); } else { return Optional.empty(); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java index 5753ef0e54..cf89762e39 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/BackgroundScanHandler.java @@ -19,8 +19,9 @@ package net.minecraftforge.fml.loading.moddiscovery; -import net.minecraftforge.forgespi.language.ModFileScanData; import net.minecraftforge.fml.loading.LoadingModList; +import net.minecraftforge.fml.loading.LogMarkers; +import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -30,8 +31,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.*; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - public class BackgroundScanHandler { private enum ScanStatus { @@ -87,7 +86,7 @@ public class BackgroundScanHandler private void addCompletedFile(final ModFile file, final ModFileScanData modFileScanData, final Throwable throwable) { if (throwable != null) { status = ScanStatus.ERRORED; - LOGGER.error(SCAN,"An error occurred scanning file {}", file, throwable); + LOGGER.error(LogMarkers.SCAN,"An error occurred scanning file {}", file, throwable); } pendingFiles.remove(file); scannedFiles.add(file); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ClasspathLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ClasspathLocator.java index 0c9d22bb27..e5b32821ed 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ClasspathLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ClasspathLocator.java @@ -19,6 +19,7 @@ package net.minecraftforge.fml.loading.moddiscovery; +import net.minecraftforge.fml.loading.LogMarkers; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -36,7 +37,6 @@ import java.util.Enumeration; import java.util.List; import java.util.Map; import java.util.stream.Stream; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; public class ClasspathLocator extends AbstractJarFileLocator { private static final Logger LOGGER = LogManager.getLogger(); @@ -62,7 +62,7 @@ public class ClasspathLocator extends AbstractJarFileLocator { return paths.build(); } catch (IOException e) { - LOGGER.fatal(SCAN, "Error trying to find resources", e); + LOGGER.fatal(LogMarkers.SCAN, "Error trying to find resources", e); throw new RuntimeException(e); } } @@ -99,7 +99,7 @@ public class ClasspathLocator extends AbstractJarFileLocator { //LOGGER.debug(CORE, "Found JAR {} at path {}", jarName, path.toString()); return path; } catch (NullPointerException | URISyntaxException e) { - LOGGER.fatal(SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName); + LOGGER.fatal(LogMarkers.SCAN, "Failed to find JAR for class {} - {}", resourceName, jarName); throw new RuntimeException("Unable to locate "+resourceName+" - "+jarName, e); } } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java index 72a9c6aa3c..6e6c69c4ab 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java @@ -19,6 +19,7 @@ package net.minecraftforge.fml.loading.moddiscovery; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModLocator; import org.apache.logging.log4j.LogManager; @@ -34,9 +35,6 @@ import java.util.Map; import java.util.function.Consumer; import java.util.stream.Stream; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - public class ExplodedDirectoryLocator implements IModLocator { private static final Logger LOGGER = LogManager.getLogger(); @@ -47,8 +45,12 @@ public class ExplodedDirectoryLocator implements IModLocator { @Override public List scanMods() { - explodedMods.forEach(explodedMod -> ModJarMetadata.buildFile(this, jar ->jar.findFile("/META-INF/mods.toml").isPresent(), explodedMod.paths().toArray(Path[]::new)) - .ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString()))); + explodedMods.forEach(explodedMod -> + ModJarMetadata.buildFile(this, + jar->jar.findFile("/META-INF/mods.toml").isPresent(), + (a,b) -> true, + explodedMod.paths().toArray(Path[]::new)) + .ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LogMarkers.LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString()))); return List.copyOf(mods.values()); } @@ -59,13 +61,13 @@ public class ExplodedDirectoryLocator implements IModLocator { @Override public void scanFile(final IModFile file, final Consumer pathConsumer) { - LOGGER.debug(SCAN,"Scanning exploded directory {}", file.getFilePath().toString()); + LOGGER.debug(LogMarkers.SCAN,"Scanning exploded directory {}", file.getFilePath().toString()); try (Stream files = Files.find(file.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { files.forEach(pathConsumer); } catch (IOException e) { e.printStackTrace(); } - LOGGER.debug(SCAN,"Exploded directory scan complete {}", file.getFilePath().toString()); + LOGGER.debug(LogMarkers.SCAN,"Exploded directory scan complete {}", file.getFilePath().toString()); } @Override diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java index d6532bced2..eee48d7f59 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/MinecraftLocator.java @@ -1,11 +1,10 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.Config; -import com.electronwill.nightconfig.core.file.FileConfig; import cpw.mods.jarhandling.SecureJar; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.forgespi.language.IModFileInfo; -import net.minecraftforge.forgespi.language.MavenVersionAdapter; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.IModLocator; import net.minecraftforge.forgespi.locating.ModFileFactory; @@ -18,8 +17,6 @@ import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; public class MinecraftLocator implements IModLocator { private static final Logger LOGGER = LogManager.getLogger(); @@ -29,8 +26,13 @@ public class MinecraftLocator implements IModLocator { final var launchHandler = FMLLoader.getLaunchHandler(); var baseMC = launchHandler.getMinecraftPaths(); var mcjar = ModJarMetadata.buildFile(j->ModFileFactory.FACTORY.build(j, this, this::buildMinecraftTOML), j->true, baseMC.minecraftFilter(), baseMC.minecraftPaths().toArray(Path[]::new)).orElseThrow(); - var artifacts = baseMC.otherArtifacts().stream().map(SecureJar::from).map(sj->ModFile.newFMLInstance(this, sj)).collect(Collectors.toList()); - var othermods = baseMC.otherModPaths().stream().map(p->ModJarMetadata.buildFile(this, p.toArray(Path[]::new))).toList(); + var artifacts = baseMC.otherArtifacts().stream() + .map(SecureJar::from) + .map(sj -> new ModFile(sj, this, ModFileParser::modsTomlParser)) + .collect(Collectors.toList()); + var othermods = baseMC.otherModPaths().stream() + .map(p->ModJarMetadata.buildFile(this, p.toArray(Path[]::new))) + .toList(); artifacts.add(mcjar); artifacts.addAll(othermods); return artifacts; @@ -97,13 +99,13 @@ public class MinecraftLocator implements IModLocator { @Override public void scanFile(final IModFile modFile, final Consumer pathConsumer) { - LOGGER.debug(SCAN, "Scan started: {}", modFile); + LOGGER.debug(LogMarkers.SCAN, "Scan started: {}", modFile); try (Stream files = Files.find(modFile.getSecureJar().getRootPath(), Integer.MAX_VALUE, (p, a) -> p.getNameCount() > 0 && p.getFileName().toString().endsWith(".class"))) { files.forEach(pathConsumer); } catch (IOException e) { e.printStackTrace(); } - LOGGER.debug(SCAN, "Scan finished: {}", modFile); + LOGGER.debug(LogMarkers.SCAN, "Scan finished: {}", modFile); } @Override diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java index 28bf80bde6..25e3bd33c9 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModDiscoverer.java @@ -22,6 +22,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import cpw.mods.modlauncher.Launcher; import cpw.mods.modlauncher.api.IModuleLayerManager; import cpw.mods.modlauncher.util.ServiceLoaderUtils; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.forgespi.Environment; import net.minecraftforge.forgespi.locating.IModFile; @@ -35,9 +36,6 @@ import java.util.Map; import java.util.ServiceLoader; import java.util.stream.Collectors; -import static net.minecraftforge.fml.loading.LogMarkers.CORE; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - public class ModDiscoverer { private static final Logger LOGGER = LogManager.getLogger(); private final ServiceLoader locators; @@ -45,12 +43,12 @@ public class ModDiscoverer { public ModDiscoverer(Map arguments) { Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.MODDIRECTORYFACTORY.get(), v->ModsFolderLocator::new); - Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v->StartupMessageManager.locatorConsumer().orElseGet(()->s->{})); + Launcher.INSTANCE.environment().computePropertyIfAbsent(Environment.Keys.PROGRESSMESSAGE.get(), v-> StartupMessageManager.locatorConsumer().orElseGet(()-> s->{})); final var moduleLayerManager = Launcher.INSTANCE.environment().findModuleLayerManager().orElseThrow(); locators = ServiceLoader.load(moduleLayerManager.getLayer(IModuleLayerManager.Layer.SERVICE).orElseThrow(), IModLocator.class); locatorList = ServiceLoaderUtils.streamServiceLoader(()->locators, sce->LOGGER.error("Failed to load locator list", sce)).collect(Collectors.toList()); locatorList.forEach(l->l.initArguments(arguments)); - LOGGER.debug(CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(","))); + LOGGER.debug(LogMarkers.CORE,"Found Mod Locators : {}", ()->locatorList.stream().map(iModLocator -> "("+iModLocator.name() + ":" + iModLocator.getClass().getPackage().getImplementationVersion()+")").collect(Collectors.joining(","))); } ModDiscoverer(List locatorList) { @@ -59,13 +57,13 @@ public class ModDiscoverer { } public ModValidator discoverMods() { - LOGGER.debug(SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size()); + LOGGER.debug(LogMarkers.SCAN,"Scanning for mods and other resources to load. We know {} ways to find mods", locatorList.size()); var loadedFiles = new ArrayList<>(); for (IModLocator locator : locatorList) { - LOGGER.debug(SCAN,"Trying locator {}", locator); + LOGGER.debug(LogMarkers.SCAN,"Trying locator {}", locator); var modFiles = locator.scanMods(); for (IModFile mf : modFiles) { - LOGGER.info(SCAN, "Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator()); + LOGGER.info(LogMarkers.SCAN, "Found mod file {} of type {} with locator {}", mf.getFileName(), mf.getType(), mf.getLocator()); StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found mod file "+mf.getFileName()+" of type "+mf.getType())); } loadedFiles.addAll(modFiles); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java index 01749046fb..a5b18ba93c 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java @@ -21,8 +21,9 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.google.common.collect.ImmutableMap; import cpw.mods.jarhandling.SecureJar; -import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.fml.loading.LogMarkers; +import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.forgespi.language.IModLanguageProvider; @@ -46,11 +47,9 @@ import java.util.function.Supplier; import java.util.jar.Attributes; import java.util.jar.Manifest; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; - public class ModFile implements IModFile { // Mods either must have a mods.toml or a manifest. We can no longer just put any jar on the classpath. - @Deprecated(forRemoval = true, since = "1.17.1") + @Deprecated(forRemoval = true, since = "1.18") public static final Manifest DEFAULTMANIFEST; private static final Logger LOGGER = LogManager.getLogger(); @@ -74,8 +73,7 @@ public class ModFile implements IModFile { private List coreMods; private Path accessTransformer; - //TODO: Make package private in 1.18+ - public static final Attributes.Name TYPE = new Attributes.Name("FMLModType"); + static final Attributes.Name TYPE = new Attributes.Name("FMLModType"); private SecureJar.Status securityStatus; public ModFile(final SecureJar jar, final IModLocator locator, final ModFileFactory.ModFileInfoParser parser) { @@ -120,9 +118,9 @@ public class ModFile implements IModFile { public boolean identifyMods() { this.modFileInfo = ModFileParser.readModList(this, this.parser); if (this.modFileInfo == null) return this.getType() != Type.MOD; - LOGGER.debug(LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders()); + LOGGER.debug(LogMarkers.LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders()); this.coreMods = ModFileParser.getCoreMods(this); - this.coreMods.forEach(mi-> LOGGER.debug(LOADING,"Found coremod {}", mi.getPath())); + this.coreMods.forEach(mi-> LOGGER.debug(LogMarkers.LOADING,"Found coremod {}", mi.getPath())); this.accessTransformer = findResource("META-INF", "accesstransformer.cfg"); return true; } @@ -189,7 +187,7 @@ public class ModFile implements IModFile { public void identifyLanguage() { this.loaders = this.modFileInfo.requiredLanguageLoaders().stream() - .map(spec->FMLLoader.getLanguageLoadingProvider().findLanguage(this, spec.languageName(), spec.acceptedVersions())) + .map(spec-> FMLLoader.getLanguageLoadingProvider().findLanguage(this, spec.languageName(), spec.acceptedVersions())) .toList(); } @@ -213,24 +211,6 @@ public class ModFile implements IModFile { return modFileInfo; } - // TODO: Remove concept of factory from forgeapi.. Why expose this? - @Deprecated(forRemoval = true, since="1.17.1") - public static ModFileFactory buildFactory() { - return ModFile::new; - } - - // TODO: Remove helper functions to cleanup api - @Deprecated(forRemoval = true, since="1.17.1") - public static ModFile newFMLInstance(final IModLocator locator, final SecureJar jar) { - return (ModFile) ModFileFactory.FACTORY.build(jar, locator, ModFileParser::modsTomlParser); - } - - // TODO: Remove helper functions to cleanup api - @Deprecated(forRemoval = true, since="1.17.1") - public static ModFile newFMLInstance(final IModLocator locator, final Path... paths) { - return (ModFile) ModJarMetadata.buildFile(locator, paths); - } - @Override public void setSecurityStatus(final SecureJar.Status status) { this.securityStatus = status; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java index 9d64be29ef..8a17274ef5 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileInfo.java @@ -21,6 +21,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.google.common.base.Strings; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.forgespi.language.IConfigurable; import net.minecraftforge.forgespi.language.IModFileInfo; @@ -43,8 +44,6 @@ import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; - public class ModFileInfo implements IModFileInfo, IConfigurable { private static final Logger LOGGER = LogManager.getLogger(); @@ -83,7 +82,7 @@ public class ModFileInfo implements IModFileInfo, IConfigurable this.mods = modConfigs.stream() .map(mi-> new ModInfo(this, mi)) .collect(Collectors.toList()); - LOGGER.debug(LOADING, "Found valid mod file {} with {} mods - versions {}", + LOGGER.debug(LogMarkers.LOADING, "Found valid mod file {} with {} mods - versions {}", this.modFile::getFileName, () -> this.mods.stream().map(IModInfo::getModId).collect(Collectors.joining(",", "{", "}")), () -> this.mods.stream().map(IModInfo::getVersion).map(Objects::toString).collect(Collectors.joining(",", "{", "}"))); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java index 1d27e64854..45ffb61779 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFileParser.java @@ -22,6 +22,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import com.electronwill.nightconfig.core.file.FileConfig; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.forgespi.language.IModFileInfo; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.forgespi.locating.ModFileFactory; @@ -37,8 +38,6 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; - public class ModFileParser { private static final Logger LOGGER = LogManager.getLogger(); @@ -48,10 +47,10 @@ public class ModFileParser { public static IModFileInfo modsTomlParser(final IModFile imodFile) { ModFile modFile = (ModFile) imodFile; - LOGGER.debug(LOADING,"Considering mod file candidate {}", modFile.getFilePath()); + LOGGER.debug(LogMarkers.LOADING,"Considering mod file candidate {}", modFile.getFilePath()); final Path modsjson = modFile.findResource("META-INF", "mods.toml"); if (!Files.exists(modsjson)) { - LOGGER.warn(LOADING, "Mod file {} is missing mods.toml file", modFile.getFilePath()); + LOGGER.warn(LogMarkers.LOADING, "Mod file {} is missing mods.toml file", modFile.getFilePath()); return null; } @@ -75,12 +74,12 @@ public class ModFileParser { final Gson gson = new Gson(); coreModPaths = gson.fromJson(Files.newBufferedReader(coremodsjson), type); } catch (IOException e) { - LOGGER.debug(LOADING,"Failed to read coremod list coremods.json", e); + LOGGER.debug(LogMarkers.LOADING,"Failed to read coremod list coremods.json", e); return Collections.emptyList(); } return coreModPaths.entrySet().stream() - .peek(e-> LOGGER.debug(LOADING,"Found coremod {} with Javascript path {}", e.getKey(), e.getValue())) + .peek(e-> LOGGER.debug(LogMarkers.LOADING,"Found coremod {} with Javascript path {}", e.getKey(), e.getValue())) .map(e -> new CoreModFile(e.getKey(), modFile.findResource(e.getValue()),modFile)) .collect(Collectors.toList()); } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java index 841b1afad5..b7e7479dfb 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModJarMetadata.java @@ -18,25 +18,19 @@ public final class ModJarMetadata implements JarMetadata { private ModuleDescriptor descriptor; // TODO: Remove helper functions to cleanup api - @Deprecated(forRemoval = true, since="1.17.1") - static Optional buildFile(IModLocator locator, Predicate jarTest, Path... files) { - return buildFile(locator, jarTest, (a,b) -> true, files); - } - - // TODO: Remove helper functions to cleanup api - @Deprecated(forRemoval = true, since="1.17.1") + @Deprecated(forRemoval = true, since="1.18") static Optional buildFile(IModLocator locator, Predicate jarTest, BiPredicate filter, Path... files) { - return buildFile(j->ModFile.newFMLInstance(locator, j), jarTest, filter, files); + return buildFile(j->new ModFile(j, locator, ModFileParser::modsTomlParser), jarTest, filter, files); } // TODO: Remove helper functions to cleanup api - @Deprecated(forRemoval = true, since="1.17.1") + @Deprecated(forRemoval = true, since="1.18") static IModFile buildFile(IModLocator locator, Path... files) { - return buildFile(locator, j->true, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file")); + return buildFile(locator, j->true, (a,b) -> true, files).orElseThrow(()->new IllegalArgumentException("Failed to find valid JAR file")); } // TODO: Remove helper functions to cleanup api - @Deprecated(forRemoval = true, since="1.17.1") + @Deprecated(forRemoval = true, since="1.18") static Optional buildFile(Function mfConstructor, Predicate jarTest, BiPredicate filter, Path... files) { var mjm = new ModJarMetadata(); var sj = SecureJar.from(()->ModFile.DEFAULTMANIFEST, j->mjm, filter, files); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java index 281007ab64..fb253a4864 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModListHandler.java @@ -21,6 +21,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.FileUtils; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.MavenCoordinateResolver; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -35,8 +36,6 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - public class ModListHandler { private static final Logger LOGGER = LogManager.getLogger(); /** @@ -59,22 +58,22 @@ public class ModListHandler { filter(path -> Files.exists(path.getLeft())). findFirst(). orElseGet(()->{ - LOGGER.warn(CORE, "Failed to find coordinate {}", mc); + LOGGER.warn(LogMarkers.CORE, "Failed to find coordinate {}", mc); return null; })). filter(Objects::nonNull). collect(Collectors.toList()); final List found = foundCoordinates.stream().map(Pair::getRight).collect(Collectors.toList()); - LOGGER.debug(CORE, "Found mod coordinates from lists: {}", found); + LOGGER.debug(LogMarkers.CORE, "Found mod coordinates from lists: {}", found); return found; } private static List transformPathToList(final String path) { - LOGGER.debug(CORE, "Reading mod list {}", path); + LOGGER.debug(LogMarkers.CORE, "Reading mod list {}", path); Path filePath = FMLPaths.GAMEDIR.get().resolve(path); if (!Files.exists(filePath)) { - LOGGER.warn(CORE, "Failed to find modlist file at {}", filePath); + LOGGER.warn(LogMarkers.CORE, "Failed to find modlist file at {}", filePath); return Collections.emptyList(); } @@ -82,7 +81,7 @@ public class ModListHandler { if (Objects.equals("list",extension)) { return readListFile(filePath).stream().filter(s -> !s.isEmpty()).collect(Collectors.toList()); } else { - LOGGER.warn(CORE, "Failed to read unknown file list type {} for file {}", extension, filePath); + LOGGER.warn(LogMarkers.CORE, "Failed to read unknown file list type {} for file {}", extension, filePath); } return Collections.emptyList(); } @@ -96,7 +95,7 @@ public class ModListHandler { try { return Files.readAllLines(filePath); } catch (IOException e) { - LOGGER.warn(CORE, "Failed to read file list {}", filePath, e); + LOGGER.warn(LogMarkers.CORE, "Failed to read file list {}", filePath, e); return Collections.emptyList(); } } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java index 344e1775d0..988bc02b70 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModValidator.java @@ -2,7 +2,10 @@ package net.minecraftforge.fml.loading.moddiscovery; import cpw.mods.modlauncher.api.IModuleLayerManager; import cpw.mods.modlauncher.api.ITransformationService; -import net.minecraftforge.fml.loading.*; +import net.minecraftforge.fml.loading.EarlyLoadingException; +import net.minecraftforge.fml.loading.LoadingModList; +import net.minecraftforge.fml.loading.LogMarkers; +import net.minecraftforge.fml.loading.ModSorter; import net.minecraftforge.fml.loading.progress.StartupMessageManager; import net.minecraftforge.forgespi.locating.IModFile; import org.apache.logging.log4j.LogManager; @@ -10,7 +13,6 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import java.util.*; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; public class ModValidator { private static final Logger LOGGER = LogManager.getLogger(); @@ -34,7 +36,7 @@ public class ModValidator { public void stage1Validation() { brokenFiles = validateFiles(candidateMods); - LOGGER.debug(SCAN,"Found {} mod files with {} mods", candidateMods::size, ()-> candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum()); + LOGGER.debug(LogMarkers.SCAN,"Found {} mod files with {} mods", candidateMods::size, ()-> candidateMods.stream().mapToInt(mf -> mf.getModInfos().size()).sum()); StartupMessageManager.modLoaderConsumer().ifPresent(c->c.accept("Found "+ candidateMods.size()+" modfiles to load")); } @@ -45,7 +47,7 @@ public class ModValidator { { ModFile mod = iterator.next(); if (!mod.getLocator().isValid(mod) || !mod.identifyMods()) { - LOGGER.warn(SCAN, "File {} has been ignored - it is invalid", mod.getFilePath()); + LOGGER.warn(LogMarkers.SCAN, "File {} has been ignored - it is invalid", mod.getFilePath()); iterator.remove(); brokenFiles.add(mod); } diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java index d5efb19d5b..1aafc5706c 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModsFolderLocator.java @@ -20,6 +20,7 @@ package net.minecraftforge.fml.loading.moddiscovery; import net.minecraftforge.fml.loading.FMLPaths; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer; import net.minecraftforge.fml.loading.StringUtils; import org.apache.logging.log4j.LogManager; @@ -32,7 +33,6 @@ import java.util.Map; import java.util.stream.Stream; import static cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; /** * Support loading mods located in JAR files in the mods folder @@ -58,7 +58,7 @@ public class ModsFolderLocator extends AbstractJarFileLocator { @Override public Stream scanCandidates() { - LOGGER.debug(SCAN,"Scanning mods dir {} for mods", this.modFolder); + LOGGER.debug(LogMarkers.SCAN,"Scanning mods dir {} for mods", this.modFolder); var excluded = ModDirTransformerDiscoverer.allExcluded(); return uncheck(()-> Files.list(this.modFolder)) diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java index 9c6989d5f0..658848e0b2 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/Scanner.java @@ -19,6 +19,7 @@ package net.minecraftforge.fml.loading.moddiscovery; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.forgespi.language.IModLanguageProvider; import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.logging.log4j.LogManager; @@ -31,8 +32,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import static net.minecraftforge.fml.loading.LogMarkers.SCAN; - public class Scanner { private static final Logger LOGGER = LogManager.getLogger(); private final ModFile fileToScan; @@ -48,7 +47,7 @@ public class Scanner { final List loaders = fileToScan.getLoaders(); if (loaders != null) { loaders.forEach(loader -> { - LOGGER.debug(SCAN, "Scanning {} with language loader {}", fileToScan.getFilePath(), loader.name()); + LOGGER.debug(LogMarkers.SCAN, "Scanning {} with language loader {}", fileToScan.getFilePath(), loader.name()); loader.getFileVisitor().accept(result); }); } @@ -56,7 +55,7 @@ public class Scanner { } private void fileVisitor(final Path path, final ModFileScanData result) { - LOGGER.debug(SCAN,"Scanning {} path {}", fileToScan, path); + LOGGER.debug(LogMarkers.SCAN,"Scanning {} path {}", fileToScan, path); try (InputStream in = Files.newInputStream(path)){ ModClassVisitor mcv = new ModClassVisitor(); ClassReader cr = new ClassReader(in); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java index d091b4de6e..b611227b12 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/progress/EarlyProgressVisualization.java @@ -20,8 +20,8 @@ package net.minecraftforge.fml.loading.progress; import cpw.mods.modlauncher.api.LamdbaExceptionUtils; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.loading.FMLLoader; +import net.minecraftforge.api.distmarker.Dist; import org.jetbrains.annotations.Nullable; import java.util.function.IntConsumer; @@ -58,7 +58,7 @@ public enum EarlyProgressVisualization { default long handOffWindow(final IntSupplier width, final IntSupplier height, final Supplier title, LongSupplier monitorSupplier) { return FMLLoader.getGameLayer().findModule("forge") - .map(l->Class.forName(l, "net.minecraftforge.fmllegacy.NoVizFallback")) + .map(l->Class.forName(l, "net.minecraftforge.client.loading.NoVizFallback")) .map(LamdbaExceptionUtils.rethrowFunction(c->c.getMethod("fallback", IntSupplier.class, IntSupplier.class, Supplier.class, LongSupplier.class))) .map(LamdbaExceptionUtils.rethrowFunction(m->(LongSupplier)m.invoke(null, width, height, title, monitorSupplier))) .map(LongSupplier::getAsLong) diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java index bfaf257798..552165a0a4 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonClientLaunchHandler.java @@ -19,10 +19,10 @@ package net.minecraftforge.fml.loading.targets; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.LibraryFinder; import net.minecraftforge.fml.loading.VersionInfo; +import net.minecraftforge.api.distmarker.Dist; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java index b33af88f19..7eb700a0c8 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonLaunchHandler.java @@ -21,6 +21,7 @@ package net.minecraftforge.fml.loading.targets; import cpw.mods.modlauncher.api.ILaunchHandlerService; import cpw.mods.modlauncher.api.ITransformingClassLoaderBuilder; +import net.minecraftforge.fml.loading.LogMarkers; import net.minecraftforge.api.distmarker.Dist; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -35,8 +36,6 @@ import java.util.Optional; import java.util.function.BiPredicate; import java.util.stream.Collectors; -import static net.minecraftforge.fml.loading.LogMarkers.CORE; - public abstract class CommonLaunchHandler implements ILaunchHandlerService { public record LocatedPaths(List minecraftPaths, BiPredicate minecraftFilter, List> otherModPaths, List otherArtifacts) {} @@ -63,7 +62,7 @@ public abstract class CommonLaunchHandler implements ILaunchHandlerService { protected final Map> getModClasses() { final String modClasses = Optional.ofNullable(System.getenv("MOD_CLASSES")).orElse(""); - LOGGER.debug(CORE, "Got mod coordinates {} from env", modClasses); + LOGGER.debug(LogMarkers.CORE, "Got mod coordinates {} from env", modClasses); record ExplodedModPath(String modid, Path path) {} // "a/b/;c/d/;" -> "modid%%c:\fish\pepper;modid%%c:\fish2\pepper2\;modid2%%c:\fishy\bums;modid2%%c:\hmm" @@ -72,7 +71,7 @@ public abstract class CommonLaunchHandler implements ILaunchHandlerService { .map(splitString -> new ExplodedModPath(splitString.length == 1 ? "defaultmodid" : splitString[0], Paths.get(splitString[splitString.length - 1]))) .collect(Collectors.groupingBy(ExplodedModPath::modid, Collectors.mapping(ExplodedModPath::path, Collectors.toList()))); - LOGGER.debug(CORE, "Found supplied mod coordinates [{}]", modClassPaths); + LOGGER.debug(LogMarkers.CORE, "Found supplied mod coordinates [{}]", modClassPaths); //final var explodedTargets = ((Map>)arguments).computeIfAbsent("explodedTargets", a -> new ArrayList<>()); //modClassPaths.forEach((modlabel,paths) -> explodedTargets.add(new ExplodedDirectoryLocator.ExplodedMod(modlabel, paths))); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java index c79f5abe45..e273b1fe1a 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/targets/CommonServerLaunchHandler.java @@ -20,10 +20,10 @@ package net.minecraftforge.fml.loading.targets; import cpw.mods.jarhandling.SecureJar; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.loading.FMLLoader; import net.minecraftforge.fml.loading.LibraryFinder; import net.minecraftforge.fml.loading.VersionInfo; +import net.minecraftforge.api.distmarker.Dist; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/fmlloader/src/main/java/net/minecraftforge/server/ServerMain.java b/fmlloader/src/main/java/net/minecraftforge/fml/server/ServerMain.java similarity index 98% rename from fmlloader/src/main/java/net/minecraftforge/server/ServerMain.java rename to fmlloader/src/main/java/net/minecraftforge/fml/server/ServerMain.java index 1d4ac5df11..164e4527f3 100644 --- a/fmlloader/src/main/java/net/minecraftforge/server/ServerMain.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/server/ServerMain.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.server; +package net.minecraftforge.fml.server; import cpw.mods.modlauncher.InvalidLauncherSetupException; import cpw.mods.modlauncher.Launcher; diff --git a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService index cf2cc7e041..00b38ab624 100644 --- a/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService +++ b/fmlloader/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService @@ -1,5 +1,4 @@ net.minecraftforge.fml.loading.RuntimeDistCleaner -net.minecraftforge.common.asm.RuntimeEnumExtender -net.minecraftforge.common.asm.ObjectHolderDefinalize -net.minecraftforge.common.asm.CapabilityInjectDefinalize -net.minecraftforge.common.asm.CapabilityTokenSubclass \ No newline at end of file +net.minecraftforge.fml.common.asm.RuntimeEnumExtender +net.minecraftforge.fml.common.asm.ObjectHolderDefinalize +net.minecraftforge.fml.common.asm.CapabilityTokenSubclass \ No newline at end of file diff --git a/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java b/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java index d9c985948c..0473b03f22 100644 --- a/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java +++ b/fmlonly/src/main/java/net/minecraftforge/fmlonlyclient/ClientModLoader.java @@ -31,7 +31,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.LoadingFailedException; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.ModWorkManager; -import net.minecraftforge.fml.VersionChecker; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -39,8 +38,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import static net.minecraftforge.fml.loading.LogMarkers.LOADING; - @OnlyIn(Dist.CLIENT) public class ClientModLoader { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254e..e750102e09 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/mdk/build.gradle b/mdk/build.gradle index 2cd5253ed4..bdeae58389 100644 --- a/mdk/build.gradle +++ b/mdk/build.gradle @@ -17,8 +17,8 @@ version = '1.0' group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'modid' -// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16. -java.toolchain.languageVersion = JavaLanguageVersion.of(16) +// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. +java.toolchain.languageVersion = JavaLanguageVersion.of(17) println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { diff --git a/mdk/src/main/java/com/example/examplemod/ExampleMod.java b/mdk/src/main/java/com/example/examplemod/ExampleMod.java index b7443262c0..4def3a4389 100644 --- a/mdk/src/main/java/com/example/examplemod/ExampleMod.java +++ b/mdk/src/main/java/com/example/examplemod/ExampleMod.java @@ -10,7 +10,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; -import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; +import net.minecraftforge.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/mdk/src/main/resources/pack.mcmeta b/mdk/src/main/resources/pack.mcmeta index 9a208763dd..b18e3cdd12 100644 --- a/mdk/src/main/resources/pack.mcmeta +++ b/mdk/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "examplemod resources", - "pack_format": 7 + "pack_format": 8 } } diff --git a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch index a9a727160f..778dda74e2 100644 --- a/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/platform/GlStateManager.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/platform/GlStateManager.java +++ b/com/mojang/blaze3d/platform/GlStateManager.java -@@ -530,9 +_,16 @@ +@@ -539,9 +_,16 @@ f_84077_[f_84076_].f_84800_ = false; } @@ -8,7 +8,7 @@ + public static float lastBrightnessX = 0.0f; + public static float lastBrightnessY = 0.0f; public static void m_84160_(int p_84161_, int p_84162_, float p_84163_) { - RenderSystem.m_69393_(RenderSystem::m_69587_); + RenderSystem.m_187555_(); GL11.glTexParameterf(p_84161_, p_84162_, p_84163_); + if (p_84161_ == GL13.GL_TEXTURE1) { + lastBrightnessX = p_84162_; diff --git a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch index f9af58b4e4..e3b1e278c7 100644 --- a/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch +++ b/patches/minecraft/com/mojang/blaze3d/vertex/VertexConsumer.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/blaze3d/vertex/VertexConsumer.java +++ b/com/mojang/blaze3d/vertex/VertexConsumer.java -@@ -15,7 +_,7 @@ +@@ -16,7 +_,7 @@ import org.lwjgl.system.MemoryStack; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ Logger f_85943_ = LogManager.getLogger(); VertexConsumer m_5483_(double p_85945_, double p_85946_, double p_85947_); -@@ -100,11 +_,12 @@ +@@ -105,11 +_,12 @@ f5 = afloat[k] * p_86001_; } diff --git a/patches/minecraft/net/minecraft/CrashReport.java.patch b/patches/minecraft/net/minecraft/CrashReport.java.patch index e886c3c15d..03b8b4fb76 100644 --- a/patches/minecraft/net/minecraft/CrashReport.java.patch +++ b/patches/minecraft/net/minecraft/CrashReport.java.patch @@ -13,7 +13,7 @@ - - p_127520_.append("\n"); + p_127520_.append("Stacktrace:"); -+ p_127520_.append(net.minecraftforge.fmllegacy.CrashReportExtender.generateEnhancedStackTrace(this.f_127506_)); ++ p_127520_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.f_127506_)); } for(CrashReportCategory crashreportcategory : this.f_127503_) { @@ -21,7 +21,7 @@ p_127520_.append("\n\n"); } -+ net.minecraftforge.fmllegacy.CrashReportExtender.extendSystemReport(f_178624_); ++ net.minecraftforge.logging.CrashReportExtender.extendSystemReport(f_178624_); this.f_178624_.m_143525_(p_127520_); } @@ -41,13 +41,13 @@ - } - - return s; -+ return net.minecraftforge.fmllegacy.CrashReportExtender.generateEnhancedStackTrace(throwable); ++ return net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(throwable); } public String m_127526_() { StringBuilder stringbuilder = new StringBuilder(); stringbuilder.append("---- Minecraft Crash Report ----\n"); -+ net.minecraftforge.fmllegacy.CrashReportExtender.addCrashReportHeader(stringbuilder, this); ++ net.minecraftforge.logging.CrashReportExtender.addCrashReportHeader(stringbuilder, this); stringbuilder.append("// "); stringbuilder.append(m_127531_()); stringbuilder.append("\n\n"); diff --git a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch index b22560c5f4..4084e1d70f 100644 --- a/patches/minecraft/net/minecraft/CrashReportCategory.java.patch +++ b/patches/minecraft/net/minecraft/CrashReportCategory.java.patch @@ -22,7 +22,7 @@ - p_128169_.append("\n\tat "); - p_128169_.append((Object)stacktraceelement); - } -+ p_128169_.append(net.minecraftforge.fmllegacy.CrashReportExtender.generateEnhancedStackTrace(this.f_128139_)); ++ p_128169_.append(net.minecraftforge.logging.CrashReportExtender.generateEnhancedStackTrace(this.f_128139_)); } } diff --git a/patches/minecraft/net/minecraft/SharedConstants.java.patch b/patches/minecraft/net/minecraft/SharedConstants.java.patch index 5d5c13d006..8b209a421c 100644 --- a/patches/minecraft/net/minecraft/SharedConstants.java.patch +++ b/patches/minecraft/net/minecraft/SharedConstants.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/SharedConstants.java +++ b/net/minecraft/SharedConstants.java -@@ -160,6 +_,7 @@ +@@ -184,6 +_,7 @@ } static { diff --git a/patches/minecraft/net/minecraft/Util.java.patch b/patches/minecraft/net/minecraft/Util.java.patch index 09a4df37e9..8fe0ff0b2d 100644 --- a/patches/minecraft/net/minecraft/Util.java.patch +++ b/patches/minecraft/net/minecraft/Util.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -127,6 +_,9 @@ - return executorservice; +@@ -149,6 +_,9 @@ + return 255; } + // We add this inner class to compensate for Mojang's missing inner class and allow us to obf subsequent anon inner classes correctly. + @SuppressWarnings("unused") private static LongSupplier INNER_CLASS_SHIFT = new LongSupplier() { public long getAsLong() { return 0; } }; + - public static Executor m_137577_() { + public static ExecutorService m_183988_() { return f_137443_; } -@@ -205,7 +_,7 @@ +@@ -227,7 +_,7 @@ try { - type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_136187_().getWorldVersion())).getChoiceType(p_137552_, p_137553_); + type = DataFixers.m_14512_().getSchema(DataFixUtils.makeKey(SharedConstants.m_183709_().getWorldVersion())).getChoiceType(p_137552_, p_137553_); } catch (IllegalArgumentException illegalargumentexception) { - f_137446_.error("No data fixer registered for {}", (Object)p_137553_); + f_137446_.debug("No data fixer registered for {}", (Object)p_137553_); diff --git a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch index 4923f08a81..ba02f67293 100644 --- a/patches/minecraft/net/minecraft/advancements/Advancement.java.patch +++ b/patches/minecraft/net/minecraft/advancements/Advancement.java.patch @@ -1,15 +1,16 @@ --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java -@@ -127,7 +_,7 @@ +@@ -129,8 +_,8 @@ return this.f_138305_; } - public static class Builder { + @Nullable + public static class Builder implements net.minecraftforge.common.extensions.IForgeAdvancementBuilder { private ResourceLocation f_138332_; + @Nullable private Advancement f_138333_; - private DisplayInfo f_138334_; -@@ -311,6 +_,7 @@ +@@ -321,6 +_,7 @@ } public static Advancement.Builder m_138380_(JsonObject p_138381_, DeserializationContext p_138382_) { diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch index 80436c26c0..2c51150adf 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/advancements/AdvancementList.java +++ b/net/minecraft/advancements/AdvancementList.java -@@ -90,6 +_,7 @@ +@@ -91,6 +_,7 @@ } } diff --git a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch index 02b079c6a7..f828d2248c 100644 --- a/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch +++ b/patches/minecraft/net/minecraft/advancements/AdvancementRewards.java.patch @@ -4,8 +4,8 @@ public void m_9989_(ServerPlayer p_9990_) { p_9990_.m_6756_(this.f_9979_); -- LootContext lootcontext = (new LootContext.Builder(p_9990_.m_9236_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78975_(LootContextParamSets.f_81418_); -+ LootContext lootcontext = (new LootContext.Builder(p_9990_.m_9236_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78963_(p_9990_.m_36336_()).m_78975_(LootContextParamSets.f_81418_); // FORGE: luck to LootContext +- LootContext lootcontext = (new LootContext.Builder(p_9990_.m_183503_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78975_(LootContextParamSets.f_81418_); ++ LootContext lootcontext = (new LootContext.Builder(p_9990_.m_183503_())).m_78972_(LootContextParams.f_81455_, p_9990_).m_78972_(LootContextParams.f_81460_, p_9990_.m_20182_()).m_78977_(p_9990_.m_21187_()).m_78963_(p_9990_.m_36336_()).m_78975_(LootContextParamSets.f_81418_); // FORGE: luck to LootContext boolean flag = false; for(ResourceLocation resourcelocation : this.f_9980_) { diff --git a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch index 2160fea8c7..a2336600d7 100644 --- a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch +++ b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.java.patch @@ -5,6 +5,6 @@ @DontObfuscate public static String m_129629_() { - return "vanilla"; -+ return net.minecraftforge.fmllegacy.BrandingControl.getClientBranding(); ++ return net.minecraftforge.internal.BrandingControl.getClientBranding(); } } diff --git a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch index 302797e4f9..3237bef33e 100644 --- a/patches/minecraft/net/minecraft/client/KeyMapping.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyMapping.java.patch @@ -105,7 +105,7 @@ public boolean m_90864_() { - return this.f_90816_.equals(this.f_90814_); -+ return this.f_90816_.equals(this.f_90814_) && getKeyModifier() == getKeyModifierDefault(); ++ return this.f_90816_.equals(this.f_90814_) && getKeyModifier() == getDefaultKeyModifier(); } public String m_90865_() { @@ -174,7 +174,7 @@ + } + + @Override -+ public net.minecraftforge.client.settings.KeyModifier getKeyModifierDefault() { ++ public net.minecraftforge.client.settings.KeyModifier getDefaultKeyModifier() { + return keyModifierDefault; + } + diff --git a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch index 215f8fc627..a891aceb77 100644 --- a/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/KeyboardHandler.java.patch @@ -1,44 +1,44 @@ --- a/net/minecraft/client/KeyboardHandler.java +++ b/net/minecraft/client/KeyboardHandler.java -@@ -312,7 +_,9 @@ +@@ -307,7 +_,9 @@ } Screen screen = this.f_90867_.f_91080_; -- if (p_90897_ == 1 && (!(this.f_90867_.f_91080_ instanceof ControlsScreen) || ((ControlsScreen)screen).f_97515_ <= Util.m_137550_() - 20L)) { +- if (p_90897_ == 1 && (!(this.f_90867_.f_91080_ instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).f_193976_ <= Util.m_137550_() - 20L)) { + -+ if ((!(this.f_90867_.f_91080_ instanceof ControlsScreen) || ((ControlsScreen)screen).f_97515_ <= Util.m_137550_() - 20L)) { ++ if ((!(this.f_90867_.f_91080_ instanceof KeyBindsScreen) || ((KeyBindsScreen)screen).f_193976_ <= Util.m_137550_() - 20L)) { + if (p_90897_ == 1) { if (this.f_90867_.f_91066_.f_92105_.m_90832_(p_90895_, p_90896_)) { this.f_90867_.m_91268_().m_85438_(); this.f_90867_.f_91066_.f_92052_ = this.f_90867_.m_91268_().m_85440_(); -@@ -331,6 +_,8 @@ +@@ -326,6 +_,8 @@ }); return; } -+ } else if (p_90897_ == 0 /*GLFW_RELEASE*/ && this.f_90867_.f_91080_ instanceof ControlsScreen) -+ ((ControlsScreen)this.f_90867_.f_91080_).f_97514_ = null; //Forge: Unset pure modifiers. ++ } else if (p_90897_ == 0 /*GLFW_RELEASE*/ && this.f_90867_.f_91080_ instanceof KeyBindsScreen) ++ ((KeyBindsScreen)this.f_90867_.f_91080_).f_193975_ = null; //Forge: Unset pure modifiers. } if (NarratorChatListener.f_93311_.m_93316_()) { -@@ -354,11 +_,15 @@ +@@ -349,11 +_,15 @@ Screen.m_96579_(() -> { if (p_90897_ != 1 && (p_90897_ != 2 || !this.f_90868_)) { if (p_90897_ == 0) { - aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPre(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleasedPre(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); + if (!aboolean[0]) aboolean[0] = screen.m_7920_(p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyReleasedPost(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyReleasedPost(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); } } else { screen.m_169416_(); - aboolean[0] = screen.m_7933_(p_90895_, p_90896_, p_90898_); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPre(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressedPre(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); + if (!aboolean[0]) aboolean[0] = screen.m_7933_(p_90895_, p_90896_, p_90898_); -+ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiKeyPressedPost(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); ++ if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenKeyPressedPost(this.f_90867_.f_91080_, p_90895_, p_90896_, p_90898_); } }, "keyPressed event handler", screen.getClass().getCanonicalName()); -@@ -411,7 +_,7 @@ +@@ -406,7 +_,7 @@ } } } @@ -47,22 +47,22 @@ } } -@@ -421,12 +_,16 @@ +@@ -416,12 +_,16 @@ if (guieventlistener != null && this.f_90867_.m_91265_() == null) { if (Character.charCount(p_90891_) == 1) { Screen.m_96579_(() -> { - guieventlistener.m_5534_((char)p_90891_, p_90892_); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.f_90867_.f_91080_, (char)p_90891_, p_90892_)) return; ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPre(this.f_90867_.f_91080_, (char)p_90891_, p_90892_)) return; + if (guieventlistener.m_5534_((char)p_90891_, p_90892_)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.f_90867_.f_91080_, (char)p_90891_, p_90892_); ++ net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPost(this.f_90867_.f_91080_, (char)p_90891_, p_90892_); }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); } else { for(char c0 : Character.toChars(p_90891_)) { Screen.m_96579_(() -> { - guieventlistener.m_5534_(c0, p_90892_); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPre(this.f_90867_.f_91080_, c0, p_90892_)) return; ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPre(this.f_90867_.f_91080_, c0, p_90892_)) return; + if (guieventlistener.m_5534_(c0, p_90892_)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiCharTypedPost(this.f_90867_.f_91080_, c0, p_90892_); ++ net.minecraftforge.client.ForgeHooksClient.onScreenCharTypedPost(this.f_90867_.f_91080_, c0, p_90892_); }, "charTyped event handler", guieventlistener.getClass().getCanonicalName()); } } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 81e7a54021..1ad1099bcb 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -257,7 +_,7 @@ +@@ -254,7 +_,7 @@ import org.lwjgl.util.tinyfd.TinyFileDialogs; @OnlyIn(Dist.CLIENT) --public class Minecraft extends ReentrantBlockableEventLoop implements SnooperPopulator, WindowEventHandler { -+public class Minecraft extends ReentrantBlockableEventLoop implements SnooperPopulator, WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft { +-public class Minecraft extends ReentrantBlockableEventLoop implements WindowEventHandler { ++public class Minecraft extends ReentrantBlockableEventLoop implements WindowEventHandler, net.minecraftforge.client.extensions.IForgeMinecraft { private static Minecraft f_90981_; private static final Logger f_90982_ = LogManager.getLogger(); public static final boolean f_91002_ = Util.m_137581_() == Util.OS.OSX; -@@ -397,14 +_,13 @@ +@@ -394,14 +_,13 @@ this.f_91029_ = p_91084_.f_101908_.f_101928_; this.f_90986_ = p_91084_.f_101905_.f_101944_; this.f_91037_ = new ClientPackSource(new File(this.f_91069_, "server-resource-packs"), p_91084_.f_101907_.m_101925_()); @@ -18,14 +18,14 @@ this.f_91030_ = p_91084_.f_101905_.f_101945_; YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); this.f_91048_ = yggdrasilauthenticationservice.createMinecraftSessionService(); - this.f_91049_ = this.m_91130_(yggdrasilauthenticationservice, p_91084_); + this.f_193584_ = this.m_193585_(yggdrasilauthenticationservice, p_91084_); this.f_90998_ = p_91084_.f_101905_.f_101942_; f_90982_.info("Setting user: {}", (Object)this.f_90998_.m_92546_()); - f_90982_.debug("(Session ID is {})", (Object)this.f_90998_.m_92544_()); this.f_91033_ = p_91084_.f_101908_.f_101926_; this.f_91034_ = !p_91084_.f_101908_.f_101929_; this.f_91035_ = !p_91084_.f_101908_.f_101930_; -@@ -436,6 +_,7 @@ +@@ -433,6 +_,7 @@ } Util.f_137440_ = RenderSystem.m_69576_(); @@ -33,7 +33,7 @@ this.f_90989_ = new VirtualScreen(this); this.f_90990_ = this.f_90989_.m_110872_(displaydata, this.f_91066_.f_92123_, this.m_91270_()); this.m_7440_(true); -@@ -450,7 +_,6 @@ +@@ -448,7 +_,6 @@ this.f_90990_.m_85380_(this.f_91066_.f_92113_); this.f_91067_ = new MouseHandler(this); @@ -41,15 +41,15 @@ this.f_91068_ = new KeyboardHandler(this); this.f_91068_.m_90887_(this.f_90990_.m_85439_()); RenderSystem.m_69580_(this.f_91066_.f_92035_, false); -@@ -458,6 +_,7 @@ +@@ -456,6 +_,7 @@ this.f_91042_.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); this.f_91042_.m_83954_(f_91002_); this.f_91036_ = new SimpleReloadableResourceManager(PackType.CLIENT_RESOURCES); -+ net.minecraftforge.fmlclient.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_); ++ net.minecraftforge.client.loading.ClientModLoader.begin(this, this.f_91038_, this.f_91036_, this.f_91037_); this.f_91038_.m_10506_(); this.f_91066_.m_92145_(this.f_91038_); this.f_91039_ = new LanguageManager(this.f_91066_.f_92075_); -@@ -506,6 +_,7 @@ +@@ -504,6 +_,7 @@ this.m_91271_(); this.f_91036_.m_7217_(this.f_90997_); this.f_91061_ = new ParticleEngine(this.f_91073_, this.f_90987_); @@ -57,7 +57,7 @@ this.f_91036_.m_7217_(this.f_91061_); this.f_91053_ = new PaintingTextureManager(this.f_90987_); this.f_91036_.m_7217_(this.f_91053_); -@@ -513,7 +_,8 @@ +@@ -511,7 +_,8 @@ this.f_91036_.m_7217_(this.f_91054_); this.f_91047_ = new GpuWarnlistManager(); this.f_91036_.m_7217_(this.f_91047_); @@ -67,7 +67,7 @@ this.f_91064_ = new DebugRenderer(this); RenderSystem.m_69900_(this::m_91113_); if (this.f_91042_.f_83915_ == this.f_90990_.m_85441_() && this.f_91042_.f_83916_ == this.f_90990_.m_85442_()) { -@@ -531,6 +_,10 @@ +@@ -529,6 +_,10 @@ TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false); } @@ -78,11 +78,11 @@ this.f_90990_.m_85409_(this.f_91066_.f_92041_); this.f_90990_.m_85424_(this.f_91066_.f_92034_); this.f_90990_.m_85426_(); -@@ -546,13 +_,16 @@ +@@ -544,13 +_,16 @@ } this.f_167847_.m_168556_(); -+ if (net.minecraftforge.fmlclient.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen ++ if (net.minecraftforge.client.loading.ClientModLoader.completeModLoading()) return; // Do not overwrite the error screen + // FORGE: Move opening initial screen to after startup and events are enabled. + // Also Fixes MC-145102 + if (s != null) { @@ -100,16 +100,16 @@ } -@@ -587,6 +_,8 @@ +@@ -585,6 +_,8 @@ - private SocialInteractionsService m_91130_(YggdrasilAuthenticationService p_91131_, GameConfig p_91132_) { + private UserApiService m_193585_(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { try { -+ if ("0".equals(p_91132_.f_101905_.f_101942_.m_92547_())) // Forge: We use "0" in dev. Short circuit to stop exception spam. -+ return new OfflineSocialInteractions(); - return p_91131_.createSocialInteractionsService(p_91132_.f_101905_.f_101942_.m_92547_()); ++ if ("0".equals(p_193587_.f_101905_.f_101942_.m_92547_())) // Forge: We use "0" in dev. Short circuit to stop exception spam. ++ return UserApiService.OFFLINE; + return p_193586_.createUserApiService(p_193587_.f_101905_.f_101942_.m_92547_()); } catch (AuthenticationException authenticationexception) { f_90982_.error("Failed to verify authentication", (Throwable)authenticationexception); -@@ -599,7 +_,7 @@ +@@ -597,7 +_,7 @@ } private void m_91239_(Throwable p_91240_) { @@ -118,7 +118,7 @@ Component component; if (p_91240_ instanceof SimpleReloadableResourceManager.ResourcePackLoadingFailure) { component = new TextComponent(((SimpleReloadableResourceManager.ResourcePackLoadingFailure)p_91240_).m_10921_().m_8017_()); -@@ -690,7 +_,7 @@ +@@ -691,7 +_,7 @@ return Stream.of(Registry.f_122827_.m_7981_(p_91317_.m_41720_())); }); ReloadableIdSearchTree reloadableidsearchtree = new ReloadableIdSearchTree<>((p_91121_) -> { @@ -127,24 +127,24 @@ }); NonNullList nonnulllist = NonNullList.m_122779_(); -@@ -760,13 +_,13 @@ +@@ -761,13 +_,13 @@ Bootstrap.m_135875_(p_91333_.m_127526_()); if (p_91333_.m_127527_() != null) { Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + p_91333_.m_127527_()); - System.exit(-1); -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleExit(-1); ++ net.minecraftforge.server.ServerLifecycleHooks.handleExit(-1); } else if (p_91333_.m_127512_(file2)) { Bootstrap.m_135875_("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); - System.exit(-1); -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleExit(-1); ++ net.minecraftforge.server.ServerLifecycleHooks.handleExit(-1); } else { Bootstrap.m_135875_("#@?@# Game crashed! Crash report could not be saved. #@?@#"); - System.exit(-2); -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleExit(-2); ++ net.minecraftforge.server.ServerLifecycleHooks.handleExit(-2); } } -@@ -876,10 +_,6 @@ +@@ -877,10 +_,6 @@ f_90982_.error("setScreen called from non-game thread"); } @@ -155,37 +155,37 @@ if (p_91153_ == null && this.f_91073_ == null) { p_91153_ = new TitleScreen(); } else if (p_91153_ == null && this.f_91074_.m_21224_()) { -@@ -890,6 +_,15 @@ +@@ -891,6 +_,15 @@ } } + net.minecraftforge.client.ForgeHooksClient.clearGuiLayers(this); + Screen old = this.f_91080_; -+ net.minecraftforge.client.event.GuiOpenEvent event = new net.minecraftforge.client.event.GuiOpenEvent(p_91153_); ++ net.minecraftforge.client.event.ScreenOpenEvent event = new net.minecraftforge.client.event.ScreenOpenEvent(p_91153_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; + -+ p_91153_ = event.getGui(); ++ p_91153_ = event.getScreen(); + if (old != null && p_91153_ != old) + old.m_7861_(); + this.f_91080_ = p_91153_; BufferUploader.m_166835_(); if (p_91153_ != null) { -@@ -1018,11 +_,13 @@ +@@ -1019,11 +_,13 @@ RenderSystem.m_69481_(); this.f_91026_.m_7238_(); if (!this.f_91079_) { -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onRenderTickStart(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); ++ net.minecraftforge.event.ForgeEventFactory.onRenderTickStart(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); this.f_91026_.m_6182_("gameRenderer"); this.f_91063_.m_109093_(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_, i, p_91384_); this.f_91026_.m_6182_("toasts"); this.f_91003_.m_94920_(new PoseStack()); this.f_91026_.m_7238_(); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onRenderTickEnd(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); ++ net.minecraftforge.event.ForgeEventFactory.onRenderTickEnd(this.f_91012_ ? this.f_91013_ : this.f_90991_.f_92518_); } if (this.f_91056_ != null) { -@@ -1132,10 +_,12 @@ +@@ -1129,10 +_,12 @@ this.f_90990_.m_85378_((double)i); if (this.f_91080_ != null) { this.f_91080_.m_6574_(this, this.f_90990_.m_85445_(), this.f_90990_.m_85446_()); @@ -198,7 +198,7 @@ this.f_91063_.m_109097_(this.f_90990_.m_85441_(), this.f_90990_.m_85442_()); this.f_91067_.m_91599_(); } -@@ -1432,11 +_,21 @@ +@@ -1429,11 +_,21 @@ if (p_91387_ && this.f_91077_ != null && this.f_91077_.m_6662_() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; BlockPos blockpos = blockhitresult.m_82425_(); @@ -222,7 +222,7 @@ } } -@@ -1455,6 +_,8 @@ +@@ -1452,6 +_,8 @@ } } else if (!this.f_91074_.m_108637_()) { @@ -231,7 +231,7 @@ switch(this.f_91077_.m_6662_()) { case ENTITY: this.f_91072_.m_105223_(this.f_91074_, ((EntityHitResult)this.f_91077_).m_82443_()); -@@ -1462,7 +_,7 @@ +@@ -1459,7 +_,7 @@ case BLOCK: BlockHitResult blockhitresult = (BlockHitResult)this.f_91077_; BlockPos blockpos = blockhitresult.m_82425_(); @@ -240,7 +240,7 @@ this.f_91072_.m_105269_(blockpos, blockhitresult.m_82434_()); break; } -@@ -1472,8 +_,10 @@ +@@ -1469,8 +_,10 @@ } this.f_91074_.m_36334_(); @@ -251,7 +251,7 @@ this.f_91074_.m_6674_(InteractionHand.MAIN_HAND); } } -@@ -1488,6 +_,11 @@ +@@ -1485,6 +_,11 @@ } for(InteractionHand interactionhand : InteractionHand.values()) { @@ -263,7 +263,7 @@ ItemStack itemstack = this.f_91074_.m_21120_(interactionhand); if (this.f_91077_ != null) { switch(this.f_91077_.m_6662_()) { -@@ -1501,6 +_,7 @@ +@@ -1502,6 +_,7 @@ if (interactionresult.m_19077_()) { if (interactionresult.m_19080_()) { @@ -271,7 +271,7 @@ this.f_91074_.m_6674_(interactionhand); } -@@ -1513,6 +_,7 @@ +@@ -1514,6 +_,7 @@ InteractionResult interactionresult1 = this.f_91072_.m_105262_(this.f_91074_, this.f_91073_, interactionhand, blockhitresult); if (interactionresult1.m_19077_()) { if (interactionresult1.m_19080_()) { @@ -279,7 +279,7 @@ this.f_91074_.m_6674_(interactionhand); if (!itemstack.m_41619_() && (itemstack.m_41613_() != i || this.f_91072_.m_105290_())) { this.f_91063_.f_109055_.m_109320_(interactionhand); -@@ -1528,6 +_,9 @@ +@@ -1529,6 +_,9 @@ } } @@ -289,25 +289,25 @@ if (!itemstack.m_41619_()) { InteractionResult interactionresult2 = this.f_91072_.m_105235_(this.f_91074_, this.f_91073_, interactionhand); if (interactionresult2.m_19077_()) { -@@ -1554,6 +_,8 @@ +@@ -1555,6 +_,8 @@ --this.f_91011_; } -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPreClientTick(); ++ net.minecraftforge.event.ForgeEventFactory.onPreClientTick(); + this.f_91026_.m_6180_("gui"); - if (!this.f_91012_) { - this.f_91065_.m_93066_(); -@@ -1679,6 +_,8 @@ + this.f_91065_.m_193832_(this.f_91012_); + this.f_91026_.m_7238_(); +@@ -1683,6 +_,8 @@ this.f_91026_.m_6182_("keyboard"); this.f_91068_.m_90931_(); this.f_91026_.m_7238_(); + -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPostClientTick(); ++ net.minecraftforge.event.ForgeEventFactory.onPostClientTick(); } private boolean m_91278_() { -@@ -1814,11 +_,11 @@ +@@ -1821,11 +_,11 @@ } public void m_91200_(String p_91201_) { @@ -321,7 +321,7 @@ return p_91204_.m_46934_(); }, (p_167886_, p_167887_, p_167888_, p_167889_) -> { RegistryWriteOps registrywriteops = RegistryWriteOps.m_135767_(JsonOps.INSTANCE, p_91205_); -@@ -1828,10 +_,10 @@ +@@ -1835,10 +_,10 @@ }); WorldGenSettings worldgensettings = dataresult.resultOrPartial(Util.m_137489_("Error reading worldgen settings after loading data packs: ", f_90982_::error)).orElse(p_91206_); return new PrimaryLevelData(p_91204_, worldgensettings, dataresult.lifecycle()); @@ -334,7 +334,7 @@ LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess; try { levelstoragesource$levelstorageaccess = this.f_91031_.m_78260_(p_91220_); -@@ -1843,12 +_,17 @@ +@@ -1850,12 +_,17 @@ } Minecraft.ServerStem minecraft$serverstem; @@ -354,7 +354,7 @@ })); try { -@@ -1868,7 +_,7 @@ +@@ -1875,7 +_,7 @@ this.f_90999_.set((StoringChunkProgressListener)null); try { @@ -363,8 +363,8 @@ minecraft$serverstem.m_91433_().m_136179_(); YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(this.f_91030_); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); -@@ -1880,7 +_,7 @@ - SkullBlockEntity.m_182462_(this); +@@ -1885,7 +_,7 @@ + SkullBlockEntity.m_196700_(gameprofilecache, minecraftsessionservice, this); GameProfileCache.m_11004_(false); this.f_91007_ = MinecraftServer.m_129872_((p_167898_) -> { - return new IntegratedServer(p_167898_, this, p_91221_, levelstoragesource$levelstorageaccess, minecraft$serverstem.m_91432_(), minecraft$serverstem.m_91433_(), worlddata, minecraftsessionservice, gameprofilerepository, gameprofilecache, (p_168000_) -> { @@ -372,7 +372,7 @@ StoringChunkProgressListener storingchunkprogresslistener = new StoringChunkProgressListener(p_168000_ + 0); this.f_90999_.set(storingchunkprogresslistener); return ProcessorChunkProgressListener.m_143583_(storingchunkprogresslistener, this.f_91023_::add); -@@ -1924,11 +_,16 @@ +@@ -1929,11 +_,16 @@ connection.m_129505_(new ClientHandshakePacketListenerImpl(connection, this, (Screen)null, (p_167998_) -> { })); connection.m_129512_(new ClientIntentionPacket(socketaddress.toString(), 0, ConnectionProtocol.LOGIN)); @@ -391,7 +391,7 @@ }); minecraft$serverstem.close(); -@@ -2016,6 +_,7 @@ +@@ -2021,6 +_,7 @@ } public void m_91156_(ClientLevel p_91157_) { @@ -399,7 +399,7 @@ ProgressScreen progressscreen = new ProgressScreen(true); progressscreen.m_6309_(new TranslatableComponent("connect.joining")); this.m_91362_(progressscreen); -@@ -2049,10 +_,12 @@ +@@ -2053,10 +_,12 @@ IntegratedServer integratedserver = this.f_91007_; this.f_91007_ = null; this.f_91063_.m_109150_(); @@ -412,23 +412,15 @@ if (integratedserver != null) { this.f_91026_.m_6180_("waitForServer"); -@@ -2067,6 +_,7 @@ +@@ -2071,6 +_,7 @@ this.f_91065_.m_93089_(); this.f_91008_ = null; this.f_91010_ = false; -+ net.minecraftforge.client.ForgeHooksClient.handleClientWorldClosing(f_91073_); ++ net.minecraftforge.client.ForgeHooksClient.handleClientLevelClosing(f_91073_); this.f_91004_.m_90740_(); } -@@ -2097,6 +_,7 @@ - this.f_91061_.m_107342_(p_91325_); - this.f_167845_.m_112257_(p_91325_); - this.m_91341_(); -+ net.minecraftforge.client.MinecraftForgeClient.clearRenderCache(); - } - - public boolean m_91400_() { -@@ -2152,66 +_,9 @@ +@@ -2157,66 +_,9 @@ private void m_91280_() { if (this.f_91077_ != null && this.f_91077_.m_6662_() != HitResult.Type.MISS) { @@ -498,7 +490,7 @@ } } -@@ -2768,7 +_,7 @@ +@@ -2707,7 +_,7 @@ return this.f_90993_; } @@ -507,7 +499,7 @@ int i = p_167938_.m_10374_(); Supplier supplier = p_167937_; if (i <= 3) { -@@ -2779,7 +_,7 @@ +@@ -2718,7 +_,7 @@ supplier = m_91352_(supplier); } @@ -516,7 +508,7 @@ } private static Supplier m_91330_(Supplier p_91331_) { -@@ -2796,6 +_,14 @@ +@@ -2735,6 +_,14 @@ public void m_91312_(int p_91313_) { this.f_91051_.m_119410_(p_91313_); diff --git a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch index b0de2cf98f..df68884eff 100755 --- a/patches/minecraft/net/minecraft/client/MouseHandler.java.patch +++ b/patches/minecraft/net/minecraft/client/MouseHandler.java.patch @@ -13,19 +13,19 @@ screen.m_169415_(); Screen.m_96579_(() -> { - aboolean[0] = screen.m_6375_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPre(this.f_91503_.f_91080_, d0, d1, i); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPre(this.f_91503_.f_91080_, d0, d1, i); + if (!aboolean[0]) { + aboolean[0] = this.f_91503_.f_91080_.m_6375_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseClickedPost(this.f_91503_.f_91080_, d0, d1, i, aboolean[0]); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPost(this.f_91503_.f_91080_, d0, d1, i, aboolean[0]); + } }, "mouseClicked event handler", screen.getClass().getCanonicalName()); } else { Screen.m_96579_(() -> { - aboolean[0] = screen.m_6348_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPre(this.f_91503_.f_91080_, d0, d1, i); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPre(this.f_91503_.f_91080_, d0, d1, i); + if (!aboolean[0]) { + aboolean[0] = this.f_91503_.f_91080_.m_6348_(d0, d1, i); -+ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onGuiMouseReleasedPost(this.f_91503_.f_91080_, d0, d1, i, aboolean[0]); ++ aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPost(this.f_91503_.f_91080_, d0, d1, i, aboolean[0]); + } }, "mouseReleased event handler", screen.getClass().getCanonicalName()); } @@ -54,9 +54,9 @@ double d2 = this.f_91508_ * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); - this.f_91503_.f_91080_.m_6050_(d1, d2, d0); this.f_91503_.f_91080_.m_169415_(); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiMouseScrollPre(this, this.f_91503_.f_91080_, d0)) return; ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPre(this, this.f_91503_.f_91080_, d0)) return; + if (this.f_91503_.f_91080_.m_6050_(d1, d2, d0)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiMouseScrollPost(this, this.f_91503_.f_91080_, d0); ++ net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPost(this, this.f_91503_.f_91080_, d0); } else if (this.f_91503_.f_91074_ != null) { if (this.f_91518_ != 0.0D && Math.signum(d0) != Math.signum(this.f_91518_)) { this.f_91518_ = 0.0D; @@ -73,9 +73,9 @@ double d3 = (p_91564_ - this.f_91508_) * (double)this.f_91503_.m_91268_().m_85446_() / (double)this.f_91503_.m_91268_().m_85444_(); Screen.m_96579_(() -> { - screen.m_7979_(d0, d1, this.f_91510_, d2, d3); -+ if (net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPre(this.f_91503_.f_91080_, d0, d1, this.f_91510_, d2, d3)) return; ++ if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPre(this.f_91503_.f_91080_, d0, d1, this.f_91510_, d2, d3)) return; + if (screen.m_7979_(d0, d1, this.f_91510_, d2, d3)) return; -+ net.minecraftforge.client.ForgeHooksClient.onGuiMouseDragPost(this.f_91503_.f_91080_, d0, d1, this.f_91510_, d2, d3); ++ net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPost(this.f_91503_.f_91080_, d0, d1, this.f_91510_, d2, d3); }, "mouseDragged event handler", screen.getClass().getCanonicalName()); } diff --git a/patches/minecraft/net/minecraft/client/Options.java.patch b/patches/minecraft/net/minecraft/client/Options.java.patch index d2f2002421..7de531fadf 100644 --- a/patches/minecraft/net/minecraft/client/Options.java.patch +++ b/patches/minecraft/net/minecraft/client/Options.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Options.java +++ b/net/minecraft/client/Options.java -@@ -179,6 +_,7 @@ +@@ -186,6 +_,7 @@ public boolean f_92076_; public Options(Minecraft p_92138_, File p_92139_) { @@ -8,8 +8,8 @@ this.f_92060_ = p_92138_; this.f_92110_ = new File(p_92139_, "options.txt"); if (p_92138_.m_91103_() && Runtime.getRuntime().maxMemory() >= 1000000000L) { -@@ -283,10 +_,14 @@ - this.f_92076_ = p_168428_.m_142682_("syncChunkWrites", this.f_92076_); +@@ -299,10 +_,14 @@ + this.f_193762_ = p_168428_.m_142682_("allowServerListing", this.f_193762_); for(KeyMapping keymapping : this.f_92059_) { - String s = keymapping.m_90865_(); @@ -25,15 +25,15 @@ } } -@@ -474,6 +_,7 @@ +@@ -490,6 +_,7 @@ } public void m_92169_() { -+ if (net.minecraftforge.fmlclient.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. ++ if (net.minecraftforge.client.loading.ClientModLoader.isLoading()) return; //Don't save settings before mods add keybindigns and the like to prevent them from being deleted. try { final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.f_92110_), StandardCharsets.UTF_8)); -@@ -622,6 +_,23 @@ +@@ -638,6 +_,23 @@ } p_92146_.m_10509_(set); diff --git a/patches/minecraft/net/minecraft/client/Screenshot.java.patch b/patches/minecraft/net/minecraft/client/Screenshot.java.patch index f97dbd6697..e60f21fc38 100644 --- a/patches/minecraft/net/minecraft/client/Screenshot.java.patch +++ b/patches/minecraft/net/minecraft/client/Screenshot.java.patch @@ -11,7 +11,7 @@ + } + final File target = event.getScreenshotFile(); + - Util.m_137579_().execute(() -> { + Util.m_183992_().execute(() -> { try { - nativeimage.m_85056_(file2); + nativeimage.m_85056_(target); diff --git a/patches/minecraft/net/minecraft/client/User.java.patch b/patches/minecraft/net/minecraft/client/User.java.patch index 068e648478..c0856fcae9 100644 --- a/patches/minecraft/net/minecraft/client/User.java.patch +++ b/patches/minecraft/net/minecraft/client/User.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/client/User.java +++ b/net/minecraft/client/User.java -@@ -18,8 +_,22 @@ - private final String f_92536_; - private final String f_92537_; +@@ -21,8 +_,22 @@ + private final Optional f_193796_; + private final Optional f_193797_; private final User.Type f_92538_; + /** Forge: Cache of the local session's GameProfile properties. */ + private com.mojang.authlib.properties.PropertyMap properties; - public User(String p_92540_, String p_92541_, String p_92542_, String p_92543_) { -+ if (p_92540_ == null || p_92540_.isEmpty()) { -+ p_92540_ = "MissingName"; -+ p_92541_ = p_92542_ = "NotValid"; + public User(String p_193799_, String p_193800_, String p_193801_, Optional p_193802_, Optional p_193803_, User.Type p_193804_) { ++ if (p_193799_ == null || p_193799_.isEmpty()) { ++ p_193799_ = "MissingName"; ++ p_193800_ = p_193801_ = "NotValid"; + org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger(getClass().getName()); + logger.warn("========================================================="); + logger.warn("WARNING!! the username was not set for this session, typically"); @@ -20,10 +20,10 @@ + logger.warn("when asking for help!"); + logger.warn("========================================================="); + } - this.f_92535_ = p_92540_; - this.f_92536_ = p_92541_; - this.f_92537_ = p_92542_; -@@ -45,10 +_,22 @@ + this.f_92535_ = p_193799_; + this.f_92536_ = p_193800_; + this.f_92537_ = p_193801_; +@@ -58,10 +_,22 @@ public GameProfile m_92548_() { try { UUID uuid = UUIDTypeAdapter.fromString(this.m_92545_()); diff --git a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch index 87407fe9b0..6f93da8658 100644 --- a/patches/minecraft/net/minecraft/client/gui/Gui.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/Gui.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/Gui.java +++ b/net/minecraft/client/gui/Gui.java -@@ -446,6 +_,10 @@ +@@ -463,6 +_,10 @@ for(MobEffectInstance mobeffectinstance : Ordering.natural().reverse().sortedCopy(collection)) { MobEffect mobeffect = mobeffectinstance.m_19544_(); @@ -9,17 +9,17 @@ + // Rebind in case previous renderHUDEffect changed texture + RenderSystem.m_157456_(0, AbstractContainerScreen.f_97725_); if (mobeffectinstance.m_19575_()) { - int k = this.f_92977_; - int l = 1; -@@ -483,6 +_,7 @@ + int i = this.f_92977_; + int j = 1; +@@ -500,6 +_,7 @@ RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, f1); - m_93200_(p_93029_, j1 + 3, k1 + 3, this.m_93252_(), 18, 18, textureatlassprite); + m_93200_(p_93029_, l + 3, i1 + 3, this.m_93252_(), 18, 18, textureatlassprite); }); -+ renderer.renderHUDEffect(mobeffectinstance,this, p_93029_, k, l, this.m_93252_(), f); ++ renderer.renderHUDEffect(mobeffectinstance,this, p_93029_, i, j, this.m_93252_(), f); } } -@@ -608,7 +_,8 @@ +@@ -625,7 +_,8 @@ mutablecomponent.m_130940_(ChatFormatting.ITALIC); } @@ -29,7 +29,7 @@ int j = (this.f_92977_ - i) / 2; int k = this.f_92978_ - 59; if (!this.f_92986_.f_91072_.m_105205_()) { -@@ -624,7 +_,13 @@ +@@ -641,7 +_,13 @@ RenderSystem.m_69478_(); RenderSystem.m_69453_(); m_93172_(p_93070_, j - 2, k - 2, j + i + 2, k + 9 + 2, this.f_92986_.f_91066_.m_92143_(0)); @@ -44,7 +44,7 @@ RenderSystem.m_69461_(); } } -@@ -1128,7 +_,7 @@ +@@ -1153,7 +_,7 @@ ItemStack itemstack = this.f_92986_.f_91074_.m_150109_().m_36056_(); if (itemstack.m_41619_()) { this.f_92993_ = 0; diff --git a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch index 0152c302be..2c2122ccfb 100644 --- a/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/MapRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/MapRenderer.java +++ b/net/minecraft/client/gui/MapRenderer.java -@@ -123,6 +_,7 @@ +@@ -118,6 +_,7 @@ for(MapDecoration mapdecoration : this.f_93280_.m_164811_()) { if (!p_93294_ || mapdecoration.m_77809_()) { diff --git a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch index 987492630b..2f20e136d8 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/AbstractSelectionList.java.patch @@ -13,4 +13,4 @@ + @OnlyIn(Dist.CLIENT) public abstract static class Entry> implements GuiEventListener { - @Deprecated + /** @deprecated */ diff --git a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch index 9a626bf75c..f8aa36b249 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/BossHealthOverlay.java.patch @@ -5,7 +5,7 @@ for(LerpingBossEvent lerpingbossevent : this.f_93699_.values()) { int k = i / 2 - 91; + net.minecraftforge.client.event.RenderGameOverlayEvent.BossInfo event = -+ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPre(p_93705_, this.f_93698_.m_91268_(), lerpingbossevent, k, j, 10 + this.f_93698_.f_91062_.f_92710_); ++ net.minecraftforge.client.ForgeHooksClient.renderBossEventPre(p_93705_, this.f_93698_.m_91268_(), lerpingbossevent, k, j, 10 + this.f_93698_.f_91062_.f_92710_); + if (!event.isCanceled()) { RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.m_157456_(0, f_93697_); @@ -17,7 +17,7 @@ - j += 10 + 9; + } + j += event.getIncrement(); -+ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPost(p_93705_, this.f_93698_.m_91268_()); ++ net.minecraftforge.client.ForgeHooksClient.renderBossEventPost(p_93705_, this.f_93698_.m_91268_()); if (j >= this.f_93698_.m_91268_().m_85446_() / 3) { break; } diff --git a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch index 659bc2cf32..0e0ccb872b 100644 --- a/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/components/DebugScreenOverlay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/components/DebugScreenOverlay.java +++ b/net/minecraft/client/gui/components/DebugScreenOverlay.java -@@ -354,7 +_,7 @@ +@@ -363,7 +_,7 @@ list.add(this.m_94071_(entry)); } @@ -9,7 +9,7 @@ list.add("#" + resourcelocation); } } -@@ -370,7 +_,7 @@ +@@ -379,7 +_,7 @@ list.add(this.m_94071_(entry1)); } @@ -18,7 +18,7 @@ list.add("#" + resourcelocation1); } } -@@ -380,6 +_,7 @@ +@@ -389,6 +_,7 @@ list.add(""); list.add(ChatFormatting.UNDERLINE + "Targeted Entity"); list.add(String.valueOf((Object)Registry.f_122826_.m_7981_(entity.m_6095_()))); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch index 78f7ad90d0..3fd6dfddbe 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/LoadingOverlay.java.patch @@ -4,7 +4,7 @@ int k1 = (int)((double)this.f_96163_.m_91268_().m_85446_() * 0.8325D); float f6 = this.f_96164_.m_7750_(); this.f_96167_ = Mth.m_14036_(this.f_96167_ * 0.95F + f6 * 0.050000012F, 0.0F, 1.0F); -+ net.minecraftforge.fmlclient.ClientModLoader.renderProgressText(); ++ net.minecraftforge.client.loading.ClientModLoader.renderProgressText(); if (f < 1.0F) { this.m_96182_(p_96178_, i / 2 - j1, k1 - 5, i / 2 + j1, k1 + 5, 1.0F - Mth.m_14036_(f, 0.0F, 1.0F)); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch index c008c74cbe..bbb6bf4c53 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/OptionsScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/OptionsScreen.java +++ b/net/minecraft/client/gui/screens/OptionsScreen.java -@@ -134,4 +_,12 @@ +@@ -141,4 +_,12 @@ m_93215_(p_96249_, this.f_96547_, this.f_96539_, this.f_96543_ / 2, 15, 16777215); super.m_6305_(p_96249_, p_96250_, p_96251_, p_96252_); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch index a8649bf8cb..f28c6450dc 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/Screen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/Screen.java +++ b/net/minecraft/client/gui/screens/Screen.java -@@ -125,7 +_,7 @@ +@@ -126,7 +_,7 @@ } public void m_7379_() { @@ -9,7 +9,7 @@ } protected T m_142416_(T p_169406_) { -@@ -162,15 +_,29 @@ +@@ -163,15 +_,29 @@ this.f_169368_.clear(); } @@ -43,7 +43,7 @@ this.m_169383_(p_169389_, list, p_169392_, p_169393_); } -@@ -183,20 +_,48 @@ +@@ -184,20 +_,44 @@ } public void m_96597_(PoseStack p_96598_, List p_96599_, int p_96600_, int p_96601_) { @@ -57,9 +57,7 @@ + public void renderComponentTooltip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, @Nullable Font font) { + this.renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, font, ItemStack.f_41583_); + } -+ @Deprecated(forRemoval = true, since = "1.17.1") public void renderComponentToolTip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, @Nullable Font font) { -+ renderComponentTooltip(poseStack, tooltips, mouseX, mouseY, font); -+ } ++ + public void renderComponentTooltip(PoseStack poseStack, List tooltips, int mouseX, int mouseY, @Nullable Font font, ItemStack stack) { + this.tooltipFont = font; + this.tooltipStack = stack; @@ -72,29 +70,27 @@ public void m_96617_(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_) { this.m_169383_(p_96618_, p_96619_.stream().map(ClientTooltipComponent::m_169948_).collect(Collectors.toList()), p_96620_, p_96621_); } -+ @Deprecated(forRemoval = true, since = "1.17.1") public void renderToolTip(PoseStack p_96618_, List p_96619_, int p_96620_, int p_96621_, Font font) { -+ renderTooltip(p_96618_, p_96619_, p_96620_, p_96621_, font); -+ } + + public void renderTooltip(PoseStack poseStack, List lines, int x, int y, Font font) { + this.tooltipFont = font; + this.m_96617_(poseStack, lines, x, y); + this.tooltipFont = null; + } - ++ private void m_169383_(PoseStack p_169384_, List p_169385_, int p_169386_, int p_169387_) { if (!p_169385_.isEmpty()) { -+ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.preTooltipEvent(this.tooltipStack, p_169384_, p_169386_, p_169387_, f_96543_, f_96544_, p_169385_, this.tooltipFont, this.f_96547_); ++ net.minecraftforge.client.event.RenderTooltipEvent.Pre preEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipPre(this.tooltipStack, p_169384_, p_169386_, p_169387_, f_96543_, f_96544_, p_169385_, this.tooltipFont, this.f_96547_); + if (preEvent.isCanceled()) return; int i = 0; int j = p_169385_.size() == 1 ? -2 : 0; for(ClientTooltipComponent clienttooltipcomponent : p_169385_) { - int k = clienttooltipcomponent.m_142069_(this.f_96547_); -+ int k = clienttooltipcomponent.m_142069_(preEvent.getFontRenderer()); ++ int k = clienttooltipcomponent.m_142069_(preEvent.getFont()); if (k > i) { i = k; } -@@ -204,8 +_,8 @@ +@@ -205,8 +_,8 @@ j += clienttooltipcomponent.m_142103_(); } @@ -105,7 +101,7 @@ if (j2 + i > this.f_96543_) { j2 -= 28 + i; } -@@ -226,15 +_,16 @@ +@@ -227,15 +_,16 @@ RenderSystem.m_157427_(GameRenderer::m_172811_); bufferbuilder.m_166779_(VertexFormat.Mode.QUADS, DefaultVertexFormat.f_85815_); Matrix4f matrix4f = p_169384_.m_85850_().m_85861_(); @@ -118,7 +114,7 @@ - m_93123_(matrix4f, bufferbuilder, j2 + i + 2, k2 - 3 + 1, j2 + i + 3, k2 + j + 3 - 1, 400, 1347420415, 1344798847); - m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 - 3 + 1, 400, 1347420415, 1347420415); - m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 2, j2 + i + 3, k2 + j + 3, 400, 1344798847, 1344798847); -+ net.minecraftforge.client.event.RenderTooltipEvent.Color colorEvent = net.minecraftforge.client.ForgeHooksClient.colorTooltipEvent(this.tooltipStack, p_169384_, j2, k2, preEvent.getFontRenderer(), p_169385_); ++ net.minecraftforge.client.event.RenderTooltipEvent.Color colorEvent = net.minecraftforge.client.ForgeHooksClient.onRenderTooltipColor(this.tooltipStack, p_169384_, j2, k2, preEvent.getFont(), p_169385_); + m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 4, j2 + i + 3, k2 - 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundStart()); + m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 + j + 3, j2 + i + 3, k2 + j + 4, 400, colorEvent.getBackgroundEnd(), colorEvent.getBackgroundEnd()); + m_93123_(matrix4f, bufferbuilder, j2 - 3, k2 - 3, j2 + i + 3, k2 + j + 3, 400, colorEvent.getBackgroundStart(), colorEvent.getBackgroundEnd()); @@ -131,25 +127,25 @@ RenderSystem.m_69482_(); RenderSystem.m_69472_(); RenderSystem.m_69478_(); -@@ -249,7 +_,7 @@ +@@ -250,7 +_,7 @@ for(int i2 = 0; i2 < p_169385_.size(); ++i2) { ClientTooltipComponent clienttooltipcomponent1 = p_169385_.get(i2); - clienttooltipcomponent1.m_142440_(this.f_96547_, j2, l1, matrix4f, multibuffersource$buffersource); -+ clienttooltipcomponent1.m_142440_(preEvent.getFontRenderer(), j2, l1, matrix4f, multibuffersource$buffersource); ++ clienttooltipcomponent1.m_142440_(preEvent.getFont(), j2, l1, matrix4f, multibuffersource$buffersource); l1 += clienttooltipcomponent1.m_142103_() + (i2 == 0 ? 2 : 0); } -@@ -259,7 +_,7 @@ +@@ -260,7 +_,7 @@ for(int l2 = 0; l2 < p_169385_.size(); ++l2) { ClientTooltipComponent clienttooltipcomponent2 = p_169385_.get(l2); -- clienttooltipcomponent2.m_142162_(this.f_96547_, j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_()); -+ clienttooltipcomponent2.m_142162_(preEvent.getFontRenderer(), j2, l1, p_169384_, this.f_96542_, 400, this.f_96541_.m_91097_()); +- clienttooltipcomponent2.m_183452_(this.f_96547_, j2, l1, p_169384_, this.f_96542_, 400); ++ clienttooltipcomponent2.m_183452_(preEvent.getFont(), j2, l1, p_169384_, this.f_96542_, 400); l1 += clienttooltipcomponent2.m_142103_() + (l2 == 0 ? 2 : 0); } -@@ -353,9 +_,12 @@ +@@ -354,9 +_,12 @@ } public void m_96612_(String p_96613_, boolean p_96614_) { @@ -162,7 +158,7 @@ this.f_96541_.f_91074_.m_108739_(p_96613_); } -@@ -366,11 +_,21 @@ +@@ -367,11 +_,21 @@ this.f_96547_ = p_96607_.f_91062_; this.f_96543_ = p_96608_; this.f_96544_ = p_96609_; @@ -173,34 +169,34 @@ + this.f_169368_.add(ne); + f_96540_.add(b); + }; -+ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Pre(this, this.f_96540_, add, this::m_169411_))) { ++ if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Pre(this, this.f_96540_, add, this::m_169411_))) { this.m_169413_(); this.m_7522_((GuiEventListener)null); this.m_7856_(); this.m_169407_(false); this.m_169378_(f_169370_); + } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Post(this, this.f_96540_, add, this::m_169411_)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.InitScreenEvent.Post(this, this.f_96540_, add, this::m_169411_)); } public List m_6702_() { -@@ -393,6 +_,7 @@ +@@ -394,6 +_,7 @@ public void m_96558_(PoseStack p_96559_, int p_96560_) { if (this.f_96541_.f_91073_ != null) { this.m_93179_(p_96559_, 0, 0, this.f_96543_, this.f_96544_, -1072689136, -804253680); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, p_96559_)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.BackgroundDrawnEvent(this, p_96559_)); } else { this.m_96626_(p_96560_); } -@@ -412,6 +_,7 @@ +@@ -413,6 +_,7 @@ bufferbuilder.m_5483_((double)this.f_96543_, 0.0D, 0.0D).m_7421_((float)this.f_96543_ / 32.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); bufferbuilder.m_5483_(0.0D, 0.0D, 0.0D).m_7421_(0.0F, (float)p_96627_).m_6122_(64, 64, 64, 255).m_5752_(); tesselator.m_85914_(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this, new PoseStack())); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.BackgroundDrawnEvent(this, new PoseStack())); } public boolean m_7043_() { -@@ -497,6 +_,10 @@ +@@ -498,6 +_,10 @@ } public void m_7400_(List p_96591_) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch index 5892a818f7..9bdf9b8c9e 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/TitleScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/TitleScreen.java +++ b/net/minecraft/client/gui/screens/TitleScreen.java -@@ -63,6 +_,7 @@ +@@ -64,6 +_,7 @@ private final PanoramaRenderer f_96729_ = new PanoramaRenderer(f_96716_); private final boolean f_96714_; private long f_96715_; @@ -8,7 +8,7 @@ public TitleScreen() { this(false); -@@ -106,11 +_,16 @@ +@@ -107,11 +_,16 @@ this.f_96728_ = this.f_96543_ - this.f_96727_ - 2; int i = 24; int j = this.f_96544_ / 4 + 48; @@ -18,14 +18,14 @@ } else { this.m_96763_(j, 24); + modButton = this.m_142416_(new Button(this.f_96543_ / 2 - 100, j + 24 * 2, 98, 20, new TranslatableComponent("fml.menu.mods"), button -> { -+ this.f_96541_.m_91152_(new net.minecraftforge.fmlclient.gui.screen.ModListScreen(this)); ++ this.f_96541_.m_91152_(new net.minecraftforge.client.gui.ModListScreen(this)); + })); } + modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton); this.m_142416_(new ImageButton(this.f_96543_ / 2 - 124, j + 72 + 12, 20, 20, 0, 106, 20, Button.f_93617_, 256, 256, (p_96791_) -> { this.f_96541_.m_91152_(new LanguageSelectScreen(this, this.f_96541_.f_91066_, this.f_96541_.m_91102_())); -@@ -158,7 +_,7 @@ +@@ -159,7 +_,7 @@ Screen screen = (Screen)(this.f_96541_.f_91066_.f_92083_ ? new JoinMultiplayerScreen(this) : new SafetyScreen(this)); this.f_96541_.m_91152_(screen); }, button$ontooltip))).f_93623_ = flag; @@ -34,7 +34,7 @@ this.m_96793_(); }, button$ontooltip))).f_93623_ = flag; } -@@ -283,6 +_,7 @@ +@@ -284,6 +_,7 @@ RenderSystem.m_157456_(0, f_96724_); m_93133_(p_96739_, j + 88, 67, 0.0F, 0.0F, 98, 14, 128, 16); @@ -42,23 +42,23 @@ if (this.f_96721_ != null) { p_96739_.m_85836_(); p_96739_.m_85837_((double)(this.f_96543_ / 2 + 90), 70.0D, 0.0D); -@@ -305,7 +_,14 @@ +@@ -306,7 +_,14 @@ s = s + I18n.m_118938_("menu.modded"); } - m_93236_(p_96739_, this.f_96547_, s, 2, this.f_96544_ - 10, 16777215 | l); -+ net.minecraftforge.fmllegacy.BrandingControl.forEachLine(true, true, (brdline, brd) -> ++ net.minecraftforge.internal.BrandingControl.forEachLine(true, true, (brdline, brd) -> + m_93236_(p_96739_, this.f_96547_, brd, 2, this.f_96544_ - ( 10 + brdline * (this.f_96547_.f_92710_ + 1)), 16777215 | l) + ); + -+ net.minecraftforge.fmllegacy.BrandingControl.forEachAboveCopyrightLine((brdline, brd) -> ++ net.minecraftforge.internal.BrandingControl.forEachAboveCopyrightLine((brdline, brd) -> + m_93236_(p_96739_, this.f_96547_, brd, this.f_96543_ - f_96547_.m_92895_(brd), this.f_96544_ - (10 + (brdline + 1) * ( this.f_96547_.f_92710_ + 1)), 16777215 | l) + ); + m_93236_(p_96739_, this.f_96547_, "Copyright Mojang AB. Do not distribute!", this.f_96728_, this.f_96544_ - 10, 16777215 | l); if (p_96740_ > this.f_96728_ && p_96740_ < this.f_96728_ + this.f_96727_ && p_96741_ > this.f_96544_ - 10 && p_96741_ < this.f_96544_) { m_93172_(p_96739_, this.f_96728_, this.f_96544_ - 1, this.f_96728_ + this.f_96727_, this.f_96544_, 16777215 | l); -@@ -321,6 +_,7 @@ +@@ -322,6 +_,7 @@ if (this.m_96789_() && f1 >= 1.0F) { this.f_96726_.m_6305_(p_96739_, p_96740_, p_96741_, p_96742_); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch index 7f758839e7..e69bb8ba9b 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java +++ b/net/minecraft/client/gui/screens/advancements/AdvancementsScreen.java -@@ -42,6 +_,7 @@ - private final Map f_97335_ = Maps.newLinkedHashMap(); +@@ -43,6 +_,7 @@ + @Nullable private AdvancementTab f_97336_; private boolean f_97337_; + private static int tabPage, maxPages; public AdvancementsScreen(ClientAdvancements p_97340_) { super(NarratorChatListener.f_93310_); -@@ -57,7 +_,13 @@ +@@ -58,7 +_,13 @@ } else { this.f_97334_.m_104401_(this.f_97336_ == null ? null : this.f_97336_.m_97182_(), true); } @@ -23,7 +23,7 @@ } public void m_7861_() { -@@ -75,7 +_,7 @@ +@@ -76,7 +_,7 @@ int j = (this.f_96544_ - 140) / 2; for(AdvancementTab advancementtab : this.f_97335_.values()) { @@ -32,7 +32,7 @@ this.f_97334_.m_104401_(advancementtab.m_97182_(), true); break; } -@@ -99,6 +_,11 @@ +@@ -100,6 +_,11 @@ int i = (this.f_96543_ - 252) / 2; int j = (this.f_96544_ - 140) / 2; this.m_7333_(p_97361_); @@ -44,7 +44,7 @@ this.m_97373_(p_97361_, p_97362_, p_97363_, i, j); this.m_97356_(p_97361_, i, j); this.m_97381_(p_97361_, p_97362_, p_97363_, i, j); -@@ -149,12 +_,14 @@ +@@ -150,12 +_,14 @@ RenderSystem.m_157456_(0, f_97330_); for(AdvancementTab advancementtab : this.f_97335_.values()) { @@ -59,7 +59,7 @@ advancementtab1.m_97159_(p_97358_, p_97359_, this.f_96542_); } -@@ -180,7 +_,7 @@ +@@ -181,7 +_,7 @@ if (this.f_97335_.size() > 1) { for(AdvancementTab advancementtab : this.f_97335_.values()) { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlList.java.patch deleted file mode 100644 index 332c783fef..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlList.java.patch +++ /dev/null @@ -1,60 +0,0 @@ ---- a/net/minecraft/client/gui/screens/controls/ControlList.java -+++ b/net/minecraft/client/gui/screens/controls/ControlList.java -@@ -53,7 +_,7 @@ - } - - protected int m_5756_() { -- return super.m_5756_() + 15; -+ return super.m_5756_() + 15 + 20; - } - - public int m_5759_() { -@@ -109,7 +_,7 @@ - KeyEntry(final KeyMapping p_97451_, final Component p_97452_) { - this.f_97445_ = p_97451_; - this.f_97446_ = p_97452_; -- this.f_97447_ = new Button(0, 0, 75, 20, p_97452_, (p_97479_) -> { -+ this.f_97447_ = new Button(0, 0, 75 + 20 /*Forge: add space*/, 20, p_97452_, (p_97479_) -> { - ControlList.this.f_97396_.f_97514_ = p_97451_; - }) { - protected MutableComponent m_5646_() { -@@ -117,6 +_,7 @@ - } - }; - this.f_97448_ = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_97475_) -> { -+ f_97445_.setToDefault(); - ControlList.this.f_93386_.f_91066_.m_92159_(p_97451_, p_97451_.m_90861_()); - KeyMapping.m_90854_(); - }) { -@@ -130,7 +_,7 @@ - boolean flag = ControlList.this.f_97396_.f_97514_ == this.f_97445_; - float f = (float)(p_97466_ + 90 - ControlList.this.f_97397_); - ControlList.this.f_93386_.f_91062_.m_92889_(p_97463_, this.f_97446_, f, (float)(p_97465_ + p_97468_ / 2 - 9 / 2), 16777215); -- this.f_97448_.f_93620_ = p_97466_ + 190; -+ this.f_97448_.f_93620_ = p_97466_ + 190 + 20; - this.f_97448_.f_93621_ = p_97465_; - this.f_97448_.f_93623_ = !this.f_97445_.m_90864_(); - this.f_97448_.m_6305_(p_97463_, p_97469_, p_97470_, p_97472_); -@@ -138,11 +_,12 @@ - this.f_97447_.f_93621_ = p_97465_; - this.f_97447_.m_93666_(this.f_97445_.m_90863_()); - boolean flag1 = false; -+ boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G - if (!this.f_97445_.m_90862_()) { - for(KeyMapping keymapping : ControlList.this.f_93386_.f_91066_.f_92059_) { - if (keymapping != this.f_97445_ && this.f_97445_.m_90850_(keymapping)) { - flag1 = true; -- break; -+ keyCodeModifierConflict &= keymapping.hasKeyCodeModifierConflict(keymapping); - } - } - } -@@ -150,7 +_,7 @@ - if (flag) { - this.f_97447_.m_93666_((new TextComponent("> ")).m_7220_(this.f_97447_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW)); - } else if (flag1) { -- this.f_97447_.m_93666_(this.f_97447_.m_6035_().m_6881_().m_130940_(ChatFormatting.RED)); -+ this.f_97447_.m_93666_(this.f_97447_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); - } - - this.f_97447_.m_6305_(p_97463_, p_97469_, p_97470_, p_97472_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlsScreen.java.patch deleted file mode 100644 index 4382ad76f9..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/screens/controls/ControlsScreen.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/net/minecraft/client/gui/screens/controls/ControlsScreen.java -+++ b/net/minecraft/client/gui/screens/controls/ControlsScreen.java -@@ -35,7 +_,7 @@ - this.m_7787_(this.f_97516_); - this.f_97517_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, new TranslatableComponent("controls.resetAll"), (p_97538_) -> { - for(KeyMapping keymapping : this.f_96282_.f_92059_) { -- keymapping.m_90848_(keymapping.m_90861_()); -+ keymapping.setToDefault(); - } - - KeyMapping.m_90854_(); -@@ -59,11 +_,14 @@ - public boolean m_7933_(int p_97526_, int p_97527_, int p_97528_) { - if (this.f_97514_ != null) { - if (p_97526_ == 256) { -+ this.f_97514_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.f_84822_); - this.f_96282_.m_92159_(this.f_97514_, InputConstants.f_84822_); - } else { -+ this.f_97514_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.m_84827_(p_97526_, p_97527_)); - this.f_96282_.m_92159_(this.f_97514_, InputConstants.m_84827_(p_97526_, p_97527_)); - } - -+ if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.f_97514_.getKey())) - this.f_97514_ = null; - this.f_97515_ = Util.m_137550_(); - KeyMapping.m_90854_(); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch new file mode 100644 index 0000000000..d34bb3b415 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsList.java.patch @@ -0,0 +1,60 @@ +--- a/net/minecraft/client/gui/screens/controls/KeyBindsList.java ++++ b/net/minecraft/client/gui/screens/controls/KeyBindsList.java +@@ -53,7 +_,7 @@ + } + + protected int m_5756_() { +- return super.m_5756_() + 15; ++ return super.m_5756_() + 15 + 20; + } + + public int m_5759_() { +@@ -109,7 +_,7 @@ + KeyEntry(final KeyMapping p_193916_, final Component p_193917_) { + this.f_193910_ = p_193916_; + this.f_193911_ = p_193917_; +- this.f_193912_ = new Button(0, 0, 75, 20, p_193917_, (p_193939_) -> { ++ this.f_193912_ = new Button(0, 0, 75 + 20 /* Forge: Add space */, 20, p_193917_, (p_193939_) -> { + KeyBindsList.this.f_193858_.f_193975_ = p_193916_; + }) { + protected MutableComponent m_5646_() { +@@ -117,6 +_,7 @@ + } + }; + this.f_193913_ = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_193935_) -> { ++ this.f_193910_.setToDefault(); + KeyBindsList.this.f_93386_.f_91066_.m_92159_(p_193916_, p_193916_.m_90861_()); + KeyMapping.m_90854_(); + }) { +@@ -130,7 +_,7 @@ + boolean flag = KeyBindsList.this.f_193858_.f_193975_ == this.f_193910_; + float f = (float)(p_193926_ + 90 - KeyBindsList.this.f_193859_); + KeyBindsList.this.f_93386_.f_91062_.m_92889_(p_193923_, this.f_193911_, f, (float)(p_193925_ + p_193928_ / 2 - 9 / 2), 16777215); +- this.f_193913_.f_93620_ = p_193926_ + 190; ++ this.f_193913_.f_93620_ = p_193926_ + 190 + 20; + this.f_193913_.f_93621_ = p_193925_; + this.f_193913_.f_93623_ = !this.f_193910_.m_90864_(); + this.f_193913_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); +@@ -138,11 +_,12 @@ + this.f_193912_.f_93621_ = p_193925_; + this.f_193912_.m_93666_(this.f_193910_.m_90863_()); + boolean flag1 = false; ++ boolean keyCodeModifierConflict = true; // gracefully handle conflicts like SHIFT vs SHIFT+G + if (!this.f_193910_.m_90862_()) { + for(KeyMapping keymapping : KeyBindsList.this.f_93386_.f_91066_.f_92059_) { + if (keymapping != this.f_193910_ && this.f_193910_.m_90850_(keymapping)) { + flag1 = true; +- break; ++ keyCodeModifierConflict &= keymapping.hasKeyModifierConflict(keymapping); + } + } + } +@@ -150,7 +_,7 @@ + if (flag) { + this.f_193912_.m_93666_((new TextComponent("> ")).m_7220_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.YELLOW)).m_130946_(" <").m_130940_(ChatFormatting.YELLOW)); + } else if (flag1) { +- this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(ChatFormatting.RED)); ++ this.f_193912_.m_93666_(this.f_193912_.m_6035_().m_6881_().m_130940_(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED)); + } + + this.f_193912_.m_6305_(p_193923_, p_193929_, p_193930_, p_193932_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch new file mode 100644 index 0000000000..7891326ea8 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java ++++ b/net/minecraft/client/gui/screens/controls/KeyBindsScreen.java +@@ -31,7 +_,7 @@ + this.m_7787_(this.f_193977_); + this.f_193978_ = this.m_142416_(new Button(this.f_96543_ / 2 - 155, this.f_96544_ - 29, 150, 20, new TranslatableComponent("controls.resetAll"), (p_193999_) -> { + for(KeyMapping keymapping : this.f_96282_.f_92059_) { +- keymapping.m_90848_(keymapping.m_90861_()); ++ keymapping.setToDefault(); + } + + KeyMapping.m_90854_(); +@@ -55,11 +_,14 @@ + public boolean m_7933_(int p_193987_, int p_193988_, int p_193989_) { + if (this.f_193975_ != null) { + if (p_193987_ == 256) { ++ this.f_193975_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.f_84822_); + this.f_96282_.m_92159_(this.f_193975_, InputConstants.f_84822_); + } else { ++ this.f_193975_.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputConstants.m_84827_(p_193987_, p_193988_)); + this.f_96282_.m_92159_(this.f_193975_, InputConstants.m_84827_(p_193987_, p_193988_)); + } + ++ if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.f_193975_.getKey())) + this.f_193975_ = null; + this.f_193976_ = Util.m_137550_(); + KeyMapping.m_90854_(); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch index 38bbefaaea..55dc986629 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/AbstractContainerScreen.java.patch @@ -4,7 +4,7 @@ int i = this.f_97735_; int j = this.f_97736_; this.m_7286_(p_97795_, p_97798_, p_97796_, p_97797_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawBackground(this, p_97795_, p_97796_, p_97797_)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ContainerScreenEvent.DrawBackground(this, p_97795_, p_97796_, p_97797_)); RenderSystem.m_69465_(); super.m_6305_(p_97795_, p_97796_, p_97797_, p_97798_); PoseStack posestack = RenderSystem.m_157191_(); @@ -18,7 +18,7 @@ } this.m_7027_(p_97795_, p_97796_, p_97797_); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiContainerEvent.DrawForeground(this, p_97795_, p_97796_, p_97797_)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ContainerScreenEvent.DrawForeground(this, p_97795_, p_97796_, p_97797_)); ItemStack itemstack = this.f_97711_.m_41619_() ? this.f_97732_.m_142621_() : this.f_97711_; if (!itemstack.m_41619_()) { int l1 = 8; @@ -53,7 +53,7 @@ if (super.m_6375_(p_97748_, p_97749_, p_97750_)) { return true; } else { -- boolean flag = this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_); +- boolean flag = this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_) && this.f_96541_.f_91072_.m_105290_(); + InputConstants.Key mouseKey = InputConstants.Type.MOUSE.m_84895_(p_97750_); + boolean flag = this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey); Slot slot = this.m_97744_(p_97748_, p_97749_); @@ -71,7 +71,7 @@ } } else if (!this.f_97738_) { if (this.f_97732_.m_142621_().m_41619_()) { -- if (this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_)) { +- if (flag) { + if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { this.m_6597_(slot, l, p_97750_, ClickType.CLONE); } else { @@ -80,7 +80,7 @@ this.f_97717_ = 0; } else if (p_97750_ == 1) { this.f_97717_ = 1; -- } else if (this.f_96541_.f_91066_.f_92097_.m_90830_(p_97750_)) { +- } else if (flag) { + } else if (this.f_96541_.f_91066_.f_92097_.isActiveAndMatches(mouseKey)) { this.f_97717_ = 2; } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch index deb5463f41..02a7b071c7 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/CreativeModeInventoryScreen.java.patch @@ -9,7 +9,7 @@ private boolean f_98515_; private final Map> f_98516_ = Maps.newTreeMap(); -@@ -242,6 +_,12 @@ +@@ -233,6 +_,12 @@ protected void m_7856_() { if (this.f_96541_.f_91072_.m_105290_()) { super.m_7856_(); @@ -22,7 +22,7 @@ this.f_96541_.f_91068_.m_90926_(true); this.f_98510_ = new EditBox(this.f_96547_, this.f_97735_ + 82, this.f_97736_ + 6, 80, 9, new TranslatableComponent("itemGroup.search")); this.f_98510_.m_94199_(50); -@@ -283,7 +_,7 @@ +@@ -274,7 +_,7 @@ public boolean m_5534_(char p_98521_, int p_98522_) { if (this.f_98514_) { return false; @@ -31,7 +31,7 @@ return false; } else { String s = this.f_98510_.m_94155_(); -@@ -301,7 +_,7 @@ +@@ -292,7 +_,7 @@ public boolean m_7933_(int p_98547_, int p_98548_, int p_98549_) { this.f_98514_ = false; @@ -40,7 +40,7 @@ if (this.f_96541_.f_91066_.f_92098_.m_90832_(p_98547_, p_98548_)) { this.f_98514_ = true; this.m_98560_(CreativeModeTab.f_40754_); -@@ -338,6 +_,32 @@ +@@ -329,6 +_,32 @@ private void m_98630_() { (this.f_97732_).f_98639_.clear(); this.f_98516_.clear(); @@ -73,7 +73,7 @@ String s = this.f_98510_.m_94155_(); if (s.isEmpty()) { for(Item item : Registry.f_122827_) { -@@ -383,9 +_,9 @@ +@@ -374,9 +_,9 @@ protected void m_7027_(PoseStack p_98616_, int p_98617_, int p_98618_) { CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; @@ -85,7 +85,7 @@ } } -@@ -396,7 +_,7 @@ +@@ -387,7 +_,7 @@ double d1 = p_98532_ - (double)this.f_97736_; for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { @@ -94,7 +94,7 @@ return true; } } -@@ -417,7 +_,7 @@ +@@ -408,7 +_,7 @@ this.f_98509_ = false; for(CreativeModeTab creativemodetab : CreativeModeTab.f_40748_) { @@ -103,7 +103,7 @@ this.m_98560_(creativemodetab); return true; } -@@ -428,12 +_,15 @@ +@@ -419,12 +_,15 @@ } private boolean m_98631_() { @@ -119,7 +119,7 @@ this.f_97737_.clear(); (this.f_97732_).f_98639_.clear(); if (p_98561_ == CreativeModeTab.f_40760_) { -@@ -510,13 +_,15 @@ +@@ -501,13 +_,15 @@ } if (this.f_98510_ != null) { @@ -136,7 +136,7 @@ this.m_98630_(); } else { -@@ -576,16 +_,34 @@ +@@ -567,16 +_,34 @@ this.m_7333_(p_98577_); super.m_6305_(p_98577_, p_98578_, p_98579_, p_98580_); @@ -173,7 +173,7 @@ RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); this.m_7025_(p_98577_, p_98578_, p_98579_); } -@@ -620,7 +_,7 @@ +@@ -611,7 +_,7 @@ list1.add(1, creativemodetab.m_40786_().m_6881_().m_130940_(ChatFormatting.BLUE)); } @@ -182,7 +182,7 @@ } else { super.m_6057_(p_98590_, p_98591_, p_98592_, p_98593_); } -@@ -631,16 +_,32 @@ +@@ -622,16 +_,32 @@ RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); CreativeModeTab creativemodetab = CreativeModeTab.f_40748_[f_98507_]; @@ -219,7 +219,7 @@ this.m_93228_(p_98572_, this.f_97735_, this.f_97736_, 0, 0, this.f_97726_, this.f_97727_); this.f_98510_.m_6305_(p_98572_, p_98574_, p_98575_, p_98573_); RenderSystem.m_157429_(1.0F, 1.0F, 1.0F, 1.0F); -@@ -648,11 +_,14 @@ +@@ -639,11 +_,14 @@ int j = this.f_97736_ + 18; int k = j + 112; RenderSystem.m_157427_(GameRenderer::m_172817_); @@ -235,7 +235,7 @@ this.m_98581_(p_98572_, creativemodetab); if (creativemodetab == CreativeModeTab.f_40761_) { InventoryScreen.m_98850_(this.f_97735_ + 88, this.f_97736_ + 45, 20, (float)(this.f_97735_ + 88 - p_98574_), (float)(this.f_97736_ + 45 - 30 - p_98575_), this.f_96541_.f_91074_); -@@ -661,6 +_,7 @@ +@@ -652,6 +_,7 @@ } protected boolean m_98562_(CreativeModeTab p_98563_, double p_98564_, double p_98565_) { @@ -243,15 +243,15 @@ int i = p_98563_.m_40793_(); int j = 28 * i; int k = 0; -@@ -729,6 +_,7 @@ - i1 = i1 + (this.f_97727_ - 4); +@@ -720,6 +_,7 @@ + i1 += this.f_97727_ - 4; } + RenderSystem.m_69478_(); //Forge: Make sure blend is enabled else tabs show a white border. this.m_93228_(p_98582_, l, i1, j, k, 28, 32); this.f_96542_.f_115093_ = 100.0F; - l = l + 6; -@@ -918,6 +_,22 @@ + l += 6; +@@ -909,6 +_,22 @@ public boolean m_8010_(Player p_98665_) { return this.f_98655_.m_8010_(p_98665_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch index 3462fc3c3b..a71baa4fbb 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java.patch @@ -1,25 +1,40 @@ --- a/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java +++ b/net/minecraft/client/gui/screens/inventory/EffectRenderingInventoryScreen.java -@@ -34,6 +_,9 @@ - this.f_97735_ = (this.f_96543_ - this.f_97726_) / 2; - this.f_98699_ = false; - } else { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this))) -+ this.f_97735_ = (this.f_96543_ - this.f_97726_) / 2; -+ else - this.f_97735_ = 160 + (this.f_96543_ - this.f_97726_ - 200) / 2; - this.f_98699_ = true; - } -@@ -58,7 +_,7 @@ - j = 132 / (collection.size() - 1); +@@ -32,13 +_,21 @@ + } + + public boolean m_194018_() { +- int i = this.f_97735_ + this.f_97726_ + 2; ++ int i; ++ if(cancelShift) ++ i = (this.f_96543_ - this.f_97726_) / 2; ++ else ++ i = this.f_97735_ + this.f_97726_ + 2; + int j = this.f_96543_ - i; + return j >= 32; + } + + private void m_194014_(PoseStack p_194015_, int p_194016_, int p_194017_) { +- int i = this.f_97735_ + this.f_97726_ + 2; ++ int i; ++ if(cancelShift) ++ i = (this.f_96543_ - this.f_97726_) / 2; ++ else ++ i = this.f_97735_ + this.f_97726_ + 2; + int j = this.f_96543_ - i; + Collection collection = this.f_96541_.f_91074_.m_21220_(); + if (!collection.isEmpty() && j >= 32) { +@@ -49,7 +_,8 @@ + k = 132 / (collection.size() - 1); } - Iterable iterable = Ordering.natural().sortedCopy(collection); -+ Iterable iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRender).sorted().collect(java.util.stream.Collectors.toList()); - this.m_98709_(p_98716_, i, j, iterable); - this.m_98717_(p_98716_, i, j, iterable); - this.m_98722_(p_98716_, i, j, iterable); -@@ -95,6 +_,12 @@ ++ ++ Iterable iterable = collection.stream().filter(net.minecraftforge.client.ForgeHooksClient::shouldRenderEffect).sorted().collect(java.util.stream.Collectors.toList()); + this.m_194002_(p_194015_, i, k, iterable, flag); + this.m_194008_(p_194015_, i, k, iterable, flag); + if (flag) { +@@ -110,6 +_,12 @@ int i = this.f_97736_; for(MobEffectInstance mobeffectinstance : p_98726_) { @@ -29,6 +44,20 @@ + i += p_98725_; + continue; + } - String s = I18n.m_118938_(mobeffectinstance.m_19544_().m_19481_()); - if (mobeffectinstance.m_19564_() >= 1 && mobeffectinstance.m_19564_() <= 9) { - s = s + " " + I18n.m_118938_("enchantment.level." + (mobeffectinstance.m_19564_() + 1)); + Component component = this.m_194000_(mobeffectinstance); + this.f_96547_.m_92763_(p_98723_, component, (float)(p_98724_ + 10 + 18), (float)(i + 6), 16777215); + String s = MobEffectUtil.m_19581_(mobeffectinstance, 1.0F); +@@ -126,5 +_,13 @@ + } + + return mutablecomponent; ++ } ++ ++ // FORGE START ++ boolean cancelShift = false; ++ @Override ++ protected void m_7856_() { ++ super.m_7856_(); ++ cancelShift = net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.ScreenEvent.PotionShiftEvent(this)); + } + } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch index 6fce9cd361..2cbd8c78ac 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java +++ b/net/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipComponent.java -@@ -22,6 +_,8 @@ +@@ -21,6 +_,8 @@ if (p_169951_ instanceof BundleTooltip) { return new ClientBundleTooltip((BundleTooltip)p_169951_); } else { diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch index 815db0c752..a4c259b70a 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java +++ b/net/minecraft/client/gui/screens/multiplayer/JoinMultiplayerScreen.java -@@ -247,6 +_,11 @@ +@@ -250,6 +_,11 @@ } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch index 5c71272ea2..f6fa61b212 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java +++ b/net/minecraft/client/gui/screens/multiplayer/ServerSelectionList.java -@@ -333,6 +_,8 @@ +@@ -334,6 +_,8 @@ this.f_99855_.m_99707_(list1); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch index 622d4ef496..e0215339a6 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java +++ b/net/minecraft/client/gui/screens/worldselection/CreateWorldScreen.java -@@ -117,7 +_,7 @@ +@@ -116,7 +_,7 @@ public static CreateWorldScreen m_100898_(@Nullable Screen p_100899_) { RegistryAccess.RegistryHolder registryaccess$registryholder = RegistryAccess.m_123086_(); -- return new CreateWorldScreen(p_100899_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$registryholder, WorldGenSettings.m_64641_(registryaccess$registryholder.m_175515_(Registry.f_122818_), registryaccess$registryholder.m_175515_(Registry.f_122885_), registryaccess$registryholder.m_175515_(Registry.f_122878_)), Optional.of(WorldPreset.f_101506_), OptionalLong.empty())); -+ return new CreateWorldScreen(p_100899_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$registryholder, net.minecraftforge.client.ForgeHooksClient.getDefaultWorldType().map(type -> type.m_7012_(registryaccess$registryholder, new java.util.Random().nextLong(), true, false)).orElseGet(() -> WorldGenSettings.m_64641_(registryaccess$registryholder.m_175512_(Registry.f_122818_), registryaccess$registryholder.m_175512_(Registry.f_122885_), registryaccess$registryholder.m_175512_(Registry.f_122878_))), net.minecraftforge.client.ForgeHooksClient.getDefaultWorldType(), OptionalLong.empty())); +- return new CreateWorldScreen(p_100899_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$registryholder, WorldGenSettings.m_190050_(registryaccess$registryholder), Optional.of(WorldPreset.f_101506_), OptionalLong.empty())); ++ return new CreateWorldScreen(p_100899_, DataPackConfig.f_45842_, new WorldGenSettingsComponent(registryaccess$registryholder, net.minecraftforge.client.ForgeHooksClient.getDefaultWorldPreset().map(type -> type.m_7012_(registryaccess$registryholder, new java.util.Random().nextLong(), true, false)).orElseGet(() -> WorldGenSettings.m_190050_(registryaccess$registryholder)), net.minecraftforge.client.ForgeHooksClient.getDefaultWorldPreset(), OptionalLong.empty())); } private CreateWorldScreen(@Nullable Screen p_100861_, DataPackConfig p_100862_, WorldGenSettingsComponent p_100863_) { -@@ -596,6 +_,7 @@ +@@ -595,6 +_,7 @@ File file1 = path.toFile(); if (this.f_100832_ == null) { this.f_100832_ = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource(), new FolderRepositorySource(file1, PackSource.f_10527_)); -+ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinderNew); ++ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(this.f_100832_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); this.f_100832_.m_10506_(); } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch index c32470f858..329922f6ea 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent.java.patch @@ -4,7 +4,7 @@ this.f_170244_.f_93624_ = false; this.f_101391_ = p_101430_.m_142416_(new Button(j, 120, 150, 20, new TranslatableComponent("selectWorld.customizeType"), (p_170248_) -> { WorldPreset.PresetEditor worldpreset$preseteditor = WorldPreset.f_101509_.get(this.f_101395_); -+ worldpreset$preseteditor = net.minecraftforge.client.ForgeHooksClient.getBiomeGeneratorTypeScreenFactory(this.f_101395_, worldpreset$preseteditor); ++ worldpreset$preseteditor = net.minecraftforge.client.ForgeHooksClient.getPresetEditor(this.f_101395_, worldpreset$preseteditor); if (worldpreset$preseteditor != null) { p_101431_.m_91152_(worldpreset$preseteditor.m_101642_(p_101430_, this.f_101394_)); } @@ -13,7 +13,7 @@ this.f_101389_.f_93624_ = p_170288_; this.f_101380_.f_93624_ = p_170288_; - this.f_101391_.f_93624_ = p_170288_ && WorldPreset.f_101509_.containsKey(this.f_101395_); -+ this.f_101391_.f_93624_ = p_170288_ && (WorldPreset.f_101509_.containsKey(this.f_101395_) || net.minecraftforge.client.ForgeHooksClient.hasBiomeGeneratorSettingsOptionsScreen(this.f_101395_)); ++ this.f_101391_.f_93624_ = p_170288_ && (WorldPreset.f_101509_.containsKey(this.f_101395_) || net.minecraftforge.client.ForgeHooksClient.hasPresetEditor(this.f_101395_)); this.f_101392_.f_93624_ = p_170288_; } diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch index 994ea79a86..a2a3df0ad0 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldPreset.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldPreset.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldPreset.java -@@ -116,6 +_,9 @@ +@@ -83,6 +_,9 @@ WorldPreset(String p_101519_) { this.f_101516_ = new TranslatableComponent("generator." + p_101519_); } @@ -10,7 +10,7 @@ private static WorldGenSettings m_101549_(RegistryAccess p_101550_, WorldGenSettings p_101551_, WorldPreset p_101552_, Biome p_101553_) { BiomeSource biomesource = new FixedBiomeSource(p_101553_); -@@ -173,4 +_,8 @@ +@@ -125,4 +_,8 @@ public interface PresetEditor { Screen m_101642_(CreateWorldScreen p_101643_, WorldGenSettings p_101644_); } diff --git a/patches/minecraft/net/minecraft/client/main/Main.java.patch b/patches/minecraft/net/minecraft/client/main/Main.java.patch index 743b407619..a937b1fc33 100644 --- a/patches/minecraft/net/minecraft/client/main/Main.java.patch +++ b/patches/minecraft/net/minecraft/client/main/Main.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/client/main/Main.java +++ b/net/minecraft/client/main/Main.java -@@ -122,7 +_,7 @@ - String s7 = m_129638_(optionset, optionspec); - Integer integer = m_129638_(optionset, optionspec1); +@@ -135,7 +_,7 @@ + } + CrashReport.m_127529_(); - Bootstrap.m_135870_(); + net.minecraftforge.fml.loading.BackgroundWaiter.runAndTick(()->Bootstrap.m_135870_(), net.minecraftforge.fml.loading.FMLLoader.progressWindowTick); Bootstrap.m_135889_(); Util.m_137584_(); - User user = new User(optionspec9.value(optionset), s5, optionspec11.value(optionset), optionspec20.value(optionset)); + String s10 = optionspec23.value(optionset); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch index 756950cb01..4872fc1ba3 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/multiplayer/ClientChunkCache.java +++ b/net/minecraft/client/multiplayer/ClientChunkCache.java -@@ -60,6 +_,7 @@ +@@ -59,6 +_,7 @@ int i = this.f_104410_.m_104481_(p_104456_, p_104457_); LevelChunk levelchunk = this.f_104410_.m_104479_(i); if (m_104438_(levelchunk, p_104456_, p_104457_)) { @@ -8,7 +8,7 @@ this.f_104410_.m_104487_(i, levelchunk, (LevelChunk)null); } -@@ -110,6 +_,7 @@ +@@ -99,6 +_,7 @@ } this.f_104411_.m_171649_(chunkpos); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch index f30cef9951..364a395efb 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientHandshakePacketListenerImpl.java.patch @@ -4,15 +4,15 @@ this.f_104521_.accept(new TranslatableComponent("connect.joining")); this.f_104523_ = p_104547_.m_134774_(); this.f_104522_.m_129498_(ConnectionProtocol.PLAY); -+ net.minecraftforge.fmllegacy.network.NetworkHooks.handleClientLoginSuccess(this.f_104522_); - this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_)); ++ net.minecraftforge.network.NetworkHooks.handleClientLoginSuccess(this.f_104522_); + this.f_104522_.m_129505_(new ClientPacketListener(this.f_104519_, this.f_104520_, this.f_104522_, this.f_104523_, this.f_104519_.m_193590_())); } @@ -143,6 +_,7 @@ } public void m_7254_(ClientboundCustomQueryPacket p_104545_) { -+ if (net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_104545_, this.f_104522_)) return; ++ if (net.minecraftforge.network.NetworkHooks.onCustomPayload(p_104545_, this.f_104522_)) return; this.f_104521_.accept(new TranslatableComponent("connect.negotiating")); this.f_104522_.m_129512_(new ServerboundCustomQueryPacket(p_104545_.m_134755_(), (FriendlyByteBuf)null)); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch index af7cf85325..742219869c 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientLevel.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/client/multiplayer/ClientLevel.java +++ b/net/minecraft/client/multiplayer/ClientLevel.java -@@ -112,6 +_,8 @@ - this.m_104752_(new BlockPos(8, 64, 8), 0.0F); +@@ -130,6 +_,8 @@ + this.f_194123_ = p_194134_; this.m_46465_(); this.m_46466_(); + this.gatherCapabilities(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(this)); } - public DimensionSpecialEffects m_104583_() { -@@ -171,6 +_,7 @@ + public void m_194171_(Runnable p_194172_) { +@@ -216,6 +_,7 @@ this.m_46473_().m_6521_(() -> { return Registry.f_122826_.m_7981_(p_104640_.m_6095_()).toString(); }); @@ -17,7 +17,7 @@ p_104640_.m_8119_(); this.m_46473_().m_7238_(); -@@ -233,8 +_,10 @@ +@@ -278,8 +_,10 @@ } private void m_104739_(int p_104740_, Entity p_104741_) { @@ -28,7 +28,7 @@ } public void m_171642_(int p_171643_, Entity.RemovalReason p_171644_) { -@@ -367,6 +_,11 @@ +@@ -410,6 +_,11 @@ } public void m_6263_(@Nullable Player p_104645_, double p_104646_, double p_104647_, double p_104648_, SoundEvent p_104649_, SoundSource p_104650_, float p_104651_, float p_104652_) { @@ -40,7 +40,7 @@ if (p_104645_ == this.f_104565_.f_91074_) { this.m_7785_(p_104646_, p_104647_, p_104648_, p_104649_, p_104650_, p_104651_, p_104652_, false); } -@@ -374,6 +_,11 @@ +@@ -417,6 +_,11 @@ } public void m_6269_(@Nullable Player p_104659_, Entity p_104660_, SoundEvent p_104661_, SoundSource p_104662_, float p_104663_, float p_104664_) { @@ -52,7 +52,7 @@ if (p_104659_ == this.f_104565_.f_91074_) { this.f_104565_.m_91106_().m_120367_(new EntityBoundSoundInstance(p_104661_, p_104662_, p_104663_, p_104664_, p_104660_)); } -@@ -818,6 +_,7 @@ +@@ -879,6 +_,7 @@ } public void m_104851_(Difficulty p_104852_) { @@ -60,7 +60,7 @@ this.f_104840_ = p_104852_; } -@@ -860,6 +_,9 @@ +@@ -921,6 +_,9 @@ public void m_141981_(Entity p_171716_) { p_171716_.m_19877_(); ClientLevel.this.f_104566_.remove(p_171716_); @@ -69,4 +69,4 @@ + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_171716_, ClientLevel.this)); } } - + } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch index 13e289795d..57f44253c8 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ClientPacketListener.java.patch @@ -1,31 +1,22 @@ --- a/net/minecraft/client/multiplayer/ClientPacketListener.java +++ b/net/minecraft/client/multiplayer/ClientPacketListener.java -@@ -360,6 +_,7 @@ +@@ -357,6 +_,7 @@ this.f_104888_.f_91064_.m_113434_(); this.f_104888_.f_91074_.m_172530_(); + net.minecraftforge.client.ForgeHooksClient.firePlayerLogin(this.f_104888_.f_91072_, this.f_104888_.f_91074_, this.f_104888_.m_91403_().m_6198_()); - int i = p_105030_.m_132398_(); + int i = p_105030_.f_132360_(); this.f_104888_.f_91074_.m_20234_(i); this.f_104889_.m_104630_(i, this.f_104888_.f_91074_); -@@ -370,6 +_,7 @@ - this.f_104888_.f_91074_.m_36393_(p_105030_.m_132410_()); - this.f_104888_.f_91074_.m_108711_(p_105030_.m_132411_()); - this.f_104888_.f_91072_.m_171805_(p_105030_.m_132403_(), p_105030_.m_132404_()); -+ net.minecraftforge.fmllegacy.network.NetworkHooks.sendMCRegistryPackets(f_104885_, "PLAY_TO_SERVER"); +@@ -368,6 +_,7 @@ + this.f_104888_.f_91074_.m_108711_(p_105030_.f_132372_()); + this.f_104888_.f_91072_.m_171805_(p_105030_.f_132363_(), p_105030_.f_132364_()); + this.f_104888_.f_91066_.m_193770_(p_105030_.f_132370_()); ++ net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(f_104885_, "PLAY_TO_SERVER"); this.f_104888_.f_91066_.m_92172_(); this.f_104885_.m_129512_(new ServerboundCustomPayloadPacket(ServerboundCustomPayloadPacket.f_133979_, (new FriendlyByteBuf(Unpooled.buffer())).m_130070_(ClientBrandRetriever.m_129629_()))); this.f_104888_.m_91309_().m_90739_(); -@@ -612,7 +_,7 @@ - BlockPos blockpos = new BlockPos(compoundtag.m_128451_("x"), compoundtag.m_128451_("y"), compoundtag.m_128451_("z")); - BlockEntity blockentity = levelchunk.m_5685_(blockpos, LevelChunk.EntityCreationType.IMMEDIATE); - if (blockentity != null) { -- blockentity.m_142466_(compoundtag); -+ blockentity.handleUpdateTag(compoundtag); - } - } - } -@@ -694,7 +_,9 @@ +@@ -715,7 +_,9 @@ public void m_5784_(ClientboundChatPacket p_104986_) { PacketUtils.m_131363_(p_104986_, this, this.f_104888_); @@ -36,7 +27,7 @@ } public void m_7791_(ClientboundAnimatePacket p_104968_) { -@@ -865,8 +_,10 @@ +@@ -886,8 +_,10 @@ localplayer1.m_21204_().m_22159_(localplayer.m_21204_()); } @@ -47,20 +38,19 @@ this.f_104889_.m_104630_(i, localplayer1); localplayer1.m_146922_(-180.0F); localplayer1.f_108618_ = new KeyboardInput(this.f_104888_.f_91066_); -@@ -977,6 +_,12 @@ +@@ -990,10 +_,7 @@ + PacketUtils.m_131363_(p_104976_, this, this.f_104888_); + BlockPos blockpos = p_104976_.m_131704_(); + this.f_104888_.f_91073_.m_141902_(blockpos, p_104976_.m_195645_()).ifPresent((p_194239_) -> { +- CompoundTag compoundtag = p_104976_.m_131708_(); +- if (compoundtag != null) { +- p_194239_.m_142466_(compoundtag); +- } ++ p_194239_.onDataPacket(f_104885_, p_104976_); - if (flag && this.f_104888_.f_91080_ instanceof CommandBlockEditScreen) { - ((CommandBlockEditScreen)this.f_104888_.f_91080_).m_98398_(); -+ } else { -+ if (blockentity == null) { -+ f_104883_.error("Received invalid update packet for null tile entity at {} with data: {}", p_104976_.m_131704_(), p_104976_.m_131708_()); -+ return; -+ } -+ blockentity.onDataPacket(f_104885_, p_104976_); - } - - } -@@ -1139,6 +_,7 @@ + if (p_194239_ instanceof CommandBlockEntity && this.f_104888_.f_91080_ instanceof CommandBlockEditScreen) { + ((CommandBlockEditScreen)this.f_104888_.f_91080_).m_98398_(); +@@ -1160,6 +_,7 @@ clientrecipebook.m_90625_(this.f_104900_.m_44051_()); clientrecipebook.m_90639_().forEach(mutablesearchtree::m_8080_); mutablesearchtree.m_7729_(); @@ -68,7 +58,7 @@ } public void m_7244_(ClientboundPlayerLookAtPacket p_105054_) { -@@ -1216,7 +_,7 @@ +@@ -1237,7 +_,7 @@ PacketUtils.m_131363_(p_105130_, this, this.f_104888_); Entity entity = this.f_104889_.m_6815_(p_105130_.m_133622_()); if (entity instanceof LivingEntity) { @@ -77,7 +67,7 @@ if (mobeffect != null) { MobEffectInstance mobeffectinstance = new MobEffectInstance(mobeffect, p_105130_.m_133625_(), p_105130_.m_133624_(), p_105130_.m_133627_(), p_105130_.m_133626_(), p_105130_.m_133628_()); mobeffectinstance.m_19562_(p_105130_.m_133619_()); -@@ -1233,6 +_,7 @@ +@@ -1254,6 +_,7 @@ f_104883_.warn("Incomplete server tags, disconnecting. Missing: {}", (Object)multimap); this.f_104885_.m_129507_(new TranslatableComponent("multiplayer.disconnect.missing_tags")); } else { @@ -85,12 +75,12 @@ this.f_104895_ = tagcontainer; if (!this.f_104885_.m_129531_()) { tagcontainer.m_13431_(); -@@ -1780,7 +_,8 @@ +@@ -1803,7 +_,8 @@ int i5 = friendlybytebuf.m_130242_(); this.f_104888_.f_91064_.f_173815_.m_173830_(positionsource, i5); } else { - f_104883_.warn("Unknown custom packed identifier: {}", (Object)resourcelocation); -+ if (!net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_105004_, this.f_104885_)) ++ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_105004_, this.f_104885_)) + f_104883_.warn("Unknown custom packet identifier: {}", (Object)resourcelocation); } } finally { diff --git a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch index bbc1893cac..064e54d4da 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/MultiPlayerGameMode.java.patch @@ -15,7 +15,7 @@ - block.m_5707_(level, p_105268_, blockstate, this.f_105189_.f_91074_); FluidState fluidstate = level.m_6425_(p_105268_); - boolean flag = level.m_7731_(p_105268_, fluidstate.m_76188_(), 11); -+ boolean flag = blockstate.removedByPlayer(level, p_105268_, f_105189_.f_91074_, false, fluidstate); ++ boolean flag = blockstate.onDestroyedByPlayer(level, p_105268_, f_105189_.f_91074_, false, fluidstate); if (flag) { block.m_6786_(level, p_105268_, blockstate); } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch index 33581bd2af..c61b6feaa3 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerInfo.java.patch @@ -4,7 +4,7 @@ } protected void m_105317_(GameType p_105318_) { -+ net.minecraftforge.client.ForgeHooksClient.onClientChangeGameMode(this, this.f_105300_, p_105318_); ++ net.minecraftforge.client.ForgeHooksClient.onClientChangeGameType(this, this.f_105300_, p_105318_); this.f_105300_ = p_105318_; } diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch index 6c05cf6f7d..a4803b21bd 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ServerData.java.patch @@ -4,7 +4,7 @@ @Nullable private String f_105372_; private boolean f_105373_; -+ public net.minecraftforge.fmlclient.ExtendedServerListData forgeData = null; ++ public net.minecraftforge.client.ExtendedServerListData forgeData = null; public ServerData(String p_105375_, String p_105376_, boolean p_105377_) { this.f_105362_ = p_105375_; diff --git a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch index 1b6a44e9e3..8366c5331f 100644 --- a/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/ParticleEngine.java.patch @@ -9,7 +9,7 @@ private final Queue f_107294_ = Queues.newArrayDeque(); private final Map f_107295_ = Maps.newHashMap(); private final TextureAtlas f_107296_; -@@ -177,13 +_,13 @@ +@@ -176,13 +_,13 @@ } public void m_107381_(ParticleType p_107382_, ParticleProvider p_107383_) { @@ -25,7 +25,7 @@ } public CompletableFuture m_5540_(PreparableReloadListener.PreparationBarrier p_107305_, ResourceManager p_107306_, ProfilerFiller p_107307_, ProfilerFiller p_107308_, Executor p_107309_, Executor p_107310_) { -@@ -301,7 +_,7 @@ +@@ -300,7 +_,7 @@ @Nullable private Particle m_107395_(T p_107396_, double p_107397_, double p_107398_, double p_107399_, double p_107400_, double p_107401_, double p_107402_) { @@ -34,7 +34,7 @@ return particleprovider == null ? null : particleprovider.m_6966_(p_107396_, this.f_107287_, p_107397_, p_107398_, p_107399_, p_107400_, p_107401_, p_107402_); } -@@ -382,7 +_,13 @@ +@@ -381,7 +_,13 @@ } } @@ -48,7 +48,7 @@ p_107339_.m_109896_(); RenderSystem.m_69482_(); PoseStack posestack = RenderSystem.m_157191_(); -@@ -390,7 +_,8 @@ +@@ -389,7 +_,8 @@ posestack.m_166854_(p_107337_.m_85850_().m_85861_()); RenderSystem.m_157182_(); @@ -58,7 +58,7 @@ Iterable iterable = this.f_107289_.get(particlerendertype); if (iterable != null) { RenderSystem.m_157427_(GameRenderer::m_172829_); -@@ -400,6 +_,7 @@ +@@ -399,6 +_,7 @@ particlerendertype.m_6505_(bufferbuilder, this.f_107291_); for(Particle particle : iterable) { @@ -66,7 +66,7 @@ try { particle.m_5744_(bufferbuilder, p_107340_, p_107341_); } catch (Throwable throwable) { -@@ -430,7 +_,7 @@ +@@ -429,7 +_,7 @@ } public void m_107355_(BlockPos p_107356_, BlockState p_107357_) { @@ -75,7 +75,7 @@ VoxelShape voxelshape = p_107357_.m_60808_(this.f_107287_, p_107356_); double d0 = 0.25D; voxelshape.m_83286_((p_172273_, p_172274_, p_172275_, p_172276_, p_172277_, p_172278_) -> { -@@ -450,7 +_,7 @@ +@@ -449,7 +_,7 @@ double d7 = d4 * d1 + p_172273_; double d8 = d5 * d2 + p_172274_; double d9 = d6 * d3 + p_172275_; @@ -84,7 +84,7 @@ } } } -@@ -494,12 +_,18 @@ +@@ -493,12 +_,18 @@ d0 = (double)i + aabb.f_82291_ + (double)0.1F; } diff --git a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch index 06dcfcda83..7d52bf2144 100644 --- a/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/AbstractClientPlayer.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/client/player/AbstractClientPlayer.java +++ b/net/minecraft/client/player/AbstractClientPlayer.java -@@ -143,6 +_,6 @@ +@@ -144,6 +_,6 @@ } } - return Mth.m_14179_(Minecraft.m_91087_().f_91066_.f_92070_, 1.0F, f); -+ return net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(this, f); ++ return net.minecraftforge.client.ForgeHooksClient.getFieldOfView(this, f); } } diff --git a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch index 9338388f52..cfd6f753f0 100644 --- a/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/player/LocalPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/player/LocalPlayer.java +++ b/net/minecraft/client/player/LocalPlayer.java -@@ -139,6 +_,7 @@ +@@ -144,6 +_,7 @@ } public boolean m_6469_(DamageSource p_108662_, float p_108663_) { @@ -8,7 +8,7 @@ return false; } -@@ -462,6 +_,11 @@ +@@ -466,6 +_,11 @@ } public void m_5496_(SoundEvent p_108651_, float p_108652_, float p_108653_) { @@ -20,15 +20,15 @@ this.f_19853_.m_7785_(this.m_20185_(), this.m_20186_(), this.m_20189_(), p_108651_, this.m_5720_(), p_108652_, p_108653_, false); } -@@ -617,6 +_,7 @@ +@@ -621,6 +_,7 @@ boolean flag2 = this.m_108733_(); this.f_108601_ = !this.m_150110_().f_35935_ && !this.m_6069_() && this.m_20175_(Pose.CROUCHING) && (this.m_6144_() || !this.m_5803_() && !this.m_20175_(Pose.STANDING)); this.f_108618_.m_7606_(this.m_108635_()); -+ net.minecraftforge.client.ForgeHooksClient.onInputUpdate(this, this.f_108618_); ++ net.minecraftforge.client.ForgeHooksClient.onMovementInputUpdate(this, this.f_108618_); this.f_108619_.m_91301_().m_120586_(this.f_108618_); if (this.m_6117_() && !this.m_20159_()) { this.f_108618_.f_108566_ *= 0.2F; -@@ -689,7 +_,7 @@ +@@ -693,7 +_,7 @@ if (this.f_108618_.f_108572_ && !flag7 && !flag && !this.m_150110_().f_35935_ && !this.m_20159_() && !this.m_6147_()) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -37,7 +37,7 @@ this.f_108617_.m_104955_(new ServerboundPlayerCommandPacket(this, ServerboundPlayerCommandPacket.Action.START_FALL_FLYING)); } } -@@ -807,6 +_,7 @@ +@@ -811,6 +_,7 @@ public void m_6083_() { super.m_6083_(); @@ -45,7 +45,7 @@ this.f_108611_ = false; if (this.m_20202_() instanceof Boat) { Boat boat = (Boat)this.m_20202_(); -@@ -1004,6 +_,18 @@ +@@ -1024,6 +_,18 @@ } else { return super.m_7398_(p_108758_); } diff --git a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch index b4b34864f8..3c29559cd6 100644 --- a/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/GameRenderer.java.patch @@ -22,7 +22,7 @@ } - return d0; -+ return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(this, p_109142_, p_109143_, d0); ++ return net.minecraftforge.client.ForgeHooksClient.getFieldOfView(this, p_109142_, p_109143_, d0); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch index 36e98ecc80..7856b9b5a4 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemModelShaper.java.patch @@ -1,12 +1,10 @@ --- a/net/minecraft/client/renderer/ItemModelShaper.java +++ b/net/minecraft/client/renderer/ItemModelShaper.java -@@ -31,7 +_,8 @@ - - public TextureAtlasSprite m_109399_(ItemStack p_109400_) { - BakedModel bakedmodel = this.m_109406_(p_109400_); -- return bakedmodel == this.f_109390_.m_119409_() && p_109400_.m_41720_() instanceof BlockItem ? this.f_109390_.m_119430_().m_110882_(((BlockItem)p_109400_.m_41720_()).m_40614_().m_49966_()) : bakedmodel.m_6160_(); -+ // FORGE: Make sure to call the item overrides -+ return bakedmodel == this.f_109390_.m_119409_() && p_109400_.m_41720_() instanceof BlockItem ? this.f_109390_.m_119430_().m_110882_(((BlockItem)p_109400_.m_41720_()).m_40614_().m_49966_()) : bakedmodel.m_7343_().m_173464_(bakedmodel, p_109400_, null, null, 0).getParticleIcon(net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); - } +@@ -24,6 +_,7 @@ public BakedModel m_109406_(ItemStack p_109407_) { + BakedModel bakedmodel = this.m_109394_(p_109407_.m_41720_()); ++ // FORGE: Make sure to call the item overrides + return bakedmodel == null ? this.f_109390_.m_119409_() : bakedmodel; + } + diff --git a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch index c6bbbc2a7f..6a70fb89fe 100644 --- a/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/LevelRenderer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/LevelRenderer.java +++ b/net/minecraft/client/renderer/LevelRenderer.java -@@ -241,6 +_,11 @@ +@@ -257,6 +_,11 @@ } private void m_109703_(LightTexture p_109704_, float p_109705_, double p_109706_, double p_109707_, double p_109708_) { @@ -12,7 +12,7 @@ float f = this.f_109461_.f_91073_.m_46722_(p_109705_); if (!(f <= 0.0F)) { p_109704_.m_109896_(); -@@ -362,6 +_,11 @@ +@@ -377,6 +_,11 @@ } public void m_109693_(Camera p_109694_) { @@ -24,33 +24,23 @@ float f = this.f_109461_.f_91073_.m_46722_(1.0F) / (Minecraft.m_91405_() ? 1.0F : 2.0F); if (!(f <= 0.0F)) { Random random = new Random((long)this.f_109477_ * 312987231L); -@@ -804,7 +_,7 @@ - this.f_109448_ = true; - BlockPos blockpos2 = chunkrenderdispatcher$renderchunk1.m_112839_().m_142082_(8, 8, 8); - boolean flag = blockpos2.m_123331_(blockpos) < 768.0D; -- if (!chunkrenderdispatcher$renderchunk1.m_112842_() && !flag) { -+ if (net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() || !chunkrenderdispatcher$renderchunk1.m_112842_() && !flag) { - this.f_109466_.add(chunkrenderdispatcher$renderchunk1); - } else { - this.f_109461_.m_91307_().m_6180_("build near"); -@@ -980,13 +_,14 @@ +@@ -1148,20 +_,23 @@ RenderSystem.m_69421_(16640, Minecraft.f_91002_); float f = p_109605_.m_109152_(); - boolean flag1 = this.f_109461_.f_91073_.m_104583_().m_5781_(Mth.m_14107_(d0), Mth.m_14107_(d1)) || this.f_109461_.f_91065_.m_93090_().m_93715_(); + boolean flag2 = this.f_109461_.f_91073_.m_104583_().m_5781_(Mth.m_14107_(d0), Mth.m_14107_(d1)) || this.f_109461_.f_91065_.m_93090_().m_93715_(); + FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag1, p_109601_); profilerfiller.m_6182_("sky"); RenderSystem.m_157427_(GameRenderer::m_172808_); this.m_181409_(p_109600_, p_109607_, p_109601_, () -> { - FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag1); + FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_SKY, f, flag2); }); profilerfiller.m_6182_("fog"); -- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag1); +- FogRenderer.m_109024_(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag2); + FogRenderer.setupFog(p_109604_, FogRenderer.FogMode.FOG_TERRAIN, Math.max(f - 16.0F, 32.0F), flag1, p_109601_); profilerfiller.m_6182_("terrain_setup"); - this.m_109695_(p_109604_, frustum, flag, this.f_109449_++, this.f_109461_.f_91074_.m_5833_()); - profilerfiller.m_6182_("updatechunks"); -@@ -1007,7 +_,9 @@ - this.m_109510_(p_109602_ + l1); + this.m_194338_(p_109604_, frustum, flag1, this.f_109461_.f_91074_.m_5833_()); + profilerfiller.m_6182_("compilechunks"); + this.m_194370_(p_109604_); profilerfiller.m_6182_("terrain"); this.m_172993_(RenderType.m_110451_(), p_109600_, d0, d1, d2, p_109607_); + this.f_109461_.m_91304_().m_119428_(TextureAtlas.f_118259_).setBlurMipmap(false, this.f_109461_.f_91066_.f_92027_ > 0); // FORGE: fix flickering leaves when mods mess up the blurMipmap settings @@ -59,7 +49,7 @@ this.m_172993_(RenderType.m_110463_(), p_109600_, d0, d1, d2, p_109607_); if (this.f_109465_.m_104583_().m_108885_()) { Lighting.m_84925_(p_109600_.m_85850_().m_85861_()); -@@ -1037,7 +_,7 @@ +@@ -1191,7 +_,7 @@ MultiBufferSource.BufferSource multibuffersource$buffersource = this.f_109464_.m_110104_(); for(Entity entity : this.f_109465_.m_104735_()) { @@ -68,7 +58,7 @@ ++this.f_109439_; if (entity.f_19797_ == 0) { entity.f_19790_ = entity.m_20185_(); -@@ -1076,6 +_,7 @@ +@@ -1230,6 +_,7 @@ List list = levelrenderer$renderchunkinfo.f_109839_.m_112835_().m_112773_(); if (!list.isEmpty()) { for(BlockEntity blockentity1 : list) { @@ -76,7 +66,7 @@ BlockPos blockpos3 = blockentity1.m_58899_(); MultiBufferSource multibuffersource1 = multibuffersource$buffersource; p_109600_.m_85836_(); -@@ -1101,6 +_,7 @@ +@@ -1255,6 +_,7 @@ synchronized(this.f_109468_) { for(BlockEntity blockentity : this.f_109468_) { @@ -84,21 +74,21 @@ BlockPos blockpos2 = blockentity.m_58899_(); p_109600_.m_85836_(); p_109600_.m_85837_((double)blockpos2.m_123341_() - d0, (double)blockpos2.m_123342_() - d1, (double)blockpos2.m_123343_() - d2); -@@ -1152,10 +_,13 @@ +@@ -1306,10 +_,13 @@ profilerfiller.m_6182_("outline"); BlockPos blockpos = ((BlockHitResult)hitresult).m_82425_(); BlockState blockstate = this.f_109465_.m_8055_(blockpos); -+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource)) ++ if (!net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource)) if (!blockstate.m_60795_() && this.f_109465_.m_6857_().m_61937_(blockpos)) { VertexConsumer vertexconsumer2 = multibuffersource$buffersource.m_6299_(RenderType.m_110504_()); this.m_109637_(p_109600_, vertexconsumer2, p_109604_.m_90592_(), d0, d1, d2, blockpos, blockstate); } + } else if (hitresult != null && hitresult.m_6662_() == HitResult.Type.ENTITY) { -+ net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource); ++ net.minecraftforge.client.ForgeHooksClient.onDrawHighlight(this, p_109604_, hitresult, p_109601_, p_109600_, multibuffersource$buffersource); } PoseStack posestack = RenderSystem.m_157191_(); -@@ -1190,7 +_,7 @@ +@@ -1344,7 +_,7 @@ this.f_109415_.m_83945_(this.f_109461_.m_91385_()); RenderStateShard.f_110126_.m_110185_(); profilerfiller.m_6182_("particles"); @@ -107,7 +97,7 @@ RenderStateShard.f_110126_.m_110188_(); } else { profilerfiller.m_6182_("translucent"); -@@ -1204,7 +_,7 @@ +@@ -1358,7 +_,7 @@ profilerfiller.m_6182_("string"); this.m_172993_(RenderType.m_110503_(), p_109600_, d0, d1, d2, p_109607_); profilerfiller.m_6182_("particles"); @@ -116,7 +106,7 @@ } posestack.m_85836_(); -@@ -1632,6 +_,11 @@ +@@ -1790,6 +_,11 @@ public void m_181409_(PoseStack p_181410_, Matrix4f p_181411_, float p_181412_, Runnable p_181413_) { p_181413_.run(); @@ -128,7 +118,7 @@ if (this.f_109461_.f_91073_.m_104583_().m_108883_() == DimensionSpecialEffects.SkyType.END) { this.m_109780_(p_181410_); } else if (this.f_109461_.f_91073_.m_104583_().m_108883_() == DimensionSpecialEffects.SkyType.NORMAL) { -@@ -1746,6 +_,11 @@ +@@ -1904,6 +_,11 @@ } public void m_172954_(PoseStack p_172955_, Matrix4f p_172956_, float p_172957_, double p_172958_, double p_172959_, double p_172960_) { @@ -140,16 +130,16 @@ float f = this.f_109465_.m_104583_().m_108871_(); if (!Float.isNaN(f)) { RenderSystem.m_69464_(); -@@ -1923,7 +_,7 @@ - - while(iterator.hasNext()) { - ChunkRenderDispatcher.RenderChunk chunkrenderdispatcher$renderchunk = iterator.next(); -- if (chunkrenderdispatcher$renderchunk.m_112842_()) { -+ if (!net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && chunkrenderdispatcher$renderchunk.m_112842_()) { - this.f_109436_.m_112715_(chunkrenderdispatcher$renderchunk); +@@ -2089,7 +_,7 @@ + } } else { - chunkrenderdispatcher$renderchunk.m_112820_(this.f_109436_); -@@ -2216,7 +_,12 @@ + BlockPos blockpos1 = chunkrenderdispatcher$renderchunk.m_112839_().m_142082_(8, 8, 8); +- flag = blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_(); ++ flag = !net.minecraftforge.common.ForgeConfig.CLIENT.alwaysSetupTerrainOffThread.get() && (blockpos1.m_123331_(blockpos) < 768.0D || chunkrenderdispatcher$renderchunk.m_112842_()); // the target is the else block below, so invert the forge addition to get there early + } + + if (flag) { +@@ -2387,7 +_,12 @@ this.f_109469_.m_110859_(p_109502_, p_109503_, p_109504_, p_109505_); } @@ -162,7 +152,7 @@ SoundInstance soundinstance = this.f_109410_.get(p_109516_); if (soundinstance != null) { this.f_109461_.m_91106_().m_120399_(soundinstance); -@@ -2224,7 +_,7 @@ +@@ -2395,7 +_,7 @@ } if (p_109515_ != null) { @@ -171,7 +161,7 @@ if (recorditem != null) { this.f_109461_.f_91065_.m_93055_(recorditem.m_43050_()); } -@@ -2376,7 +_,7 @@ +@@ -2547,7 +_,7 @@ break; case 1010: if (Item.m_41445_(p_109536_) instanceof RecordItem) { @@ -180,7 +170,7 @@ } else { this.m_109514_((SoundEvent)null, p_109535_); } -@@ -2546,7 +_,7 @@ +@@ -2717,7 +_,7 @@ case 2001: BlockState blockstate = Block.m_49803_(p_109536_); if (!blockstate.m_60795_()) { @@ -189,7 +179,7 @@ this.f_109465_.m_104677_(p_109535_, soundtype.m_56775_(), SoundSource.BLOCKS, (soundtype.m_56773_() + 1.0F) / 2.0F, soundtype.m_56774_() * 0.8F, false); } -@@ -2711,7 +_,7 @@ +@@ -2882,7 +_,7 @@ } else { int i = p_109538_.m_45517_(LightLayer.SKY, p_109540_); int j = p_109538_.m_45517_(LightLayer.BLOCK, p_109540_); diff --git a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch index 10e2f37d15..4117e205ca 100644 --- a/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/PostChain.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/PostChain.java +++ b/net/minecraft/client/renderer/PostChain.java -@@ -168,7 +_,8 @@ +@@ -169,7 +_,8 @@ throw new ChainedJsonException("Render target '" + s4 + "' can't be used as depth buffer"); } @@ -10,7 +10,7 @@ Resource resource = null; try { -@@ -278,6 +_,7 @@ +@@ -279,6 +_,7 @@ public void m_110038_(String p_110039_, int p_110040_, int p_110041_) { RenderTarget rendertarget = new TextureTarget(p_110040_, p_110041_, true, Minecraft.f_91002_); rendertarget.m_83931_(0.0F, 0.0F, 0.0F, 0.0F); diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch index a6e93c9738..16fa9f96fc 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch @@ -1,32 +1,23 @@ --- a/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java +++ b/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java -@@ -70,12 +_,15 @@ +@@ -72,12 +_,15 @@ private Vec3 f_112683_ = Vec3.f_82478_; - public ChunkRenderDispatcher(Level p_112686_, LevelRenderer p_112687_, Executor p_112688_, boolean p_112689_, ChunkBufferBuilderPack p_112690_) { -+ this(p_112686_, p_112687_, p_112688_, p_112689_, p_112690_, -1); + public ChunkRenderDispatcher(ClientLevel p_194405_, LevelRenderer p_194406_, Executor p_194407_, boolean p_194408_, ChunkBufferBuilderPack p_194409_) { ++ this(p_194405_, p_194406_, p_194407_, p_194408_, p_194409_, -1); + } -+ public ChunkRenderDispatcher(Level p_112686_, LevelRenderer p_112687_, Executor p_112688_, boolean p_112689_, ChunkBufferBuilderPack p_112690_, int countRenderBuilders) { - this.f_112681_ = p_112686_; - this.f_112682_ = p_112687_; ++ public ChunkRenderDispatcher(ClientLevel p_194405_, LevelRenderer p_194406_, Executor p_194407_, boolean p_194408_, ChunkBufferBuilderPack p_194409_, int countRenderBuilders) { + this.f_112681_ = p_194405_; + this.f_112682_ = p_194406_; int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / (RenderType.m_110506_().stream().mapToInt(RenderType::m_110507_).sum() * 4) - 1); int j = Runtime.getRuntime().availableProcessors(); - int k = p_112689_ ? j : Math.min(j, 4); + int k = p_194408_ ? j : Math.min(j, 4); - int l = Math.max(1, Math.min(k, i)); + int l = countRenderBuilders < 0 ? Math.max(1, Math.min(k, i)) : countRenderBuilders; - this.f_112678_ = p_112690_; + this.f_112678_ = p_194409_; List list = Lists.newArrayListWithExpectedSize(l); -@@ -258,7 +_,7 @@ - } - - @OnlyIn(Dist.CLIENT) -- public class RenderChunk { -+ public class RenderChunk implements net.minecraftforge.client.extensions.IForgeRenderChunk { - public static final int f_173716_ = 16; - public final int f_173717_; - public final AtomicReference f_112784_ = new AtomicReference<>(ChunkRenderDispatcher.CompiledChunk.f_112748_); -@@ -390,7 +_,7 @@ +@@ -415,7 +_,7 @@ if (!chunkrenderdispatcher$compiledchunk.f_112750_.contains(p_112810_)) { return false; } else { @@ -35,29 +26,28 @@ p_112811_.m_112709_(this.f_112788_); return true; } -@@ -413,8 +_,8 @@ - this.m_112843_(); +@@ -443,7 +_,7 @@ BlockPos blockpos = this.f_112793_.m_7949_(); int i = 1; -- RenderChunkRegion renderchunkregion = RenderChunkRegion.m_112920_(ChunkRenderDispatcher.this.f_112681_, blockpos.m_142082_(-1, -1, -1), blockpos.m_142082_(16, 16, 16), 1); -- this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(this.m_112832_(), renderchunkregion); -+ RenderChunkRegion renderchunkregion = createRegionRenderCache(ChunkRenderDispatcher.this.f_112681_, blockpos.m_142082_(-1, -1, -1), blockpos.m_142082_(16, 16, 16), 1); -+ this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), renderchunkregion); + RenderChunkRegion renderchunkregion = p_200438_.m_200465_(ChunkRenderDispatcher.this.f_112681_, blockpos.m_142082_(-1, -1, -1), blockpos.m_142082_(16, 16, 16), 1); +- this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(this.m_112832_(), renderchunkregion, flag || this.f_112784_.get() != ChunkRenderDispatcher.CompiledChunk.f_112748_); ++ this.f_112787_ = new ChunkRenderDispatcher.RenderChunk.RebuildTask(new net.minecraft.world.level.ChunkPos(m_112839_()), this.m_112832_(), renderchunkregion, flag || this.f_112784_.get() != ChunkRenderDispatcher.CompiledChunk.f_112748_); return this.f_112787_; } -@@ -442,9 +_,19 @@ - abstract class ChunkCompileTask implements Comparable { +@@ -476,10 +_,20 @@ protected final double f_112847_; protected final AtomicBoolean f_112848_ = new AtomicBoolean(false); + protected final boolean f_194420_; + protected java.util.Map modelData; - public ChunkCompileTask(double p_112852_) { -+ this(null, p_112852_); + public ChunkCompileTask(double p_194423_, boolean p_194424_) { ++ this(null, p_194423_, p_194424_); + } + -+ public ChunkCompileTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112852_) { - this.f_112847_ = p_112852_; ++ public ChunkCompileTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_194423_, boolean p_194424_) { + this.f_112847_ = p_194423_; + this.f_194420_ = p_194424_; + if (pos == null) { + this.modelData = java.util.Collections.emptyMap(); + } else { @@ -66,7 +56,7 @@ } public abstract CompletableFuture m_5869_(ChunkBufferBuilderPack p_112853_); -@@ -454,6 +_,10 @@ +@@ -491,6 +_,10 @@ public int compareTo(ChunkRenderDispatcher.RenderChunk.ChunkCompileTask p_112855_) { return Doubles.compare(this.f_112847_, p_112855_.f_112847_); } @@ -77,22 +67,22 @@ } @OnlyIn(Dist.CLIENT) -@@ -461,8 +_,13 @@ +@@ -498,8 +_,13 @@ @Nullable protected RenderChunkRegion f_112858_; + @Deprecated - public RebuildTask(@Nullable double p_112862_, RenderChunkRegion p_112863_) { -- super(p_112862_); -+ this(null, p_112862_, p_112863_); + public RebuildTask(@Nullable double p_194427_, RenderChunkRegion p_194428_, boolean p_194429_) { +- super(p_194427_, p_194429_); ++ this(null, p_194427_, p_194428_, p_194429_); + } + -+ public RebuildTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112862_, @Nullable RenderChunkRegion p_112863_) { -+ super(pos, p_112862_); - this.f_112858_ = p_112863_; ++ public RebuildTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_194427_, @Nullable RenderChunkRegion p_194428_, boolean p_194429_) { ++ super(pos, p_194427_, p_194429_); + this.f_112858_ = p_194428_; } -@@ -535,8 +_,10 @@ +@@ -580,8 +_,10 @@ } FluidState fluidstate = renderchunkregion.m_6425_(blockpos2); @@ -100,12 +90,12 @@ - RenderType rendertype = ItemBlockRenderTypes.m_109287_(fluidstate); + net.minecraftforge.client.model.data.IModelData modelData = getModelData(blockpos2); + for (RenderType rendertype : RenderType.m_110506_()) { -+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(rendertype); ++ net.minecraftforge.client.ForgeHooksClient.setRenderType(rendertype); + if (!fluidstate.m_76178_() && ItemBlockRenderTypes.canRenderInLayer(fluidstate, rendertype)) { BufferBuilder bufferbuilder = p_112870_.m_108839_(rendertype); if (p_112869_.f_112750_.add(rendertype)) { RenderChunk.this.m_112805_(bufferbuilder); -@@ -548,8 +_,8 @@ +@@ -593,8 +_,8 @@ } } @@ -116,7 +106,7 @@ BufferBuilder bufferbuilder2 = p_112870_.m_108839_(rendertype1); if (p_112869_.f_112750_.add(rendertype1)) { RenderChunk.this.m_112805_(bufferbuilder2); -@@ -557,14 +_,16 @@ +@@ -602,14 +_,16 @@ posestack.m_85836_(); posestack.m_85837_((double)(blockpos2.m_123341_() & 15), (double)(blockpos2.m_123342_() & 15), (double)(blockpos2.m_123343_() & 15)); @@ -130,11 +120,11 @@ } + } } -+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); ++ net.minecraftforge.client.ForgeHooksClient.setRenderType(null); if (p_112869_.f_112749_.contains(RenderType.m_110466_())) { BufferBuilder bufferbuilder1 = p_112870_.m_108839_(RenderType.m_110466_()); -@@ -583,10 +_,10 @@ +@@ -628,10 +_,10 @@ private void m_112877_(ChunkRenderDispatcher.CompiledChunk p_112878_, Set p_112879_, E p_112880_) { BlockEntityRenderer blockentityrenderer = Minecraft.m_91087_().m_167982_().m_112265_(p_112880_); if (blockentityrenderer != null) { @@ -146,18 +136,18 @@ } } -@@ -604,8 +_,13 @@ +@@ -649,8 +_,13 @@ class ResortTransparencyTask extends ChunkRenderDispatcher.RenderChunk.ChunkCompileTask { private final ChunkRenderDispatcher.CompiledChunk f_112886_; + @Deprecated public ResortTransparencyTask(double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { -- super(p_112889_); +- super(p_112889_, true); + this(null, p_112889_, p_112890_); + } + + public ResortTransparencyTask(@Nullable net.minecraft.world.level.ChunkPos pos, double p_112889_, ChunkRenderDispatcher.CompiledChunk p_112890_) { -+ super(pos, p_112889_); ++ super(pos, p_112889_, true); this.f_112886_ = p_112890_; } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch index 57698c4f67..9e90b95e85 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/FallingBlockRenderer.java.patch @@ -7,11 +7,11 @@ - blockrenderdispatcher.m_110937_().m_111047_(level, blockrenderdispatcher.m_110910_(blockstate), blockstate, blockpos, p_114637_, p_114638_.m_6299_(ItemBlockRenderTypes.m_109293_(blockstate)), false, new Random(), blockstate.m_60726_(p_114634_.m_31978_()), OverlayTexture.f_118083_); + for (net.minecraft.client.renderer.RenderType type : net.minecraft.client.renderer.RenderType.m_110506_()) { + if (ItemBlockRenderTypes.canRenderInLayer(blockstate, type)) { -+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(type); ++ net.minecraftforge.client.ForgeHooksClient.setRenderType(type); + blockrenderdispatcher.m_110937_().m_111047_(level, blockrenderdispatcher.m_110910_(blockstate), blockstate, blockpos, p_114637_, p_114638_.m_6299_(type), false, new Random(), blockstate.m_60726_(p_114634_.m_31978_()), OverlayTexture.f_118083_); + } + } -+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); ++ net.minecraftforge.client.ForgeHooksClient.setRenderType(null); p_114637_.m_85849_(); super.m_7392_(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_); } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch index fcdb1caa0a..e4acb6ae63 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/LivingEntityRenderer.java.patch @@ -20,7 +20,7 @@ LivingEntity livingentity = (LivingEntity)p_115308_.m_20202_(); f = Mth.m_14189_(p_115310_, livingentity.f_20884_, livingentity.f_20883_); f2 = f1 - f; -@@ -93,7 +_,7 @@ +@@ -98,7 +_,7 @@ p_115311_.m_85837_(0.0D, (double)-1.501F, 0.0D); float f8 = 0.0F; float f5 = 0.0F; @@ -29,7 +29,7 @@ f8 = Mth.m_14179_(p_115310_, p_115308_.f_20923_, p_115308_.f_20924_); f5 = p_115308_.f_20925_ - p_115308_.f_20924_ * (1.0F - p_115310_); if (p_115308_.m_6162_()) { -@@ -126,6 +_,7 @@ +@@ -131,6 +_,7 @@ p_115311_.m_85849_(); super.m_7392_(p_115308_, p_115309_, p_115310_, p_115311_, p_115312_, p_115313_); diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch index 66389edcd7..8f67c13fae 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/AbstractTexture.java.patch @@ -19,5 +19,5 @@ + } + public int m_117963_() { - RenderSystem.m_69393_(RenderSystem::m_69587_); + RenderSystem.m_187555_(); if (this.f_117950_ == -1) { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch index 1947ab1ae2..1ccc48f31c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlas.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlas.java +++ b/net/minecraft/client/renderer/texture/TextureAtlas.java -@@ -83,6 +_,7 @@ +@@ -85,6 +_,7 @@ } } @@ -8,7 +8,7 @@ } public TextureAtlas.Preparations m_118307_(ResourceManager p_118308_, Stream p_118309_, ProfilerFiller p_118310_, int p_118311_) { -@@ -97,6 +_,7 @@ +@@ -99,6 +_,7 @@ int j = Integer.MAX_VALUE; int k = 1 << p_118311_; p_118310_.m_6182_("extracting_frames"); @@ -16,7 +16,7 @@ for(TextureAtlasSprite.Info textureatlassprite$info : this.m_118304_(p_118308_, set)) { j = Math.min(j, Math.min(textureatlassprite$info.m_118434_(), textureatlassprite$info.m_118437_())); -@@ -111,7 +_,8 @@ +@@ -113,7 +_,8 @@ int i1 = Math.min(j, k); int j1 = Mth.m_14173_(i1); @@ -26,7 +26,7 @@ if (j1 < p_118311_) { f_118261_.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.f_118265_, p_118311_, j1, i1); k1 = j1; -@@ -227,6 +_,8 @@ +@@ -229,6 +_,8 @@ TextureAtlasSprite textureatlassprite; try { NativeImage nativeimage = NativeImage.m_85058_(resource.m_6679_()); diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index 91beaf4752..d648a4922d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ b/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -24,7 +_,7 @@ - import org.apache.logging.log4j.Logger; - - @OnlyIn(Dist.CLIENT) --public class TextureAtlasSprite implements AutoCloseable { -+public class TextureAtlasSprite implements AutoCloseable, net.minecraftforge.client.extensions.IForgeTextureAtlasSprite { - private static final Logger f_174721_ = LogManager.getLogger(); - private final TextureAtlas f_118343_; - private final ResourceLocation f_174722_; @@ -145,6 +_,7 @@ void m_118375_(int p_118376_, int p_118377_, NativeImage[] p_118378_) { diff --git a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch index ab211c7e1f..a9dc237579 100644 --- a/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/language/I18n.java.patch @@ -4,7 +4,7 @@ static void m_118941_(Language p_118942_) { f_118934_ = p_118942_; -+ net.minecraftforge.fmllegacy.ForgeI18n.loadLanguageData(p_118942_.getLanguageData()); ++ net.minecraftforge.common.ForgeI18n.loadLanguageData(p_118942_.getLanguageData()); } public static String m_118938_(String p_118939_, Object... p_118940_) { diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch index 8c199591fc..a934ddc7b2 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/resources/model/ModelBakery.java +++ b/net/minecraft/client/resources/model/ModelBakery.java -@@ -156,8 +_,17 @@ +@@ -155,8 +_,17 @@ }); public ModelBakery(ResourceManager p_119247_, BlockColors p_119248_, ProfilerFiller p_119249_, int p_119250_) { @@ -18,7 +18,7 @@ p_119249_.m_6180_("missing_model"); try { -@@ -191,12 +_,16 @@ +@@ -190,12 +_,16 @@ p_119249_.m_6182_("special"); this.m_119306_(new ModelResourceLocation("minecraft:trident_in_hand#inventory")); this.m_119306_(new ModelResourceLocation("minecraft:spyglass_in_hand#inventory")); @@ -35,7 +35,7 @@ set.stream().filter((p_119357_) -> { return !p_119357_.getSecond().equals(f_119236_); }).forEach((p_119292_) -> { -@@ -235,6 +_,7 @@ +@@ -234,6 +_,7 @@ try { bakedmodel = this.m_119349_(p_119369_, BlockModelRotation.X0_Y0); } catch (Exception exception) { @@ -43,7 +43,7 @@ f_119235_.warn("Unable to bake model: '{}': {}", p_119369_, exception); } -@@ -474,6 +_,13 @@ +@@ -473,6 +_,13 @@ this.f_119210_.addAll(p_119354_.m_7970_()); } @@ -57,7 +57,7 @@ private void m_119306_(ModelResourceLocation p_119307_) { UnbakedModel unbakedmodel = this.m_119341_(p_119307_); this.f_119212_.put(p_119307_, unbakedmodel); -@@ -488,7 +_,13 @@ +@@ -487,7 +_,13 @@ } @Nullable @@ -71,7 +71,7 @@ Triple triple = Triple.of(p_119350_, p_119351_.m_6189_(), p_119351_.m_7538_()); if (this.f_119213_.containsKey(triple)) { return this.f_119213_.get(triple); -@@ -499,11 +_,11 @@ +@@ -498,11 +_,11 @@ if (unbakedmodel instanceof BlockModel) { BlockModel blockmodel = (BlockModel)unbakedmodel; if (blockmodel.m_111490_() == f_119232_) { @@ -85,7 +85,7 @@ this.f_119213_.put(triple, bakedmodel); return bakedmodel; } -@@ -556,11 +_,19 @@ +@@ -555,11 +_,19 @@ return this.f_119218_; } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch index e397af71df..a20d434860 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch @@ -25,7 +25,7 @@ protected ModelBakery m_5944_(ResourceManager p_119413_, ProfilerFiller p_119414_) { p_119414_.m_7242_(); - ModelBakery modelbakery = new ModelBakery(p_119413_, this.f_119401_, p_119414_, this.f_119402_); -+ net.minecraftforge.client.model.ModelLoader modelbakery = new net.minecraftforge.client.model.ModelLoader(p_119413_, this.f_119401_, p_119414_, this.f_119402_); ++ net.minecraftforge.client.model.ForgeModelBakery modelbakery = new net.minecraftforge.client.model.ForgeModelBakery(p_119413_, this.f_119401_, p_119414_, this.f_119402_); p_119414_.m_7241_(); return modelbakery; } @@ -33,7 +33,7 @@ this.f_119397_ = p_119419_.m_119251_(); this.f_119404_ = p_119419_.m_119355_(); this.f_119403_ = this.f_119397_.get(ModelBakery.f_119230_); -+ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.f_119397_, (net.minecraftforge.client.model.ModelLoader) p_119419_); ++ net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.f_119397_, (net.minecraftforge.client.model.ForgeModelBakery) p_119419_); p_119421_.m_6182_("cache"); this.f_119399_.m_110892_(); p_119421_.m_7238_(); diff --git a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch index 8c418e8104..b15a259510 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/MultiPartBakedModel.java.patch @@ -45,8 +45,8 @@ return this.f_119453_; } -+ public boolean isAmbientOcclusion(BlockState state) { -+ return this.defaultModel.isAmbientOcclusion(state); ++ public boolean useAmbientOcclusion(BlockState state) { ++ return this.defaultModel.useAmbientOcclusion(state); + } + public boolean m_7539_() { diff --git a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch deleted file mode 100644 index dd44a1f937..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/UnbakedModel.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/client/resources/model/UnbakedModel.java -+++ b/net/minecraft/client/resources/model/UnbakedModel.java -@@ -11,7 +_,7 @@ - import net.minecraftforge.api.distmarker.OnlyIn; - - @OnlyIn(Dist.CLIENT) --public interface UnbakedModel { -+public interface UnbakedModel extends net.minecraftforge.client.extensions.IForgeUnbakedModel { - Collection m_7970_(); - - Collection m_5500_(Function p_119538_, Set> p_119539_); diff --git a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch index 8ca8326696..f17f0e678c 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/model/WeightedBakedModel.java.patch @@ -29,8 +29,8 @@ } + @Override -+ public boolean isAmbientOcclusion(BlockState state) { -+ return this.f_119542_.isAmbientOcclusion(state); ++ public boolean useAmbientOcclusion(BlockState state) { ++ return this.f_119542_.useAmbientOcclusion(state); + } + public boolean m_7539_() { diff --git a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch index e4b13b0ff1..a4e07ced49 100644 --- a/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/client/server/IntegratedServer.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/client/server/IntegratedServer.java +++ b/net/minecraft/client/server/IntegratedServer.java -@@ -61,9 +_,10 @@ +@@ -62,9 +_,10 @@ this.m_129997_(true); this.m_129999_(true); this.m_129793_(); -+ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; ++ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; this.m_130006_(); this.m_129989_(this.m_129791_() + " - " + this.m_129910_().m_5462_()); - return true; -+ return net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarting(this); ++ return net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(this); } public void m_5705_(BooleanSupplier p_120049_) { -@@ -189,6 +_,7 @@ +@@ -181,6 +_,7 @@ } public void m_7570_(boolean p_120053_) { diff --git a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch index ca26623c22..e29c9c5ce2 100644 --- a/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch +++ b/patches/minecraft/net/minecraft/client/sounds/SoundEngine.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/sounds/SoundEngine.java +++ b/net/minecraft/client/sounds/SoundEngine.java -@@ -68,6 +_,7 @@ +@@ -76,6 +_,7 @@ this.f_120217_ = p_120236_; this.f_120218_ = p_120237_; this.f_120222_ = new SoundBufferLibrary(p_120238_); @@ -8,7 +8,7 @@ } public void m_120239_() { -@@ -83,6 +_,7 @@ +@@ -91,6 +_,7 @@ this.m_120304_(); this.m_120323_(); @@ -16,7 +16,7 @@ } private synchronized void m_120323_() { -@@ -278,7 +_,8 @@ +@@ -321,7 +_,8 @@ public void m_120312_(SoundInstance p_120313_) { if (this.f_120219_) { @@ -26,25 +26,25 @@ WeighedSoundEvents weighedsoundevents = p_120313_.m_6775_(this.f_120217_); ResourceLocation resourcelocation = p_120313_.m_7904_(); if (weighedsoundevents == null) { -@@ -343,11 +_,13 @@ - p_120254_.m_83654_(vec3); - p_120254_.m_83670_(flag); +@@ -389,11 +_,13 @@ + p_194488_.m_83654_(vec3); + p_194488_.m_83670_(flag); }); + final SoundInstance soundinstance = p_120313_; if (!flag3) { - this.f_120222_.m_120202_(sound.m_119790_()).thenAccept((p_120291_) -> { - channelaccess$channelhandle.m_120154_((p_174993_) -> { - p_174993_.m_83656_(p_120291_); - p_174993_.m_83672_(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlaySoundSourceEvent(this, soundinstance, p_174993_)); + this.f_120222_.m_120202_(sound.m_119790_()).thenAccept((p_194501_) -> { + channelaccess$channelhandle.m_120154_((p_194495_) -> { + p_194495_.m_83656_(p_194501_); + p_194495_.m_83672_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlaySoundSourceEvent(this, soundinstance, p_194495_)); }); }); } else { -@@ -355,6 +_,7 @@ - channelaccess$channelhandle.m_120154_((p_174996_) -> { - p_174996_.m_83658_(p_120294_); - p_174996_.m_83672_(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlayStreamingSourceEvent(this, soundinstance, p_174996_)); +@@ -401,6 +_,7 @@ + channelaccess$channelhandle.m_120154_((p_194498_) -> { + p_194498_.m_83658_(p_194504_); + p_194498_.m_83672_(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlayStreamingSourceEvent(this, soundinstance, p_194498_)); }); }); } diff --git a/patches/minecraft/net/minecraft/commands/Commands.java.patch b/patches/minecraft/net/minecraft/commands/Commands.java.patch index dbf46d6ee1..14f62b18d1 100644 --- a/patches/minecraft/net/minecraft/commands/Commands.java.patch +++ b/patches/minecraft/net/minecraft/commands/Commands.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -193,6 +_,7 @@ +@@ -199,6 +_,7 @@ if (p_82093_.f_82144_) { PublishCommand.m_138184_(this.f_82090_); } @@ -8,7 +8,7 @@ this.f_82090_.findAmbiguities((p_82108_, p_82109_, p_82110_, p_82111_) -> { f_82089_.warn("Ambiguity between arguments {} and {} with inputs: {}", this.f_82090_.getPath(p_82109_), this.f_82090_.getPath(p_82110_), p_82111_); -@@ -212,7 +_,15 @@ +@@ -218,7 +_,15 @@ try { try { diff --git a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch index efc8d5733a..9477d6c111 100644 --- a/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch +++ b/patches/minecraft/net/minecraft/core/MappedRegistry.java.patch @@ -1,12 +1,15 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -219,7 +_,8 @@ +@@ -218,9 +_,10 @@ } public static Codec> m_122756_(ResourceKey> p_122757_, Lifecycle p_122758_, Codec p_122759_) { -- return Codec.unboundedMap(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_122757_), ResourceKey::m_135782_), p_122759_).xmap((p_122726_) -> { +- return Codec.unboundedMap(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_122757_), ResourceKey::m_135782_), p_122759_).xmap((p_194547_) -> { + // FORGE: Fix MC-197860 + return new net.minecraftforge.common.LenientUnboundedMapCodec<>(ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(p_122757_), ResourceKey::m_135782_), p_122759_).xmap((p_122726_) -> { MappedRegistry mappedregistry = new MappedRegistry<>(p_122757_, p_122758_); - p_122726_.forEach((p_175387_, p_175388_) -> { - mappedregistry.m_7135_(p_175387_, p_175388_, p_122758_); +- p_194547_.forEach((p_194536_, p_194537_) -> { ++ p_122726_.forEach((p_194536_, p_194537_) -> { + mappedregistry.m_7135_(p_194536_, p_194537_, p_122758_); + }); + return mappedregistry; diff --git a/patches/minecraft/net/minecraft/core/Registry.java.patch b/patches/minecraft/net/minecraft/core/Registry.java.patch index c9489bce69..631d867290 100644 --- a/patches/minecraft/net/minecraft/core/Registry.java.patch +++ b/patches/minecraft/net/minecraft/core/Registry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Registry.java +++ b/net/minecraft/core/Registry.java -@@ -105,6 +_,10 @@ +@@ -106,6 +_,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -8,10 +8,10 @@ + * Attention Modders: This SHOULD NOT be used, you should use ForgeRegistries instead. As it has a cleaner modder facing API. + * We will be wrapping all of these in our API as necessary for syncing and management. + */ - public abstract class Registry implements Codec, Keyable, IdMap { + public abstract class Registry implements Keyable, IdMap { protected static final Logger f_122894_ = LogManager.getLogger(); private static final Map> f_122834_ = Maps.newLinkedHashMap(); -@@ -152,43 +_,43 @@ +@@ -153,43 +_,43 @@ public static final DefaultedRegistry f_175412_ = m_122995_(f_175423_, "step", () -> { return GameEvent.f_157785_; }); @@ -67,7 +67,7 @@ return ChunkStatus.f_62314_; }); public static final Registry> f_122861_ = m_122999_(f_122911_, () -> { -@@ -197,43 +_,43 @@ +@@ -198,43 +_,43 @@ public static final Registry> f_122862_ = m_122999_(f_122912_, () -> { return PosRuleTestType.f_74205_; }); @@ -121,14 +121,9 @@ return Activity.f_37979_; }); public static final Registry f_122875_ = m_122999_(f_122815_, () -> { -@@ -275,19 +_,19 @@ - public static final ResourceKey> f_122884_ = m_122978_("worldgen/template_pool"); +@@ -281,15 +_,15 @@ public static final ResourceKey> f_122885_ = m_122978_("worldgen/biome"); - public static final ResourceKey>> f_122886_ = m_122978_("worldgen/surface_builder"); -- public static final Registry> f_122835_ = m_122999_(f_122886_, () -> { -+ @Deprecated public static final Registry> f_122835_ = forge(f_122886_, () -> { - return SurfaceBuilder.f_75214_; - }); + public static final ResourceKey> f_194568_ = m_122978_("worldgen/noise"); public static final ResourceKey>> f_122836_ = m_122978_("worldgen/carver"); - public static final Registry> f_122837_ = m_122999_(f_122836_, () -> { + @Deprecated public static final Registry> f_122837_ = forge(f_122836_, () -> { @@ -145,40 +140,16 @@ return StructureFeature.f_67014_; }); public static final ResourceKey> f_122842_ = m_122978_("worldgen/structure_piece"); -@@ -295,7 +_,7 @@ - return StructurePieceType.f_67138_; - }); - public static final ResourceKey>> f_122844_ = m_122978_("worldgen/decorator"); -- public static final Registry> f_122845_ = m_122999_(f_122844_, () -> { -+ @Deprecated public static final Registry> f_122845_ = forge(f_122844_, () -> { - return FeatureDecorator.f_70681_; - }); - public static final ResourceKey>> f_122846_ = m_122978_("worldgen/block_state_provider_type"); -@@ -308,19 +_,19 @@ - public static final ResourceKey>> f_122853_ = m_122978_("worldgen/chunk_generator"); +@@ -311,7 +_,7 @@ + public static final ResourceKey>> f_194572_ = m_122978_("worldgen/material_rule"); public static final ResourceKey>> f_122854_ = m_122978_("worldgen/structure_processor"); public static final ResourceKey>> f_122855_ = m_122978_("worldgen/structure_pool_element"); - public static final Registry> f_122856_ = m_122999_(f_122846_, () -> { + @Deprecated public static final Registry> f_122856_ = forge(f_122846_, () -> { return BlockStateProviderType.f_68752_; }); -- public static final Registry> f_122857_ = m_122999_(f_122847_, () -> { -+ @Deprecated public static final Registry> f_122857_ = forge(f_122847_, () -> { - return BlockPlacerType.f_67487_; - }); -- public static final Registry> f_122858_ = m_122999_(f_122848_, () -> { -+ @Deprecated public static final Registry> f_122858_ = forge(f_122848_, () -> { - return FoliagePlacerType.f_68591_; - }); - public static final Registry> f_122859_ = m_122999_(f_122849_, () -> { - return TrunkPlacerType.f_70315_; - }); -- public static final Registry> f_122860_ = m_122999_(f_122850_, () -> { -+ @Deprecated public static final Registry> f_122860_ = forge(f_122850_, () -> { - return TreeDecoratorType.f_70043_; - }); - public static final Registry> f_122888_ = m_122999_(f_122851_, () -> { -@@ -363,16 +_,32 @@ + public static final Registry> f_122858_ = m_122999_(f_122848_, () -> { +@@ -365,16 +_,32 @@ return m_122981_(p_123000_, Lifecycle.experimental(), p_123001_); } diff --git a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch index e712cd89d2..fbeb3f8c69 100644 --- a/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch +++ b/patches/minecraft/net/minecraft/core/RegistryAccess.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/core/RegistryAccess.java +++ b/net/minecraft/core/RegistryAccess.java -@@ -100,6 +_,8 @@ - ResourceKey> resourcekey = p_123074_.m_123108_(); +@@ -109,6 +_,8 @@ + ResourceKey> resourcekey = p_194617_.f_123101_(); boolean flag = !resourcekey.equals(Registry.f_122878_) && !resourcekey.equals(Registry.f_122818_); Registry registry = f_123049_.m_175515_(resourcekey); + if (!resourcekey.equals(Registry.f_122818_)) + registry = ((Registry>)BuiltinRegistries.f_123858_).m_6246_((ResourceKey>)resourcekey); - WritableRegistry writableregistry = p_123072_.m_175512_(resourcekey); + WritableRegistry writableregistry = p_194615_.m_175512_(resourcekey); for(Entry, E> entry : registry.m_6579_()) { diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index 0cc4d29d67..bcb3790270 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -8,7 +8,7 @@ - TntBlock.m_57433_(level, blockpos); - level.m_7471_(blockpos, false); + if (blockstate.isFlammable(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_())) { -+ blockstate.catchFire(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_(), null); ++ blockstate.onCaughtFire(level, blockpos, p_123412_.m_6414_().m_61143_(DispenserBlock.f_52659_).m_122424_(), null); + if (blockstate.m_60734_() instanceof TntBlock) + level.m_7471_(blockpos, false); } else { diff --git a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch index 802b074e12..b05904a008 100644 --- a/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch +++ b/patches/minecraft/net/minecraft/data/BuiltinRegistries.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/BuiltinRegistries.java +++ b/net/minecraft/data/BuiltinRegistries.java -@@ -48,13 +_,17 @@ +@@ -44,7 +_,7 @@ return ProcessorLists.f_127199_; }); public static final Registry f_123864_ = m_123893_(Registry.f_122884_, Pools::m_127189_); @@ -9,6 +9,7 @@ return Biomes.f_127321_; }); public static final Registry f_123866_ = m_123893_(Registry.f_122878_, NoiseGeneratorSettings::m_64488_); +@@ -52,6 +_,10 @@ private static Registry m_123893_(ResourceKey> p_123894_, Supplier p_123895_) { return m_123884_(p_123894_, Lifecycle.stable(), p_123895_); diff --git a/patches/minecraft/net/minecraft/data/Main.java.patch b/patches/minecraft/net/minecraft/data/Main.java.patch index 1ceecd41c7..e714ed32d6 100644 --- a/patches/minecraft/net/minecraft/data/Main.java.patch +++ b/patches/minecraft/net/minecraft/data/Main.java.patch @@ -30,7 +30,7 @@ + java.util.Set existingMods = new java.util.HashSet<>(optionset.valuesOf(existingMod)); + java.util.Set mods = new java.util.HashSet<>(optionset.valuesOf(mod)); + boolean isFlat = mods.isEmpty() || optionset.has(flat); -+ net.minecraftforge.fmllegacy.DatagenModLoader.begin(mods, path, inputs, existingPacks, existingMods, flag2, flag1, flag3, flag4, flag5, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir)); ++ net.minecraftforge.data.loading.DatagenModLoader.begin(mods, path, inputs, existingPacks, existingMods, flag2, flag1, flag3, flag4, flag5, isFlat, optionset.valueOf(assetIndex), optionset.valueOf(assetsDir)); + if (mods.contains("minecraft") || mods.isEmpty()) + m_129660_(isFlat ? path : path.resolve("minecraft"), inputs, flag1, flag2, flag3, flag4, flag5).m_123917_(); } else { diff --git a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch index 5f1a1b4ca3..10ce79129e 100644 --- a/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/BlockLoot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/BlockLoot.java +++ b/net/minecraft/data/loot/BlockLoot.java -@@ -249,7 +_,7 @@ +@@ -250,7 +_,7 @@ return LootTable.m_79147_(); } @@ -9,7 +9,7 @@ this.m_124288_(Blocks.f_50122_); this.m_124288_(Blocks.f_50175_); this.m_124288_(Blocks.f_50228_); -@@ -1251,9 +_,13 @@ +@@ -1252,9 +_,13 @@ this.m_124165_(Blocks.f_50142_, m_124125_()); this.m_124165_(Blocks.f_152491_, m_124125_()); this.m_124165_(Blocks.f_152499_, m_124125_()); @@ -24,7 +24,7 @@ ResourceLocation resourcelocation = block.m_60589_(); if (resourcelocation != BuiltInLootTables.f_78712_ && set.add(resourcelocation)) { LootTable.Builder loottable$builder = this.f_124070_.remove(resourcelocation); -@@ -1278,6 +_,10 @@ +@@ -1279,6 +_,10 @@ public static LootTable.Builder m_124137_(Block p_124138_) { return m_124161_(p_124138_, DoorBlock.f_52730_, DoubleBlockHalf.LOWER); diff --git a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch index 3e4d9c8c49..3d318b41ed 100644 --- a/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch +++ b/patches/minecraft/net/minecraft/data/loot/EntityLoot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/EntityLoot.java +++ b/net/minecraft/data/loot/EntityLoot.java -@@ -50,7 +_,7 @@ +@@ -49,7 +_,7 @@ return LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(p_124375_))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootTableReference.m_79776_(EntityType.f_20520_.m_20677_()))); } @@ -9,7 +9,7 @@ this.m_124371_(EntityType.f_20529_, LootTable.m_79147_()); this.m_124371_(EntityType.f_147039_, LootTable.m_79147_()); this.m_124371_(EntityType.f_20549_, LootTable.m_79147_()); -@@ -144,11 +_,15 @@ +@@ -141,11 +_,15 @@ this.m_124371_(EntityType.f_20511_, LootTable.m_79147_()); this.m_124371_(EntityType.f_20512_, LootTable.m_79147_()); this.m_124371_(EntityType.f_20530_, LootTable.m_79147_().m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42583_).m_5577_(SetItemCountFunction.m_165412_(UniformGenerator.m_165780_(0.0F, 2.0F))).m_5577_(LootingEnchantFunction.m_165229_(UniformGenerator.m_165780_(0.0F, 1.0F))))).m_79161_(LootPool.m_79043_().m_165133_(ConstantValue.m_165692_(1.0F)).m_79076_(LootItem.m_79579_(Items.f_42416_)).m_79076_(LootItem.m_79579_(Items.f_42619_)).m_79076_(LootItem.m_79579_(Items.f_42620_).m_5577_(SmeltItemFunction.m_81271_().m_6509_(LootItemEntityPropertyCondition.m_81864_(LootContext.EntityTarget.THIS, f_124366_)))).m_6509_(LootItemKilledByPlayerCondition.m_81901_()).m_6509_(LootItemRandomChanceWithLootingCondition.m_81963_(0.025F, 0.01F)))); @@ -27,10 +27,10 @@ if (resourcelocation != BuiltInLootTables.f_78712_ && this.f_124368_.remove(resourcelocation) != null) { throw new IllegalStateException(String.format("Weird loottable '%s' for '%s', not a LivingEntity so should not have loot", resourcelocation, Registry.f_122826_.m_7981_(entitytype))); } -@@ -163,6 +_,14 @@ +@@ -160,6 +_,14 @@ } - this.f_124368_.forEach(p_124377_::accept); + this.f_124368_.forEach(p_124377_); + } + + protected Iterable> getKnownEntities() { diff --git a/patches/minecraft/net/minecraft/data/worldgen/biome/Biomes.java.patch b/patches/minecraft/net/minecraft/data/worldgen/biome/Biomes.java.patch deleted file mode 100644 index 9392e95283..0000000000 --- a/patches/minecraft/net/minecraft/data/worldgen/biome/Biomes.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/data/worldgen/biome/Biomes.java -+++ b/net/minecraft/data/worldgen/biome/Biomes.java -@@ -18,7 +_,7 @@ - } - - public static ResourceKey m_127325_(int p_127326_) { -- return f_127323_.get(p_127326_); -+ return ((net.minecraftforge.registries.ForgeRegistry)net.minecraftforge.registries.ForgeRegistries.BIOMES).getKey(p_127326_); - } - - static { diff --git a/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch b/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch new file mode 100644 index 0000000000..74829db9d3 --- /dev/null +++ b/patches/minecraft/net/minecraft/data/worldgen/biome/OverworldBiomes.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/data/worldgen/biome/OverworldBiomes.java ++++ b/net/minecraft/data/worldgen/biome/OverworldBiomes.java +@@ -19,6 +_,8 @@ + import net.minecraft.world.level.levelgen.GenerationStep; + + public class OverworldBiomes { ++ // TODO: getAdditionalOverworldBiomes, likely in this class. -C ++ + protected static final int f_194836_ = 4159204; + protected static final int f_194837_ = 329011; + private static final int f_194838_ = 12638463; diff --git a/patches/minecraft/net/minecraft/locale/Language.java.patch b/patches/minecraft/net/minecraft/locale/Language.java.patch index c82df77f5f..f82a97b8a7 100644 --- a/patches/minecraft/net/minecraft/locale/Language.java.patch +++ b/patches/minecraft/net/minecraft/locale/Language.java.patch @@ -6,7 +6,7 @@ - final Map map = builder.build(); + final Map map = new java.util.HashMap<>(builder.build()); -+ net.minecraftforge.fmllegacy.server.LanguageHook.captureLanguageMap(map); ++ net.minecraftforge.server.LanguageHook.captureLanguageMap(map); return new Language() { public String m_6834_(String p_128127_) { return map.getOrDefault(p_128127_, p_128127_); diff --git a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch index e6dc3a137e..018f181276 100644 --- a/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch +++ b/patches/minecraft/net/minecraft/nbt/CompoundTag.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/CompoundTag.java +++ b/net/minecraft/nbt/CompoundTag.java -@@ -39,6 +_,7 @@ +@@ -40,6 +_,7 @@ while((b0 = CompoundTag.m_128420_(p_128485_, p_128487_)) != 0) { String s = CompoundTag.m_128432_(p_128485_, p_128487_); p_128487_.m_6800_((long)(224 + 16 * s.length())); @@ -8,7 +8,7 @@ Tag tag = CompoundTag.m_128413_(TagTypes.m_129397_(b0), s, p_128485_, p_128486_ + 1, p_128487_); if (map.put(s, tag) != null) { p_128487_.m_6800_(288L); -@@ -94,6 +_,7 @@ +@@ -154,6 +_,7 @@ @Nullable public Tag m_128365_(String p_128366_, Tag p_128367_) { @@ -16,7 +16,7 @@ return this.f_128329_.put(p_128366_, p_128367_); } -@@ -386,11 +_,12 @@ +@@ -446,11 +_,12 @@ } static byte m_128420_(DataInput p_128421_, NbtAccounter p_128422_) throws IOException { diff --git a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch index e79d95893e..91c534df34 100644 --- a/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NbtIo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -194,10 +_,12 @@ +@@ -218,10 +_,12 @@ private static Tag m_128930_(DataInput p_128931_, int p_128932_, NbtAccounter p_128933_) throws IOException { byte b0 = p_128931_.readByte(); @@ -8,7 +8,7 @@ if (b0 == 0) { return EndTag.f_128534_; } else { -- p_128931_.readUTF(); +- StringTag.m_197563_(p_128931_); + p_128933_.readUTF(p_128931_.readUTF()); //Forge: Count this string. + p_128933_.m_6800_(32); //Forge: 4 extra bytes for the object allocation. diff --git a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch index 702c163528..411a5b07d3 100644 --- a/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch +++ b/patches/minecraft/net/minecraft/network/CompressionEncoder.java.patch @@ -16,7 +16,7 @@ + if (!DISABLE_PACKET_DEBUG && i > 2097152) { + p_129453_.markReaderIndex(); + LOGGER.error("Attempted to send packet over maximum protocol size: {} > 2097152\nData:\n{}", i, -+ net.minecraftforge.fmllegacy.common.network.ByteBufUtils.getContentDump(p_129453_)); ++ net.minecraftforge.logging.PacketDump.getContentDump(p_129453_)); + p_129453_.resetReaderIndex(); + } byte[] abyte = new byte[i]; diff --git a/patches/minecraft/net/minecraft/network/Connection.java.patch b/patches/minecraft/net/minecraft/network/Connection.java.patch index 52d5751136..59430eefb3 100644 --- a/patches/minecraft/net/minecraft/network/Connection.java.patch +++ b/patches/minecraft/net/minecraft/network/Connection.java.patch @@ -31,7 +31,7 @@ public static Connection m_178300_(InetSocketAddress p_178301_, boolean p_178302_) { + if (p_178301_.getAddress() instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false"); final Connection connection = new Connection(PacketFlow.CLIENTBOUND); -+ connection.activationHandler = net.minecraftforge.fmllegacy.network.NetworkHooks::registerClientLoginChannel; ++ connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel; Class oclass; LazyLoadedValue lazyloadedvalue; if (Epoll.isAvailable() && p_178302_) { @@ -39,7 +39,7 @@ public static Connection m_129493_(SocketAddress p_129494_) { final Connection connection = new Connection(PacketFlow.CLIENTBOUND); -+ connection.activationHandler = net.minecraftforge.fmllegacy.network.NetworkHooks::registerClientLoginChannel; ++ connection.activationHandler = net.minecraftforge.network.NetworkHooks::registerClientLoginChannel; (new Bootstrap()).group(f_129464_.m_13971_()).handler(new ChannelInitializer() { protected void initChannel(Channel p_129557_) { p_129557_.pipeline().addLast("packet_handler", connection); diff --git a/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch b/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch index a82efcce57..4002cd3316 100644 --- a/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch +++ b/patches/minecraft/net/minecraft/network/PacketEncoder.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/network/PacketEncoder.java +++ b/net/minecraft/network/PacketEncoder.java -@@ -44,7 +_,7 @@ - throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + p_130546_); +@@ -48,7 +_,7 @@ + JvmProfiler.f_185340_.m_183508_(k, integer, p_130545_.channel().remoteAddress(), j); } } catch (Throwable throwable) { - f_130538_.error(throwable); diff --git a/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch b/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch index 11f8648d10..d3f3f21515 100644 --- a/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch +++ b/patches/minecraft/net/minecraft/network/chat/TranslatableComponent.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/network/chat/TranslatableComponent.java +++ b/net/minecraft/network/chat/TranslatableComponent.java -@@ -87,6 +_,10 @@ +@@ -89,6 +_,10 @@ } } + if (j == 0) { + // if we failed to match above, lets try the messageformat handler instead. -+ j = net.minecraftforge.fmllegacy.TextComponentMessageFormatHandler.handle(this, this.f_131301_, this.f_131299_, p_131322_); ++ j = net.minecraftforge.internal.TextComponentMessageFormatHandler.handle(this, p_200007_, this.f_131299_, p_200006_); + } - if (j < p_131322_.length()) { - String s3 = p_131322_.substring(j); + if (j < p_200006_.length()) { + String s3 = p_200006_.substring(j); if (s3.indexOf(37) != -1) { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch index 5bfd5eb064..2b0a4b6f71 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ClientboundCustomPayloadPacket.java.patch @@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceLocation; -public class ClientboundCustomPayloadPacket implements Packet { -+public class ClientboundCustomPayloadPacket implements Packet, net.minecraftforge.fmllegacy.network.ICustomPacket { ++public class ClientboundCustomPayloadPacket implements Packet, net.minecraftforge.network.ICustomPacket { private static final int f_178834_ = 1048576; public static final ResourceLocation f_132012_ = new ResourceLocation("brand"); public static final ResourceLocation f_132013_ = new ResourceLocation("debug/path"); @@ -13,7 +13,7 @@ public void m_5797_(ClientGamePacketListener p_132041_) { p_132041_.m_7413_(this); -+ this.f_132030_.release(); // FORGE: Fix network buffer leaks (MC-121884) ++ this.f_132030_.release(); // FORGE: Fix impl buffer leaks (MC-121884) } public ResourceLocation m_132042_() { diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch index 47b2dbd503..68d3944f66 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java -@@ -47,7 +_,7 @@ +@@ -49,7 +_,7 @@ p_133961_.writeByte(this.f_133941_); p_133961_.m_130068_(this.f_133944_); p_133961_.m_178355_(this.f_179569_, FriendlyByteBuf::writeShort, FriendlyByteBuf::m_130055_); diff --git a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch index 3f6e1f09c5..4a7941f19f 100644 --- a/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/game/ServerboundCustomPayloadPacket.java.patch @@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceLocation; -public class ServerboundCustomPayloadPacket implements Packet { -+public class ServerboundCustomPayloadPacket implements Packet, net.minecraftforge.fmllegacy.network.ICustomPacket { ++public class ServerboundCustomPayloadPacket implements Packet, net.minecraftforge.network.ICustomPacket { private static final int f_179586_ = 32767; public static final ResourceLocation f_133979_ = new ResourceLocation("brand"); private final ResourceLocation f_133980_; diff --git a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch index ce38de6a8e..60b59dc6ca 100644 --- a/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -4,10 +4,10 @@ private final String f_134721_; private final int f_134722_; private final ConnectionProtocol f_134723_; -+ private String fmlVersion = net.minecraftforge.fmllegacy.network.FMLNetworkConstants.NETVERSION; ++ private String fmlVersion = net.minecraftforge.network.NetworkConstants.NETVERSION; public ClientIntentionPacket(String p_134726_, int p_134727_, ConnectionProtocol p_134728_) { - this.f_134720_ = SharedConstants.m_136187_().getProtocolVersion(); + this.f_134720_ = SharedConstants.m_183709_().getProtocolVersion(); @@ -21,14 +_,16 @@ public ClientIntentionPacket(FriendlyByteBuf p_179801_) { @@ -16,14 +16,14 @@ + String hostName = p_179801_.m_130136_(255); this.f_134722_ = p_179801_.readUnsignedShort(); this.f_134723_ = ConnectionProtocol.m_129583_(p_179801_.m_130242_()); -+ this.fmlVersion = net.minecraftforge.fmllegacy.network.NetworkHooks.getFMLVersion(hostName); ++ this.fmlVersion = net.minecraftforge.network.NetworkHooks.getFMLVersion(hostName); + this.f_134721_ = hostName.split("\0")[0]; } public void m_5779_(FriendlyByteBuf p_134737_) { p_134737_.m_130130_(this.f_134720_); - p_134737_.m_130070_(this.f_134721_); -+ p_134737_.m_130070_(this.f_134721_ + "\0"+ net.minecraftforge.fmllegacy.network.FMLNetworkConstants.NETVERSION+"\0"); ++ p_134737_.m_130070_(this.f_134721_ + "\0"+ net.minecraftforge.network.NetworkConstants.NETVERSION+"\0"); p_134737_.writeShort(this.f_134722_); p_134737_.m_130130_(this.f_134723_.m_129582_()); } diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch index ad43712c87..1cfbdc6e6a 100644 --- a/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/login/ClientboundCustomQueryPacket.java.patch @@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceLocation; -public class ClientboundCustomQueryPacket implements Packet { -+public class ClientboundCustomQueryPacket implements Packet, net.minecraftforge.fmllegacy.network.ICustomPacket { ++public class ClientboundCustomQueryPacket implements Packet, net.minecraftforge.network.ICustomPacket { private static final int f_179804_ = 1048576; private final int f_134745_; private final ResourceLocation f_134746_; diff --git a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch index ac8eeebd9f..f52d6c542e 100644 --- a/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java +++ b/net/minecraft/network/protocol/login/ServerboundCustomQueryPacket.java -@@ -4,7 +_,7 @@ +@@ -4,7 +_,8 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.Packet; -public class ServerboundCustomQueryPacket implements Packet { -+public class ServerboundCustomQueryPacket implements Packet, net.minecraftforge.fmllegacy.network.ICustomPacket { ++public class ServerboundCustomQueryPacket implements Packet, net.minecraftforge.network.ICustomPacket ++{ private static final int f_179821_ = 1048576; private final int f_134825_; - private final FriendlyByteBuf f_134826_; + @Nullable diff --git a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch index b5d74dbf1c..3590a8c1d4 100644 --- a/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch +++ b/patches/minecraft/net/minecraft/network/protocol/status/ServerStatus.java.patch @@ -1,39 +1,39 @@ --- a/net/minecraft/network/protocol/status/ServerStatus.java +++ b/net/minecraft/network/protocol/status/ServerStatus.java -@@ -21,6 +_,16 @@ - private ServerStatus.Players f_134901_; +@@ -26,6 +_,16 @@ private ServerStatus.Version f_134902_; + @Nullable private String f_134903_; -+ private transient net.minecraftforge.fmllegacy.network.FMLStatusPing forgeData; ++ private transient net.minecraftforge.network.ServerStatusPing forgeData; + -+ public net.minecraftforge.fmllegacy.network.FMLStatusPing getForgeData() { ++ public net.minecraftforge.network.ServerStatusPing getForgeData() { + return this.forgeData; + } + -+ public void setForgeData(net.minecraftforge.fmllegacy.network.FMLStatusPing data){ ++ public void setForgeData(net.minecraftforge.network.ServerStatusPing data){ + this.forgeData = data; + invalidateJson(); + } + @Nullable public Component m_134905_() { - return this.f_134900_; -@@ -28,6 +_,7 @@ +@@ -34,6 +_,7 @@ public void m_134908_(Component p_134909_) { this.f_134900_ = p_134909_; + invalidateJson(); } - public ServerStatus.Players m_134914_() { -@@ -36,6 +_,7 @@ + @Nullable +@@ -43,6 +_,7 @@ public void m_134910_(ServerStatus.Players p_134911_) { this.f_134901_ = p_134911_; + invalidateJson(); } - public ServerStatus.Version m_134915_() { -@@ -44,16 +_,51 @@ + @Nullable +@@ -52,10 +_,12 @@ public void m_134912_(ServerStatus.Version p_134913_) { this.f_134902_ = p_134913_; @@ -45,7 +45,8 @@ + invalidateJson(); } - public String m_134916_() { + @Nullable +@@ -63,6 +_,39 @@ return this.f_134903_; } @@ -58,7 +59,7 @@ + * Also to prevent potentially large memory allocations on the server + * this is moved from the SPacketServerInfo writePacket function + * -+ * As this method is called from the network threads so thread safety is important! ++ * As this method is called from the impl threads so thread safety is important! + */ + public String getJson() { + String ret = this.json; @@ -85,25 +86,25 @@ public static class Players { private final int f_134917_; private final int f_134918_; -@@ -145,6 +_,10 @@ +@@ -157,6 +_,10 @@ serverstatus.m_134906_(GsonHelper.m_13906_(jsonobject, "favicon")); } + if (jsonobject.has("forgeData")) { -+ serverstatus.setForgeData(net.minecraftforge.fmllegacy.network.FMLStatusPing.Serializer.deserialize(GsonHelper.m_13930_(jsonobject, "forgeData"), p_134949_)); ++ serverstatus.setForgeData(net.minecraftforge.network.ServerStatusPing.Serializer.deserialize(GsonHelper.m_13930_(jsonobject, "forgeData"), p_134949_)); + } + return serverstatus; } -@@ -164,6 +_,10 @@ +@@ -176,6 +_,10 @@ if (p_134951_.m_134916_() != null) { jsonobject.addProperty("favicon", p_134951_.m_134916_()); + } + + if(p_134951_.getForgeData() != null){ -+ jsonobject.add("forgeData", net.minecraftforge.fmllegacy.network.FMLStatusPing.Serializer.serialize(p_134951_.getForgeData(), p_134953_)); ++ jsonobject.add("forgeData", net.minecraftforge.network.ServerStatusPing.Serializer.serialize(p_134951_.getForgeData(), p_134953_)); } return jsonobject; diff --git a/patches/minecraft/net/minecraft/resources/RegistryReadOps.java.patch b/patches/minecraft/net/minecraft/resources/RegistryReadOps.java.patch deleted file mode 100644 index 2a26274cc6..0000000000 --- a/patches/minecraft/net/minecraft/resources/RegistryReadOps.java.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/net/minecraft/resources/RegistryReadOps.java -+++ b/net/minecraft/resources/RegistryReadOps.java -@@ -217,6 +_,7 @@ - try { - JsonParser jsonparser = new JsonParser(); - JsonElement jsonelement = jsonparser.parse(reader); -+ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_179899_.m_135782_().toString()); - optional = Optional.of(p_179900_.parse(p_179897_, jsonelement).map((p_135730_) -> { - return Pair.of(p_135730_, OptionalInt.empty()); - })); -@@ -287,6 +_,7 @@ - - public Optional>> m_142701_(DynamicOps p_179902_, ResourceKey> p_179903_, ResourceKey p_179904_, Decoder p_179905_) { - JsonElement jsonelement = this.f_135736_.get(p_179904_); -+ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_179904_.m_135782_().toString()); - return jsonelement == null ? Optional.of(DataResult.error("Unknown element: " + p_179904_)) : Optional.of(p_179905_.parse(p_179902_, jsonelement).setLifecycle(this.f_135738_.get(p_179904_)).map((p_135756_) -> { - return Pair.of(p_135756_, OptionalInt.of(this.f_135737_.getInt(p_179904_))); - })); diff --git a/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch b/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch new file mode 100644 index 0000000000..2e974710e7 --- /dev/null +++ b/patches/minecraft/net/minecraft/resources/RegistryResourceAccess.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/resources/RegistryResourceAccess.java ++++ b/net/minecraft/resources/RegistryResourceAccess.java +@@ -66,6 +_,7 @@ + + try { + JsonElement jsonelement = JsonParser.parseReader(reader); ++ if (jsonelement != null) jsonelement.getAsJsonObject().addProperty("forge:registry_name", p_195895_.m_135782_().toString()); + optional = Optional.of(p_195896_.parse(p_195893_, jsonelement).map(RegistryResourceAccess.ParsedEntry::m_195956_)); + } catch (Throwable throwable2) { + try { +@@ -138,6 +_,7 @@ + + public Optional>> m_183313_(DynamicOps p_195917_, ResourceKey> p_195918_, ResourceKey p_195919_, Decoder p_195920_) { + RegistryResourceAccess.InMemoryStorage.Entry registryresourceaccess$inmemorystorage$entry = this.f_195913_.get(p_195919_); ++ if (registryresourceaccess$inmemorystorage$entry != null && registryresourceaccess$inmemorystorage$entry.f_195936_ != null) registryresourceaccess$inmemorystorage$entry.f_195936_.getAsJsonObject().addProperty("forge:registry_name", p_195919_.m_135782_().toString()); + return registryresourceaccess$inmemorystorage$entry == null ? Optional.of(DataResult.error("Unknown element: " + p_195919_)) : Optional.of(p_195920_.parse(p_195917_, registryresourceaccess$inmemorystorage$entry.f_195936_).setLifecycle(registryresourceaccess$inmemorystorage$entry.f_195938_).map((p_195930_) -> { + return RegistryResourceAccess.ParsedEntry.m_195958_(p_195930_, registryresourceaccess$inmemorystorage$entry.f_195937_); + })); diff --git a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch index ae573a9c13..0840199a2a 100644 --- a/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch +++ b/patches/minecraft/net/minecraft/resources/ResourceKey.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/ResourceKey.java +++ b/net/minecraft/resources/ResourceKey.java -@@ -6,7 +_,7 @@ +@@ -8,7 +_,7 @@ import java.util.function.Function; import net.minecraft.core.Registry; @@ -9,9 +9,9 @@ private static final Map> f_135775_ = Collections.synchronizedMap(Maps.newIdentityHashMap()); private final ResourceLocation f_135776_; private final ResourceLocation f_135777_; -@@ -47,5 +_,23 @@ - return (p_135801_) -> { - return m_135785_(p_135798_, p_135801_); +@@ -59,5 +_,23 @@ + return (p_195974_) -> { + return m_135785_(p_135798_, p_195974_); }; + } + diff --git a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch index 48f93a19d3..e43f122cf5 100644 --- a/patches/minecraft/net/minecraft/server/Bootstrap.java.patch +++ b/patches/minecraft/net/minecraft/server/Bootstrap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/Bootstrap.java +++ b/net/minecraft/server/Bootstrap.java -@@ -50,6 +_,8 @@ +@@ -56,6 +_,8 @@ CauldronInteraction.m_175649_(); ArgumentTypes.m_121586_(); StaticTags.m_13282_(); @@ -9,11 +9,11 @@ m_135890_(); } } -@@ -122,7 +_,6 @@ - Commands.m_82138_(); +@@ -129,7 +_,6 @@ + m_197757_(); } - DefaultAttributes.m_22296_(); } - private static void m_135890_() { + private static void m_197757_() { diff --git a/patches/minecraft/net/minecraft/server/Main.java.patch b/patches/minecraft/net/minecraft/server/Main.java.patch index 09d315a659..a475dd84bf 100644 --- a/patches/minecraft/net/minecraft/server/Main.java.patch +++ b/patches/minecraft/net/minecraft/server/Main.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java @@ -76,6 +_,8 @@ - OptionSpec optionspec11 = optionparser.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(-1); OptionSpec optionspec12 = optionparser.accepts("serverId").withRequiredArg(); - OptionSpec optionspec13 = optionparser.nonOptions(); + OptionSpec optionspec13 = optionparser.accepts("jfrProfile"); + OptionSpec optionspec14 = optionparser.nonOptions(); + optionparser.accepts("allowUpdates").withRequiredArg().ofType(Boolean.class).defaultsTo(Boolean.TRUE); // Forge: allow mod updates to proceed + optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")); //Forge: Consume this argument, we use it in the launcher, and the client side. try { OptionSet optionset = optionparser.parse(p_129699_); -@@ -83,33 +_,38 @@ +@@ -83,6 +_,13 @@ optionparser.printHelpOn(System.err); return; } @@ -22,10 +22,12 @@ + } CrashReport.m_127529_(); + if (optionset.has(optionspec13)) { +@@ -92,28 +_,26 @@ Bootstrap.m_135870_(); Bootstrap.m_135889_(); Util.m_137584_(); -+ if (!optionset.has(optionspec1)) net.minecraftforge.fmllegacy.server.ServerModLoader.load(); // Load mods before we load almost anything else anymore. Single spot now. Only loads if they haven't passed the initserver param ++ if (!optionset.has(optionspec1)) net.minecraftforge.server.loading.ServerModLoader.load(); // Load mods before we load almost anything else anymore. Single spot now. Only loads if they haven't passed the initserver param RegistryAccess.RegistryHolder registryaccess$registryholder = RegistryAccess.m_123086_(); Path path = Paths.get("server.properties"); DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(path); @@ -54,8 +56,8 @@ + } LevelStorageSource levelstoragesource = LevelStorageSource.m_78242_(file1.toPath()); LevelStorageSource.LevelStorageAccess levelstoragesource$levelstorageaccess = levelstoragesource.m_78260_(s); - MinecraftServer.m_129845_(levelstoragesource$levelstorageaccess); -@@ -154,6 +_,8 @@ + LevelSummary levelsummary = levelstoragesource$levelstorageaccess.m_78308_(); +@@ -164,6 +_,8 @@ worldgensettings = optionset.has(optionspec3) ? dedicatedserverproperties.m_180927_(registryaccess$registryholder).m_64671_() : dedicatedserverproperties.m_180927_(registryaccess$registryholder); } @@ -64,7 +66,7 @@ worlddata = new PrimaryLevelData(levelsettings, worldgensettings, Lifecycle.stable()); } -@@ -181,6 +_,7 @@ +@@ -191,6 +_,7 @@ Thread thread = new Thread("Server Shutdown Thread") { public void run() { dedicatedserver.m_7570_(true); diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index e75b975751..012b83573f 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -9,15 +9,15 @@ atomicreference.get().m_130011_(); }, "Server thread"); thread.setUncaughtExceptionHandler((p_177909_, p_177910_) -> { -@@ -365,6 +_,7 @@ +@@ -355,6 +_,7 @@ + this.m_129841_(dimensiondatastorage); this.f_129732_ = new CommandStorage(dimensiondatastorage); WorldBorder worldborder = serverlevel.m_6857_(); - worldborder.m_61931_(serverleveldata.m_5813_()); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(f_129762_.get(Level.f_46428_))); if (!serverleveldata.m_6535_()) { try { m_177896_(serverlevel, serverleveldata, worldgensettings.m_64660_(), flag); -@@ -401,6 +_,7 @@ +@@ -391,6 +_,7 @@ ServerLevel serverlevel1 = new ServerLevel(this, this.f_129738_, this.f_129744_, derivedleveldata, resourcekey1, dimensiontype1, p_129816_, chunkgenerator1, flag, j, ImmutableList.of(), false); worldborder.m_61929_(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.m_6857_())); this.f_129762_.put(resourcekey1, serverlevel1); @@ -25,15 +25,15 @@ } } -@@ -411,6 +_,7 @@ +@@ -402,6 +_,7 @@ p_177898_.m_7250_(BlockPos.f_121853_.m_6630_(80), 0.0F); } else { ChunkGenerator chunkgenerator = p_177897_.m_7726_().m_8481_(); + if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(p_177897_, p_177898_)) return; - BiomeSource biomesource = chunkgenerator.m_62218_(); - Random random = new Random(p_177897_.m_7328_()); - BlockPos blockpos = biomesource.m_47909_(0, p_177897_.m_5736_(), 0, 256, (p_177905_) -> { -@@ -482,6 +_,7 @@ + ChunkPos chunkpos = new ChunkPos(chunkgenerator.m_183403_().m_183230_()); + int i = chunkgenerator.m_142051_(p_177897_); + if (i < p_177897_.m_141937_()) { +@@ -455,6 +_,7 @@ } private void m_129940_(ChunkProgressListener p_129941_) { @@ -41,7 +41,7 @@ ServerLevel serverlevel = this.m_129783_(); f_129750_.info("Preparing start region for dimension {}", (Object)serverlevel.m_46472_().m_135782_()); BlockPos blockpos = serverlevel.m_8900_(); -@@ -509,6 +_,7 @@ +@@ -482,6 +_,7 @@ ChunkPos chunkpos = new ChunkPos(i); serverlevel1.m_7726_().m_6692_(chunkpos, true); } @@ -49,7 +49,7 @@ } } -@@ -604,6 +_,7 @@ +@@ -591,6 +_,7 @@ for(ServerLevel serverlevel1 : this.m_129785_()) { if (serverlevel1 != null) { try { @@ -57,66 +57,66 @@ serverlevel1.close(); } catch (IOException ioexception1) { f_129750_.error("Exception closing the level", (Throwable)ioexception1); -@@ -652,6 +_,7 @@ +@@ -636,6 +_,7 @@ protected void m_130011_() { try { if (this.m_7038_()) { -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarted(this); ++ net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(this); this.f_129726_ = Util.m_137550_(); this.f_129757_.m_134908_(new TextComponent(this.f_129709_)); - this.f_129757_.m_134912_(new ServerStatus.Version(SharedConstants.m_136187_().getName(), SharedConstants.m_136187_().getProtocolVersion())); -@@ -683,7 +_,10 @@ - this.m_177946_(); + this.f_129757_.m_134912_(new ServerStatus.Version(SharedConstants.m_183709_().getName(), SharedConstants.m_183709_().getProtocolVersion())); +@@ -668,7 +_,10 @@ this.f_129717_ = true; + JvmProfiler.f_185340_.m_183597_(this.f_129737_); } -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStopping(this); -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions ++ net.minecraftforge.server.ServerLifecycleHooks.handleServerStopping(this); ++ net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions } else { -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions ++ net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions this.m_7268_((CrashReport)null); } } catch (Throwable throwable1) { -@@ -703,6 +_,7 @@ +@@ -688,6 +_,7 @@ f_129750_.error("We were unable to save this crash report to disk."); } -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions ++ net.minecraftforge.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions this.m_7268_(crashreport); } finally { try { -@@ -711,6 +_,7 @@ - } catch (Throwable throwable) { - f_129750_.error("Exception stopping the server", throwable); - } finally { -+ net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStopped(this); +@@ -700,6 +_,7 @@ + this.f_129723_.m_196559_(); + } + ++ net.minecraftforge.server.ServerLifecycleHooks.handleServerStopped(this); this.m_6988_(); } -@@ -802,6 +_,7 @@ +@@ -791,6 +_,7 @@ public void m_5705_(BooleanSupplier p_129871_) { long i = Util.m_137569_(); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPreServerTick(); ++ net.minecraftforge.event.ForgeEventFactory.onPreServerTick(); ++this.f_129766_; this.m_5703_(p_129871_); if (i - this.f_129724_ >= 5000000000L) { -@@ -816,6 +_,7 @@ - - Collections.shuffle(Arrays.asList(agameprofile)); - this.f_129757_.m_134914_().m_134924_(agameprofile); +@@ -812,6 +_,7 @@ + Collections.shuffle(Arrays.asList(agameprofile)); + this.f_129757_.m_134914_().m_134924_(agameprofile); + } + this.f_129757_.invalidateJson(); } if (this.f_129766_ % 6000 == 0) { -@@ -843,6 +_,7 @@ +@@ -828,6 +_,7 @@ long i1 = Util.m_137569_(); this.f_129735_.m_13755_(i1 - i); this.f_129754_.m_7238_(); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPostServerTick(); ++ net.minecraftforge.event.ForgeEventFactory.onPostServerTick(); } public void m_5703_(BooleanSupplier p_129954_) { -@@ -850,7 +_,8 @@ +@@ -835,7 +_,8 @@ this.m_129890_().m_136128_(); this.f_129754_.m_6182_("levels"); @@ -126,19 +126,19 @@ this.f_129754_.m_6521_(() -> { return serverlevel + " " + serverlevel.m_46472_().m_135782_(); }); -@@ -861,6 +_,7 @@ +@@ -846,6 +_,7 @@ } this.f_129754_.m_6180_("tick"); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPreWorldTick(serverlevel); ++ net.minecraftforge.event.ForgeEventFactory.onPreWorldTick(serverlevel); try { serverlevel.m_8793_(p_129954_); -@@ -869,9 +_,11 @@ +@@ -854,9 +_,11 @@ serverlevel.m_6026_(crashreport); throw new ReportedException(crashreport); } -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPostWorldTick(serverlevel); ++ net.minecraftforge.event.ForgeEventFactory.onPostWorldTick(serverlevel); this.f_129754_.m_7238_(); this.f_129754_.m_7238_(); @@ -146,16 +146,16 @@ } this.f_129754_.m_6182_("connection"); -@@ -946,7 +_,7 @@ +@@ -931,7 +_,7 @@ @DontObfuscate public String m_130001_() { - return "vanilla"; -+ return net.minecraftforge.fmllegacy.BrandingControl.getServerBranding(); ++ return net.minecraftforge.internal.BrandingControl.getServerBranding(); } public SystemReport m_177935_(SystemReport p_177936_) { -@@ -959,6 +_,7 @@ +@@ -947,6 +_,7 @@ p_177936_.m_143522_("Data Packs", () -> { StringBuilder stringbuilder = new StringBuilder(); @@ -163,7 +163,7 @@ for(Pack pack : this.f_129730_.m_10524_()) { if (stringbuilder.length() > 0) { stringbuilder.append(", "); -@@ -1312,6 +_,7 @@ +@@ -1261,6 +_,7 @@ this.m_6846_().m_11315_(); this.f_129734_.m_136120_(this.f_129740_.m_136157_()); this.f_129741_.m_74335_(this.f_129740_.m_136178_()); @@ -171,11 +171,11 @@ }, this); if (this.m_18695_()) { this.m_18701_(completablefuture::isDone); -@@ -1321,10 +_,13 @@ +@@ -1270,10 +_,13 @@ } public static DataPackConfig m_129819_(PackRepository p_129820_, DataPackConfig p_129821_, boolean p_129822_) { -+ net.minecraftforge.fmllegacy.packs.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.fmllegacy.server.ServerLifecycleHooks::buildPackFinderNew); ++ net.minecraftforge.resource.ResourcePackLoader.loadResourcePacks(p_129820_, net.minecraftforge.server.ServerLifecycleHooks::buildPackFinder); p_129820_.m_10506_(); + DataPackConfig.f_45842_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); + p_129821_.addModPacks(net.minecraftforge.common.ForgeHooks.getModPacks()); @@ -187,7 +187,7 @@ } else { Set set = Sets.newLinkedHashSet(); -@@ -1479,6 +_,31 @@ +@@ -1428,6 +_,31 @@ public abstract boolean m_7779_(GameProfile p_129840_); @@ -219,7 +219,7 @@ public void m_142116_(Path p_177911_) throws IOException { } -@@ -1677,6 +_,10 @@ +@@ -1681,6 +_,10 @@ public WorldData m_129910_() { return this.f_129749_; diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index 4707b4aa0b..8dcdda1d24 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -8,11 +8,11 @@ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); String s1; -@@ -171,11 +_,13 @@ - SkullBlockEntity.m_59771_(this.m_129925_()); - SkullBlockEntity.m_182462_(this); +@@ -169,11 +_,13 @@ + long i = Util.m_137569_(); + SkullBlockEntity.m_196700_(this.m_129927_(), this.m_129925_(), this); GameProfileCache.m_11004_(this.m_129797_()); -+ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; ++ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerAboutToStart(this)) return false; f_139598_.info("Preparing level \"{}\"", (Object)this.m_7123_()); this.m_130006_(); long j = Util.m_137569_() - i; @@ -22,7 +22,7 @@ if (dedicatedserverproperties.f_139744_ != null) { this.m_129900_().m_46170_(GameRules.f_46153_).m_46246_(dedicatedserverproperties.f_139744_, this); } -@@ -199,12 +_,13 @@ +@@ -197,12 +_,13 @@ } Items.f_41852_.m_6787_(CreativeModeTab.f_40754_, NonNullList.m_122779_()); @@ -33,11 +33,11 @@ } - return true; -+ return net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerStarting(this); ++ return net.minecraftforge.server.ServerLifecycleHooks.handleServerStarting(this); } } -@@ -556,6 +_,11 @@ +@@ -545,6 +_,11 @@ public boolean m_7779_(GameProfile p_139642_) { return false; diff --git a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch index 1def591788..40e50446e4 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkHolder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkHolder.java +++ b/net/minecraft/server/level/ChunkHolder.java -@@ -66,6 +_,7 @@ +@@ -64,6 +_,7 @@ private final ChunkHolder.PlayerProvider f_140016_; private boolean f_140017_; private boolean f_140018_; diff --git a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch index 313c94e99e..c6bcef710b 100644 --- a/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ChunkMap.java.patch @@ -1,20 +1,21 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -405,6 +_,7 @@ - if (this.f_140131_.remove(p_140182_, p_140183_) && p_140309_ != null) { - if (p_140309_ instanceof LevelChunk) { - ((LevelChunk)p_140309_).m_62913_(false); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload((LevelChunk)p_140309_)); +@@ -473,6 +_,7 @@ + if (this.f_140131_.remove(p_140182_, p_140183_) && p_198809_ != null) { + if (p_198809_ instanceof LevelChunk) { + ((LevelChunk)p_198809_).m_62913_(false); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Unload((LevelChunk)p_198809_)); } - this.m_140258_(p_140309_); -@@ -583,7 +_,13 @@ + this.m_140258_(p_198809_); +@@ -654,8 +_,14 @@ levelchunk.m_62952_(); if (this.f_140132_.add(chunkpos.m_45588_())) { levelchunk.m_62913_(true); + try { + p_140384_.currentlyLoading = levelchunk; // Forge - bypass the future chain when getChunk is called, this prevents deadlocks. levelchunk.m_156369_(); + levelchunk.m_187958_(this.f_140133_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(levelchunk)); + } finally { + p_140384_.currentlyLoading = null; // Forge - Stop bypassing the future chain. @@ -22,7 +23,7 @@ } return levelchunk; -@@ -659,6 +_,7 @@ +@@ -745,6 +_,7 @@ this.f_140133_.m_46473_().m_6174_("chunkSave"); CompoundTag compoundtag = ChunkSerializer.m_63454_(this.f_140133_, p_140259_); @@ -30,15 +31,15 @@ this.m_63502_(chunkpos, compoundtag); this.m_140229_(chunkpos, chunkstatus.m_62494_()); return true; -@@ -715,6 +_,7 @@ +@@ -800,6 +_,7 @@ - protected void m_140186_(ServerPlayer p_140187_, ChunkPos p_140188_, Packet[] p_140189_, boolean p_140190_, boolean p_140191_) { - if (p_140187_.f_19853_ == this.f_140133_) { -+ net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_140190_, p_140191_, p_140187_, p_140188_, this.f_140133_); - if (p_140191_ && !p_140190_) { - ChunkHolder chunkholder = this.m_140327_(p_140188_.m_45588_()); + protected void m_183754_(ServerPlayer p_183755_, ChunkPos p_183756_, MutableObject p_183757_, boolean p_183758_, boolean p_183759_) { + if (p_183755_.f_19853_ == this.f_140133_) { ++ // tODO: net.minecraftforge.event.ForgeEventFactory.fireChunkWatch(p_140190_, p_140191_, p_140187_, p_140188_, this.level); + if (p_183759_ && !p_183758_) { + ChunkHolder chunkholder = this.m_140327_(p_183756_.m_45588_()); if (chunkholder != null) { -@@ -921,7 +_,7 @@ +@@ -1054,7 +_,7 @@ } protected void m_140199_(Entity p_140200_) { diff --git a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch index 91aad81b72..16d0279b36 100644 --- a/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch +++ b/patches/minecraft/net/minecraft/server/level/DistanceManager.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -52,6 +_,8 @@ - final Executor f_140770_; +@@ -58,6 +_,8 @@ private long f_140771_; + private int f_183902_ = 10; + private final Long2ObjectOpenHashMap>> forcedTickets = new Long2ObjectOpenHashMap<>(); + protected DistanceManager(Executor p_140774_, Executor p_140775_) { ProcessorHandle processorhandle = ProcessorHandle.m_18714_("player ticket throttler", p_140775_::execute); ChunkTaskPriorityQueueSorter chunktaskpriorityqueuesorter = new ChunkTaskPriorityQueueSorter(ImmutableList.of(processorhandle), p_140774_, 4); -@@ -146,6 +_,10 @@ +@@ -163,6 +_,10 @@ this.f_140762_.m_140715_(p_140785_, p_140786_.m_9433_(), true); } @@ -20,7 +20,7 @@ } void m_140818_(long p_140819_, Ticket p_140820_) { -@@ -158,6 +_,13 @@ +@@ -175,6 +_,13 @@ } this.f_140762_.m_140715_(p_140819_, m_140797_(sortedarrayset), false); @@ -34,8 +34,8 @@ } public void m_140792_(TicketType p_140793_, ChunkPos p_140794_, int p_140795_, T p_140796_) { -@@ -178,6 +_,14 @@ - this.m_140818_(p_140851_.m_45588_(), ticket); +@@ -200,6 +_,14 @@ + this.f_183901_.m_184165_(i, ticket); } + public void registerTicking(TicketType type, ChunkPos pos, int distance, T value) { @@ -47,9 +47,9 @@ + } + private SortedArraySet> m_140857_(long p_140858_) { - return this.f_140761_.computeIfAbsent(p_140858_, (p_140867_) -> { + return this.f_140761_.computeIfAbsent(p_140858_, (p_183923_) -> { return SortedArraySet.m_14246_(4); -@@ -243,6 +_,11 @@ +@@ -285,6 +_,11 @@ public String m_140837_() { return this.f_140766_.m_140558_(); diff --git a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch index cc1aa99fc0..d7745e5422 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -161,6 +_,7 @@ +@@ -163,6 +_,7 @@ if (chunkholder == null) { return null; } else { @@ -8,16 +8,16 @@ Either either = chunkholder.m_140080_(ChunkStatus.f_62326_).getNow((Either)null); if (either == null) { return null; -@@ -337,7 +_,7 @@ - if (optional.isPresent()) { - LevelChunk levelchunk = optional.get(); - ChunkPos chunkpos = levelchunk.m_7697_(); -- if (this.f_8329_.m_143275_(chunkpos) && !this.f_8325_.m_140397_(chunkpos)) { -+ if ((this.f_8329_.m_143275_(chunkpos) && !this.f_8325_.m_140397_(chunkpos)) || this.f_8327_.shouldForceTicks(chunkpos.m_45588_())) { - levelchunk.m_6141_(levelchunk.m_6319_() + j); - if (flag1 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) { - NaturalSpawner.m_47029_(this.f_8329_, levelchunk, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag2); -@@ -414,6 +_,14 @@ +@@ -348,7 +_,7 @@ + for(ServerChunkCache.ChunkAndHolder serverchunkcache$chunkandholder : list) { + LevelChunk levelchunk1 = serverchunkcache$chunkandholder.f_184028_; + ChunkPos chunkpos = levelchunk1.m_7697_(); +- if (this.f_8329_.m_143275_(chunkpos) && this.f_8325_.m_183879_(chunkpos)) { ++ if ((this.f_8329_.m_143275_(chunkpos) && this.f_8325_.m_183879_(chunkpos)) || this.f_8327_.shouldForceTicks(chunkpos.m_45588_())) { + levelchunk1.m_187632_(j); + if (flag2 && (this.f_8335_ || this.f_8336_) && this.f_8329_.m_6857_().m_61927_(chunkpos)) { + NaturalSpawner.m_47029_(this.f_8329_, levelchunk1, naturalspawner$spawnstate, this.f_8336_, this.f_8335_, flag1); +@@ -426,6 +_,14 @@ public void m_8438_(TicketType p_8439_, ChunkPos p_8440_, int p_8441_, T p_8442_) { this.f_8327_.m_140849_(p_8439_, p_8440_, p_8441_, p_8442_); diff --git a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch index 187ce77e8e..1291de74f7 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerLevel.java.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -170,9 +_,10 @@ +@@ -176,10 +_,11 @@ private final List f_8558_; @Nullable private final EndDragonFight f_8559_; - final Int2ObjectMap f_143247_ = new Int2ObjectOpenHashMap<>(); + final Int2ObjectMap> f_143247_ = new Int2ObjectOpenHashMap<>(); private final StructureFeatureManager f_8560_; + private final StructureCheck f_196556_; private final boolean f_8561_; + private net.minecraftforge.common.util.WorldCapabilityData capabilityData; public ServerLevel(MinecraftServer p_8571_, Executor p_8572_, LevelStorageSource.LevelStorageAccess p_8573_, ServerLevelData p_8574_, ResourceKey p_8575_, DimensionType p_8576_, ChunkProgressListener p_8577_, ChunkGenerator p_8578_, boolean p_8579_, long p_8580_, List p_8581_, boolean p_8582_) { super(p_8574_, p_8575_, p_8576_, p_8571_::m_129905_, false, p_8579_, p_8580_); -@@ -208,6 +_,7 @@ +@@ -217,6 +_,7 @@ } this.f_143245_ = new SleepStatus(); @@ -20,7 +21,46 @@ } public void m_8606_(int p_8607_, int p_8608_, boolean p_8609_, boolean p_8610_) { -@@ -303,22 +_,26 @@ +@@ -245,8 +_,8 @@ + int i = this.m_46469_().m_46215_(GameRules.f_151486_); + if (this.f_143245_.m_144002_(i) && this.f_143245_.m_144004_(i, this.f_8546_)) { + if (this.m_46469_().m_46207_(GameRules.f_46140_)) { +- long j = this.f_46442_.m_6792_() + 24000L; +- this.m_8615_(j - j % 24000L); ++ long j = this.m_46468_() + 24000L; ++ this.m_8615_(net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, j - j % 24000L, this.m_46468_())); + } + + this.m_8804_(); +@@ -275,7 +_,7 @@ + this.m_8807_(); + this.f_8557_ = false; + profilerfiller.m_7238_(); +- boolean flag = !this.f_8546_.isEmpty() || !this.m_8902_().isEmpty(); ++ boolean flag = !this.f_8546_.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones + if (flag) { + this.m_8886_(); + } +@@ -307,7 +_,9 @@ + } + + profilerfiller.m_6180_("tick"); +- this.m_46653_(this::m_8647_, p_184065_); ++ if (!p_184065_.m_146910_() && !(p_184065_ instanceof net.minecraftforge.entity.PartEntity)) { ++ this.m_46653_(this::m_8647_, p_184065_); ++ } + profilerfiller.m_7238_(); + } + } +@@ -396,6 +_,7 @@ + BlockPos blockpos2 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); + BlockPos blockpos3 = blockpos2.m_7495_(); + Biome biome = this.m_46857_(blockpos2); ++ if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks + if (biome.m_47477_(this, blockpos3)) { + this.m_46597_(blockpos3, Blocks.f_50126_.m_49966_()); + } +@@ -586,15 +_,19 @@ this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); } @@ -43,45 +83,8 @@ + this.f_8548_.m_6846_().m_11270_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132161_, this.f_46440_), this.m_46472_()); } - int l = this.m_46469_().m_46215_(GameRules.f_151486_); - if (this.f_143245_.m_144002_(l) && this.f_143245_.m_144004_(l, this.f_8546_)) { - if (this.m_46469_().m_46207_(GameRules.f_46140_)) { -- long i1 = this.f_46442_.m_6792_() + 24000L; -- this.m_8615_(i1 - i1 % 24000L); -+ long k = this.m_46468_() + 24000L; -+ this.m_8615_(net.minecraftforge.event.ForgeEventFactory.onSleepFinished(this, k - k % 24000L, this.m_46468_())); - } - - this.m_8804_(); -@@ -343,7 +_,7 @@ - this.m_8807_(); - this.f_8557_ = false; - profilerfiller.m_7238_(); -- boolean flag3 = !this.f_8546_.isEmpty() || !this.m_8902_().isEmpty(); -+ boolean flag3 = !this.f_8546_.isEmpty() || net.minecraftforge.common.world.ForgeChunkManager.hasForcedChunks(this); //Forge: Replace vanilla's has forced chunk check with forge's that checks both the vanilla and forge added ones - if (flag3) { - this.m_8886_(); - } -@@ -374,7 +_,9 @@ - } - - profilerfiller.m_6180_("tick"); -- this.m_46653_(this::m_8647_, p_143266_); -+ if (!p_143266_.m_146910_() && !(p_143266_ instanceof net.minecraftforge.entity.PartEntity)) { -+ this.m_46653_(this::m_8647_, p_143266_); -+ } - profilerfiller.m_7238_(); - } - } -@@ -458,6 +_,7 @@ - BlockPos blockpos2 = this.m_5452_(Heightmap.Types.MOTION_BLOCKING, this.m_46496_(i, 0, j, 15)); - BlockPos blockpos3 = blockpos2.m_7495_(); - Biome biome = this.m_46857_(blockpos2); -+ if (this.isAreaLoaded(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks - if (biome.m_47477_(this, blockpos3)) { - this.m_46597_(blockpos3, Blocks.f_50126_.m_49966_()); - } -@@ -627,9 +_,10 @@ + } +@@ -650,9 +_,10 @@ ++p_8664_.f_19797_; ProfilerFiller profilerfiller = this.m_46473_(); profilerfiller.m_6521_(() -> { @@ -93,7 +96,7 @@ p_8664_.m_6083_(); profilerfiller.m_7238_(); -@@ -666,6 +_,7 @@ +@@ -689,6 +_,7 @@ this.f_143244_.m_157554_(); } @@ -101,7 +104,7 @@ } } -@@ -738,7 +_,48 @@ +@@ -761,7 +_,48 @@ this.m_8853_(p_8846_); } @@ -150,7 +153,7 @@ Entity entity = this.m_142646_().m_142694_(p_8854_.m_142081_()); if (entity != null) { f_8566_.warn("Force-added player with duplicate UUID {}", (Object)p_8854_.m_142081_().toString()); -@@ -746,7 +_,8 @@ +@@ -769,7 +_,8 @@ this.m_143261_((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -160,7 +163,7 @@ } private boolean m_8872_(Entity p_8873_) { -@@ -754,7 +_,12 @@ +@@ -777,7 +_,12 @@ f_8566_.warn("Tried to add entity {} but it was marked as removed already", (Object)EntityType.m_20613_(p_8873_.m_6095_())); return false; } else { @@ -174,7 +177,7 @@ } } -@@ -790,10 +_,20 @@ +@@ -814,10 +_,20 @@ } public void m_6263_(@Nullable Player p_8675_, double p_8676_, double p_8677_, double p_8678_, SoundEvent p_8679_, SoundSource p_8680_, float p_8681_, float p_8682_) { @@ -195,7 +198,7 @@ this.f_8548_.m_6846_().m_11241_(p_8689_, p_8690_.m_20185_(), p_8690_.m_20186_(), p_8690_.m_20189_(), p_8693_ > 1.0F ? (double)(16.0F * p_8693_) : 16.0D, this.m_46472_(), new ClientboundSoundEntityPacket(p_8691_, p_8692_, p_8690_, p_8693_, p_8694_)); } -@@ -838,6 +_,7 @@ +@@ -862,6 +_,7 @@ public Explosion m_7703_(@Nullable Entity p_8653_, @Nullable DamageSource p_8654_, @Nullable ExplosionDamageCalculator p_8655_, double p_8656_, double p_8657_, double p_8658_, float p_8659_, boolean p_8660_, Explosion.BlockInteraction p_8661_) { Explosion explosion = new Explosion(this, p_8653_, p_8654_, p_8655_, p_8656_, p_8657_, p_8658_, p_8659_, p_8660_, p_8661_); @@ -203,7 +206,7 @@ explosion.m_46061_(); explosion.m_46075_(false); if (p_8661_ == Explosion.BlockInteraction.NONE) { -@@ -1357,6 +_,12 @@ +@@ -1389,6 +_,12 @@ }); } @@ -216,7 +219,7 @@ public LevelEntityGetter m_142646_() { return this.f_143244_.m_157567_(); } -@@ -1422,8 +_,8 @@ +@@ -1463,8 +_,8 @@ ServerLevel.this.f_143246_.add((Mob)p_143371_); } @@ -227,7 +230,7 @@ ServerLevel.this.f_143247_.put(enderdragonpart.m_142049_(), enderdragonpart); } } -@@ -1442,8 +_,8 @@ +@@ -1483,8 +_,8 @@ ServerLevel.this.f_143246_.remove(p_143375_); } diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch index 0ed8150c39..359bcb3a39 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -500,6 +_,7 @@ +@@ -541,6 +_,7 @@ } public void m_6667_(DamageSource p_9035_) { @@ -8,7 +8,7 @@ boolean flag = this.f_19853_.m_46469_().m_46207_(GameRules.f_46142_); if (flag) { Component component = this.m_21231_().m_19293_(); -@@ -644,13 +_,14 @@ +@@ -685,13 +_,14 @@ } @Nullable @@ -16,17 +16,17 @@ + public Entity changeDimension(ServerLevel p_9180_, net.minecraftforge.common.util.ITeleporter teleporter) { + if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9180_.m_46472_())) return null; this.f_8927_ = true; - ServerLevel serverlevel = this.m_9236_(); + ServerLevel serverlevel = this.m_183503_(); ResourceKey resourcekey = serverlevel.m_46472_(); - if (resourcekey == Level.f_46430_ && p_9180_.m_46472_() == Level.f_46428_) { + if (resourcekey == Level.f_46430_ && p_9180_.m_46472_() == Level.f_46428_ && teleporter.isVanilla()) { //Forge: Fix non-vanilla teleporters triggering end credits this.m_19877_(); -- this.m_9236_().m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); -+ this.m_9236_().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom +- this.m_183503_().m_143261_(this, Entity.RemovalReason.CHANGED_DIMENSION); ++ this.m_183503_().removePlayer(this, true); //Forge: The player entity is cloned so keep the data until after cloning calls copyFrom if (!this.f_8944_) { this.f_8944_ = true; this.f_8906_.m_141995_(new ClientboundGameEventPacket(ClientboundGameEventPacket.f_132157_, this.f_8928_ ? 0.0F : 1.0F)); -@@ -664,14 +_,15 @@ +@@ -705,14 +_,15 @@ this.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); PlayerList playerlist = this.f_8924_.m_6846_(); playerlist.m_11289_(this); @@ -46,7 +46,7 @@ this.m_9006_(p_9180_, new BlockPos(portalinfo.f_77676_)); } -@@ -683,6 +_,9 @@ +@@ -724,6 +_,9 @@ this.m_6027_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_); serverlevel.m_46473_().m_7238_(); this.m_9209_(serverlevel); @@ -56,7 +56,7 @@ this.f_8906_.m_141995_(new ClientboundPlayerAbilitiesPacket(this.m_150110_())); playerlist.m_11229_(this, p_9180_); playerlist.m_11292_(this); -@@ -691,10 +_,12 @@ +@@ -732,10 +_,12 @@ this.f_8906_.m_141995_(new ClientboundUpdateMobEffectPacket(this.m_142049_(), mobeffectinstance)); } @@ -65,11 +65,11 @@ this.f_8920_ = -1; this.f_8917_ = -1.0F; this.f_8918_ = -1; -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, resourcekey, p_9180_.m_46472_()); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(this, resourcekey, p_9180_.m_46472_()); } return this; -@@ -768,6 +_,9 @@ +@@ -799,6 +_,9 @@ } public Either m_7720_(BlockPos p_9115_) { @@ -79,7 +79,7 @@ Direction direction = this.f_19853_.m_8055_(p_9115_).m_61143_(HorizontalDirectionalBlock.f_54117_); if (!this.m_5803_() && this.m_6084_()) { if (!this.f_19853_.m_6042_().m_63956_()) { -@@ -778,7 +_,7 @@ +@@ -809,7 +_,7 @@ return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { this.m_9158_(this.f_19853_.m_46472_(), p_9115_, this.m_146908_(), false, true); @@ -88,7 +88,7 @@ return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { if (!this.m_7500_()) { -@@ -816,6 +_,7 @@ +@@ -847,6 +_,7 @@ } private boolean m_9116_(BlockPos p_9117_, Direction p_9118_) { @@ -96,7 +96,7 @@ return this.m_9222_(p_9117_) || this.m_9222_(p_9117_.m_142300_(p_9118_.m_122424_())); } -@@ -924,6 +_,7 @@ +@@ -955,6 +_,7 @@ this.f_8906_.m_141995_(new ClientboundOpenScreenPacket(abstractcontainermenu.f_38840_, abstractcontainermenu.m_6772_(), p_9033_.m_5446_())); this.m_143399_(abstractcontainermenu); this.f_36096_ = abstractcontainermenu; @@ -104,7 +104,7 @@ return OptionalInt.of(this.f_8940_); } } -@@ -942,6 +_,7 @@ +@@ -973,6 +_,7 @@ this.f_8906_.m_141995_(new ClientboundHorseScreenOpenPacket(this.f_8940_, p_9060_.m_6643_(), p_9059_.m_142049_())); this.f_36096_ = new HorseInventoryMenu(this.f_8940_, this.m_150109_(), p_9060_, p_9059_); this.m_143399_(this.f_36096_); @@ -112,7 +112,7 @@ } public void m_6986_(ItemStack p_9082_, InteractionHand p_9083_) { -@@ -968,6 +_,7 @@ +@@ -998,6 +_,7 @@ public void m_9230_() { this.f_36096_.m_6877_(this); this.f_36095_.m_150414_(this.f_36096_); @@ -120,7 +120,7 @@ this.f_36096_ = this.f_36095_; } -@@ -1093,6 +_,13 @@ +@@ -1123,6 +_,13 @@ this.f_8933_ = p_9016_.f_8933_; this.m_36362_(p_9016_.m_36331_()); this.m_36364_(p_9016_.m_36332_()); @@ -134,7 +134,7 @@ } protected void m_142540_(MobEffectInstance p_143393_, @Nullable Entity p_143394_) { -@@ -1151,6 +_,7 @@ +@@ -1181,6 +_,7 @@ } public boolean m_143403_(GameType p_143404_) { @@ -142,23 +142,23 @@ if (!this.f_8941_.m_143473_(p_143404_)) { return false; } else { -@@ -1206,6 +_,7 @@ - this.f_143378_ = p_9157_.m_179563_(); - this.m_20088_().m_135381_(f_36089_, (byte)p_9157_.m_133887_()); - this.m_20088_().m_135381_(f_36090_, (byte)(p_9157_.m_133888_() == HumanoidArm.LEFT ? 0 : 1)); -+ this.language = p_9157_.m_179561_(); +@@ -1237,6 +_,7 @@ + this.f_184127_ = p_9157_.f_195812_(); + this.m_20088_().m_135381_(f_36089_, (byte)p_9157_.f_133867_()); + this.m_20088_().m_135381_(f_36090_, (byte)(p_9157_.f_133868_() == HumanoidArm.LEFT ? 0 : 1)); ++ this.language = p_9157_.f_133863_(); } public boolean m_143432_() { -@@ -1265,6 +_,7 @@ - public void m_9213_(Entity p_9214_) { +@@ -1296,6 +_,7 @@ + public void m_9213_(@Nullable Entity p_9214_) { Entity entity = this.m_8954_(); this.f_8926_ = (Entity)(p_9214_ == null ? this : p_9214_); + while (this.f_8926_ instanceof net.minecraftforge.entity.PartEntity partEntity) this.f_8926_ = partEntity.getParent(); // FORGE: fix MC-46486 if (entity != this.f_8926_) { this.f_8906_.m_141995_(new ClientboundSetCameraPacket(this.f_8926_)); this.m_6021_(this.f_8926_.m_20185_(), this.f_8926_.m_20186_(), this.f_8926_.m_20189_()); -@@ -1294,7 +_,11 @@ +@@ -1325,7 +_,11 @@ @Nullable public Component m_8957_() { @@ -171,13 +171,13 @@ } public void m_6674_(InteractionHand p_9031_) { -@@ -1319,21 +_,23 @@ +@@ -1350,21 +_,23 @@ this.m_8127_(); if (p_9000_ == this.f_19853_) { this.f_8906_.m_9774_(p_9001_, p_9002_, p_9003_, p_9004_, p_9005_); - } else { + } else if (net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_9000_.m_46472_())) { - ServerLevel serverlevel = this.m_9236_(); + ServerLevel serverlevel = this.m_183503_(); LevelData leveldata = p_9000_.m_6106_(); this.f_8906_.m_141995_(new ClientboundRespawnPacket(p_9000_.m_6042_(), p_9000_.m_46472_(), BiomeManager.m_47877_(p_9000_.m_7328_()), this.f_8941_.m_9290_(), this.f_8941_.m_9293_(), p_9000_.m_46659_(), p_9000_.m_8584_(), true)); this.f_8906_.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); @@ -194,11 +194,11 @@ + this.f_8941_.m_9260_(p_9000_); this.f_8924_.m_6846_().m_11229_(this, p_9000_); this.f_8924_.m_6846_().m_11292_(this); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerChangedDimensionEvent(this, serverlevel.m_46472_(), p_9000_.m_46472_()); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerChangedDimensionEvent(this, serverlevel.m_46472_(), p_9000_.m_46472_()); } } -@@ -1356,6 +_,7 @@ +@@ -1387,6 +_,7 @@ } public void m_9158_(ResourceKey p_9159_, @Nullable BlockPos p_9160_, float p_9161_, boolean p_9162_, boolean p_9163_) { @@ -206,7 +206,7 @@ if (p_9160_ != null) { boolean flag = p_9160_.equals(this.f_8936_) && p_9159_.equals(this.f_8935_); if (p_9163_ && !flag) { -@@ -1408,6 +_,8 @@ +@@ -1438,6 +_,8 @@ if (itementity == null) { return null; } else { @@ -215,7 +215,7 @@ this.f_19853_.m_7967_(itementity); ItemStack itemstack = itementity.m_32055_(); if (p_9087_) { -@@ -1422,6 +_,29 @@ +@@ -1452,6 +_,29 @@ } } @@ -245,7 +245,7 @@ public TextFilter m_8967_() { return this.f_8939_; } -@@ -1481,10 +_,12 @@ +@@ -1511,11 +_,13 @@ public boolean m_182294_(boolean p_182295_) { Inventory inventory = this.m_150109_(); @@ -258,4 +258,5 @@ - return this.m_7197_(itemstack, false, true) != null; + return net.minecraftforge.common.ForgeHooks.onPlayerTossEvent(this, itemstack, true) != null; } - } + + public boolean m_184128_() { diff --git a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch index 4f07599e52..e002f571d3 100644 --- a/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/patches/minecraft/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -78,7 +78,7 @@ + + private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) { + BlockState state = this.f_9244_.m_8055_(p_180235_1_); -+ boolean removed = state.removedByPlayer(this.f_9244_, p_180235_1_, this.f_9245_, canHarvest, this.f_9244_.m_6425_(p_180235_1_)); ++ boolean removed = state.onDestroyedByPlayer(this.f_9244_, p_180235_1_, this.f_9245_, canHarvest, this.f_9244_.m_6425_(p_180235_1_)); + if (removed) + state.m_60734_().m_6786_(this.f_9244_, p_180235_1_, state); + return removed; diff --git a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch index 1573cbfcc7..841d455e1c 100644 --- a/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/MemoryServerHandshakePacketListenerImpl.java.patch @@ -4,7 +4,7 @@ } public void m_7322_(ClientIntentionPacket p_9697_) { -+ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerLogin(p_9697_, this.f_9689_)) return; ++ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9697_, this.f_9689_)) return; this.f_9689_.m_129498_(p_9697_.m_134735_()); this.f_9689_.m_129505_(new ServerLoginPacketListenerImpl(this.f_9688_, this.f_9689_)); } diff --git a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index a3b8f44d0b..e045652ee8 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -21,7 +21,7 @@ } public void m_7376_(ServerboundAcceptTeleportationPacket p_9835_) { -@@ -963,7 +_,9 @@ +@@ -966,7 +_,9 @@ this.f_9743_.m_9243_(); int i = this.f_9743_.f_19853_.m_151558_(); if (blockpos.m_123342_() < i) { @@ -32,7 +32,7 @@ InteractionResult interactionresult = this.f_9743_.f_8941_.m_7179_(this.f_9743_, serverlevel, itemstack, interactionhand, blockhitresult); if (direction == Direction.UP && !interactionresult.m_19077_() && blockpos.m_123342_() >= i - 1 && m_9790_(this.f_9743_, itemstack)) { Component component = (new TranslatableComponent("build.tooHigh", i - 1)).m_130940_(ChatFormatting.RED); -@@ -1077,7 +_,7 @@ +@@ -1080,7 +_,7 @@ } public void m_7388_(ServerboundChatPacket p_9841_) { @@ -41,19 +41,19 @@ for(int i = 0; i < s.length(); ++i) { if (!SharedConstants.m_136188_(s.charAt(i))) { -@@ -1107,8 +_,10 @@ +@@ -1110,8 +_,10 @@ String s1 = p_143629_.m_143722_(); Component component = s1.isEmpty() ? null : new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s1); Component component1 = new TranslatableComponent("chat.type.text", this.f_9743_.m_5446_(), s); + component1 = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, component1); + Component finalComponent = component1; - this.f_9745_.m_6846_().m_143991_(component1, (p_143644_) -> { -- return this.f_9743_.m_143421_(p_143644_) ? component : component1; -+ return this.f_9743_.m_143421_(p_143644_) ? component : finalComponent; + this.f_9745_.m_6846_().m_143991_(component1, (p_184197_) -> { +- return this.f_9743_.m_143421_(p_184197_) ? component : component1; ++ return this.f_9743_.m_143421_(p_184197_) ? component : finalComponent; }, ChatType.CHAT, this.f_9743_.m_142081_()); } -@@ -1196,6 +_,7 @@ +@@ -1203,6 +_,7 @@ private void m_143678_(InteractionHand p_143679_, ServerGamePacketListenerImpl.EntityInteraction p_143680_) { ItemStack itemstack = ServerGamePacketListenerImpl.this.f_9743_.m_21120_(p_143679_).m_41777_(); InteractionResult interactionresult = p_143680_.m_143694_(ServerGamePacketListenerImpl.this.f_9743_, entity, p_143679_); @@ -61,12 +61,12 @@ if (interactionresult.m_19077_()) { CriteriaTriggers.f_10565_.m_61494_(ServerGamePacketListenerImpl.this.f_9743_, itemstack, entity); if (interactionresult.m_19080_()) { -@@ -1401,6 +_,8 @@ +@@ -1404,6 +_,8 @@ } public void m_7423_(ServerboundCustomPayloadPacket p_9860_) { -+ PacketUtils.m_131359_(p_9860_, this, this.f_9743_.m_9236_()); -+ net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_9860_, this.f_9742_); ++ PacketUtils.m_131359_(p_9860_, this, this.f_9743_.m_183503_()); ++ net.minecraftforge.network.NetworkHooks.onCustomPayload(p_9860_, this.f_9742_); } public void m_7477_(ServerboundChangeDifficultyPacket p_9839_) { diff --git a/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index 744020db14..50c6b52a93 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -4,7 +4,7 @@ } public void m_7322_(ClientIntentionPacket p_9975_) { -+ if (!net.minecraftforge.fmllegacy.server.ServerLifecycleHooks.handleServerLogin(p_9975_, this.f_9966_)) return; ++ if (!net.minecraftforge.server.ServerLifecycleHooks.handleServerLogin(p_9975_, this.f_9966_)) return; switch(p_9975_.m_134735_()) { case LOGIN: this.f_9966_.m_129498_(ConnectionProtocol.LOGIN); diff --git a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 910b3979f0..35b6a358b2 100644 --- a/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/patches/minecraft/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -8,14 +8,14 @@ + if (this.f_10019_ == State.NEGOTIATING) { + // We force the state into "NEGOTIATING" which is otherwise unused. Once we're completed we move the negotiation onto "READY_TO_ACCEPT" + // Might want to promote player object creation to here as well.. -+ boolean negotiationComplete = net.minecraftforge.fmllegacy.network.NetworkHooks.tickNegotiation(this, this.f_10013_, this.f_10024_); ++ boolean negotiationComplete = net.minecraftforge.network.NetworkHooks.tickNegotiation(this, this.f_10013_, this.f_10024_); + if (negotiationComplete) + this.f_10019_ = State.READY_TO_ACCEPT; + } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT) { this.m_10055_(); } else if (this.f_10019_ == ServerLoginPacketListenerImpl.State.DELAY_ACCEPT) { ServerPlayer serverplayer = this.f_10018_.m_6846_().m_11259_(this.f_10021_.getId()); -@@ -146,7 +_,7 @@ +@@ -147,7 +_,7 @@ this.f_10019_ = ServerLoginPacketListenerImpl.State.KEY; this.f_10013_.m_129512_(new ClientboundHelloPacket("", this.f_10018_.m_129790_().getPublic().getEncoded(), this.f_10017_)); } else { @@ -24,7 +24,7 @@ } } -@@ -171,7 +_,7 @@ +@@ -172,7 +_,7 @@ throw new IllegalStateException("Protocol error", cryptexception); } @@ -33,7 +33,7 @@ public void run() { GameProfile gameprofile = ServerLoginPacketListenerImpl.this.f_10021_; -@@ -179,11 +_,11 @@ +@@ -180,11 +_,11 @@ ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.f_10018_.m_129925_().hasJoinedServer(new GameProfile((UUID)null, gameprofile.getName()), s, this.m_10064_()); if (ServerLoginPacketListenerImpl.this.f_10021_ != null) { ServerLoginPacketListenerImpl.f_10015_.info("UUID of player {} is {}", ServerLoginPacketListenerImpl.this.f_10021_.getName(), ServerLoginPacketListenerImpl.this.f_10021_.getId()); @@ -47,7 +47,7 @@ } else { ServerLoginPacketListenerImpl.this.m_10053_(new TranslatableComponent("multiplayer.disconnect.unverified_username")); ServerLoginPacketListenerImpl.f_10015_.error("Username '{}' tried to join with an invalid session", (Object)gameprofile.getName()); -@@ -192,7 +_,7 @@ +@@ -193,7 +_,7 @@ if (ServerLoginPacketListenerImpl.this.f_10018_.m_129792_()) { ServerLoginPacketListenerImpl.f_10015_.warn("Authentication servers are down but will let them in anyway!"); ServerLoginPacketListenerImpl.this.f_10021_ = ServerLoginPacketListenerImpl.this.m_10038_(gameprofile); @@ -56,11 +56,11 @@ } else { ServerLoginPacketListenerImpl.this.m_10053_(new TranslatableComponent("multiplayer.disconnect.authservers_down")); ServerLoginPacketListenerImpl.f_10015_.error("Couldn't verify username because servers are unavailable"); -@@ -212,6 +_,7 @@ +@@ -213,6 +_,7 @@ } public void m_7223_(ServerboundCustomQueryPacket p_10045_) { -+ if (!net.minecraftforge.fmllegacy.network.NetworkHooks.onCustomPayload(p_10045_, this.f_10013_)) ++ if (!net.minecraftforge.network.NetworkHooks.onCustomPayload(p_10045_, this.f_10013_)) this.m_10053_(new TranslatableComponent("multiplayer.disconnect.unexpected_query_response")); } diff --git a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch index 9cc8410172..97758a31c1 100644 --- a/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch +++ b/patches/minecraft/net/minecraft/server/packs/VanillaPackResources.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/packs/VanillaPackResources.java +++ b/net/minecraft/server/packs/VanillaPackResources.java -@@ -202,7 +_,7 @@ +@@ -203,7 +_,7 @@ try { URL url = VanillaPackResources.class.getResource(s); @@ -9,7 +9,7 @@ } catch (IOException ioexception) { return VanillaPackResources.class.getResourceAsStream(s); } -@@ -218,7 +_,7 @@ +@@ -219,7 +_,7 @@ @Nullable protected InputStream m_5539_(String p_10334_) { @@ -18,7 +18,7 @@ } public boolean m_7211_(PackType p_10355_, ResourceLocation p_10356_) { -@@ -291,6 +_,20 @@ +@@ -292,6 +_,20 @@ } public void close() { diff --git a/patches/minecraft/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java.patch b/patches/minecraft/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java.patch deleted file mode 100644 index 2ed9ee8ea6..0000000000 --- a/patches/minecraft/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -+++ b/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -@@ -17,4 +_,11 @@ - } - - void m_6213_(ResourceManager p_10758_); -+ -+ /** @deprecated Selective reloading is no longer supported due to vanilla now reloading resources in parallel, so this is no longer needed */ -+ @Deprecated(since="1.17.1", forRemoval = true) -+ @javax.annotation.Nullable -+ default net.minecraftforge.resource.IResourceType getResourceType() { -+ return null; -+ } - } diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 3afecde553..ba2877bde5 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -115,6 +_,7 @@ +@@ -117,6 +_,7 @@ private boolean f_11209_; private static final boolean f_143988_ = false; private int f_11210_; @@ -8,15 +8,15 @@ public PlayerList(MinecraftServer p_11213_, RegistryAccess.RegistryHolder p_11214_, PlayerDataStorage p_11215_, int p_11216_) { this.f_11195_ = p_11213_; -@@ -150,6 +_,7 @@ +@@ -152,6 +_,7 @@ LevelData leveldata = serverlevel1.m_6106_(); p_11263_.m_143427_(compoundtag); ServerGamePacketListenerImpl servergamepacketlistenerimpl = new ServerGamePacketListenerImpl(this.f_11195_, p_11262_, p_11263_); -+ net.minecraftforge.fmllegacy.network.NetworkHooks.sendMCRegistryPackets(p_11262_, "PLAY_TO_CLIENT"); ++ net.minecraftforge.network.NetworkHooks.sendMCRegistryPackets(p_11262_, "PLAY_TO_CLIENT"); GameRules gamerules = serverlevel1.m_46469_(); boolean flag = gamerules.m_46207_(GameRules.f_46156_); boolean flag1 = gamerules.m_46207_(GameRules.f_46145_); -@@ -158,6 +_,7 @@ +@@ -160,6 +_,7 @@ servergamepacketlistenerimpl.m_141995_(new ClientboundChangeDifficultyPacket(leveldata.m_5472_(), leveldata.m_5474_())); servergamepacketlistenerimpl.m_141995_(new ClientboundPlayerAbilitiesPacket(p_11263_.m_150110_())); servergamepacketlistenerimpl.m_141995_(new ClientboundSetCarriedItemPacket(p_11263_.m_150109_().f_35977_)); @@ -24,7 +24,7 @@ servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_())); servergamepacketlistenerimpl.m_141995_(new ClientboundUpdateTagsPacket(this.f_11195_.m_129895_().m_144442_(this.f_11206_))); this.m_11289_(p_11263_); -@@ -174,7 +_,7 @@ +@@ -176,7 +_,7 @@ this.m_11264_(mutablecomponent.m_130940_(ChatFormatting.YELLOW), ChatType.SYSTEM, Util.f_137441_); servergamepacketlistenerimpl.m_9774_(p_11263_.m_20185_(), p_11263_.m_20186_(), p_11263_.m_20189_(), p_11263_.m_146908_(), p_11263_.m_146909_()); @@ -33,15 +33,15 @@ this.f_11197_.put(p_11263_.m_142081_(), p_11263_); this.m_11268_(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, p_11263_)); -@@ -229,6 +_,7 @@ +@@ -231,6 +_,7 @@ } p_11263_.m_143429_(); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerLoggedIn( p_11263_ ); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedIn( p_11263_ ); } protected void m_11273_(ServerScoreboard p_11274_, ServerPlayer p_11275_) { -@@ -289,6 +_,7 @@ +@@ -291,6 +_,7 @@ compoundtag1 = compoundtag; p_11225_.m_20258_(compoundtag); f_11188_.debug("loading single player"); @@ -49,7 +49,7 @@ } else { compoundtag1 = this.f_11204_.m_78435_(p_11225_); } -@@ -297,6 +_,7 @@ +@@ -299,6 +_,7 @@ } protected void m_6765_(ServerPlayer p_11277_) { @@ -57,15 +57,15 @@ this.f_11204_.m_78433_(p_11277_); ServerStatsCounter serverstatscounter = this.f_11202_.get(p_11277_.m_142081_()); if (serverstatscounter != null) { -@@ -311,6 +_,7 @@ +@@ -313,6 +_,7 @@ } public void m_11286_(ServerPlayer p_11287_) { -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerLoggedOut(p_11287_); - ServerLevel serverlevel = p_11287_.m_9236_(); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerLoggedOut(p_11287_); + ServerLevel serverlevel = p_11287_.m_183503_(); p_11287_.m_36220_(Stats.f_12989_); this.m_6765_(p_11287_); -@@ -447,10 +_,11 @@ +@@ -449,10 +_,11 @@ this.m_11229_(serverplayer, serverlevel1); this.m_11289_(serverplayer); serverlevel1.m_8845_(serverplayer); @@ -74,11 +74,11 @@ this.f_11197_.put(serverplayer.m_142081_(), serverplayer); serverplayer.m_143429_(); serverplayer.m_21153_(serverplayer.m_21223_()); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerRespawnEvent(serverplayer, p_11238_); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerRespawnEvent(serverplayer, p_11238_); if (flag2) { serverplayer.f_8906_.m_141995_(new ClientboundSoundPacket(SoundEvents.f_12377_, SoundSource.BLOCKS, (double)blockpos.m_123341_(), (double)blockpos.m_123342_(), (double)blockpos.m_123343_(), 1.0F, 1.0F)); } -@@ -535,6 +_,7 @@ +@@ -537,6 +_,7 @@ } public void m_5749_(GameProfile p_11254_) { @@ -86,7 +86,7 @@ this.f_11200_.m_11381_(new ServerOpListEntry(p_11254_, this.f_11195_.m_7022_(), this.f_11200_.m_11351_(p_11254_))); ServerPlayer serverplayer = this.m_11259_(p_11254_.getId()); if (serverplayer != null) { -@@ -544,6 +_,7 @@ +@@ -546,6 +_,7 @@ } public void m_5750_(GameProfile p_11281_) { @@ -94,7 +94,7 @@ this.f_11200_.m_11393_(p_11281_); ServerPlayer serverplayer = this.m_11259_(p_11281_.getId()); if (serverplayer != null) { -@@ -726,13 +_,6 @@ +@@ -733,13 +_,6 @@ if (serverstatscounter == null) { File file1 = this.f_11195_.m_129843_(LevelResource.f_78175_).toFile(); File file2 = new File(file1, uuid + ".json"); @@ -108,7 +108,7 @@ serverstatscounter = new ServerStatsCounter(this.f_11195_, file2); this.f_11202_.put(uuid, serverstatscounter); -@@ -751,6 +_,8 @@ +@@ -758,6 +_,8 @@ this.f_11203_.put(uuid, playeradvancements); } @@ -117,7 +117,7 @@ playeradvancements.m_135979_(p_11297_); return playeradvancements; } -@@ -768,7 +_,7 @@ +@@ -787,7 +_,7 @@ } public List m_11314_() { @@ -126,7 +126,7 @@ } @Nullable -@@ -785,6 +_,7 @@ +@@ -804,6 +_,7 @@ playeradvancements.m_135981_(this.f_11195_.m_129889_()); } @@ -134,7 +134,7 @@ this.m_11268_(new ClientboundUpdateTagsPacket(this.f_11195_.m_129895_().m_144442_(this.f_11206_))); ClientboundUpdateRecipesPacket clientboundupdaterecipespacket = new ClientboundUpdateRecipesPacket(this.f_11195_.m_129894_().m_44051_()); -@@ -797,5 +_,13 @@ +@@ -816,5 +_,13 @@ public boolean m_11316_() { return this.f_11209_; diff --git a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch index aa06f3d691..22c4c268d2 100644 --- a/patches/minecraft/net/minecraft/tags/BlockTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/BlockTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/BlockTags.java +++ b/net/minecraft/tags/BlockTags.java -@@ -131,6 +_,14 @@ +@@ -145,6 +_,14 @@ return f_13053_.m_13244_(p_13117_); } diff --git a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch index e19cb2f80d..6b7a6a30ac 100644 --- a/patches/minecraft/net/minecraft/tags/FluidTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/FluidTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/FluidTags.java +++ b/net/minecraft/tags/FluidTags.java -@@ -28,4 +_,12 @@ +@@ -29,4 +_,12 @@ public static List> m_144300_() { return f_144297_; } diff --git a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch index 8b358e49d1..2c3e390140 100644 --- a/patches/minecraft/net/minecraft/tags/ItemTags.java.patch +++ b/patches/minecraft/net/minecraft/tags/ItemTags.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/tags/ItemTags.java +++ b/net/minecraft/tags/ItemTags.java -@@ -82,6 +_,14 @@ +@@ -84,6 +_,14 @@ return f_13163_.m_13244_(p_13195_); } diff --git a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch index 564598aa1c..66ccd9483b 100644 --- a/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/patches/minecraft/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -55,7 +55,7 @@ public int compareTo(MobEffectInstance p_19566_) { int i = 32147; - return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().m_19484_(), p_19566_.m_19544_().m_19484_()).result(); -+ return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().getGuiSortColor(this), p_19566_.m_19544_().getGuiSortColor(this)).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().getGuiSortColor(this), p_19566_.m_19544_().getGuiSortColor(this)).result(); ++ return (this.m_19557_() <= 32147 || p_19566_.m_19557_() <= 32147) && (!this.m_19571_() || !p_19566_.m_19571_()) ? ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19557_(), p_19566_.m_19557_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result() : ComparisonChain.start().compare(this.m_19571_(), p_19566_.m_19571_()).compare(this.m_19544_().getSortOrder(this), p_19566_.m_19544_().getSortOrder(this)).result(); + } + + //======================= FORGE START =========================== diff --git a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch index 56ff2730a7..d18660af80 100644 --- a/patches/minecraft/net/minecraft/world/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Entity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -113,7 +_,7 @@ +@@ -114,7 +_,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,7 +9,7 @@ protected static final Logger f_19849_ = LogManager.getLogger(); public static final String f_146815_ = "id"; public static final String f_146816_ = "Passengers"; -@@ -132,6 +_,7 @@ +@@ -133,6 +_,7 @@ private static final double f_146812_ = 0.0023333333333333335D; public static final String f_146824_ = "UUID"; private static double f_19846_ = 1.0D; @@ -17,15 +17,15 @@ private final EntityType f_19847_; private int f_19848_ = f_19843_.incrementAndGet(); public boolean f_19850_; -@@ -222,6 +_,7 @@ - private boolean f_146813_; +@@ -227,6 +_,7 @@ + private BlockState f_185934_ = null; public Entity(EntityType p_19870_, Level p_19871_) { + super(Entity.class); this.f_19847_ = p_19870_; this.f_19853_ = p_19871_; this.f_19815_ = p_19870_.m_20680_(); -@@ -239,7 +_,11 @@ +@@ -245,7 +_,11 @@ this.f_19804_.m_135372_(f_146800_, 0); this.m_8097_(); this.m_6034_(0.0D, 0.0D, 0.0D); @@ -38,7 +38,7 @@ } public boolean m_20039_(BlockPos p_20040_, BlockState p_20041_) { -@@ -335,6 +_,7 @@ +@@ -341,6 +_,7 @@ if (p_146834_ == Entity.RemovalReason.KILLED) { this.m_146850_(GameEvent.f_157809_); } @@ -46,7 +46,7 @@ } -@@ -599,13 +_,13 @@ +@@ -612,13 +_,13 @@ double d0 = vec3.f_82479_; double d1 = vec3.f_82480_; double d2 = vec3.f_82481_; @@ -63,7 +63,7 @@ if (this.f_19788_ > this.f_19829_ && !blockstate.m_60795_()) { this.f_19829_ = this.m_6059_(); if (this.m_20069_()) { -@@ -637,25 +_,23 @@ +@@ -650,25 +_,23 @@ this.m_146872_(); float f2 = this.m_6041_(); @@ -103,7 +103,7 @@ } } -@@ -689,10 +_,10 @@ +@@ -706,10 +_,10 @@ int j = Mth.m_14107_(this.f_19825_.f_82480_ - (double)0.2F); int k = Mth.m_14107_(this.f_19825_.f_82481_); BlockPos blockpos = new BlockPos(i, j, k); @@ -116,7 +116,7 @@ return blockpos1; } } -@@ -934,7 +_,7 @@ +@@ -920,7 +_,7 @@ protected void m_7355_(BlockPos p_20135_, BlockState p_20136_) { if (!p_20136_.m_60767_().m_76332_()) { BlockState blockstate = this.f_19853_.m_8055_(p_20135_.m_7494_()); @@ -125,7 +125,7 @@ this.m_5496_(soundtype.m_56776_(), soundtype.m_56773_() * 0.15F, soundtype.m_56774_()); } } -@@ -1156,9 +_,10 @@ +@@ -1142,9 +_,10 @@ int k = Mth.m_14107_(this.m_20189_()); BlockPos blockpos = new BlockPos(i, j, k); BlockState blockstate = this.f_19853_.m_8055_(blockpos); @@ -137,7 +137,7 @@ } } -@@ -1479,6 +_,7 @@ +@@ -1465,6 +_,7 @@ if (this.f_146813_) { p_20241_.m_128379_("HasVisualFire", this.f_146813_); } @@ -145,7 +145,7 @@ if (!this.f_19841_.isEmpty()) { ListTag listtag = new ListTag(); -@@ -1490,6 +_,10 @@ +@@ -1476,6 +_,10 @@ p_20241_.m_128365_("Tags", listtag); } @@ -156,7 +156,7 @@ this.m_7380_(p_20241_); if (this.m_20160_()) { ListTag listtag1 = new ListTag(); -@@ -1564,6 +_,9 @@ +@@ -1550,6 +_,9 @@ this.m_146915_(p_20259_.m_128471_("Glowing")); this.m_146917_(p_20259_.m_128451_("TicksFrozen")); this.f_146813_ = p_20259_.m_128471_("HasVisualFire"); @@ -166,7 +166,7 @@ if (p_20259_.m_128425_("Tags", 9)) { this.f_19841_.clear(); ListTag listtag3 = p_20259_.m_128437_("Tags", 8); -@@ -1652,6 +_,8 @@ +@@ -1638,6 +_,8 @@ } else { ItemEntity itementity = new ItemEntity(this.f_19853_, this.m_20185_(), this.m_20186_() + (double)p_19986_, this.m_20189_(), p_19985_); itementity.m_32060_(); @@ -175,7 +175,7 @@ this.f_19853_.m_7967_(itementity); return itementity; } -@@ -1687,6 +_,7 @@ +@@ -1675,6 +_,7 @@ public void m_6083_() { this.m_20256_(Vec3.f_82478_); @@ -183,7 +183,7 @@ this.m_8119_(); if (this.m_20159_()) { this.m_20202_().m_7332_(this); -@@ -1733,6 +_,7 @@ +@@ -1721,6 +_,7 @@ } } @@ -191,7 +191,7 @@ if (p_19967_ || this.m_7341_(p_19966_) && p_19966_.m_7310_(this)) { if (this.m_20159_()) { this.m_8127_(); -@@ -1771,6 +_,7 @@ +@@ -1759,6 +_,7 @@ public void m_6038_() { if (this.f_19824_ != null) { Entity entity = this.f_19824_; @@ -199,7 +199,7 @@ this.f_19824_ = null; entity.m_20351_(this); } -@@ -1936,6 +_,7 @@ +@@ -1924,6 +_,7 @@ return !this.f_19823_.isEmpty(); } @@ -207,7 +207,7 @@ public boolean m_6146_() { return true; } -@@ -2093,7 +_,7 @@ +@@ -2081,7 +_,7 @@ this.m_20254_(8); } @@ -216,7 +216,7 @@ } public void m_6845_(boolean p_20313_) { -@@ -2177,7 +_,7 @@ +@@ -2169,7 +_,7 @@ } protected Component m_5677_() { @@ -225,7 +225,7 @@ } public boolean m_7306_(Entity p_20356_) { -@@ -2232,14 +_,19 @@ +@@ -2225,14 +_,19 @@ @Nullable public Entity m_5489_(ServerLevel p_20118_) { @@ -246,7 +246,7 @@ this.f_19853_.m_46473_().m_6182_("reloading"); Entity entity = this.m_6095_().m_20615_(p_20118_); if (entity != null) { -@@ -2247,17 +_,19 @@ +@@ -2240,17 +_,19 @@ entity.m_7678_(portalinfo.f_77676_.f_82479_, portalinfo.f_77676_.f_82480_, portalinfo.f_77676_.f_82481_, portalinfo.f_77678_, entity.m_146909_()); entity.m_20256_(portalinfo.f_77677_); p_20118_.m_143334_(entity); @@ -268,7 +268,7 @@ } } else { return null; -@@ -2462,8 +_,10 @@ +@@ -2451,8 +_,10 @@ EntityDimensions entitydimensions = this.f_19815_; Pose pose = this.m_20089_(); EntityDimensions entitydimensions1 = this.m_6972_(pose); @@ -280,18 +280,18 @@ this.m_20090_(); boolean flag = (double)entitydimensions1.f_20377_ <= 4.0D && (double)entitydimensions1.f_20378_ <= 4.0D; if (!this.f_19853_.f_46443_ && !this.f_19803_ && !this.f_19794_ && flag && (entitydimensions1.f_20377_ > entitydimensions.f_20377_ || entitydimensions1.f_20378_ > entitydimensions.f_20378_) && !(this instanceof Player)) { -@@ -2471,8 +_,9 @@ +@@ -2460,8 +_,9 @@ double d0 = (double)Math.max(0.0F, entitydimensions1.f_20377_ - entitydimensions.f_20377_) + 1.0E-6D; double d1 = (double)Math.max(0.0F, entitydimensions1.f_20378_ - entitydimensions.f_20378_) + 1.0E-6D; VoxelShape voxelshape = Shapes.m_83064_(AABB.m_165882_(vec3, d0, d1, d0)); + EntityDimensions finalEntitydimensions = entitydimensions1; - this.f_19853_.m_151418_(this, voxelshape, vec3, (double)entitydimensions1.f_20377_, (double)entitydimensions1.f_20378_, (double)entitydimensions1.f_20377_).ifPresent((p_146842_) -> { -- this.m_146884_(p_146842_.m_82520_(0.0D, (double)(-entitydimensions1.f_20378_) / 2.0D, 0.0D)); -+ this.m_146884_(p_146842_.m_82520_(0.0D, (double)(-finalEntitydimensions.f_20378_) / 2.0D, 0.0D)); + this.f_19853_.m_151418_(this, voxelshape, vec3, (double)entitydimensions1.f_20377_, (double)entitydimensions1.f_20378_, (double)entitydimensions1.f_20377_).ifPresent((p_185956_) -> { +- this.m_146884_(p_185956_.m_82520_(0.0D, (double)(-entitydimensions1.f_20378_) / 2.0D, 0.0D)); ++ this.m_146884_(p_185956_.m_82520_(0.0D, (double)(-finalEntitydimensions.f_20378_) / 2.0D, 0.0D)); }); } -@@ -2941,6 +_,7 @@ +@@ -2938,6 +_,7 @@ gameeventlistenerregistrar.m_157862_(this.f_19853_); } } @@ -299,7 +299,7 @@ } -@@ -3048,6 +_,76 @@ +@@ -3045,6 +_,76 @@ public boolean m_142265_(Level p_146843_, BlockPos p_146844_) { return true; } @@ -374,5 +374,5 @@ + /* ================================== Forge End =====================================*/ + - @FunctionalInterface - public interface MoveFunction { + public Level m_183503_() { + return this.f_19853_; diff --git a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch index c0cce220f6..d09dc6b02d 100644 --- a/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/EntityType.java.patch @@ -16,7 +16,7 @@ + private final java.util.function.Predicate> velocityUpdateSupplier; + private final java.util.function.ToIntFunction> trackingRangeSupplier; + private final java.util.function.ToIntFunction> updateIntervalSupplier; -+ private final java.util.function.BiFunction customClientFactory; ++ private final java.util.function.BiFunction customClientFactory; + private final net.minecraftforge.common.util.ReverseTagWrapper> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, net.minecraft.tags.EntityTypeTags::m_13126_); + private static EntityType m_20634_(String p_20635_, EntityType.Builder p_20636_) { @@ -28,7 +28,7 @@ public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_) { + this(p_20574_, p_20575_, p_20576_, p_20577_, p_20578_, p_20579_, p_20580_, p_20581_, p_20582_, p_20583_, EntityType::defaultVelocitySupplier, EntityType::defaultTrackingRangeSupplier, EntityType::defaultUpdateIntervalSupplier, null); + } -+ public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory) { ++ public EntityType(EntityType.EntityFactory p_20574_, MobCategory p_20575_, boolean p_20576_, boolean p_20577_, boolean p_20578_, boolean p_20579_, ImmutableSet p_20580_, EntityDimensions p_20581_, int p_20582_, int p_20583_, final java.util.function.Predicate> velocityUpdateSupplier, final java.util.function.ToIntFunction> trackingRangeSupplier, final java.util.function.ToIntFunction> updateIntervalSupplier, final java.util.function.BiFunction customClientFactory) { this.f_20535_ = p_20574_; this.f_20536_ = p_20575_; this.f_20541_ = p_20579_; @@ -51,7 +51,7 @@ p_20601_.m_47205_(t); } -@@ -543,14 +_,23 @@ +@@ -541,14 +_,23 @@ } public int m_20681_() { @@ -75,11 +75,11 @@ return this != f_20532_ && this != f_20467_ && this != f_20496_ && this != f_20549_ && this != f_20462_ && this != f_147033_ && this != f_20464_ && this != f_20506_ && this != f_20564_ && this != f_20569_; } -@@ -567,6 +_,19 @@ +@@ -565,6 +_,19 @@ return Entity.class; } -+ public T customClientSpawn(net.minecraftforge.fmllegacy.network.FMLPlayMessages.SpawnEntity packet, Level world) { ++ public T customClientSpawn(net.minecraftforge.network.PlayMessages.SpawnEntity packet, Level world) { + if (customClientFactory == null) return this.m_20615_(world); + return customClientFactory.apply(packet, world); + } @@ -95,19 +95,19 @@ public static class Builder { private final EntityType.EntityFactory f_20685_; private final MobCategory f_20686_; -@@ -579,6 +_,11 @@ +@@ -577,6 +_,11 @@ private int f_20693_ = 3; private EntityDimensions f_20694_ = EntityDimensions.m_20395_(0.6F, 1.8F); + private java.util.function.Predicate> velocityUpdateSupplier = EntityType::defaultVelocitySupplier; + private java.util.function.ToIntFunction> trackingRangeSupplier = EntityType::defaultTrackingRangeSupplier; + private java.util.function.ToIntFunction> updateIntervalSupplier = EntityType::defaultUpdateIntervalSupplier; -+ private java.util.function.BiFunction customClientFactory; ++ private java.util.function.BiFunction customClientFactory; + private Builder(EntityType.EntityFactory p_20696_, MobCategory p_20697_) { this.f_20685_ = p_20696_; this.f_20686_ = p_20697_; -@@ -635,12 +_,36 @@ +@@ -633,12 +_,36 @@ return this; } @@ -130,7 +130,7 @@ + * By default, entities are spawned clientside via {@link EntityType#create(Level)}}. + * If you need finer control over the spawning process, use this to get read access to the spawn packet. + */ -+ public EntityType.Builder setCustomClientFactory(java.util.function.BiFunction customClientFactory) { ++ public EntityType.Builder setCustomClientFactory(java.util.function.BiFunction customClientFactory) { + this.customClientFactory = customClientFactory; + return this; + } diff --git a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch index 7524f3987e..bbe9465979 100644 --- a/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/LivingEntity.java.patch @@ -29,7 +29,7 @@ } } -@@ -352,7 +_,7 @@ +@@ -350,7 +_,7 @@ } } @@ -38,7 +38,7 @@ this.m_8127_(); } } else if (this.m_20146_() < this.m_6062_()) { -@@ -716,7 +_,7 @@ +@@ -714,7 +_,7 @@ if (!mobeffectinstance.m_19552_(this, () -> { this.m_141973_(mobeffectinstance, true, (Entity)null); })) { @@ -47,7 +47,7 @@ iterator.remove(); this.m_7285_(mobeffectinstance); } -@@ -766,8 +_,10 @@ +@@ -764,8 +_,10 @@ this.m_6842_(false); } else { Collection collection = this.f_20945_.values(); @@ -60,7 +60,7 @@ this.m_6842_(this.m_21023_(MobEffects.f_19609_)); } -@@ -803,7 +_,7 @@ +@@ -801,7 +_,7 @@ d0 *= 0.5D; } } @@ -69,7 +69,7 @@ return d0; } -@@ -846,7 +_,9 @@ +@@ -844,7 +_,9 @@ boolean flag; for(flag = false; iterator.hasNext(); flag = true) { @@ -80,7 +80,7 @@ iterator.remove(); } -@@ -880,6 +_,7 @@ +@@ -878,6 +_,7 @@ return false; } else { MobEffectInstance mobeffectinstance = this.f_20945_.get(p_147208_.m_19544_()); @@ -88,7 +88,7 @@ if (mobeffectinstance == null) { this.f_20945_.put(p_147208_.m_19544_(), p_147208_); this.m_142540_(p_147208_, p_147209_); -@@ -894,6 +_,9 @@ +@@ -892,6 +_,9 @@ } public boolean m_7301_(MobEffectInstance p_21197_) { @@ -98,7 +98,7 @@ if (this.m_6336_() == MobType.f_21641_) { MobEffect mobeffect = p_21197_.m_19544_(); if (mobeffect == MobEffects.f_19605_ || mobeffect == MobEffects.f_19614_) { -@@ -926,6 +_,7 @@ +@@ -924,6 +_,7 @@ } public boolean m_21195_(MobEffect p_21196_) { @@ -106,7 +106,7 @@ MobEffectInstance mobeffectinstance = this.m_6234_(p_21196_); if (mobeffectinstance != null) { this.m_7285_(mobeffectinstance); -@@ -962,6 +_,8 @@ +@@ -960,6 +_,8 @@ } public void m_5634_(float p_21116_) { @@ -115,7 +115,7 @@ float f = this.m_21223_(); if (f > 0.0F) { this.m_21153_(f + p_21116_); -@@ -982,6 +_,7 @@ +@@ -980,6 +_,7 @@ } public boolean m_6469_(DamageSource p_21016_, float p_21017_) { @@ -123,7 +123,7 @@ if (this.m_6673_(p_21016_)) { return false; } else if (this.f_19853_.f_46443_) { -@@ -1046,11 +_,11 @@ +@@ -1044,11 +_,11 @@ if (entity1 instanceof Player) { this.f_20889_ = 100; this.f_20888_ = (Player)entity1; @@ -139,7 +139,7 @@ if (livingentity != null && livingentity.m_6095_() == EntityType.f_20532_) { this.f_20888_ = (Player)livingentity; } else { -@@ -1123,7 +_,7 @@ +@@ -1121,7 +_,7 @@ if (this instanceof ServerPlayer) { CriteriaTriggers.f_10574_.m_35174_((ServerPlayer)this, p_21016_, f, p_21017_, flag); if (f1 > 0.0F && f1 < 3.4028235E37F) { @@ -148,7 +148,7 @@ } } -@@ -1161,7 +_,7 @@ +@@ -1159,7 +_,7 @@ if (itemstack != null) { if (this instanceof ServerPlayer) { ServerPlayer serverplayer = (ServerPlayer)this; @@ -157,7 +157,7 @@ CriteriaTriggers.f_10551_.m_74431_(serverplayer, itemstack); } -@@ -1231,6 +_,7 @@ +@@ -1229,6 +_,7 @@ } public void m_6667_(DamageSource p_21014_) { @@ -165,7 +165,7 @@ if (!this.m_146910_() && !this.f_20890_) { Entity entity = p_21014_.m_7639_(); LivingEntity livingentity = this.m_21232_(); -@@ -1266,10 +_,10 @@ +@@ -1264,10 +_,10 @@ if (!this.f_19853_.f_46443_) { boolean flag = false; if (p_21269_ instanceof WitherBoss) { @@ -178,7 +178,7 @@ this.f_19853_.m_7731_(blockpos, blockstate, 3); flag = true; } -@@ -1286,12 +_,9 @@ +@@ -1284,12 +_,9 @@ protected void m_6668_(DamageSource p_21192_) { Entity entity = p_21192_.m_7639_(); @@ -194,7 +194,7 @@ boolean flag = this.f_20889_ > 0; if (this.m_6125_() && this.f_19853_.m_46469_().m_46207_(GameRules.f_46135_)) { -@@ -1301,6 +_,10 @@ +@@ -1299,6 +_,10 @@ this.m_5907_(); this.m_21226_(); @@ -205,7 +205,7 @@ } protected void m_5907_() { -@@ -1324,7 +_,8 @@ +@@ -1322,7 +_,8 @@ ResourceLocation resourcelocation = this.m_5743_(); LootTable loottable = this.f_19853_.m_142572_().m_129898_().m_79217_(resourcelocation); LootContext.Builder lootcontext$builder = this.m_7771_(p_21022_, p_21021_); @@ -215,7 +215,7 @@ } protected LootContext.Builder m_7771_(boolean p_21105_, DamageSource p_21106_) { -@@ -1337,6 +_,11 @@ +@@ -1335,6 +_,11 @@ } public void m_147240_(double p_147241_, double p_147242_, double p_147243_) { @@ -224,10 +224,10 @@ + p_147241_ = event.getStrength(); + p_147242_ = event.getRatioX(); + p_147243_ = event.getRatioZ(); - p_147241_ = p_147241_ * (1.0D - this.m_21133_(Attributes.f_22278_)); + p_147241_ *= 1.0D - this.m_21133_(Attributes.f_22278_); if (!(p_147241_ <= 0.0D)) { this.f_19812_ = true; -@@ -1386,15 +_,7 @@ +@@ -1388,15 +_,7 @@ } else { BlockPos blockpos = this.m_142538_(); BlockState blockstate = this.m_146900_(); @@ -244,7 +244,7 @@ } } -@@ -1414,6 +_,11 @@ +@@ -1416,6 +_,11 @@ } public boolean m_142535_(float p_147187_, float p_147188_, DamageSource p_147189_) { @@ -256,7 +256,7 @@ boolean flag = super.m_142535_(p_147187_, p_147188_, p_147189_); int i = this.m_5639_(p_147187_, p_147188_); if (i > 0) { -@@ -1437,9 +_,10 @@ +@@ -1439,9 +_,10 @@ int i = Mth.m_14107_(this.m_20185_()); int j = Mth.m_14107_(this.m_20186_() - (double)0.2F); int k = Mth.m_14107_(this.m_20189_()); @@ -269,7 +269,7 @@ this.m_5496_(soundtype.m_56779_(), soundtype.m_56773_() * 0.5F, soundtype.m_56774_() * 0.75F); } -@@ -1487,9 +_,9 @@ +@@ -1489,9 +_,9 @@ float f2 = f1 - p_21194_; if (f2 > 0.0F && f2 < 3.4028235E37F) { if (this instanceof ServerPlayer) { @@ -281,7 +281,7 @@ } } } -@@ -1509,19 +_,22 @@ +@@ -1511,19 +_,22 @@ protected void m_6475_(DamageSource p_21240_, float p_21241_) { if (!this.m_6673_(p_21240_)) { @@ -306,7 +306,7 @@ this.m_7911_(this.m_6103_() - f2); this.m_146852_(GameEvent.f_157808_, p_21240_.m_7639_()); } -@@ -1576,6 +_,8 @@ +@@ -1578,6 +_,8 @@ } public void m_21011_(InteractionHand p_21012_, boolean p_21013_) { @@ -315,7 +315,7 @@ if (!this.f_20911_ || this.f_20913_ >= this.m_21304_() / 2 || this.f_20913_ < 0) { this.f_20913_ = -1; this.f_20911_ = true; -@@ -1935,14 +_,15 @@ +@@ -1937,14 +_,15 @@ } this.f_19812_ = true; @@ -333,7 +333,7 @@ } protected float m_6108_() { -@@ -1956,11 +_,15 @@ +@@ -1958,11 +_,15 @@ public void m_7023_(Vec3 p_21280_) { if (this.m_6142_() || this.m_6109_()) { double d0 = 0.08D; @@ -342,7 +342,7 @@ if (flag && this.m_21023_(MobEffects.f_19591_)) { - d0 = 0.01D; + if (!gravity.m_22109_(SLOW_FALLING)) gravity.m_22118_(SLOW_FALLING); - this.f_19789_ = 0.0F; + this.m_183634_(); + } else if (gravity.m_22109_(SLOW_FALLING)) { + gravity.m_22130_(SLOW_FALLING); } @@ -350,7 +350,7 @@ FluidState fluidstate = this.f_19853_.m_6425_(this.m_142538_()); if (this.m_20069_() && this.m_6129_() && !this.m_7479_(fluidstate.m_76152_())) { -@@ -1985,6 +_,7 @@ +@@ -1987,6 +_,7 @@ f5 = 0.96F; } @@ -358,7 +358,7 @@ this.m_19920_(f6, p_21280_); this.m_6478_(MoverType.SELF, this.m_20184_()); Vec3 vec36 = this.m_20184_(); -@@ -2063,7 +_,7 @@ +@@ -2065,7 +_,7 @@ } } else { BlockPos blockpos = this.m_20099_(); @@ -367,7 +367,7 @@ float f4 = this.f_19861_ ? f3 * 0.91F : 0.91F; Vec3 vec35 = this.m_21074_(p_21280_, f3); double d2 = vec35.f_82480_; -@@ -2139,7 +_,7 @@ +@@ -2141,7 +_,7 @@ double d0 = Mth.m_14008_(p_21298_.f_82479_, (double)-0.15F, (double)0.15F); double d1 = Mth.m_14008_(p_21298_.f_82481_, (double)-0.15F, (double)0.15F); double d2 = Math.max(p_21298_.f_82480_, (double)-0.15F); @@ -376,7 +376,7 @@ d2 = 0.0D; } -@@ -2167,6 +_,7 @@ +@@ -2169,6 +_,7 @@ } public void m_8119_() { @@ -384,7 +384,7 @@ super.m_8119_(); this.m_21329_(); this.m_21333_(); -@@ -2315,6 +_,7 @@ +@@ -2317,6 +_,7 @@ ItemStack itemstack1 = this.m_6844_(equipmentslot); if (!ItemStack.m_41728_(itemstack1, itemstack)) { @@ -392,7 +392,7 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2538,6 +_,8 @@ +@@ -2540,6 +_,8 @@ boolean flag = this.m_20291_(7); if (flag && !this.f_19861_ && !this.m_20159_() && !this.m_21023_(MobEffects.f_19620_)) { ItemStack itemstack = this.m_6844_(EquipmentSlot.CHEST); @@ -401,7 +401,7 @@ if (itemstack.m_150930_(Items.f_42741_) && ElytraItem.m_41140_(itemstack)) { flag = true; int i = this.f_20937_ + 1; -@@ -2781,8 +_,16 @@ +@@ -2783,8 +_,16 @@ private void m_21329_() { if (this.m_6117_()) { @@ -420,7 +420,7 @@ this.m_142106_(this.f_20935_); } else { this.m_5810_(); -@@ -2835,8 +_,10 @@ +@@ -2837,8 +_,10 @@ public void m_6672_(InteractionHand p_21159_) { ItemStack itemstack = this.m_21120_(p_21159_); if (!itemstack.m_41619_() && !this.m_6117_()) { @@ -432,7 +432,7 @@ if (!this.f_19853_.f_46443_) { this.m_21155_(1, true); this.m_21155_(2, p_21159_ == InteractionHand.OFF_HAND); -@@ -2896,6 +_,9 @@ +@@ -2898,6 +_,9 @@ vec31 = vec31.m_82496_(-this.m_146909_() * ((float)Math.PI / 180F)); vec31 = vec31.m_82524_(-this.m_146908_() * ((float)Math.PI / 180F)); vec31 = vec31.m_82520_(this.m_20185_(), this.m_20188_(), this.m_20189_()); @@ -442,17 +442,17 @@ this.f_19853_.m_7106_(new ItemParticleOption(ParticleTypes.f_123752_, p_21061_), vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, vec3.f_82479_, vec3.f_82480_ + 0.05D, vec3.f_82481_); } -@@ -2908,7 +_,8 @@ - } else { - if (!this.f_20935_.m_41619_() && this.m_6117_()) { - this.m_21137_(this.f_20935_, 16); -- ItemStack itemstack = this.f_20935_.m_41671_(this.f_19853_, this); +@@ -2911,7 +_,8 @@ + } else { + if (!this.f_20935_.m_41619_() && this.m_6117_()) { + this.m_21137_(this.f_20935_, 16); +- ItemStack itemstack = this.f_20935_.m_41671_(this.f_19853_, this); + ItemStack copy = this.f_20935_.m_41777_(); + ItemStack itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, m_21212_(), this.f_20935_.m_41671_(this.f_19853_, this)); - if (itemstack != this.f_20935_) { - this.m_21008_(interactionhand, itemstack); - } -@@ -2933,7 +_,11 @@ + if (itemstack != this.f_20935_) { + this.m_21008_(interactionhand, itemstack); + } +@@ -2937,7 +_,11 @@ public void m_21253_() { if (!this.f_20935_.m_41619_()) { @@ -464,7 +464,7 @@ if (this.f_20935_.m_41781_()) { this.m_21329_(); } -@@ -3080,8 +_,8 @@ +@@ -3084,8 +_,8 @@ } BlockState blockstate = this.f_19853_.m_8055_(p_21141_); @@ -475,7 +475,7 @@ } this.m_20124_(Pose.SLEEPING); -@@ -3097,15 +_,15 @@ +@@ -3101,15 +_,15 @@ private boolean m_21334_() { return this.m_21257_().map((p_147236_) -> { @@ -494,7 +494,7 @@ Vec3 vec31 = BedBlock.m_49458_(this.m_6095_(), this.f_19853_, p_147228_, this.m_146908_()).orElseGet(() -> { BlockPos blockpos = p_147228_.m_7494_(); return new Vec3((double)blockpos.m_123341_() + 0.5D, (double)blockpos.m_123342_() + 0.1D, (double)blockpos.m_123343_() + 0.5D); -@@ -3127,7 +_,9 @@ +@@ -3131,7 +_,9 @@ @Nullable public Direction m_21259_() { BlockPos blockpos = this.m_21257_().orElse((BlockPos)null); @@ -505,7 +505,7 @@ } public boolean m_5830_() { -@@ -3200,6 +_,64 @@ +@@ -3204,6 +_,64 @@ this.m_21166_(p_21191_ == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND); } @@ -570,7 +570,7 @@ public AABB m_6921_() { if (this.m_6844_(EquipmentSlot.HEAD).m_150930_(Items.f_42683_)) { float f = 0.5F; -@@ -3210,6 +_,8 @@ +@@ -3214,6 +_,8 @@ } public static EquipmentSlot m_147233_(ItemStack p_147234_) { @@ -579,7 +579,7 @@ Item item = p_147234_.m_41720_(); if (!p_147234_.m_150930_(Items.f_42047_) && (!(item instanceof BlockItem) || !(((BlockItem)item).m_40614_() instanceof AbstractSkullBlock))) { if (item instanceof ArmorItem) { -@@ -3217,7 +_,7 @@ +@@ -3221,7 +_,7 @@ } else if (p_147234_.m_150930_(Items.f_42741_)) { return EquipmentSlot.CHEST; } else { diff --git a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch index eecabf4f0c..f79ee304b2 100644 --- a/patches/minecraft/net/minecraft/world/entity/Mob.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/Mob.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -202,6 +_,7 @@ +@@ -206,6 +_,7 @@ public void m_6710_(@Nullable LivingEntity p_21544_) { this.f_21362_ = p_21544_; @@ -8,7 +8,7 @@ } public boolean m_6549_(EntityType p_21399_) { -@@ -489,7 +_,7 @@ +@@ -493,7 +_,7 @@ public void m_8107_() { super.m_8107_(); this.f_19853_.m_46473_().m_6180_("looting"); @@ -17,7 +17,7 @@ for(ItemEntity itementity : this.f_19853_.m_45976_(ItemEntity.class, this.m_142469_().m_82377_(1.0D, 0.0D, 1.0D))) { if (!itementity.m_146910_() && !itementity.m_32055_().m_41619_() && !itementity.m_32063_() && this.m_7243_(itementity.m_32055_())) { this.m_7581_(itementity); -@@ -642,6 +_,14 @@ +@@ -646,6 +_,14 @@ this.m_146870_(); } else if (!this.m_21532_() && !this.m_8023_()) { Entity entity = this.f_19853_.m_45930_(this, -1.0D); diff --git a/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch b/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch index 7a4c65b105..3335563a42 100644 --- a/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/MobCategory.java.patch @@ -9,7 +9,7 @@ MONSTER("monster", 70, false, false, 128), CREATURE("creature", 10, true, true, 128), AMBIENT("ambient", 15, true, false, 128), -@@ -15,7 +_,7 @@ +@@ -16,7 +_,7 @@ WATER_AMBIENT("water_ambient", 20, true, false, 64), MISC("misc", -1, true, true, 128); @@ -18,7 +18,7 @@ private static final Map f_21585_ = Arrays.stream(values()).collect(Collectors.toMap(MobCategory::m_21607_, (p_21604_) -> { return p_21604_; })); -@@ -56,6 +_,16 @@ +@@ -57,6 +_,16 @@ public boolean m_21610_() { return this.f_21588_; diff --git a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch index 768470adc2..6d8eda003b 100644 --- a/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/SpawnPlacements.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/SpawnPlacements.java +++ b/net/minecraft/world/entity/SpawnPlacements.java -@@ -151,10 +_,26 @@ +@@ -153,10 +_,26 @@ boolean m_21780_(EntityType p_21781_, ServerLevelAccessor p_21782_, MobSpawnType p_21783_, BlockPos p_21784_, Random p_21785_); } diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index 361bdfe037..7cd7c071c2 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ai/goal/EatBlockGoal.java +++ b/net/minecraft/world/entity/ai/goal/EatBlockGoal.java @@ -61,7 +_,7 @@ - if (this.f_25204_ == 4) { + if (this.f_25204_ == this.m_183277_(4)) { BlockPos blockpos = this.f_25202_.m_142538_(); if (f_25201_.test(this.f_25203_.m_8055_(blockpos))) { - if (this.f_25203_.m_46469_().m_46207_(GameRules.f_46132_)) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch index 9f541ecadc..00ea5e18a5 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.java.patch @@ -25,10 +25,10 @@ this.f_25543_ = this.f_25540_.m_21573_().m_6570_(livingentity, 0); if (this.f_25543_ != null) { return true; -@@ -93,6 +_,18 @@ - this.f_25545_ = livingentity.m_20186_(); - this.f_25546_ = livingentity.m_20189_(); - this.f_25547_ = 4 + this.f_25540_.m_21187_().nextInt(7); +@@ -98,6 +_,18 @@ + this.f_25545_ = livingentity.m_20186_(); + this.f_25546_ = livingentity.m_20189_(); + this.f_25547_ = 4 + this.f_25540_.m_21187_().nextInt(7); + if (this.canPenalize) { + this.f_25547_ += failedPathFindingPenalty; + if (this.f_25540_.m_21573_().m_26570_() != null) { @@ -41,6 +41,6 @@ + failedPathFindingPenalty += 10; + } + } - if (d0 > 1024.0D) { - this.f_25547_ += 10; - } else if (d0 > 256.0D) { + if (d0 > 1024.0D) { + this.f_25547_ += 10; + } else if (d0 > 256.0D) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch index 46d8cc5054..29c76db065 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedBowAttackGoal.java.patch @@ -29,7 +29,7 @@ } public boolean m_8045_() { -@@ -117,7 +_,7 @@ +@@ -121,7 +_,7 @@ } } } else if (--this.f_25786_ <= 0 && this.f_25787_ >= -60) { diff --git a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch index 5b8a0b0347..f72cfe4732 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/goal/RangedCrossbowAttackGoal.java.patch @@ -9,7 +9,7 @@ } public boolean m_8045_() { -@@ -89,7 +_,7 @@ +@@ -93,7 +_,7 @@ this.f_25805_.m_21563_().m_24960_(livingentity, 30.0F, 30.0F); if (this.f_25806_ == RangedCrossbowAttackGoal.CrossbowState.UNCHARGED) { if (!flag2) { @@ -18,7 +18,7 @@ this.f_25806_ = RangedCrossbowAttackGoal.CrossbowState.CHARGING; this.f_25805_.m_6136_(true); } -@@ -113,7 +_,7 @@ +@@ -117,7 +_,7 @@ } } else if (this.f_25806_ == RangedCrossbowAttackGoal.CrossbowState.READY_TO_ATTACK && flag) { this.f_25805_.m_6504_(livingentity, 1.0F); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 2f147ad0d1..b1aedebe7b 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -223,10 +_,10 @@ +@@ -229,10 +_,10 @@ Vec3 vec3 = this.m_7475_(); this.f_26505_ = this.f_26494_.m_20205_() > 0.75F ? this.f_26494_.m_20205_() / 2.0F : 0.75F - this.f_26494_.m_20205_() / 2.0F; Vec3i vec3i = this.f_26496_.m_77400_(); diff --git a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch index 7d4c25a629..7c04f291de 100644 --- a/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java +++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java -@@ -39,7 +_,8 @@ +@@ -41,7 +_,8 @@ super.m_7638_(); } else { if (this.f_26578_ != null) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch index a7b6481554..0efb6ac179 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -201,6 +_,17 @@ +@@ -208,6 +_,17 @@ public void m_27563_(ServerLevel p_27564_, Animal p_27565_) { AgeableMob ageablemob = this.m_142606_(p_27564_, p_27565_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch index 88f51188b9..b8e294d970 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -469,7 +_,7 @@ +@@ -471,7 +_,7 @@ return false; } else { BlockEntity blockentity = this.f_19853_.m_7702_(this.f_27698_); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch index 6a424dc081..bf6583b841 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -415,7 +_,7 @@ +@@ -416,7 +_,7 @@ } } else if (this.m_6898_(itemstack)) { this.m_142075_(p_28153_, p_28154_, itemstack); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch index 7d727e9ea9..1b016e1cf4 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -796,6 +_,17 @@ +@@ -802,6 +_,17 @@ protected void m_8026_() { ServerLevel serverlevel = (ServerLevel)this.f_25114_; Fox fox = (Fox)this.f_25113_.m_142606_(serverlevel, this.f_25115_); @@ -18,7 +18,7 @@ if (fox != null) { ServerPlayer serverplayer = this.f_25113_.m_27592_(); ServerPlayer serverplayer1 = this.f_25115_.m_27592_(); -@@ -867,7 +_,7 @@ +@@ -873,7 +_,7 @@ } protected void m_28686_() { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch index 9d3d94148e..7af7eb13b9 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/IronGolem.java +++ b/net/minecraft/world/entity/animal/IronGolem.java -@@ -119,9 +_,10 @@ +@@ -120,9 +_,10 @@ int i = Mth.m_14107_(this.m_20185_()); int j = Mth.m_14107_(this.m_20186_() - (double)0.2F); int k = Mth.m_14107_(this.m_20189_()); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch index ef20dfe759..9a3474c911 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -40,7 +_,7 @@ +@@ -42,7 +_,7 @@ import net.minecraft.world.level.gameevent.GameEvent; import org.apache.commons.lang3.tuple.Pair; @@ -8,8 +8,8 @@ +public class MushroomCow extends Cow implements Shearable, net.minecraftforge.common.IForgeShearable { private static final EntityDataAccessor f_28908_ = SynchedEntityData.m_135353_(MushroomCow.class, EntityDataSerializers.f_135030_); private static final int f_148934_ = 1024; - private MobEffect f_28909_; -@@ -100,7 +_,7 @@ + @Nullable +@@ -104,7 +_,7 @@ this.m_5496_(soundevent, 1.0F, 1.0F); return InteractionResult.m_19078_(this.f_19853_.f_46443_); @@ -18,7 +18,7 @@ this.m_5851_(SoundSource.PLAYERS); this.m_146852_(GameEvent.f_157781_, p_28941_); if (!this.f_19853_.f_46443_) { -@@ -141,7 +_,16 @@ +@@ -145,7 +_,16 @@ } } @@ -35,7 +35,7 @@ this.f_19853_.m_6269_((Player)null, this, SoundEvents.f_12075_, p_28924_, 1.0F, 1.0F); if (!this.f_19853_.m_5776_()) { ((ServerLevel)this.f_19853_).m_8767_(ParticleTypes.f_123813_, this.m_20185_(), this.m_20227_(0.5D), this.m_20189_(), 1, 0.0D, 0.0D, 0.0D, 0.0D); -@@ -162,10 +_,13 @@ +@@ -166,10 +_,13 @@ cow.m_20331_(this.m_20147_()); this.f_19853_.m_7967_(cow); @@ -50,7 +50,7 @@ } -@@ -234,6 +_,11 @@ +@@ -238,6 +_,11 @@ } return mushroomcow$mushroomtype2; diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch index 2169a41d17..3834dd4950 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -162,7 +_,7 @@ +@@ -164,7 +_,7 @@ if ((this.f_28984_ == null || this.f_28984_.m_25955_()) && !this.m_29038_() && this.m_6898_(itemstack) && p_29021_.m_20280_(this) < 9.0D) { this.m_142075_(p_29021_, p_29022_, itemstack); if (!this.f_19853_.f_46443_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch index 707c96bc5a..c6956a7377 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -235,7 +_,7 @@ +@@ -240,7 +_,7 @@ } if (!this.f_19853_.f_46443_) { diff --git a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch index 3e8e7aa8b2..25cf811137 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/SnowGolem.java +++ b/net/minecraft/world/entity/animal/SnowGolem.java -@@ -39,7 +_,7 @@ +@@ -40,7 +_,7 @@ import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3; @@ -9,7 +9,7 @@ private static final EntityDataAccessor f_29899_ = SynchedEntityData.m_135353_(SnowGolem.class, EntityDataSerializers.f_135027_); private static final byte f_149047_ = 16; private static final float f_149048_ = 1.7F; -@@ -94,7 +_,7 @@ +@@ -97,7 +_,7 @@ this.m_6469_(DamageSource.f_19307_, 1.0F); } @@ -18,16 +18,16 @@ return; } -@@ -105,7 +_,7 @@ +@@ -108,7 +_,7 @@ j = Mth.m_14107_(this.m_20186_()); k = Mth.m_14107_(this.m_20189_() + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); - BlockPos blockpos = new BlockPos(i, j, k); -- if (this.f_19853_.m_8055_(blockpos).m_60795_() && this.f_19853_.m_46857_(blockpos).m_47505_(blockpos) < 0.8F && blockstate.m_60710_(this.f_19853_, blockpos)) { -+ if (this.f_19853_.m_46859_(blockpos) && this.f_19853_.m_46857_(blockpos).m_47505_(blockpos) < 0.8F && blockstate.m_60710_(this.f_19853_, blockpos)) { - this.f_19853_.m_46597_(blockpos, blockstate); + BlockPos blockpos1 = new BlockPos(i, j, k); +- if (this.f_19853_.m_8055_(blockpos1).m_60795_() && blockstate.m_60710_(this.f_19853_, blockpos1)) { ++ if (this.f_19853_.m_46859_(blockpos) && blockstate.m_60710_(this.f_19853_, blockpos)) { + this.f_19853_.m_46597_(blockpos1, blockstate); } } -@@ -131,7 +_,7 @@ +@@ -134,7 +_,7 @@ protected InteractionResult m_6071_(Player p_29920_, InteractionHand p_29921_) { ItemStack itemstack = p_29920_.m_21120_(p_29921_); @@ -36,7 +36,7 @@ this.m_5851_(SoundSource.PLAYERS); this.m_146852_(GameEvent.f_157781_, p_29920_); if (!this.f_19853_.f_46443_) { -@@ -190,5 +_,21 @@ +@@ -193,5 +_,21 @@ public Vec3 m_7939_() { return new Vec3(0.0D, (double)(0.75F * this.m_20192_()), (double)(this.m_20205_() * 0.4F)); diff --git a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch index c1731838b2..bbf3145e35 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/Wolf.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Wolf.java +++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -348,7 +_,7 @@ +@@ -353,7 +_,7 @@ itemstack.m_41774_(1); } diff --git a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 66176e253e..d141ecb194 100644 --- a/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -286,6 +_,7 @@ +@@ -288,6 +_,7 @@ this.f_30520_.m_19164_(this); this.m_7493_(); @@ -8,7 +8,7 @@ } protected void m_7493_() { -@@ -344,9 +_,9 @@ +@@ -346,9 +_,9 @@ protected void m_7355_(BlockPos p_30584_, BlockState p_30585_) { if (!p_30585_.m_60767_().m_76332_()) { BlockState blockstate = this.f_19853_.m_8055_(p_30584_.m_7494_()); @@ -20,7 +20,7 @@ } if (this.m_20160_() && this.f_30523_) { -@@ -698,6 +_,7 @@ +@@ -700,6 +_,7 @@ this.m_20334_(vec3.f_82479_, d1, vec3.f_82481_); this.m_30655_(true); this.f_19812_ = true; @@ -28,7 +28,7 @@ if (f1 > 0.0F) { float f2 = Mth.m_14031_(this.m_146908_() * ((float)Math.PI / 180F)); float f3 = Mth.m_14089_(this.m_146908_() * ((float)Math.PI / 180F)); -@@ -1027,6 +_,25 @@ +@@ -1029,6 +_,25 @@ this.m_7505_(); return super.m_6518_(p_30555_, p_30556_, p_30557_, p_30558_, p_30559_); diff --git a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index 8315f1ab16..f3d5a0a698 100644 --- a/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -209,7 +_,7 @@ +@@ -219,7 +_,7 @@ int k1 = this.m_31502_() - 1; this.f_31430_.m_142711_(1.0F - (float)k1 / 220.0F); if (k1 <= 0) { @@ -9,7 +9,7 @@ this.f_19853_.m_46518_(this, this.m_20185_(), this.m_20188_(), this.m_20189_(), 7.0F, false, explosion$blockinteraction); if (!this.m_20067_()) { this.f_19853_.m_6798_(1023, this.m_142538_(), 0); -@@ -270,7 +_,7 @@ +@@ -280,7 +_,7 @@ if (this.f_31429_ > 0) { --this.f_31429_; @@ -18,7 +18,7 @@ int j1 = Mth.m_14107_(this.m_20186_()); int i2 = Mth.m_14107_(this.m_20185_()); int j2 = Mth.m_14107_(this.m_20189_()); -@@ -284,7 +_,7 @@ +@@ -294,7 +_,7 @@ int i1 = j2 + k2; BlockPos blockpos = new BlockPos(l2, l, i1); BlockState blockstate = this.f_19853_.m_8055_(blockpos); @@ -27,7 +27,7 @@ flag = this.f_19853_.m_46953_(blockpos, true, this) || flag; } } -@@ -305,6 +_,7 @@ +@@ -315,6 +_,7 @@ } } diff --git a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch index 5b83c04174..463abfea57 100644 --- a/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -41,6 +_,10 @@ - private UUID f_31988_; +@@ -43,6 +_,10 @@ + @Nullable private UUID f_31982_; public final float f_31983_; + /** @@ -11,7 +11,7 @@ public ItemEntity(EntityType p_31991_, Level p_31992_) { super(p_31991_, p_31992_); -@@ -57,6 +_,7 @@ +@@ -59,6 +_,7 @@ this.m_6034_(p_149664_, p_149665_, p_149666_); this.m_20334_(p_149668_, p_149669_, p_149670_); this.m_32045_(p_149667_); @@ -19,7 +19,7 @@ } private ItemEntity(ItemEntity p_31994_) { -@@ -80,6 +_,7 @@ +@@ -82,6 +_,7 @@ } public void m_8119_() { @@ -101,7 +101,7 @@ + ItemStack copy = itemstack.m_41777_(); + if (this.f_31986_ == 0 && (this.f_31982_ == null || lifespan - this.f_31985_ <= 200 || this.f_31982_.equals(p_32040_.m_142081_())) && (hook == 1 || i <= 0 || p_32040_.m_150109_().m_36054_(itemstack))) { + copy.m_41764_(copy.m_41613_() - m_32055_().m_41613_()); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerItemPickupEvent(p_32040_, this, copy); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerItemPickupEvent(p_32040_, this, copy); p_32040_.m_7938_(this, i); if (itemstack.m_41619_()) { this.m_146870_(); diff --git a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch index 5c989c6e35..df1f87c774 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -98,7 +_,6 @@ +@@ -105,7 +_,6 @@ } public void m_6710_(@Nullable LivingEntity p_32537_) { @@ -8,7 +8,7 @@ AttributeInstance attributeinstance = this.m_21051_(Attributes.f_22279_); if (p_32537_ == null) { this.f_32477_ = 0; -@@ -113,6 +_,7 @@ +@@ -120,6 +_,7 @@ } } @@ -16,7 +16,7 @@ } protected void m_8097_() { -@@ -186,7 +_,7 @@ +@@ -194,7 +_,7 @@ boolean m_32534_(Player p_32535_) { ItemStack itemstack = p_32535_.m_150109_().f_35975_.get(3); @@ -25,7 +25,7 @@ return false; } else { Vec3 vec3 = p_32535_.m_20252_(1.0F).m_82541_(); -@@ -265,7 +_,9 @@ +@@ -273,7 +_,9 @@ boolean flag = blockstate.m_60767_().m_76334_(); boolean flag1 = blockstate.m_60819_().m_76153_(FluidTags.f_13131_); if (flag && !flag1) { @@ -36,7 +36,7 @@ if (flag2 && !this.m_20067_()) { this.f_19853_.m_6263_((Player)null, this.f_19854_, this.f_19855_, this.f_19856_, SoundEvents.f_11852_, this.m_5720_(), 1.0F, 1.0F); this.m_5496_(SoundEvents.f_11852_, 1.0F, 1.0F); -@@ -382,7 +_,7 @@ +@@ -407,7 +_,7 @@ public boolean m_8036_() { if (this.f_32554_.m_32530_() == null) { return false; @@ -44,8 +44,8 @@ + } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_32554_.f_19853_, this.f_32554_)) { return false; } else { - return this.f_32554_.m_21187_().nextInt(2000) == 0; -@@ -402,7 +_,7 @@ + return this.f_32554_.m_21187_().nextInt(m_186073_(2000)) == 0; +@@ -427,7 +_,7 @@ BlockState blockstate2 = this.f_32554_.m_32530_(); if (blockstate2 != null) { blockstate2 = Block.m_49931_(blockstate2, this.f_32554_.f_19853_, blockpos); @@ -54,7 +54,7 @@ level.m_7731_(blockpos, blockstate2, 3); level.m_142346_(this.f_32554_, GameEvent.f_157797_, blockpos); this.f_32554_.m_32521_((BlockState)null); -@@ -412,7 +_,7 @@ +@@ -437,7 +_,7 @@ } private boolean m_32558_(Level p_32559_, BlockPos p_32560_, BlockState p_32561_, BlockState p_32562_, BlockState p_32563_, BlockPos p_32564_) { @@ -63,7 +63,7 @@ } } -@@ -501,7 +_,7 @@ +@@ -527,7 +_,7 @@ public boolean m_8036_() { if (this.f_32583_.m_32530_() != null) { return false; @@ -71,4 +71,4 @@ + } else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_32583_.f_19853_, this.f_32583_)) { return false; } else { - return this.f_32583_.m_21187_().nextInt(20) == 0; + return this.f_32583_.m_21187_().nextInt(m_186073_(20)) == 0; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch index d39b340fc7..c5f884f9e5 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Evoker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Evoker.java +++ b/net/minecraft/world/entity/monster/Evoker.java -@@ -272,7 +_,7 @@ +@@ -273,7 +_,7 @@ return false; } else if (Evoker.this.f_19797_ < this.f_33775_) { return false; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch index f6c2bbf85c..8a0d749f07 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Pillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Pillager.java +++ b/net/minecraft/world/entity/monster/Pillager.java -@@ -121,7 +_,7 @@ +@@ -119,7 +_,7 @@ public AbstractIllager.IllagerArmPose m_6768_() { if (this.m_33309_()) { return AbstractIllager.IllagerArmPose.CROSSBOW_CHARGE; diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch index 01456c1b9e..56f47545a4 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -142,7 +_,7 @@ +@@ -144,7 +_,7 @@ this.m_21051_(Attributes.f_22279_).m_22100_(Mth.m_14139_(0.1D, d1, d0)); } diff --git a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch index cce9f52ef3..8e64cf7ab8 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/Silverfish.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/Silverfish.java +++ b/net/minecraft/world/entity/monster/Silverfish.java -@@ -135,7 +_,7 @@ +@@ -138,7 +_,7 @@ return false; } else { Random random = this.f_25725_.m_21187_(); -- if (this.f_25725_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && random.nextInt(10) == 0) { +- if (this.f_25725_.f_19853_.m_46469_().m_46207_(GameRules.f_46132_) && random.nextInt(m_186073_(10)) == 0) { + if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.f_25725_.f_19853_, this.f_25725_) && random.nextInt(10) == 0) { this.f_33555_ = Direction.m_122404_(random); BlockPos blockpos = (new BlockPos(this.f_25725_.m_20185_(), this.f_25725_.m_20186_() + 0.5D, this.f_25725_.m_20189_())).m_142300_(this.f_33555_); BlockState blockstate = this.f_25725_.f_19853_.m_8055_(blockpos); -@@ -204,7 +_,7 @@ +@@ -207,7 +_,7 @@ BlockState blockstate = level.m_8055_(blockpos1); Block block = blockstate.m_60734_(); if (block instanceof InfestedBlock) { diff --git a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch index 5f24c79d1e..100504f861 100644 --- a/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -119,7 +_,7 @@ +@@ -122,7 +_,7 @@ if (!this.f_19853_.f_46443_ && this.m_6084_() && this.m_34408_()) { int i = this.m_34410_(); this.f_34365_ -= i; @@ -9,7 +9,7 @@ this.m_34398_((ServerLevel)this.f_19853_); } } -@@ -221,7 +_,7 @@ +@@ -224,7 +_,7 @@ if (!this.m_20067_()) { p_34399_.m_5898_((Player)null, 1027, this.m_142538_(), 0); } diff --git a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch index dc1af63ed8..1d01d54e54 100644 --- a/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -250,7 +_,7 @@ +@@ -251,7 +_,7 @@ public InteractionResult m_6071_(Player p_35472_, InteractionHand p_35473_) { ItemStack itemstack = p_35472_.m_21120_(p_35473_); @@ -9,7 +9,7 @@ if (this.m_6162_()) { this.m_35518_(); return InteractionResult.m_19078_(this.f_19853_.f_46443_); -@@ -651,7 +_,8 @@ +@@ -655,7 +_,8 @@ } protected Component m_5677_() { @@ -19,7 +19,7 @@ } public void m_7822_(byte p_35391_) { -@@ -703,7 +_,7 @@ +@@ -707,7 +_,7 @@ } public void m_8038_(ServerLevel p_35409_, LightningBolt p_35410_) { @@ -28,7 +28,7 @@ f_19849_.info("Villager {} was struck by lightning {}.", this, p_35410_); Witch witch = EntityType.f_20495_.m_20615_(p_35409_); witch.m_7678_(this.m_20185_(), this.m_20186_(), this.m_20189_(), this.m_146908_(), this.m_146909_()); -@@ -715,6 +_,7 @@ +@@ -719,6 +_,7 @@ } witch.m_21530_(); diff --git a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch index 4136246203..6f92962750 100644 --- a/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/player/Player.java.patch @@ -31,7 +31,7 @@ } public void m_8119_() { -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPlayerPreTick(this); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerPreTick(this); this.f_19794_ = this.m_5833_(); if (this.m_5833_()) { this.f_19861_ = false; @@ -48,7 +48,7 @@ this.m_36372_(); this.f_36087_.m_41518_(); this.m_7594_(); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.onPlayerPostTick(this); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerPostTick(this); } public boolean m_36341_() { @@ -206,7 +206,7 @@ boolean flag1 = false; - int i = 0; + float i = (float)this.m_21133_(Attributes.f_22282_); // Forge: Initialize this value to the attack knockback attribute of the player, which is by default 0 - i = i + EnchantmentHelper.m_44894_(this); + i += EnchantmentHelper.m_44894_(this); if (this.m_20142_() && flag) { this.f_19853_.m_6263_((Player)null, this.m_20185_(), this.m_20186_(), this.m_20189_(), SoundEvents.f_12314_, this.m_5720_(), 1.0F, 1.0F); @@ -1055,8 +_,10 @@ @@ -220,7 +220,7 @@ + f *= hitResult.getDamageModifier(); } - f = f + f1; + f += f1; @@ -1064,9 +_,7 @@ double d0 = (double)(this.f_19787_ - this.f_19867_); if (flag && !flag2 && !flag1 && this.f_19861_ && d0 < (double)this.m_6113_()) { diff --git a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index cbe04f54db..f3c9ec1e7f 100644 --- a/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -14,7 +14,7 @@ } + entity.m_6021_(event.getTargetX(), event.getTargetY(), event.getTargetZ()); - entity.f_19789_ = 0.0F; + entity.m_183634_(); - entity.m_6469_(DamageSource.f_19315_, 5.0F); + entity.m_6469_(DamageSource.f_19315_, event.getAttackDamage()); + } //Forge: End diff --git a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch index 4be881557a..7bb4d0d4b2 100644 --- a/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch +++ b/patches/minecraft/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -809,7 +_,7 @@ +@@ -812,7 +_,7 @@ } } @@ -9,7 +9,7 @@ VINDICATOR(EntityType.f_20493_, new int[]{0, 0, 2, 0, 1, 4, 2, 5}), EVOKER(EntityType.f_20568_, new int[]{0, 0, 0, 0, 0, 1, 1, 2}), PILLAGER(EntityType.f_20513_, new int[]{0, 4, 3, 3, 4, 4, 4, 2}), -@@ -823,6 +_,20 @@ +@@ -826,6 +_,20 @@ private RaiderType(EntityType p_37821_, int[] p_37822_) { this.f_37814_ = p_37821_; this.f_37815_ = p_37822_; diff --git a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch index b0e0e1a137..a30261c7ed 100644 --- a/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -20,7 +20,7 @@ p_150479_.m_7471_(p_150480_, false); @@ -100,8 +_,11 @@ Map map = EnchantmentHelper.m_44831_(itemstack1); - j = j + itemstack.m_41610_() + (itemstack2.m_41619_() ? 0 : itemstack2.m_41610_()); + j += itemstack.m_41610_() + (itemstack2.m_41619_() ? 0 : itemstack2.m_41610_()); this.f_39000_ = 0; + boolean flag = false; + diff --git a/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch index f7c25e4c84..4075320550 100644 --- a/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/FurnaceResultSlot.java.patch @@ -4,6 +4,6 @@ } this.f_39540_ = 0; -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerSmeltedEvent(this.f_39539_, p_39558_); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerSmeltedEvent(this.f_39539_, p_39558_); } } diff --git a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch index 14c3c0923a..f9582ab53e 100644 --- a/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/MenuType.java.patch @@ -5,7 +5,7 @@ import net.minecraft.world.entity.player.Inventory; -public class MenuType { -+public class MenuType extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeContainerType { ++public class MenuType extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeMenuType { public static final MenuType f_39957_ = m_39988_("generic_9x1", ChestMenu::m_39234_); public static final MenuType f_39958_ = m_39988_("generic_9x2", ChestMenu::m_39243_); public static final MenuType f_39959_ = m_39988_("generic_9x3", ChestMenu::m_39255_); @@ -17,8 +17,8 @@ + + @Override + public T create(int windowId, Inventory playerInv, net.minecraft.network.FriendlyByteBuf extraData) { -+ if (this.f_39981_ instanceof net.minecraftforge.fmllegacy.network.IContainerFactory) { -+ return ((net.minecraftforge.fmllegacy.network.IContainerFactory) this.f_39981_).create(windowId, playerInv, extraData); ++ if (this.f_39981_ instanceof net.minecraftforge.network.IContainerFactory) { ++ return ((net.minecraftforge.network.IContainerFactory) this.f_39981_).create(windowId, playerInv, extraData); + } + return m_39985_(windowId, playerInv); } diff --git a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch index 4f2d48e8c5..aa5506c92f 100644 --- a/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch +++ b/patches/minecraft/net/minecraft/world/inventory/ResultSlot.java.patch @@ -4,7 +4,7 @@ protected void m_5845_(ItemStack p_40185_) { if (this.f_40164_ > 0) { p_40185_.m_41678_(this.f_40163_.f_19853_, this.f_40163_, this.f_40164_); -+ net.minecraftforge.fmllegacy.hooks.BasicEventHooks.firePlayerCraftingEvent(this.f_40163_, p_40185_, this.f_40162_); ++ net.minecraftforge.event.ForgeEventFactory.firePlayerCraftingEvent(this.f_40163_, p_40185_, this.f_40162_); } if (this.f_40218_ instanceof RecipeHolder) { diff --git a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch index 71cacf8c35..c1221179ae 100644 --- a/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BlockItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -78,9 +_,9 @@ +@@ -80,9 +_,9 @@ } } @@ -12,7 +12,7 @@ if (player == null || !player.m_150110_().f_35937_) { itemstack.m_41774_(1); } -@@ -91,10 +_,16 @@ +@@ -93,10 +_,16 @@ } } @@ -29,7 +29,7 @@ @Nullable public BlockPlaceContext m_7732_(BlockPlaceContext p_40609_) { return p_40609_; -@@ -201,11 +_,19 @@ +@@ -200,11 +_,19 @@ } public Block m_40614_() { diff --git a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch index 9f4b2b4a7d..81fccaa062 100644 --- a/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/BucketItem.java.patch @@ -13,7 +13,7 @@ + } + + /** -+ * @param supplier A fluid supplier such as {@link net.minecraftforge.fmllegacy.RegistryObject} ++ * @param supplier A fluid supplier such as {@link net.minecraftforge.registries.RegistryObject} + */ + public BucketItem(java.util.function.Supplier supplier, Item.Properties builder) { + super(builder); diff --git a/patches/minecraft/net/minecraft/world/item/Item.java.patch b/patches/minecraft/net/minecraft/world/item/Item.java.patch index a6efa142b3..358108e9d9 100644 --- a/patches/minecraft/net/minecraft/world/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Item.java.patch @@ -12,7 +12,7 @@ protected static final UUID f_41374_ = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); protected static final UUID f_41375_ = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); public static final int f_150884_ = 64; -@@ -92,7 +_,8 @@ +@@ -95,7 +_,8 @@ f_150883_.error("Item classes should end with Item and {} doesn't.", (Object)s); } } @@ -22,7 +22,7 @@ } public void m_5929_(Level p_41428_, LivingEntity p_41429_, ItemStack p_41430_, int p_41431_) { -@@ -138,10 +_,12 @@ +@@ -141,10 +_,12 @@ return this.m_41472_() ? p_41411_.m_5584_(p_41410_, p_41409_) : p_41409_; } @@ -35,27 +35,7 @@ public final int m_41462_() { return this.f_41371_; } -@@ -151,16 +_,15 @@ - } - - public boolean m_142522_(ItemStack p_150899_) { -- return p_150899_.m_41768_(); -+ return p_150899_.m_41720_().showDurabilityBar(p_150899_); - } - - public int m_142158_(ItemStack p_150900_) { -- return Math.round(13.0F - (float)p_150900_.m_41773_() * 13.0F / (float)this.f_41371_); -+ return Math.round(13.0F - ((float) p_150900_.m_41720_().getDurabilityForDisplay(p_150900_) * 13.0F)); - } - - public int m_142159_(ItemStack p_150901_) { -- float f = Math.max(0.0F, ((float)this.f_41371_ - (float)p_150901_.m_41773_()) / (float)this.f_41371_); -- return Mth.m_14169_(f / 3.0F, 1.0F, 1.0F); -+ return p_150901_.m_41720_().getRGBDurabilityForDisplay(p_150901_); - } - - public boolean m_142207_(ItemStack p_150888_, Slot p_150889_, ClickAction p_150890_, Player p_150891_) { -@@ -216,10 +_,12 @@ +@@ -219,10 +_,12 @@ } @Nullable @@ -68,7 +48,7 @@ public boolean m_41470_() { return this.f_41378_ != null; } -@@ -282,7 +_,7 @@ +@@ -285,7 +_,7 @@ } public boolean m_8120_(ItemStack p_41456_) { @@ -77,7 +57,7 @@ } protected static BlockHitResult m_41435_(Level p_41436_, Player p_41437_, ClipContext.Fluid p_41438_) { -@@ -295,8 +_,8 @@ +@@ -298,8 +_,8 @@ float f5 = Mth.m_14031_(-f * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; @@ -88,7 +68,7 @@ return p_41436_.m_45547_(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_41438_, p_41437_)); } -@@ -312,6 +_,7 @@ +@@ -315,6 +_,7 @@ } protected boolean m_41389_(CreativeModeTab p_41390_) { @@ -96,7 +76,7 @@ CreativeModeTab creativemodetab = this.m_41471_(); return creativemodetab != null && (p_41390_ == CreativeModeTab.f_40754_ || p_41390_ == creativemodetab); } -@@ -325,12 +_,26 @@ +@@ -328,12 +_,26 @@ return false; } @@ -124,7 +104,7 @@ } public ItemStack m_7968_() { -@@ -371,6 +_,32 @@ +@@ -374,6 +_,32 @@ return true; } @@ -157,15 +137,15 @@ public static class Properties { int f_41478_ = 64; int f_41479_; -@@ -379,6 +_,7 @@ - Rarity f_41482_ = Rarity.COMMON; +@@ -385,6 +_,7 @@ + @Nullable FoodProperties f_41483_; boolean f_41484_; + private boolean canRepair = true; public Item.Properties m_41489_(FoodProperties p_41490_) { this.f_41483_ = p_41490_; -@@ -421,6 +_,11 @@ +@@ -427,6 +_,11 @@ public Item.Properties m_41486_() { this.f_41484_ = true; diff --git a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch index 0ccd711ee8..97ad17f991 100644 --- a/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ItemStack.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -74,7 +_,7 @@ +@@ -71,7 +_,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public final class ItemStack { +public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider implements net.minecraftforge.common.extensions.IForgeItemStack { public static final Codec f_41582_ = RecordCodecBuilder.create((p_41697_) -> { - return p_41697_.group(Registry.f_122827_.fieldOf("id").forGetter((p_150946_) -> { + return p_41697_.group(Registry.f_122827_.m_194605_().fieldOf("id").forGetter((p_150946_) -> { return p_150946_.f_41589_; -@@ -84,6 +_,9 @@ +@@ -81,6 +_,9 @@ return Optional.ofNullable(p_150939_.f_41590_); })).apply(p_41697_, ItemStack::new); }); @@ -217,7 +217,7 @@ return multimap; } -@@ -1005,6 +_,23 @@ +@@ -955,6 +_,23 @@ public boolean m_41614_() { return this.m_41720_().m_41472_(); diff --git a/patches/minecraft/net/minecraft/world/item/Items.java.patch b/patches/minecraft/net/minecraft/world/item/Items.java.patch index a94e5ec13f..16bbaba9a1 100644 --- a/patches/minecraft/net/minecraft/world/item/Items.java.patch +++ b/patches/minecraft/net/minecraft/world/item/Items.java.patch @@ -8,7 +8,7 @@ public class Items { public static final Item f_41852_ = m_42810_(Blocks.f_50016_, new AirItem(Blocks.f_50016_, new Item.Properties())); public static final Item f_41905_ = m_42807_(Blocks.f_50069_, CreativeModeTab.f_40749_); -@@ -1137,11 +_,23 @@ +@@ -1138,11 +_,23 @@ } private static Item m_151089_(Block p_151090_, CreativeModeTab p_151091_, Block... p_151092_) { diff --git a/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch b/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch index 75fb7fd47d..857149edae 100644 --- a/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/RecordItem.java.patch @@ -26,7 +26,7 @@ + * + * @param comparatorValue The value this music disc should output on the comparator. Must be between 0 and 15. + * @param soundSupplier A supplier that provides the sound that should be played. Use a -+ * {@link net.minecraftforge.fmllegacy.RegistryObject}{@code } or a ++ * {@link net.minecraftforge.registries.RegistryObject} or a + * {@link net.minecraftforge.registries.IRegistryDelegate} for this parameter. + * @param builder A set of {@link Item.Properties} that describe this item. + */ diff --git a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch index bd6897c0ea..a8dc90fa4e 100644 --- a/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShearsItem.java.patch @@ -1,10 +1,9 @@ --- a/net/minecraft/world/item/ShearsItem.java +++ b/net/minecraft/world/item/ShearsItem.java -@@ -38,4 +_,30 @@ - return 15.0F; +@@ -48,6 +_,32 @@ } } -+ + + @Override + public net.minecraft.world.InteractionResult m_6880_(ItemStack stack, net.minecraft.world.entity.player.Player playerIn, LivingEntity entity, net.minecraft.world.InteractionHand hand) { + if (entity.f_19853_.f_46443_) return net.minecraft.world.InteractionResult.PASS; @@ -30,4 +29,7 @@ + public boolean canPerformAction(ItemStack stack, net.minecraftforge.common.ToolAction toolAction) { + return net.minecraftforge.common.ToolActions.DEFAULT_SHEARS_ACTIONS.contains(toolAction); + } - } ++ + public InteractionResult m_6225_(UseOnContext p_186371_) { + Level level = p_186371_.m_43725_(); + BlockPos blockpos = p_186371_.m_8083_(); diff --git a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch index 69944c432d..2722f5ca08 100644 --- a/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/ShieldItem.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/item/ShieldItem.java +++ b/net/minecraft/world/item/ShieldItem.java -@@ -49,4 +_,11 @@ - public static DyeColor m_43102_(ItemStack p_43103_) { - return DyeColor.m_41053_(p_43103_.m_41698_("BlockEntityTag").m_128451_("Base")); +@@ -51,4 +_,11 @@ + CompoundTag compoundtag = BlockItem.m_186336_(p_43103_); + return compoundtag != null ? DyeColor.m_41053_(compoundtag.m_128451_("Base")) : DyeColor.WHITE; } + + /* ******************** FORGE START ******************** */ diff --git a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch index 7daa9b779e..0b7b0c0114 100644 --- a/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch +++ b/patches/minecraft/net/minecraft/world/item/alchemy/Potion.java.patch @@ -1,16 +1,17 @@ --- a/net/minecraft/world/item/alchemy/Potion.java +++ b/net/minecraft/world/item/alchemy/Potion.java -@@ -7,7 +_,8 @@ +@@ -7,8 +_,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffectInstance; -public class Potion { + @Nullable +public class Potion extends net.minecraftforge.registries.ForgeRegistryEntry { + private final net.minecraftforge.common.util.ReverseTagWrapper reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.SerializationTags.m_13199_().m_144452_(Registry.f_122905_)); private final String f_43481_; private final ImmutableList f_43482_; -@@ -22,6 +_,14 @@ +@@ -23,6 +_,14 @@ public Potion(@Nullable String p_43484_, MobEffectInstance... p_43485_) { this.f_43481_ = p_43484_; this.f_43482_ = ImmutableList.copyOf(p_43485_); diff --git a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch index 002296845a..3581de2a5f 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/Ingredient.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Ingredient.java +++ b/net/minecraft/world/item/crafting/Ingredient.java -@@ -29,15 +_,24 @@ +@@ -29,17 +_,26 @@ import net.minecraft.world.level.ItemLike; public class Ingredient implements Predicate { @@ -12,7 +12,9 @@ + public static final Ingredient f_43901_ = new Ingredient(Stream.empty()); private final Ingredient.Value[] f_43902_; + @Nullable private ItemStack[] f_43903_; + @Nullable private IntList f_43904_; + private final boolean isSimple; @@ -20,12 +22,12 @@ this.f_43902_ = p_43907_.toArray((p_43933_) -> { return new Ingredient.Value[p_43933_]; }); -+ this.isSimple = !net.minecraftforge.fmllegacy.DatagenModLoader.isRunningDataGen() && !Arrays.stream(f_43902_).anyMatch(list -> list.m_6223_().stream().anyMatch(stack -> stack.m_41720_().isDamageable(stack))); ++ this.isSimple = !net.minecraftforge.data.loading.DatagenModLoader.isRunningDataGen() && !Arrays.stream(f_43902_).anyMatch(list -> list.m_6223_().stream().anyMatch(stack -> stack.m_41720_().isDamageable(stack))); + Ingredient.INSTANCES.add(this); } public ItemStack[] m_43908_() { -@@ -92,6 +_,10 @@ +@@ -94,6 +_,10 @@ public final void m_43923_(FriendlyByteBuf p_43924_) { this.m_43948_(); @@ -36,7 +38,7 @@ p_43924_.m_178352_(Arrays.asList(this.f_43903_), FriendlyByteBuf::m_130055_); } -@@ -113,6 +_,25 @@ +@@ -115,6 +_,25 @@ return this.f_43902_.length == 0 && (this.f_43903_ == null || this.f_43903_.length == 0) && (this.f_43904_ == null || this.f_43904_.isEmpty()); } @@ -62,7 +64,7 @@ public static Ingredient m_43938_(Stream p_43939_) { Ingredient ingredient = new Ingredient(p_43939_); return ingredient.f_43902_.length == 0 ? f_43901_ : ingredient; -@@ -141,11 +_,15 @@ +@@ -143,11 +_,15 @@ } public static Ingredient m_43940_(FriendlyByteBuf p_43941_) { @@ -79,7 +81,7 @@ if (p_43918_.isJsonObject()) { return m_43938_(Stream.of(m_43919_(p_43918_.getAsJsonObject()))); } else if (p_43918_.isJsonArray()) { -@@ -182,6 +_,12 @@ +@@ -184,6 +_,12 @@ } } @@ -92,7 +94,7 @@ public static class ItemValue implements Ingredient.Value { private final ItemStack f_43951_; -@@ -214,6 +_,9 @@ +@@ -216,6 +_,9 @@ list.add(new ItemStack(item)); } diff --git a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch index e477d21882..c4655f205e 100644 --- a/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch +++ b/patches/minecraft/net/minecraft/world/item/crafting/RecipeManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/RecipeManager.java +++ b/net/minecraft/world/item/crafting/RecipeManager.java -@@ -49,9 +_,18 @@ +@@ -50,9 +_,18 @@ for(Entry entry : p_44037_.entrySet()) { ResourceLocation resourcelocation = entry.getKey(); diff --git a/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch b/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch index fc5f3b28c5..4784c00d4b 100644 --- a/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch +++ b/patches/minecraft/net/minecraft/world/item/enchantment/FrostWalkerEnchantment.java.patch @@ -8,5 +8,5 @@ + boolean isFull = blockstate2.m_60734_() == Blocks.f_49990_ && blockstate2.m_61143_(LiquidBlock.f_54688_) == 0; //TODO: Forge, modded waters? + if (blockstate2.m_60767_() == Material.f_76305_ && isFull && blockstate.m_60710_(p_45020_, blockpos) && p_45020_.m_45752_(blockstate, blockpos, CollisionContext.m_82749_()) && !net.minecraftforge.event.ForgeEventFactory.onBlockPlace(p_45019_, net.minecraftforge.common.util.BlockSnapshot.create(p_45020_.m_46472_(), p_45020_, blockpos), net.minecraft.core.Direction.UP)) { p_45020_.m_46597_(blockpos, blockstate); - p_45020_.m_6219_().m_5945_(blockpos, Blocks.f_50449_, Mth.m_14072_(p_45019_.m_21187_(), 60, 120)); + p_45020_.m_186460_(blockpos, Blocks.f_50449_, Mth.m_14072_(p_45019_.m_21187_(), 60, 120)); } diff --git a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch index 75f0f9b3ad..e9df4d2f66 100644 --- a/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -127,11 +_,12 @@ +@@ -125,11 +_,12 @@ entity.m_7678_(entity.m_20185_(), entity.m_20186_(), entity.m_20189_(), p_151312_.f_46441_.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob) { Mob mob = (Mob)entity; -- if (!mob.m_5545_(p_151312_, MobSpawnType.SPAWNER) || !mob.m_6914_(p_151312_)) { +- if (this.f_45444_.m_186574_().isEmpty() && !mob.m_5545_(p_151312_, MobSpawnType.SPAWNER) || !mob.m_6914_(p_151312_)) { + if (!net.minecraftforge.event.ForgeEventFactory.canEntitySpawnSpawner(mob, p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this)) { continue; } - if (this.f_45444_.m_47265_().m_128440_() == 1 && this.f_45444_.m_47265_().m_128425_("id", 8)) { + if (this.f_45444_.m_186567_().m_128440_() == 1 && this.f_45444_.m_186567_().m_128425_("id", 8)) { + if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mob, p_151312_, (float)entity.m_20185_(), (float)entity.m_20186_(), (float)entity.m_20189_(), this, MobSpawnType.SPAWNER)) ((Mob)entity).m_6518_(p_151312_, p_151312_.m_6436_(entity.m_142538_()), MobSpawnType.SPAWNER, (SpawnGroupData)null, (CompoundTag)null); } } -@@ -272,4 +_,12 @@ +@@ -271,4 +_,12 @@ public double m_45474_() { return this.f_45446_; } diff --git a/patches/minecraft/net/minecraft/world/level/Level.java.patch b/patches/minecraft/net/minecraft/world/level/Level.java.patch index bba40e9611..670a145f9a 100644 --- a/patches/minecraft/net/minecraft/world/level/Level.java.patch +++ b/patches/minecraft/net/minecraft/world/level/Level.java.patch @@ -9,10 +9,10 @@ protected static final Logger f_46426_ = LogManager.getLogger(); public static final Codec> f_46427_ = ResourceLocation.f_135803_.xmap(ResourceKey.m_135797_(Registry.f_122819_), ResourceKey::m_135782_); public static final ResourceKey f_46428_ = ResourceKey.m_135785_(Registry.f_122819_, new ResourceLocation("overworld")); -@@ -99,8 +_,14 @@ - private final WorldBorder f_46447_; +@@ -100,8 +_,14 @@ private final BiomeManager f_46420_; private final ResourceKey f_46421_; + private long f_186455_; + public boolean restoringBlockSnapshots = false; + public boolean captureBlockSnapshots = false; + public java.util.ArrayList capturedBlockSnapshots = new java.util.ArrayList<>(); @@ -24,7 +24,7 @@ this.f_46446_ = p_46453_; this.f_46442_ = p_46450_; this.f_46445_ = p_46452_; -@@ -180,17 +_,45 @@ +@@ -181,17 +_,45 @@ } else { LevelChunk levelchunk = this.m_46745_(p_46605_); Block block = p_46606_.m_60734_(); @@ -71,7 +71,7 @@ if (blockstate1 == p_46606_) { if (blockstate != blockstate1) { this.m_6550_(p_46605_, blockstate, blockstate1); -@@ -216,8 +_,6 @@ +@@ -217,8 +_,6 @@ this.m_6559_(p_46605_, blockstate, blockstate1); } @@ -80,7 +80,7 @@ } } } -@@ -267,6 +_,8 @@ +@@ -268,6 +_,8 @@ } public void m_46672_(BlockPos p_46673_, Block p_46674_) { @@ -89,7 +89,7 @@ this.m_46586_(p_46673_.m_142125_(), p_46674_, p_46673_); this.m_46586_(p_46673_.m_142126_(), p_46674_, p_46673_); this.m_46586_(p_46673_.m_7495_(), p_46674_, p_46673_); -@@ -276,6 +_,11 @@ +@@ -277,6 +_,11 @@ } public void m_46590_(BlockPos p_46591_, Block p_46592_, Direction p_46593_) { @@ -101,7 +101,7 @@ if (p_46593_ != Direction.WEST) { this.m_46586_(p_46591_.m_142125_(), p_46592_, p_46591_); } -@@ -313,9 +_,9 @@ +@@ -314,9 +_,9 @@ CrashReportCategory crashreportcategory = crashreport.m_127514_("Block being updated"); crashreportcategory.m_128165_("Source block type", () -> { try { @@ -113,7 +113,7 @@ } }); CrashReportCategory.m_178950_(crashreportcategory, this, p_46587_, blockstate); -@@ -401,10 +_,26 @@ +@@ -402,10 +_,26 @@ (this.f_151504_ ? this.f_151503_ : this.f_151512_).add(p_151526_); } @@ -140,7 +140,7 @@ if (!this.f_151503_.isEmpty()) { this.f_151512_.addAll(this.f_151503_); this.f_151503_.clear(); -@@ -427,12 +_,15 @@ +@@ -428,12 +_,15 @@ public void m_46653_(Consumer p_46654_, T p_46655_) { try { @@ -156,7 +156,7 @@ } } -@@ -446,6 +_,7 @@ +@@ -455,6 +_,7 @@ public Explosion m_7703_(@Nullable Entity p_46526_, @Nullable DamageSource p_46527_, @Nullable ExplosionDamageCalculator p_46528_, double p_46529_, double p_46530_, double p_46531_, float p_46532_, boolean p_46533_, Explosion.BlockInteraction p_46534_) { Explosion explosion = new Explosion(this, p_46526_, p_46527_, p_46528_, p_46529_, p_46530_, p_46531_, p_46532_, p_46533_, p_46534_); @@ -164,7 +164,7 @@ explosion.m_46061_(); explosion.m_46075_(true); return explosion; -@@ -473,6 +_,7 @@ +@@ -482,6 +_,7 @@ if (!this.m_151570_(p_46748_)) { this.m_46745_(p_46748_).m_8114_(p_46748_); } @@ -172,7 +172,7 @@ } public boolean m_46749_(BlockPos p_46750_) { -@@ -530,8 +_,8 @@ +@@ -539,8 +_,8 @@ list.add(p_151522_); } @@ -183,26 +183,28 @@ if (p_151522_ != p_46536_ && p_46538_.test(enderdragonpart)) { list.add(enderdragonpart); } -@@ -550,8 +_,8 @@ +@@ -559,10 +_,8 @@ list.add(p_151539_); } - if (p_151539_ instanceof EnderDragon) { -- for(EnderDragonPart enderdragonpart : ((EnderDragon)p_151539_).m_31156_()) { +- EnderDragon enderdragon = (EnderDragon)p_151539_; +- +- for(EnderDragonPart enderdragonpart : enderdragon.m_31156_()) { + if (p_151539_.isMultipartEntity()) { + for(net.minecraftforge.entity.PartEntity enderdragonpart : p_151539_.getParts()) { T t = p_151528_.m_141992_(enderdragonpart); if (t != null && p_151530_.test(t)) { list.add(t); -@@ -571,6 +_,7 @@ - this.m_46745_(p_151544_).m_6427_(); +@@ -582,6 +_,7 @@ + this.m_46745_(p_151544_).m_8092_(true); } + this.m_46717_(p_151544_, m_8055_(p_151544_).m_60734_()); //Notify neighbors of changes } public int m_5736_() { -@@ -615,7 +_,7 @@ +@@ -626,7 +_,7 @@ public int m_46681_(BlockPos p_46682_, Direction p_46683_) { BlockState blockstate = this.m_8055_(p_46682_); int i = blockstate.m_60746_(this, p_46682_, p_46683_); @@ -211,7 +213,7 @@ } public boolean m_46753_(BlockPos p_46754_) { -@@ -768,16 +_,15 @@ +@@ -779,16 +_,15 @@ public abstract Scoreboard m_6188_(); public void m_46717_(BlockPos p_46718_, Block p_46719_) { @@ -232,7 +234,7 @@ blockstate.m_60690_(this, blockpos, p_46719_, p_46718_, false); } } -@@ -856,6 +_,18 @@ +@@ -867,6 +_,18 @@ public BiomeManager m_7062_() { return this.f_46420_; diff --git a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch index 857e64ee46..ff9d22898a 100644 --- a/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch +++ b/patches/minecraft/net/minecraft/world/level/LevelReader.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java -@@ -169,6 +_,10 @@ - return this.m_151577_(p_46806_.m_123341_(), p_46806_.m_123343_()); +@@ -175,6 +_,10 @@ } + /** @deprecated */ + default boolean isAreaLoaded(BlockPos center, int range) { + return this.m_46832_(center.m_142082_(-range, -range, -range), center.m_142082_(range, range, range)); + } diff --git a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch index f2bf5a1c65..ef6ca29e27 100644 --- a/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/patches/minecraft/net/minecraft/world/level/NaturalSpawner.java.patch @@ -15,9 +15,9 @@ - MobCategory mobcategory = entity.m_6095_().m_20674_(); + MobCategory mobcategory = entity.getClassification(true); if (mobcategory != MobCategory.MISC) { - Entity finalEntity = entity; + Entity entity_f = entity; BlockPos blockpos = entity.m_142538_(); -@@ -174,13 +_,15 @@ +@@ -177,13 +_,15 @@ } mob.m_7678_(d0, (double)i, d1, p_47040_.f_46441_.nextFloat() * 360.0F, 0.0F); @@ -35,7 +35,7 @@ return; } -@@ -290,6 +_,13 @@ +@@ -297,6 +_,13 @@ if (p_47052_ == SpawnPlacements.Type.NO_RESTRICTIONS) { return true; } else if (p_47055_ != null && p_47053_.m_6857_().m_61937_(p_47054_)) { @@ -49,12 +49,12 @@ BlockState blockstate = p_47053_.m_8055_(p_47054_); FluidState fluidstate = p_47053_.m_6425_(p_47054_); BlockPos blockpos = p_47054_.m_7494_(); -@@ -302,14 +_,12 @@ +@@ -309,14 +_,12 @@ case ON_GROUND: default: BlockState blockstate1 = p_47053_.m_8055_(blockpos1); - if (!blockstate1.m_60643_(p_47053_, blockpos1, p_47055_)) { -+ if (!blockstate1.canCreatureSpawn(p_47053_, blockpos1, p_47052_, p_47055_)) { ++ if (!blockstate1.isValidSpawn(p_47053_, blockpos1, p_47052_, p_47055_)) { return false; } else { return m_47056_(p_47053_, p_47054_, blockstate, fluidstate, p_47055_) && m_47056_(p_47053_, blockpos, p_47053_.m_8055_(blockpos), p_47053_.m_6425_(blockpos), p_47055_); @@ -65,7 +65,7 @@ } } -@@ -355,6 +_,7 @@ +@@ -362,6 +_,7 @@ entity.m_7678_(d0, (double)blockpos.m_123342_(), d1, p_151620_.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob) { Mob mob = (Mob)entity; diff --git a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch index 7d2a332a4c..4b16a12bed 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/Biome.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -51,7 +_,7 @@ +@@ -37,7 +_,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public final class Biome { +public final class Biome extends net.minecraftforge.registries.ForgeRegistryEntry.UncheckedRegistryEntry { public static final Logger f_47428_ = LogManager.getLogger(); - public static final Codec f_47429_ = RecordCodecBuilder.create((p_47527_) -> { - return p_47527_.group(Biome.ClimateSettings.f_47679_.forGetter((p_151717_) -> { -@@ -68,7 +_,9 @@ - return p_151707_.f_47438_; - }), MobSpawnSettings.f_48327_.forGetter((p_151705_) -> { - return p_151705_.f_47439_; -- })).apply(p_47527_, Biome::new); + public static final Codec f_47429_ = RecordCodecBuilder.create((p_186636_) -> { + return p_186636_.group(Biome.ClimateSettings.f_47679_.forGetter((p_151717_) -> { +@@ -50,7 +_,9 @@ + return p_186642_.f_47438_; + }), MobSpawnSettings.f_48327_.forGetter((p_186640_) -> { + return p_186640_.f_47439_; +- })).apply(p_186636_, Biome::new); + }), ResourceLocation.f_135803_.optionalFieldOf("forge:registry_name").forGetter(b -> Optional.ofNullable(b.getRegistryName()))) -+ .apply(p_47527_, (climate, category, depth, scale, effects, gen, spawns, name) -> -+ net.minecraftforge.common.ForgeHooks.enhanceBiome(name.orElse(null), climate, category, depth, scale, effects, gen, spawns, p_47527_, Biome::new)); ++ .apply(p_186636_, (climate, category, effects, gen, spawns, name) -> ++ net.minecraftforge.common.ForgeHooks.enhanceBiome(name.orElse(null), climate, category, effects, gen, spawns, p_186636_, Biome::new)); }); - public static final Codec f_47430_ = RecordCodecBuilder.create((p_47504_) -> { - return p_47504_.group(Biome.ClimateSettings.f_47679_.forGetter((p_151703_) -> { + public static final Codec f_47430_ = RecordCodecBuilder.create((p_186632_) -> { + return p_186632_.group(Biome.ClimateSettings.f_47679_.forGetter((p_186638_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch index f86043f75f..b6fcd83f28 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeGenerationSettings.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/biome/BiomeGenerationSettings.java +++ b/net/minecraft/world/level/biome/BiomeGenerationSettings.java -@@ -48,6 +_,7 @@ +@@ -37,6 +_,7 @@ + })).apply(p_186655_, BiomeGenerationSettings::new); }); - private final Supplier> f_47779_; private final Map>>> f_47780_; + private final java.util.Set carversView; - private final List>>> f_47781_; - private final List>> f_47782_; + private final List>> f_47781_; private final List> f_47783_; -@@ -60,10 +_,15 @@ - this.f_47783_ = p_47788_.stream().flatMap(Collection::stream).map(Supplier::get).flatMap(ConfiguredFeature::m_65398_).filter((p_47802_) -> { - return p_47802_.f_65377_ == Feature.f_65761_; + private final Set f_186648_; +@@ -48,10 +_,15 @@ + return p_186657_.f_65377_ == Feature.f_65761_; }).collect(ImmutableList.toImmutableList()); + this.f_186648_ = p_186651_.stream().flatMap(Collection::stream).map(Supplier::get).collect(Collectors.toSet()); + this.carversView = java.util.Collections.unmodifiableSet(f_47780_.keySet()); } @@ -23,4 +23,4 @@ + return this.carversView; } - public boolean m_47808_(StructureFeature p_47809_) { + public List> m_47815_() { diff --git a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch index cf77f52a52..737db24c2a 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/BiomeSpecialEffects.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/BiomeSpecialEffects.java +++ b/net/minecraft/world/level/biome/BiomeSpecialEffects.java -@@ -202,7 +_,7 @@ +@@ -203,7 +_,7 @@ } } @@ -9,7 +9,7 @@ NONE("none") { public int m_6583_(double p_48081_, double p_48082_, int p_48083_) { return p_48083_; -@@ -221,17 +_,35 @@ +@@ -222,17 +_,35 @@ }; private final String f_48051_; diff --git a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index c81a8d6204..20ac1d7388 100644 --- a/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -1,17 +1,16 @@ --- a/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -44,21 +_,33 @@ +@@ -39,20 +_,32 @@ + private final float f_48328_; private final Map> f_48329_; private final Map, MobSpawnSettings.MobSpawnCost> f_48330_; - private final boolean f_48331_; + private final java.util.Set typesView; + private final java.util.Set> costView; - MobSpawnSettings(float p_48334_, Map> p_48335_, Map, MobSpawnSettings.MobSpawnCost> p_48336_, boolean p_48337_) { - this.f_48328_ = p_48334_; - this.f_48329_ = ImmutableMap.copyOf(p_48335_); - this.f_48330_ = ImmutableMap.copyOf(p_48336_); - this.f_48331_ = p_48337_; + MobSpawnSettings(float p_196689_, Map> p_196690_, Map, MobSpawnSettings.MobSpawnCost> p_196691_) { + this.f_48328_ = p_196689_; + this.f_48329_ = ImmutableMap.copyOf(p_196690_); + this.f_48330_ = ImmutableMap.copyOf(p_196691_); + this.typesView = java.util.Collections.unmodifiableSet(this.f_48329_.keySet()); + this.costView = java.util.Collections.unmodifiableSet(this.f_48330_.keySet()); } diff --git a/patches/minecraft/net/minecraft/world/level/biome/OverworldBiomeSource.java.patch b/patches/minecraft/net/minecraft/world/level/biome/OverworldBiomeSource.java.patch deleted file mode 100644 index 5b82df17d0..0000000000 --- a/patches/minecraft/net/minecraft/world/level/biome/OverworldBiomeSource.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/biome/OverworldBiomeSource.java -+++ b/net/minecraft/world/level/biome/OverworldBiomeSource.java -@@ -31,7 +_,7 @@ - private final Registry f_48587_; - - public OverworldBiomeSource(long p_48590_, boolean p_48591_, boolean p_48592_, Registry p_48593_) { -- super(f_48583_.stream().map((p_48603_) -> { -+ super(java.util.stream.Stream.concat(f_48583_.stream(), net.minecraftforge.common.BiomeManager.getAdditionalOverworldBiomes().stream()).map((p_48603_) -> { - return () -> { - return p_48593_.m_123013_(p_48603_); - }; diff --git a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch index 7ac3261ded..8adbb3f278 100644 --- a/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -71,6 +_,9 @@ +@@ -72,6 +_,9 @@ public int m_6782_(BlockState p_49620_, Level p_49621_, BlockPos p_49622_) { return p_49620_.m_61143_(f_49564_); } @@ -10,7 +10,7 @@ public void m_6240_(Level p_49584_, Player p_49585_, BlockPos p_49586_, BlockState p_49587_, @Nullable BlockEntity p_49588_, ItemStack p_49589_) { super.m_6240_(p_49584_, p_49585_, p_49586_, p_49587_, p_49588_, p_49589_); -@@ -91,6 +_,7 @@ +@@ -92,6 +_,7 @@ List list = p_49650_.m_45976_(Bee.class, (new AABB(p_49651_)).m_82377_(8.0D, 6.0D, 8.0D)); if (!list.isEmpty()) { List list1 = p_49650_.m_45976_(Player.class, (new AABB(p_49651_)).m_82377_(8.0D, 6.0D, 8.0D)); @@ -18,7 +18,7 @@ int i = list1.size(); for(Bee bee : list) { -@@ -112,7 +_,7 @@ +@@ -113,7 +_,7 @@ boolean flag = false; if (i >= 5) { Item item = itemstack.m_41720_(); diff --git a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch index b09388a3f8..c4d906656c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -62,9 +_,10 @@ +@@ -61,9 +_,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -13,7 +13,7 @@ private static final LoadingCache f_49785_ = CacheBuilder.newBuilder().maximumSize(512L).weakKeys().build(new CacheLoader() { public Boolean load(VoxelShape p_49972_) { return !Shapes.m_83157_(Shapes.m_83144_(), p_49972_, BooleanOp.f_82687_); -@@ -177,7 +_,7 @@ +@@ -176,7 +_,7 @@ f_49790_.error("Block classes should end with Block and {} doesn't.", (Object)s); } } @@ -22,7 +22,7 @@ } public static boolean m_152463_(BlockState p_152464_) { -@@ -323,7 +_,7 @@ +@@ -322,7 +_,7 @@ } private static void m_152440_(Level p_152441_, Supplier p_152442_, ItemStack p_152443_) { @@ -31,7 +31,7 @@ ItemEntity itementity = p_152442_.get(); itementity.m_32060_(); p_152441_.m_7967_(itementity); -@@ -331,12 +_,13 @@ +@@ -330,12 +_,13 @@ } public void m_49805_(ServerLevel p_49806_, BlockPos p_49807_, int p_49808_) { @@ -46,7 +46,7 @@ public float m_7325_() { return this.f_60444_; } -@@ -383,8 +_,10 @@ +@@ -382,8 +_,10 @@ public void m_5548_(BlockGetter p_49821_, Entity p_49822_) { p_49822_.m_20256_(p_49822_.m_20184_().m_82542_(1.0D, 0.0D, 1.0D)); @@ -57,7 +57,7 @@ public ItemStack m_7397_(BlockGetter p_49823_, BlockPos p_49824_, BlockState p_49825_) { return new ItemStack(this); } -@@ -421,6 +_,7 @@ +@@ -420,6 +_,7 @@ public void m_141997_(BlockState p_152450_, Level p_152451_, BlockPos p_152452_, Biome.Precipitation p_152453_) { } @@ -65,7 +65,7 @@ public boolean m_6903_(Explosion p_49826_) { return true; } -@@ -456,6 +_,7 @@ +@@ -455,6 +_,7 @@ return p_152456_.m_61124_(p_152457_, p_152455_.m_61143_(p_152457_)); } @@ -73,7 +73,7 @@ public SoundType m_49962_(BlockState p_49963_) { return this.f_60446_; } -@@ -465,7 +_,7 @@ +@@ -464,7 +_,7 @@ this.f_49788_ = Item.m_41439_(this); } @@ -82,7 +82,7 @@ } public boolean m_49967_() { -@@ -473,7 +_,7 @@ +@@ -472,7 +_,7 @@ } public String toString() { @@ -91,7 +91,7 @@ } public void m_5871_(ItemStack p_49816_, @Nullable BlockGetter p_49817_, List p_49818_, TooltipFlag p_49819_) { -@@ -486,6 +_,82 @@ +@@ -485,6 +_,82 @@ protected ImmutableMap m_152458_(Function p_152459_) { return this.f_49792_.m_61056_().stream().collect(ImmutableMap.toImmutableMap(Function.identity(), p_152459_)); } diff --git a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch index e0f433a30f..3fc1f4c955 100644 --- a/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/Blocks.java.patch @@ -17,7 +17,7 @@ public static final Block f_50031_ = m_50795_("detector_rail", new DetectorRailBlock(BlockBehaviour.Properties.m_60939_(Material.f_76310_).m_60910_().m_60978_(0.7F).m_60918_(SoundType.f_56743_))); public static final Block f_50032_ = m_50795_("sticky_piston", m_50798_(true)); public static final Block f_50033_ = m_50795_("cobweb", new WebBlock(BlockBehaviour.Properties.m_60939_(Material.f_76311_).m_60910_().m_60999_().m_60978_(4.0F))); -@@ -1107,16 +_,5 @@ +@@ -1111,16 +_,5 @@ public static void m_50758_() { Block.f_49791_.forEach(BlockBehaviour.BlockStateBase::m_60611_); diff --git a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch index 9e088138f6..0363473c71 100644 --- a/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/FireBlock.java.patch @@ -83,7 +83,7 @@ - TntBlock tntblock = (TntBlock)block; - TntBlock.m_57433_(p_53432_, p_53433_); - } -+ blockstate.catchFire(p_53432_, p_53433_, face, null); ++ blockstate.onCaughtFire(p_53432_, p_53433_, face, null); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch index 197fb5a7a3..d99a32b03f 100644 --- a/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -24,7 +24,7 @@ + } + + /** -+ * @param p_54694_ A fluid supplier such as {@link net.minecraftforge.fmllegacy.RegistryObject} ++ * @param p_54694_ A fluid supplier such as {@link net.minecraftforge.registries.RegistryObject} + */ + public LiquidBlock(java.util.function.Supplier p_54694_, BlockBehaviour.Properties p_54695_) { + super(p_54695_); diff --git a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch index 07ac97b3d8..591cc10d77 100644 --- a/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/TntBlock.java.patch @@ -4,7 +4,7 @@ this.m_49959_(this.m_49966_().m_61124_(f_57419_, Boolean.valueOf(false))); } -+ public void catchFire(BlockState state, Level world, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { ++ public void onCaughtFire(BlockState state, Level world, BlockPos pos, @Nullable net.minecraft.core.Direction face, @Nullable LivingEntity igniter) { + m_57436_(world, pos, igniter); + } + @@ -12,7 +12,7 @@ if (!p_57469_.m_60713_(p_57466_.m_60734_())) { if (p_57467_.m_46753_(p_57468_)) { - m_57433_(p_57467_, p_57468_); -+ catchFire(p_57466_, p_57467_, p_57468_, null, null); ++ onCaughtFire(p_57466_, p_57467_, p_57468_, null, null); p_57467_.m_7471_(p_57468_, false); } @@ -21,7 +21,7 @@ public void m_6861_(BlockState p_57457_, Level p_57458_, BlockPos p_57459_, Block p_57460_, BlockPos p_57461_, boolean p_57462_) { if (p_57458_.m_46753_(p_57459_)) { - m_57433_(p_57458_, p_57459_); -+ catchFire(p_57457_, p_57458_, p_57459_, null, null); ++ onCaughtFire(p_57457_, p_57458_, p_57459_, null, null); p_57458_.m_7471_(p_57459_, false); } @@ -30,7 +30,7 @@ public void m_5707_(Level p_57445_, BlockPos p_57446_, BlockState p_57447_, Player p_57448_) { if (!p_57445_.m_5776_() && !p_57448_.m_7500_() && p_57447_.m_61143_(f_57419_)) { - m_57433_(p_57445_, p_57446_); -+ catchFire(p_57447_, p_57445_, p_57446_, null, null); ++ onCaughtFire(p_57447_, p_57445_, p_57446_, null, null); } super.m_5707_(p_57445_, p_57446_, p_57447_, p_57448_); @@ -52,7 +52,7 @@ return super.m_6227_(p_57450_, p_57451_, p_57452_, p_57453_, p_57454_, p_57455_); } else { - m_57436_(p_57451_, p_57452_, p_57453_); -+ catchFire(p_57450_, p_57451_, p_57452_, p_57455_.m_82434_(), p_57453_); ++ onCaughtFire(p_57450_, p_57451_, p_57452_, p_57455_.m_82434_(), p_57453_); p_57451_.m_7731_(p_57452_, Blocks.f_50016_.m_49966_(), 11); Item item = itemstack.m_41720_(); if (!p_57453_.m_7500_()) { @@ -61,7 +61,7 @@ Entity entity = p_57432_.m_37282_(); if (p_57432_.m_6060_() && p_57432_.m_142265_(p_57429_, blockpos)) { - m_57436_(p_57429_, blockpos, entity instanceof LivingEntity ? (LivingEntity)entity : null); -+ catchFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); ++ onCaughtFire(p_57430_, p_57429_, blockpos, null, entity instanceof LivingEntity ? (LivingEntity)entity : null); p_57429_.m_7471_(blockpos, false); } } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index 81c47e909a..17883d7955 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -23,18 +23,18 @@ @@ -218,9 +_,9 @@ - public CompoundTag m_6945_(CompoundTag p_58379_) { - super.m_6945_(p_58379_); -- p_58379_.m_128376_("BurnTime", (short)this.f_58316_); -- p_58379_.m_128376_("CookTime", (short)this.f_58318_); -- p_58379_.m_128376_("CookTimeTotal", (short)this.f_58319_); -+ p_58379_.m_128405_("BurnTime", this.f_58316_); -+ p_58379_.m_128405_("CookTime", this.f_58318_); -+ p_58379_.m_128405_("CookTimeTotal", this.f_58319_); - ContainerHelper.m_18973_(p_58379_, this.f_58310_); + protected void m_183515_(CompoundTag p_187452_) { + super.m_183515_(p_187452_); +- p_187452_.m_128376_("BurnTime", (short)this.f_58316_); +- p_187452_.m_128376_("CookTime", (short)this.f_58318_); +- p_187452_.m_128376_("CookTimeTotal", (short)this.f_58319_); ++ p_187452_.m_128405_("BurnTime", this.f_58316_); ++ p_187452_.m_128405_("CookTime", this.f_58318_); ++ p_187452_.m_128405_("CookTimeTotal", this.f_58319_); + ContainerHelper.m_18973_(p_187452_, this.f_58310_); CompoundTag compoundtag = new CompoundTag(); - this.f_58320_.forEach((p_58382_, p_58383_) -> { -@@ -239,30 +_,32 @@ + this.f_58320_.forEach((p_187449_, p_187450_) -> { +@@ -238,34 +_,35 @@ ItemStack itemstack = p_155017_.f_58310_.get(1); if (p_155017_.m_58425_() || !itemstack.m_41619_() && !p_155017_.f_58310_.get(0).m_41619_()) { @@ -73,7 +73,11 @@ p_155017_.m_6029_(recipe); } -@@ -287,9 +_,9 @@ +- flag1 = true; + } + } else { + p_155017_.f_58318_ = 0; +@@ -286,9 +_,9 @@ } @@ -85,7 +89,7 @@ if (itemstack.m_41619_()) { return false; } else { -@@ -298,10 +_,10 @@ +@@ -297,10 +_,10 @@ return true; } else if (!itemstack1.m_41656_(itemstack)) { return false; @@ -98,7 +102,7 @@ } } } else { -@@ -309,15 +_,15 @@ +@@ -308,15 +_,15 @@ } } @@ -118,7 +122,7 @@ } if (itemstack.m_150930_(Blocks.f_50057_.m_5456_()) && !p_155028_.get(1).m_41619_() && p_155028_.get(1).m_150930_(Items.f_42446_)) { -@@ -336,7 +_,7 @@ +@@ -335,7 +_,7 @@ return 0; } else { Item item = p_58343_.m_41720_(); @@ -127,7 +131,7 @@ } } -@@ -345,7 +_,7 @@ +@@ -344,7 +_,7 @@ } public static boolean m_58399_(ItemStack p_58400_) { @@ -136,7 +140,7 @@ } public int[] m_7071_(Direction p_58363_) { -@@ -425,7 +_,7 @@ +@@ -424,7 +_,7 @@ return true; } else { ItemStack itemstack = this.f_58310_.get(1); @@ -145,7 +149,7 @@ } } -@@ -483,5 +_,34 @@ +@@ -482,5 +_,34 @@ p_58342_.m_36491_(itemstack); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index b0a3a14aba..380a029c69 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -82,4 +_,27 @@ +@@ -81,4 +_,27 @@ } protected abstract AbstractContainerMenu m_6555_(int p_58627_, Inventory p_58628_); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch index bd08940282..86d9a4cfaf 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -12,7 +_,7 @@ +@@ -15,7 +_,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,7 +9,7 @@ private static final Logger f_58854_ = LogManager.getLogger(); private final BlockEntityType f_58855_; @Nullable -@@ -20,11 +_,14 @@ +@@ -23,11 +_,14 @@ protected final BlockPos f_58858_; protected boolean f_58859_; private BlockState f_58856_; @@ -23,26 +23,31 @@ + this.gatherCapabilities(); } - @Nullable -@@ -41,6 +_,8 @@ + public static BlockPos m_187472_(CompoundTag p_187473_) { +@@ -48,6 +_,13 @@ } public void m_142466_(CompoundTag p_155245_) { + if (p_155245_.m_128441_("ForgeData")) this.customTileData = p_155245_.m_128469_("ForgeData"); + if (getCapabilities() != null && p_155245_.m_128441_("ForgeCaps")) deserializeCaps(p_155245_.m_128469_("ForgeCaps")); ++ } ++ ++ public CompoundTag save(CompoundTag tag) { ++ m_187478_(tag); ++ return tag; } - public CompoundTag m_6945_(CompoundTag p_58888_) { -@@ -56,6 +_,8 @@ - p_58895_.m_128405_("x", this.f_58858_.m_123341_()); - p_58895_.m_128405_("y", this.f_58858_.m_123342_()); - p_58895_.m_128405_("z", this.f_58858_.m_123343_()); -+ if (this.customTileData != null) p_58895_.m_128365_("ForgeData", this.customTileData.m_6426_()); -+ if (getCapabilities() != null) p_58895_.m_128365_("ForgeCaps", serializeCaps()); - return p_58895_; - } + protected void m_183515_(CompoundTag p_187471_) { +@@ -93,6 +_,8 @@ + p_187479_.m_128405_("x", this.f_58858_.m_123341_()); + p_187479_.m_128405_("y", this.f_58858_.m_123342_()); + p_187479_.m_128405_("z", this.f_58858_.m_123343_()); ++ if (this.customTileData != null) p_187479_.m_128365_("ForgeData", this.customTileData.m_6426_()); ++ if (getCapabilities() != null) p_187479_.m_128365_("ForgeCaps", serializeCaps()); } -@@ -128,6 +_,13 @@ + + @Nullable +@@ -163,6 +_,13 @@ public void m_7651_() { this.f_58859_ = true; @@ -56,7 +61,7 @@ } public void m_6339_() { -@@ -154,6 +_,13 @@ +@@ -189,6 +_,13 @@ public BlockEntityType m_58903_() { return this.f_58855_; @@ -69,4 +74,4 @@ + return this.customTileData; } - @Deprecated + /** @deprecated */ diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index 3cd9b5a1cc..ea94ebd7e3 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -37,7 +37,7 @@ p_155293_.set(3, itemstack); p_155291_.m_46796_(1035, p_155292_, 0); -@@ -230,11 +_,11 @@ +@@ -229,11 +_,11 @@ public boolean m_7013_(int p_59017_, ItemStack p_59018_) { if (p_59017_ == 3) { @@ -51,7 +51,7 @@ } } -@@ -260,5 +_,34 @@ +@@ -259,5 +_,34 @@ protected AbstractContainerMenu m_6555_(int p_58990_, Inventory p_58991_) { return new BrewingStandMenu(p_58990_, p_58991_, this, this.f_58971_); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch index 8c74589d76..0aae35280b 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -162,6 +_,45 @@ +@@ -161,6 +_,45 @@ return ChestMenu.m_39237_(p_59082_, p_59083_, this); } diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 7977d23baa..e75e0f28d9 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -155,10 +_,8 @@ +@@ -153,10 +_,8 @@ BlockPos blockpos1 = p_155416_.m_142082_(j1, k1, l1); BlockState blockstate = p_155415_.m_8055_(blockpos1); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index e7a1f89475..a3e0767c19 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -104,7 +_,7 @@ +@@ -103,7 +_,7 @@ if (!p_155582_.m_59407_() && p_155581_.m_61143_(HopperBlock.f_54022_)) { boolean flag = false; if (!p_155582_.m_7983_()) { @@ -9,7 +9,7 @@ } if (!p_155582_.m_59404_()) { -@@ -132,7 +_,8 @@ +@@ -131,7 +_,8 @@ return true; } @@ -19,7 +19,7 @@ Container container = m_155592_(p_155563_, p_155564_, p_155565_); if (container == null) { return false; -@@ -177,6 +_,8 @@ +@@ -176,6 +_,8 @@ } public static boolean m_155552_(Level p_155553_, Hopper p_155554_) { @@ -28,7 +28,7 @@ Container container = m_155596_(p_155553_, p_155554_); if (container != null) { Direction direction = Direction.DOWN; -@@ -400,5 +_,14 @@ +@@ -399,5 +_,14 @@ protected AbstractContainerMenu m_6555_(int p_59312_, Inventory p_59313_) { return new HopperMenu(p_59312_, p_59313_, this); diff --git a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index 71b58be7d0..948c00afd4 100644 --- a/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -241,6 +_,11 @@ +@@ -236,6 +_,11 @@ return this.f_59647_ == ShulkerBoxBlockEntity.AnimationStatus.CLOSED; } diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index cfca3fa756..8add842fab 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -18,9 +18,9 @@ + this.lootTableSupplier = lootTableCache != null ? () -> lootTableCache : p_60452_.lootTableSupplier != null ? p_60452_.lootTableSupplier : () -> new ResourceLocation(this.getRegistryName().m_135827_(), "blocks/" + this.getRegistryName().m_135815_()); } - @Deprecated -@@ -132,7 +_,7 @@ - + /** @deprecated */ +@@ -139,7 +_,7 @@ + /** @deprecated */ @Deprecated public void m_6810_(BlockState p_60515_, Level p_60516_, BlockPos p_60517_, BlockState p_60518_, boolean p_60519_) { - if (p_60515_.m_155947_() && !p_60515_.m_60713_(p_60518_.m_60734_())) { @@ -28,16 +28,16 @@ p_60516_.m_46747_(p_60517_); } -@@ -202,7 +_,7 @@ - +@@ -220,7 +_,7 @@ + /** @deprecated */ @Deprecated public boolean m_6864_(BlockState p_60470_, BlockPlaceContext p_60471_) { - return this.f_60442_.m_76336_() && (p_60471_.m_43722_().m_41619_() || !p_60471_.m_43722_().m_150930_(this.m_5456_())); + return p_60470_.m_60767_().m_76336_() && (p_60471_.m_43722_().m_41619_() || p_60471_.m_43722_().m_41720_() != this.m_5456_()); } - @Deprecated -@@ -308,8 +_,8 @@ + /** @deprecated */ +@@ -344,8 +_,8 @@ if (f == -1.0F) { return 0.0F; } else { @@ -48,7 +48,7 @@ } } -@@ -337,8 +_,7 @@ +@@ -378,8 +_,7 @@ public final ResourceLocation m_60589_() { if (this.f_60440_ == null) { @@ -58,7 +58,7 @@ } return this.f_60440_; -@@ -360,6 +_,14 @@ +@@ -402,6 +_,14 @@ return this.f_60439_.f_60888_; } @@ -73,7 +73,7 @@ public abstract static class BlockStateBase extends StateHolder { private final int f_60594_; private final boolean f_60595_; -@@ -438,18 +_,22 @@ +@@ -480,18 +_,22 @@ return this.f_60595_; } @@ -97,7 +97,7 @@ public BlockState m_60717_(Rotation p_60718_) { return this.m_60734_().m_6843_(this.m_7160_(), p_60718_); } -@@ -821,8 +_,9 @@ +@@ -863,8 +_,9 @@ ResourceLocation f_60894_; boolean f_60895_ = true; boolean f_60896_; @@ -108,7 +108,7 @@ }; BlockBehaviour.StatePredicate f_60898_ = (p_60985_, p_60986_, p_60987_) -> { return p_60985_.m_60767_().m_76337_() && p_60985_.m_60838_(p_60986_, p_60987_); -@@ -949,9 +_,15 @@ +@@ -991,9 +_,15 @@ return this; } diff --git a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch index ef1d685ab6..acf7303c9c 100644 --- a/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/state/BlockState.java.patch @@ -6,6 +6,6 @@ -public class BlockState extends BlockBehaviour.BlockStateBase { +public class BlockState extends BlockBehaviour.BlockStateBase implements net.minecraftforge.common.extensions.IForgeBlockState { - public static final Codec f_61039_ = m_61127_(Registry.f_122824_, Block::m_49966_).stable(); + public static final Codec f_61039_ = m_61127_(Registry.f_122824_.m_194605_(), Block::m_49966_).stable(); public BlockState(Block p_61042_, ImmutableMap, Comparable> p_61043_, MapCodec p_61044_) { diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch index fe6c8fd362..0911edf6ea 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -1,12 +1,10 @@ --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java -@@ -158,4 +_,9 @@ - boolean m_6332_(); +@@ -410,4 +_,7 @@ - void m_8094_(boolean p_62100_); + public static record TicksToSave(SerializableTickContainer f_187680_, SerializableTickContainer f_187681_) { + } + + @Nullable -+ default net.minecraft.world.level.LevelAccessor getWorldForge() { -+ return null; -+ } ++ public net.minecraft.world.level.LevelAccessor getWorldForge() { return null; } } diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch index d8fa802a48..808d9edeba 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ChunkStatus.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/chunk/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/ChunkStatus.java -@@ -23,7 +_,7 @@ - import net.minecraft.world.level.levelgen.Heightmap; +@@ -27,7 +_,7 @@ + import net.minecraft.world.level.levelgen.blending.Blender; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; -public class ChunkStatus { +public class ChunkStatus extends net.minecraftforge.registries.ForgeRegistryEntry { + public static final int f_187758_ = 8; private static final EnumSet f_62327_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.WORLD_SURFACE_WG); - private static final EnumSet f_62328_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES); - private static final ChunkStatus.LoadingTask f_62329_ = (p_62461_, p_62462_, p_62463_, p_62464_, p_62465_, p_62466_) -> { + public static final EnumSet f_62328_ = EnumSet.of(Heightmap.Types.OCEAN_FLOOR, Heightmap.Types.WORLD_SURFACE, Heightmap.Types.MOTION_BLOCKING, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES); diff --git a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch index ec3c592b4f..56c56df560 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,69 +1,61 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -57,7 +_,7 @@ +@@ -49,7 +_,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; --public class LevelChunk implements ChunkAccess { -+public class LevelChunk extends net.minecraftforge.common.capabilities.CapabilityProvider implements ChunkAccess, net.minecraftforge.common.extensions.IForgeLevelChunk { +-public class LevelChunk extends ChunkAccess { ++public class LevelChunk extends ChunkAccess implements net.minecraftforge.common.capabilities.ICapabilityProviderImpl { static final Logger f_62771_ = LogManager.getLogger(); private static final TickingBlockEntity f_156361_ = new TickingBlockEntity() { public void m_142224_() { -@@ -106,6 +_,7 @@ +@@ -123,6 +_,7 @@ + + this.m_8094_(p_196851_.m_6332_()); + this.f_187603_ = true; ++ this.capProvider.initInternal(); } - public LevelChunk(Level p_62800_, ChunkPos p_62801_, ChunkBiomeContainer p_62802_, UpgradeData p_62803_, TickList p_62804_, TickList p_62805_, long p_62806_, @Nullable LevelChunkSection[] p_62807_, @Nullable Consumer p_62808_) { -+ super(LevelChunk.class); - this.f_62776_ = p_62800_; - this.f_62792_ = p_62801_; - this.f_62778_ = p_62803_; -@@ -132,6 +_,7 @@ - } - - this.f_62783_ = new ShortList[p_62800_.m_151559_()]; -+ this.gatherCapabilities(); - } - - public LevelChunk(ServerLevel p_156365_, ProtoChunk p_156366_, @Nullable Consumer p_156367_) { -@@ -279,14 +_,14 @@ - boolean flag2 = blockstate.m_155947_(); - if (!this.f_62776_.f_46443_) { - blockstate.m_60753_(this.f_62776_, p_62865_, p_62866_, p_62867_); -- } else if (!blockstate.m_60713_(block) && flag2) { + public TickContainerAccess m_183531_() { +@@ -233,14 +_,14 @@ + boolean flag2 = blockstate.m_155947_(); + if (!this.f_62776_.f_46443_) { + blockstate.m_60753_(this.f_62776_, p_62865_, p_62866_, p_62867_); +- } else if (!blockstate.m_60713_(block) && flag2) { + } else if ((!blockstate.m_60713_(block) || !p_62866_.m_155947_()) && flag2) { - this.m_8114_(p_62865_); - } - - if (!levelchunksection.m_62982_(k, l, i1).m_60713_(block)) { - return null; - } else { -- if (!this.f_62776_.f_46443_) { -+ if (!this.f_62776_.f_46443_ && !this.f_62776_.captureBlockSnapshots) { - p_62866_.m_60696_(this.f_62776_, p_62865_, blockstate, p_62867_); + this.m_8114_(p_62865_); } -@@ -349,6 +_,10 @@ + if (!levelchunksection.m_62982_(j, k, l).m_60713_(block)) { + return null; + } else { +- if (!this.f_62776_.f_46443_) { ++ if (!this.f_62776_.f_46443_ && !this.f_62776_.captureBlockSnapshots) { + p_62866_.m_60696_(this.f_62776_, p_62865_, blockstate, p_62867_); + } + +@@ -283,6 +_,10 @@ @Nullable public BlockEntity m_5685_(BlockPos p_62868_, LevelChunk.EntityCreationType p_62869_) { - BlockEntity blockentity = this.f_62779_.get(p_62868_); + BlockEntity blockentity = this.f_187610_.get(p_62868_); + if (blockentity != null && blockentity.m_58901_()) { -+ f_62779_.remove(p_62868_); ++ f_187610_.remove(p_62868_); + blockentity = null; + } if (blockentity == null) { - CompoundTag compoundtag = this.f_62774_.remove(p_62868_); + CompoundTag compoundtag = this.f_187609_.remove(p_62868_); if (compoundtag != null) { -@@ -366,9 +_,6 @@ +@@ -300,9 +_,6 @@ this.m_142170_(blockentity); } } - } else if (blockentity.m_58901_()) { -- this.f_62779_.remove(p_62868_); +- this.f_187610_.remove(p_62868_); - return null; } return blockentity; -@@ -379,6 +_,7 @@ +@@ -313,6 +_,7 @@ if (this.m_156370_()) { this.m_156404_(p_156391_); this.m_156406_(p_156391_); @@ -71,12 +63,12 @@ } } -@@ -418,9 +_,14 @@ +@@ -352,9 +_,14 @@ public CompoundTag m_8051_(BlockPos p_62932_) { BlockEntity blockentity = this.m_7702_(p_62932_); if (blockentity != null && !blockentity.m_58901_()) { + try { - CompoundTag compoundtag1 = blockentity.m_6945_(new CompoundTag()); + CompoundTag compoundtag1 = blockentity.m_187480_(); compoundtag1.m_128379_("keepPacked", false); return compoundtag1; + } catch (Exception e) { @@ -84,31 +76,76 @@ + return null; + } } else { - CompoundTag compoundtag = this.f_62774_.get(p_62932_); + CompoundTag compoundtag = this.f_187609_.get(p_62932_); if (compoundtag != null) { -@@ -567,7 +_,7 @@ +@@ -453,7 +_,7 @@ public Stream m_6267_() { - return StreamSupport.stream(BlockPos.m_121976_(this.f_62792_.m_45604_(), this.m_141937_(), this.f_62792_.m_45605_(), this.f_62792_.m_45608_(), this.m_151558_() - 1, this.f_62792_.m_45609_()).spliterator(), false).filter((p_156419_) -> { -- return this.m_8055_(p_156419_).m_60791_() != 0; -+ return this.m_8055_(p_156419_).getLightEmission(m_62953_(), p_156419_) != 0; + return StreamSupport.stream(BlockPos.m_121976_(this.f_187604_.m_45604_(), this.m_141937_(), this.f_187604_.m_45605_(), this.f_187604_.m_45608_(), this.m_151558_() - 1, this.f_187604_.m_45609_()).spliterator(), false).filter((p_187990_) -> { +- return this.m_8055_(p_187990_).m_60791_() != 0; ++ return this.m_8055_(p_187990_).getLightEmission(m_62953_(), p_187990_) != 0; }); } -@@ -759,10 +_,12 @@ +@@ -541,6 +_,7 @@ } - public void m_156368_() { -+ this.f_62779_.values().forEach(BlockEntity::onChunkUnloaded); - this.f_62779_.values().forEach(this::m_156400_); + public void m_187957_() { ++ this.f_187610_.values().forEach(BlockEntity::onChunkUnloaded); + this.f_187610_.values().forEach(BlockEntity::m_7651_); + this.f_187610_.clear(); + this.f_156362_.values().forEach((p_187966_) -> { +@@ -550,6 +_,7 @@ } public void m_156369_() { -+ this.f_62776_.addFreshBlockEntities(this.f_62779_.values()); - this.f_62779_.values().forEach((p_156409_) -> { - this.m_156404_(p_156409_); - this.m_156406_(p_156409_); -@@ -826,6 +_,7 @@ ++ this.f_62776_.addFreshBlockEntities(this.f_187610_.values()); + this.f_187610_.values().forEach((p_187988_) -> { + this.m_156404_(p_187988_); + this.m_156406_(p_187988_); +@@ -605,6 +_,41 @@ + this.f_196848_ = p_196865_; + } + ++ // FORGE START ++ private final net.minecraftforge.common.capabilities.CapabilityProvider.AsField capProvider = new net.minecraftforge.common.capabilities.CapabilityProvider.AsField<>(LevelChunk.class); ++ ++ @org.jetbrains.annotations.NotNull ++ @Override ++ public net.minecraftforge.common.util.LazyOptional getCapability(@org.jetbrains.annotations.NotNull net.minecraftforge.common.capabilities.Capability cap, @org.jetbrains.annotations.Nullable net.minecraft.core.Direction side) ++ { ++ return capProvider.getCapability(cap, side); ++ } ++ ++ @Override ++ public boolean areCapsCompatible(net.minecraftforge.common.capabilities.CapabilityProvider other) ++ { ++ return capProvider.areCapsCompatible(other); ++ } ++ ++ @Override ++ public boolean areCapsCompatible(@org.jetbrains.annotations.Nullable net.minecraftforge.common.capabilities.CapabilityDispatcher other) ++ { ++ return capProvider.areCapsCompatible(other); ++ } ++ ++ @Override ++ public void invalidateCaps() ++ { ++ capProvider.invalidateCaps(); ++ } ++ ++ @Override ++ public void reviveCaps() ++ { ++ capProvider.reviveCaps(); ++ } ++ // FORGE END ++ + class BoundTickingBlockEntity implements TickingBlockEntity { + private final T f_156428_; + private final BlockEntityTicker f_156429_; +@@ -621,6 +_,7 @@ if (LevelChunk.this.m_156410_(blockpos)) { try { ProfilerFiller profilerfiller = LevelChunk.this.f_62776_.m_46473_(); @@ -116,7 +153,7 @@ profilerfiller.m_6521_(this::m_142280_); BlockState blockstate = LevelChunk.this.m_8055_(blockpos); if (this.f_156428_.m_58903_().m_155262_(blockstate)) { -@@ -843,6 +_,12 @@ +@@ -638,6 +_,12 @@ CrashReport crashreport = CrashReport.m_127521_(throwable, "Ticking block entity"); CrashReportCategory crashreportcategory = crashreport.m_127514_("Block entity being ticked"); this.f_156428_.m_58886_(crashreportcategory); @@ -129,12 +166,13 @@ throw new ReportedException(crashreport); } } -@@ -871,6 +_,32 @@ +@@ -666,6 +_,34 @@ IMMEDIATE, QUEUED, CHECK; + } + ++ + /** + * FOR INTERNAL USE ONLY + *

@@ -143,17 +181,18 @@ + @java.lang.Deprecated + @javax.annotation.Nullable + public final CompoundTag writeCapsToNBT() { -+ return this.serializeCaps(); ++ return capProvider.serializeInternal(); + } + + /** + * FOR INTERNAL USE ONLY + *

+ * Only public for use in {@link net.minecraft.world.level.chunk.storage.ChunkSerializer}. ++ * + */ + @java.lang.Deprecated + public final void readCapsFromNBT(CompoundTag tag) { -+ this.deserializeCaps(tag); ++ capProvider.deserializeInternal(tag); + } + + @Override @@ -161,4 +200,4 @@ + return m_62953_(); } - class RebindableTickingBlockEntityWrapper implements TickingBlockEntity { + @FunctionalInterface diff --git a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch index 68547df889..fcd0aacad0 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/PalettedContainer.java.patch @@ -1,40 +1,10 @@ --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -62,6 +_,9 @@ - } +@@ -24,6 +_,7 @@ + import net.minecraft.util.ZeroBitStorage; - private void m_63121_(int p_63122_) { -+ setBits(p_63122_, false); -+ } -+ private void setBits(int p_63122_, boolean forceBits) { - if (p_63122_ != this.f_63076_) { - this.f_63076_ = p_63122_; - if (this.f_63076_ <= 4) { -@@ -72,6 +_,8 @@ - } else { - this.f_63075_ = this.f_63069_; - this.f_63076_ = Mth.m_14163_(this.f_63071_.m_122659_()); -+ if (forceBits) -+ this.f_63076_ = p_63122_; - } - - this.f_63075_.m_6796_(this.f_63074_); -@@ -147,7 +_,7 @@ - this.m_63084_(); - int i = p_63119_.readByte(); - if (this.f_63076_ != i) { -- this.m_63121_(i); -+ this.setBits(i, true); //Forge, Force bit density to fix network issues, resize below if needed. - } - - this.f_63075_.m_5680_(p_63119_); -@@ -156,6 +_,9 @@ - this.m_63120_(); - } - -+ int regSize = Mth.m_14163_(this.f_63071_.m_122659_()); -+ if (this.f_63075_ == f_63069_ && this.f_63076_ != regSize) // Resize bits to fit registry. -+ this.m_7248_(regSize, f_63074_); - } - - public void m_63135_(FriendlyByteBuf p_63136_) { + public class PalettedContainer implements PaletteResize { ++ // TODO: forceBits-parametered setBits function. -C + private static final int f_188031_ = 0; + private final PaletteResize f_63070_ = (p_63139_, p_63140_) -> { + return 0; diff --git a/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch index 0e22b425b7..cc5316fd1d 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -142,13 +_,13 @@ - if (this.f_63156_[l] == LevelChunk.f_62770_ && p_63218_.m_60713_(Blocks.f_50016_)) { +@@ -122,13 +_,13 @@ + if (this.f_187612_[l].m_188008_() && p_63218_.m_60713_(Blocks.f_50016_)) { return p_63218_; } else { - if (p_63218_.m_60791_() > 0) { @@ -9,7 +9,7 @@ this.f_63158_.add(new BlockPos((i & 15) + this.m_7697_().m_45604_(), j, (k & 15) + this.m_7697_().m_45605_())); } - LevelChunkSection levelchunksection = this.m_156115_(l); + LevelChunkSection levelchunksection = this.m_183278_(l); BlockState blockstate = levelchunksection.m_62986_(i & 15, j & 15, k & 15, p_63218_); - if (this.f_63153_.m_62427_(ChunkStatus.f_62322_) && p_63218_ != blockstate && (p_63218_.m_60739_(this, p_63217_) != blockstate.m_60739_(this, p_63217_) || p_63218_.m_60791_() != blockstate.m_60791_() || p_63218_.m_60787_() || blockstate.m_60787_())) { + if (this.f_63153_.m_62427_(ChunkStatus.f_62322_) && p_63218_ != blockstate && (p_63218_.m_60739_(this, p_63217_) != blockstate.m_60739_(this, p_63217_) || p_63218_.getLightEmission(this, p_63217_) != blockstate.getLightEmission(this, p_63217_) || p_63218_.m_60787_() || blockstate.m_60787_())) { diff --git a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch index 5a48c19cfb..cdcf17a3d0 100644 --- a/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch +++ b/patches/minecraft/net/minecraft/world/level/chunk/storage/ChunkSerializer.java.patch @@ -1,60 +1,60 @@ --- a/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -@@ -131,6 +_,7 @@ - chunkaccess = new LevelChunk(p_63458_.m_6018_(), p_63461_, chunkbiomecontainer, upgradedata, ticklist, ticklist1, k1, alevelchunksection, (p_156533_) -> { - m_156522_(p_63458_, compoundtag, p_156533_); - }); -+ if (compoundtag.m_128441_("ForgeCaps")) ((LevelChunk)chunkaccess).readCapsFromNBT(compoundtag.m_128469_("ForgeCaps")); +@@ -144,6 +_,7 @@ + return Registry.f_122822_.m_6612_(ResourceLocation.m_135820_(p_188285_)); + }, p_188233_); + chunkaccess = new LevelChunk(p_188231_.m_6018_(), p_188233_, upgradedata, levelchunkticks, levelchunkticks1, j1, alevelchunksection, m_196890_(p_188231_, p_188234_), blendingdata); ++ if (p_188234_.m_128441_("ForgeCaps")) ((LevelChunk)chunkaccess).readCapsFromNBT(p_188234_.m_128469_("ForgeCaps")); } else { - ProtoChunk protochunk = new ProtoChunk(p_63461_, upgradedata, alevelchunksection, prototicklist, prototicklist1, p_63458_); - protochunk.m_7329_(chunkbiomecontainer); -@@ -143,7 +_,7 @@ - - if (!flag && protochunk.m_6415_().m_62427_(ChunkStatus.f_62323_)) { - for(BlockPos blockpos : BlockPos.m_121976_(p_63461_.m_45604_(), p_63458_.m_141937_(), p_63461_.m_45605_(), p_63461_.m_45608_(), p_63458_.m_151558_() - 1, p_63461_.m_45609_())) { + ProtoChunkTicks protochunkticks = ProtoChunkTicks.m_193302_(p_188234_.m_128437_("block_ticks", 10), (p_196906_) -> { + return Registry.f_122824_.m_6612_(ResourceLocation.m_135820_(p_196906_)); +@@ -168,7 +_,7 @@ + boolean flag2 = chunkstatus.m_62427_(ChunkStatus.f_62323_) || belowzeroretrogen != null && belowzeroretrogen.m_188466_().m_62427_(ChunkStatus.f_62323_); + if (!flag && flag2) { + for(BlockPos blockpos : BlockPos.m_121976_(p_188233_.m_45604_(), p_188231_.m_141937_(), p_188233_.m_45605_(), p_188233_.m_45608_(), p_188231_.m_151558_() - 1, p_188233_.m_45609_())) { - if (chunkaccess.m_8055_(blockpos).m_60791_() != 0) { + if (chunkaccess.m_8055_(blockpos).getLightEmission(chunkaccess, blockpos) != 0) { protochunk.m_63277_(blockpos); } } -@@ -166,7 +_,7 @@ +@@ -191,7 +_,7 @@ Heightmap.m_64256_(chunkaccess, enumset); - CompoundTag compoundtag4 = compoundtag.m_128469_("Structures"); - chunkaccess.m_8040_(m_156518_(p_63458_, compoundtag4, p_63458_.m_7328_())); -- chunkaccess.m_7946_(m_63471_(p_63461_, compoundtag4)); -+ net.minecraftforge.common.ForgeHooks.fixNullStructureReferences(chunkaccess, m_63471_(p_63461_, compoundtag4)); - if (compoundtag.m_128471_("shouldSave")) { + CompoundTag compoundtag3 = p_188234_.m_128469_("structures"); + chunkaccess.m_8040_(m_188254_(StructurePieceSerializationContext.m_192770_(p_188231_), compoundtag3, p_188231_.m_7328_())); +- chunkaccess.m_7946_(m_63471_(p_188233_, compoundtag3)); ++ net.minecraftforge.common.ForgeHooks.fixNullStructureReferences(chunkaccess, m_63471_(p_188233_, compoundtag3)); + if (p_188234_.m_128471_("shouldSave")) { chunkaccess.m_8092_(true); } -@@ -182,6 +_,7 @@ +@@ -207,6 +_,7 @@ } if (chunkstatus$chunktype == ChunkStatus.ChunkType.LEVELCHUNK) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_63462_, chunkstatus$chunktype)); - return new ImposterProtoChunk((LevelChunk)chunkaccess); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_188234_, chunkstatus$chunktype)); + return new ImposterProtoChunk((LevelChunk)chunkaccess, false); } else { ProtoChunk protochunk1 = (ProtoChunk)chunkaccess; -@@ -215,6 +_,7 @@ - protochunk1.m_63189_(generationstep$carving, BitSet.valueOf(compoundtag5.m_128463_(s1))); +@@ -240,6 +_,7 @@ + protochunk1.m_188186_(generationstep$carving, new CarvingMask(compoundtag4.m_128467_(s1), chunkaccess.m_141937_())); } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_63462_, chunkstatus$chunktype)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Load(chunkaccess, p_188234_, chunkstatus$chunktype)); return protochunk1; } } -@@ -302,6 +_,15 @@ +@@ -347,6 +_,15 @@ } - compoundtag1.m_128365_("CarvingMasks", compoundtag4); + compoundtag.m_128365_("CarvingMasks", compoundtag4); + } + else { + LevelChunk levelChunk = (LevelChunk) p_63456_; + try { + final CompoundTag capTag = levelChunk.writeCapsToNBT(); -+ if (capTag != null) compoundtag1.m_128365_("ForgeCaps", capTag); ++ if (capTag != null) capTag.m_128365_("ForgeCaps", capTag); + } catch (Exception exception) { + LogManager.getLogger().error("A capability provider has thrown an exception trying to write state. It will not persist. Report this to the mod author", exception); + } } - TickList ticklist = p_63456_.m_5782_(); + m_188235_(p_63455_, compoundtag, p_63456_.m_183568_()); diff --git a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index aee3c0400a..d131027ea2 100644 --- a/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/patches/minecraft/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -96,6 +_,7 @@ +@@ -100,6 +_,7 @@ this.f_64068_ = p_64080_.m_128471_("DragonKilled"); this.f_64069_ = p_64080_.m_128471_("PreviouslyKilled"); @@ -8,7 +8,7 @@ if (p_64080_.m_128471_("IsRespawning")) { this.f_64073_ = DragonRespawnAnimation.START; } -@@ -127,13 +_,14 @@ +@@ -131,13 +_,14 @@ compoundtag.m_128379_("NeedsStateScanning", this.f_64071_); if (this.f_64070_ != null) { compoundtag.m_128362_("Dragon", this.f_64070_); @@ -24,7 +24,7 @@ ListTag listtag = new ListTag(); -@@ -503,6 +_,13 @@ +@@ -507,6 +_,13 @@ endcrystal.m_31052_((BlockPos)null); } } diff --git a/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch index bf410c7bca..ace7f49f82 100644 --- a/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch +++ b/patches/minecraft/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch @@ -34,7 +34,7 @@ @@ -371,9 +_,11 @@ PersistentEntitySectionManager.this.m_157509_(this.f_157610_, this.f_157611_); EntitySection entitysection = PersistentEntitySectionManager.this.f_157495_.m_156893_(i); - entitysection.m_156840_(this.f_157609_); + entitysection.m_188346_(this.f_157609_); + long oldSectionKey = f_157610_; this.f_157611_ = entitysection; this.f_157610_ = i; diff --git a/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch b/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch index fdc28e09d8..862b212b09 100644 --- a/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch +++ b/patches/minecraft/net/minecraft/world/level/entity/TransientEntitySectionManager.java.patch @@ -17,7 +17,7 @@ @@ -113,6 +_,7 @@ TransientEntitySectionManager.this.m_157648_(this.f_157669_, this.f_157670_); EntitySection entitysection = TransientEntitySectionManager.this.f_157638_.m_156893_(i); - entitysection.m_156840_(this.f_157668_); + entitysection.m_188346_(this.f_157668_); + long oldSectionKey = f_157669_; this.f_157670_ = entitysection; this.f_157669_ = i; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch index 9cf70ef48a..c43c786192 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/DebugLevelSource.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/DebugLevelSource.java +++ b/net/minecraft/world/level/levelgen/DebugLevelSource.java -@@ -107,4 +_,10 @@ +@@ -107,6 +_,12 @@ return blockstate; } @@ -10,4 +10,6 @@ + f_64115_ = Mth.m_14167_(Mth.m_14116_(f_64114_.size())); + f_64116_ = Mth.m_14167_((float) (f_64114_.size() / f_64115_)); + } - } + + public Climate.Sampler m_183403_() { + return (p_188507_, p_188508_, p_188509_) -> { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch index ba2a5518bb..5645968ed1 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -@@ -464,6 +_,9 @@ - } - - public WeightedRandomList m_142184_(Biome p_158433_, StructureFeatureManager p_158434_, MobCategory p_158435_, BlockPos p_158436_) { +@@ -387,6 +_,9 @@ + if (!p_158434_.m_186605_(p_158436_)) { + return super.m_142184_(p_158433_, p_158434_, p_158435_, p_158436_); + } else { + WeightedRandomList spawns = net.minecraftforge.common.world.StructureSpawnManager.getStructureSpawns(p_158434_, p_158435_, p_158436_); + if (spawns != null) return spawns; + if (false) {//Forge: We handle these hardcoded cases above in StructureSpawnManager#getStructureSpawns, but allow for insideOnly to be changed and allow for creatures to be spawned in ones other than just the witch hut - if (p_158434_.m_47285_(p_158436_, true, StructureFeature.f_67021_).m_73603_()) { - if (p_158435_ == MobCategory.MONSTER) { - return StructureFeature.f_67021_.m_142494_(); -@@ -486,6 +_,7 @@ - if (p_158434_.m_47285_(p_158436_, true, StructureFeature.f_67025_).m_73603_()) { - return StructureFeature.f_67025_.m_142494_(); + if (p_158434_.m_186613_(p_158436_, StructureFeature.f_67021_).m_73603_()) { + if (p_158435_ == MobCategory.MONSTER) { + return SwamplandHutFeature.f_67169_; +@@ -410,6 +_,7 @@ + return NetherFortressFeature.f_66381_; + } } + } - } - return p_158435_ == MobCategory.UNDERGROUND_WATER_CREATURE && p_158434_.m_47285_(p_158436_, false, StructureFeature.f_67023_).m_73603_() ? StructureFeature.f_67023_.m_160477_() : super.m_142184_(p_158433_, p_158434_, p_158435_, p_158436_); + return (p_158435_ == MobCategory.UNDERGROUND_WATER_CREATURE || p_158435_ == MobCategory.AXOLOTLS) && p_158434_.m_186607_(p_158436_, StructureFeature.f_67023_).m_73603_() ? MobSpawnSettings.f_151796_ : super.m_142184_(p_158433_, p_158434_, p_158435_, p_158436_); + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch index a6a3cef8a9..8297f6ae6c 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/WorldGenSettings.java.patch @@ -1,19 +1,19 @@ --- a/net/minecraft/world/level/levelgen/WorldGenSettings.java +++ b/net/minecraft/world/level/levelgen/WorldGenSettings.java -@@ -183,7 +_,7 @@ +@@ -198,7 +_,7 @@ String s3 = (String)p_64649_.get("level-type"); - String s4 = Optional.ofNullable(s3).map((p_64651_) -> { - return p_64651_.toLowerCase(Locale.ROOT); + String s4 = Optional.ofNullable(s3).map((p_190047_) -> { + return p_190047_.toLowerCase(Locale.ROOT); - }).orElse("default"); -+ }).orElseGet(net.minecraftforge.common.ForgeHooks::getDefaultWorldType); ++ }).orElseGet(net.minecraftforge.common.ForgeHooks::getDefaultWorldPreset); p_64649_.put("level-type", s4); long i = (new Random()).nextLong(); if (!s1.isEmpty()) { -@@ -201,6 +_,8 @@ +@@ -215,6 +_,8 @@ + Registry registry1 = p_64648_.m_175515_(Registry.f_122818_); Registry registry = p_64648_.m_175515_(Registry.f_122885_); - Registry registry1 = p_64648_.m_175515_(Registry.f_122878_); - MappedRegistry mappedregistry = DimensionType.m_63921_(registry2, registry, registry1, i); -+ net.minecraftforge.common.world.ForgeWorldType type = net.minecraftforge.registries.ForgeRegistries.WORLD_TYPES.getValue(new net.minecraft.resources.ResourceLocation(s4)); + MappedRegistry mappedregistry = DimensionType.m_188317_(p_64648_, i); ++ net.minecraftforge.common.world.ForgeWorldPreset type = net.minecraftforge.registries.ForgeRegistries.WORLD_TYPES.getValue(new net.minecraft.resources.ResourceLocation(s4)); + if (type != null) return type.createSettings(p_64648_, i, flag, false, s); switch(s4) { case "flat": diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch index 7e8b130d74..924da44d51 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/carver/WorldCarver.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/carver/WorldCarver.java +++ b/net/minecraft/world/level/levelgen/carver/WorldCarver.java -@@ -27,7 +_,7 @@ +@@ -24,7 +_,7 @@ import net.minecraft.world.level.material.Fluids; import org.apache.commons.lang3.mutable.MutableBoolean; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch index 137b389c8e..dbbf855518 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/Feature.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/feature/Feature.java +++ b/net/minecraft/world/level/levelgen/feature/Feature.java -@@ -49,7 +_,7 @@ +@@ -50,7 +_,7 @@ import net.minecraft.world.level.levelgen.feature.configurations.UnderwaterMagmaConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.VegetationPatchConfiguration; @@ -8,7 +8,7 @@ +public abstract class Feature extends net.minecraftforge.registries.ForgeRegistryEntry> { public static final Feature f_65759_ = m_65807_("no_op", new NoOpFeature(NoneFeatureConfiguration.f_67815_)); public static final Feature f_65760_ = m_65807_("tree", new TreeFeature(TreeConfiguration.f_68184_)); - public static final AbstractFlowerFeature f_65761_ = m_65807_("flower", new DefaultFlowerFeature(RandomPatchConfiguration.f_67902_)); + public static final Feature f_65761_ = m_65807_("flower", new RandomPatchFeature(RandomPatchConfiguration.f_67902_)); @@ -157,11 +_,11 @@ public abstract boolean m_142674_(FeaturePlaceContext p_159749_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java.patch deleted file mode 100644 index 659dcb1570..0000000000 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java -+++ b/net/minecraft/world/level/levelgen/feature/NetherFortressFeature.java -@@ -33,8 +_,11 @@ - return NetherFortressFeature.NetherBridgeStart::new; - } - -- public WeightedRandomList m_142494_() { -- return f_66381_; -+ @Override -+ public List getDefaultSpawnList(net.minecraft.world.entity.MobCategory category) { -+ if (category == net.minecraft.world.entity.MobCategory.MONSTER) -+ return f_66381_.m_146338_(); -+ return java.util.Collections.emptyList(); - } - - public static class NetherBridgeStart extends StructureStart { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch index cea7d68054..5aa405a10c 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java +++ b/net/minecraft/world/level/levelgen/feature/OceanMonumentFeature.java -@@ -55,8 +_,11 @@ - return OceanMonumentFeature.OceanMonumentStart::new; +@@ -28,8 +_,11 @@ + super(p_66472_, PieceGeneratorSupplier.m_197349_(OceanMonumentFeature::m_197131_, OceanMonumentFeature::m_191045_)); } -- public WeightedRandomList m_142494_() { -- return f_66469_; +- protected boolean m_5910_() { +- return false; + @Override + public java.util.List getDefaultSpawnList(net.minecraft.world.entity.MobCategory category) { + if (category == net.minecraft.world.entity.MobCategory.MONSTER) @@ -13,4 +13,4 @@ + return java.util.Collections.emptyList(); } - public static class OceanMonumentStart extends StructureStart { + private static boolean m_197131_(PieceGeneratorSupplier.Context p_197132_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java.patch deleted file mode 100644 index 87022276f9..0000000000 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java -+++ b/net/minecraft/world/level/levelgen/feature/PillagerOutpostFeature.java -@@ -20,8 +_,11 @@ - super(p_66562_, 0, true, true); - } - -- public WeightedRandomList m_142494_() { -- return f_66559_; -+ @Override -+ public java.util.List getDefaultSpawnList(net.minecraft.world.entity.MobCategory category) { -+ if (category == net.minecraft.world.entity.MobCategory.MONSTER) -+ return f_66559_.m_146338_(); -+ return java.util.Collections.emptyList(); - } - - protected boolean m_142290_(ChunkGenerator p_160197_, BiomeSource p_160198_, long p_160199_, WorldgenRandom p_160200_, ChunkPos p_160201_, Biome p_160202_, ChunkPos p_160203_, JigsawConfiguration p_160204_, LevelHeightAccessor p_160205_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch index 8806ac6469..06a9448d72 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/StructureFeature.java.patch @@ -1,35 +1,23 @@ --- a/net/minecraft/world/level/levelgen/feature/StructureFeature.java +++ b/net/minecraft/world/level/levelgen/feature/StructureFeature.java -@@ -49,7 +_,7 @@ +@@ -55,7 +_,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; --public abstract class StructureFeature { +-public class StructureFeature { +public abstract class StructureFeature extends net.minecraftforge.registries.ForgeRegistryEntry> implements net.minecraftforge.common.extensions.IForgeStructureFeature { public static final BiMap> f_67012_ = HashBiMap.create(); private static final Map, GenerationStep.Decoration> f_67032_ = Maps.newHashMap(); private static final Logger f_67033_ = LogManager.getLogger(); -@@ -250,15 +_,20 @@ - } +@@ -256,6 +_,11 @@ - public WeightedRandomList m_142494_() { -- return MobSpawnSettings.f_151796_; -+ return getSpawnList(net.minecraft.world.entity.MobCategory.MONSTER); - } - - public WeightedRandomList m_142498_() { -- return MobSpawnSettings.f_151796_; -+ return getSpawnList(net.minecraft.world.entity.MobCategory.CREATURE); - } - - public WeightedRandomList m_160477_() { -- return MobSpawnSettings.f_151796_; -+ return getSpawnList(net.minecraft.world.entity.MobCategory.UNDERGROUND_WATER_CREATURE); + public String m_67098_() { + return f_67012_.inverse().get(this); + } + + @Override -+ public final WeightedRandomList getSpawnList(net.minecraft.world.entity.MobCategory classification) { ++ public final net.minecraft.util.random.WeightedRandomList getSpawnList(net.minecraft.world.entity.MobCategory classification) { + return net.minecraftforge.common.world.StructureSpawnManager.getSpawnList(this, classification); } - public interface StructureStartFactory { + public BoundingBox m_183606_(BoundingBox p_191127_) { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java.patch deleted file mode 100644 index b228d7fedc..0000000000 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java -+++ b/net/minecraft/world/level/levelgen/feature/SwamplandHutFeature.java -@@ -26,12 +_,13 @@ - return SwamplandHutFeature.FeatureStart::new; - } - -- public WeightedRandomList m_142494_() { -- return f_67169_; -- } -- -- public WeightedRandomList m_142498_() { -- return f_67170_; -+ @Override -+ public java.util.List getDefaultSpawnList(net.minecraft.world.entity.MobCategory category) { -+ if (category == net.minecraft.world.entity.MobCategory.MONSTER) -+ return f_67169_.m_146338_(); -+ else if (category == net.minecraft.world.entity.MobCategory.CREATURE) -+ return f_67170_.m_146338_(); -+ return java.util.Collections.emptyList(); - } - - public static class FeatureStart extends StructureStart { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java.patch deleted file mode 100644 index 01780dff14..0000000000 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java -+++ b/net/minecraft/world/level/levelgen/feature/blockplacers/BlockPlacerType.java -@@ -3,7 +_,7 @@ - import com.mojang.serialization.Codec; - import net.minecraft.core.Registry; - --public class BlockPlacerType

{ -+public class BlockPlacerType

extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final BlockPlacerType f_67487_ = m_67495_("simple_block_placer", SimpleBlockPlacer.f_67528_); - public static final BlockPlacerType f_67488_ = m_67495_("double_plant_placer", DoublePlantPlacer.f_67517_); - public static final BlockPlacerType f_67489_ = m_67495_("column_placer", ColumnPlacer.f_67498_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch index aca52ac182..30e4e0399f 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java +++ b/net/minecraft/world/level/levelgen/feature/configurations/TreeConfiguration.java -@@ -36,6 +_,7 @@ - return p_161230_.f_161215_; - })).apply(p_161228_, TreeConfiguration::new); +@@ -33,6 +_,7 @@ + return p_161232_.f_161215_; + })).apply(p_191347_, TreeConfiguration::new); }); + //TODO: Review this, see if we can hook in the sapling into the Codec public final BlockStateProvider f_68185_; diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch index 4d19b15173..98be01c4ef 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProviderType.java.patch @@ -8,4 +8,4 @@ +public class BlockStateProviderType

extends net.minecraftforge.registries.ForgeRegistryEntry> { public static final BlockStateProviderType f_68752_ = m_68762_("simple_state_provider", SimpleStateProvider.f_68797_); public static final BlockStateProviderType f_68753_ = m_68762_("weighted_state_provider", WeightedStateProvider.f_68808_); - public static final BlockStateProviderType f_68754_ = m_68762_("plain_flower_provider", PlainFlowerProvider.f_68775_); + public static final BlockStateProviderType f_191386_ = m_68762_("noise_threshold_provider", NoiseThresholdProvider.f_191463_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch index 6b2b15a1f5..153929dd86 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java.patch @@ -1,29 +1,11 @@ --- a/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java +++ b/net/minecraft/world/level/levelgen/flat/FlatLevelGeneratorSettings.java -@@ -153,8 +_,16 @@ - biomegenerationsettings$builder.m_47842_(GenerationStep.Decoration.LAKES, Features.f_126876_); - } - -+ Map, ConfiguredStructureFeature> map = new java.util.HashMap<>(f_70349_); -+ net.minecraft.data.BuiltinRegistries.f_123862_.m_123024_().filter(f -> !map.containsKey(f.f_65403_)).forEach(f -> map.put(f.f_65403_, f)); - for(Entry, StructureFeatureConfiguration> entry : this.f_70351_.m_64590_().entrySet()) { -- biomegenerationsettings$builder.m_47849_(biomegenerationsettings.m_47803_(f_70349_.get(entry.getKey()))); -+ if (!map.containsKey(entry.getKey())) { -+ f_70348_.error("FORGE: There's no known StructureFeature for {} when preparing the {} flatworld biome." + -+ " The structure will be skipped and may not spawn." + -+ " Please register your StructureFeatures in the WorldGenRegistries!", entry.getKey().m_67098_(), biome.getRegistryName()); -+ continue; -+ } -+ biomegenerationsettings$builder.m_47849_(biomegenerationsettings.m_47803_(map.get(entry.getKey()))); - } - - boolean flag = (!this.f_70355_ || this.f_70350_.m_7854_(biome).equals(Optional.of(Biomes.f_48173_))) && this.f_70356_; -@@ -180,7 +_,7 @@ +@@ -152,7 +_,7 @@ } } -- return (new Biome.BiomeBuilder()).m_47597_(biome.m_47530_()).m_47595_(biome.m_47567_()).m_47593_(biome.m_47545_()).m_47607_(biome.m_47551_()).m_47609_(biome.m_47554_()).m_47611_(biome.m_47548_()).m_47603_(biome.m_47557_()).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47605_(biome.m_47518_()).m_47592_(); -+ return (new Biome.BiomeBuilder()).m_47597_(biome.m_47530_()).m_47595_(biome.m_47567_()).m_47593_(biome.m_47545_()).m_47607_(biome.m_47551_()).m_47609_(biome.m_47554_()).m_47611_(biome.m_47548_()).m_47603_(biome.m_47557_()).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47605_(biome.m_47518_()).m_47592_().setRegistryName(biome.getRegistryName()); +- return (new Biome.BiomeBuilder()).m_47597_(biome.m_47530_()).m_47595_(biome.m_47567_()).m_47609_(biome.m_47554_()).m_47611_(biome.m_47548_()).m_47603_(biome.m_47557_()).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47605_(biome.m_47518_()).m_47592_(); ++ return (new Biome.BiomeBuilder()).m_47597_(biome.m_47530_()).m_47595_(biome.m_47567_()).m_47609_(biome.m_47554_()).m_47611_(biome.m_47548_()).m_47603_(biome.m_47557_()).m_47601_(biomegenerationsettings$builder.m_47831_()).m_47605_(biome.m_47518_()).m_47592_().setRegistryName(biome.getRegistryName()); } public StructureSettings m_70395_() { diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java.patch deleted file mode 100644 index ddc9ba405a..0000000000 --- a/patches/minecraft/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java -+++ b/net/minecraft/world/level/levelgen/placement/FeatureDecorator.java -@@ -13,7 +_,7 @@ - import net.minecraft.world.level.levelgen.feature.configurations.RangeDecoratorConfiguration; - import net.minecraft.world.level.levelgen.placement.nether.CountMultiLayerDecorator; - --public abstract class FeatureDecorator { -+public abstract class FeatureDecorator extends net.minecraftforge.registries.ForgeRegistryEntry> { - public static final FeatureDecorator f_70681_ = m_70717_("nope", new NopePlacementDecorator(NoneDecoratorConfiguration.f_67810_)); - public static final FeatureDecorator f_70678_ = m_70717_("decorated", new DecoratedDecorator(DecoratedDecoratorConfiguration.f_70570_)); - public static final FeatureDecorator f_70697_ = m_70717_("carving_mask", new CarvingMaskDecorator(CarvingMaskDecoratorConfiguration.f_70441_)); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index 048cebf007..1a1356ed05 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -70,6 +_,9 @@ +@@ -72,6 +_,9 @@ } - public final CompoundTag m_163549_(ServerLevel p_163550_) { + public final CompoundTag m_192644_(StructurePieceSerializationContext p_192645_) { + if (Registry.f_122843_.m_7981_(this.m_73550_()) == null) { // FORGE: Friendlier error then the Null String error below. + throw new RuntimeException("StructurePiece \"" + this.getClass().getName() + "\": \"" + this.m_73550_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + } diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 8b7c21e15e..0ec2bde494 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureStart.java +++ b/net/minecraft/world/level/levelgen/structure/StructureStart.java -@@ -96,6 +_,9 @@ - public CompoundTag m_163606_(ServerLevel p_163607_, ChunkPos p_163608_) { +@@ -62,6 +_,9 @@ + public CompoundTag m_192660_(StructurePieceSerializationContext p_192661_, ChunkPos p_192662_) { CompoundTag compoundtag = new CompoundTag(); if (this.m_73603_()) { + if (Registry.f_122841_.m_7981_(this.m_73610_()) == null) { // FORGE: This is just a more friendly error instead of the 'Null String' below + throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\": \"" + this.m_73610_() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + } compoundtag.m_128359_("id", Registry.f_122841_.m_7981_(this.m_73610_()).toString()); - compoundtag.m_128405_("ChunkX", p_163608_.f_45578_); - compoundtag.m_128405_("ChunkZ", p_163608_.f_45579_); + compoundtag.m_128405_("ChunkX", p_192662_.f_45578_); + compoundtag.m_128405_("ChunkZ", p_192662_.f_45579_); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index cbfa9f4a83..e8e52f4d68 100644 --- a/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/patches/minecraft/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -204,6 +_,10 @@ +@@ -200,6 +_,10 @@ return m_74593_(p_74565_, p_74564_.m_74401_(), p_74564_.m_74404_(), p_74564_.m_74407_()); } @@ -11,7 +11,7 @@ public boolean m_74536_(ServerLevelAccessor p_74537_, BlockPos p_74538_, BlockPos p_74539_, StructurePlaceSettings p_74540_, Random p_74541_, int p_74542_) { if (this.f_74482_.isEmpty()) { return false; -@@ -221,7 +_,7 @@ +@@ -217,7 +_,7 @@ int i1 = Integer.MIN_VALUE; int j1 = Integer.MIN_VALUE; @@ -20,7 +20,7 @@ BlockPos blockpos = structuretemplate$structureblockinfo.f_74675_; if (boundingbox == null || boundingbox.m_71051_(blockpos)) { FluidState fluidstate = p_74540_.m_74413_() ? p_74537_.m_6425_(blockpos) : null; -@@ -336,7 +_,7 @@ +@@ -329,7 +_,7 @@ } if (!p_74540_.m_74408_()) { @@ -29,7 +29,7 @@ } return true; -@@ -365,14 +_,19 @@ +@@ -358,14 +_,19 @@ }); } @@ -50,7 +50,7 @@ } if (structuretemplate$structureblockinfo1 != null) { -@@ -383,13 +_,30 @@ +@@ -376,13 +_,30 @@ return list; } @@ -87,12 +87,12 @@ ListTag listtag = new ListTag(); listtag.add(DoubleTag.m_128500_(vec31.f_82479_)); listtag.add(DoubleTag.m_128500_(vec31.f_82480_)); -@@ -397,10 +_,10 @@ +@@ -390,10 +_,10 @@ compoundtag.m_128365_("Pos", listtag); compoundtag.m_128473_("UUID"); m_74543_(p_74524_, compoundtag).ifPresent((p_74553_) -> { - float f = p_74553_.m_6961_(p_74526_); -- f = f + (p_74553_.m_146908_() - p_74553_.m_7890_(p_74527_)); +- f += p_74553_.m_146908_() - p_74553_.m_7890_(p_74527_); + float f = p_74553_.m_6961_(placementIn.m_74401_()); + f = f + (p_74553_.m_146908_() - p_74553_.m_7890_(placementIn.m_74404_())); p_74553_.m_7678_(vec31.f_82479_, vec31.f_82480_, vec31.f_82481_, f, p_74553_.m_146909_()); diff --git a/patches/minecraft/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java.patch b/patches/minecraft/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java.patch deleted file mode 100644 index d7121eea2a..0000000000 --- a/patches/minecraft/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java -+++ b/net/minecraft/world/level/levelgen/surfacebuilders/SurfaceBuilder.java -@@ -8,7 +_,7 @@ - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.chunk.ChunkAccess; - --public abstract class SurfaceBuilder { -+public abstract class SurfaceBuilder extends net.minecraftforge.registries.ForgeRegistryEntry> { - private static final BlockState f_75193_ = Blocks.f_50493_.m_49966_(); - private static final BlockState f_75194_ = Blocks.f_50440_.m_49966_(); - private static final BlockState f_75195_ = Blocks.f_50599_.m_49966_(); diff --git a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch index b0fb102815..9d25ea00dc 100644 --- a/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch +++ b/patches/minecraft/net/minecraft/world/level/material/FluidState.java.patch @@ -6,11 +6,11 @@ -public final class FluidState extends StateHolder { +public final class FluidState extends StateHolder implements net.minecraftforge.common.extensions.IForgeFluidState { - public static final Codec f_76146_ = m_61127_(Registry.f_122822_, Fluid::m_76145_).stable(); + public static final Codec f_76146_ = m_61127_(Registry.f_122822_.m_194605_(), Fluid::m_76145_).stable(); public static final int f_164510_ = 9; public static final int f_164511_ = 8; -@@ -102,6 +_,7 @@ - return this.m_76152_().m_76108_(p_76154_); +@@ -106,6 +_,7 @@ + return this.m_76152_() == p_192918_; } + @Deprecated //Forge: Use more sensitive version diff --git a/patches/minecraft/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java.patch b/patches/minecraft/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java.patch deleted file mode 100644 index ef5c220f63..0000000000 --- a/patches/minecraft/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java.patch +++ /dev/null @@ -1,64 +0,0 @@ ---- a/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java -+++ b/net/minecraft/world/level/newbiome/layer/BiomeInitLayer.java -@@ -10,12 +_,13 @@ - private static final int[] f_76688_ = new int[]{4, 3, 5, 1}; - private static final int[] f_76689_ = new int[]{12, 12, 12, 30}; - private int[] f_76690_ = f_76686_; -+ private final boolean legacyDesert; -+ private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; - - public BiomeInitLayer(boolean p_76693_) { -- if (p_76693_) { -- this.f_76690_ = f_76685_; -- } -- -+ this.legacyDesert = p_76693_; -+ for (net.minecraftforge.common.BiomeManager.BiomeType type : net.minecraftforge.common.BiomeManager.BiomeType.values()) -+ biomes[type.ordinal()] = new java.util.ArrayList<>(net.minecraftforge.common.BiomeManager.getBiomes(type)); - } - - public int m_8006_(Context p_76695_, int p_76696_) { -@@ -28,26 +_,39 @@ - return p_76695_.m_5826_(3) == 0 ? 39 : 38; - } - -- return this.f_76690_[p_76695_.m_5826_(this.f_76690_.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.DESERT, p_76695_); - case 2: - if (i > 0) { - return 21; - } - -- return f_76687_[p_76695_.m_5826_(f_76687_.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.WARM, p_76695_); - case 3: - if (i > 0) { - return 32; - } - -- return f_76688_[p_76695_.m_5826_(f_76688_.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.COOL, p_76695_); - case 4: -- return f_76689_[p_76695_.m_5826_(f_76689_.length)]; -+ return getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType.ICY, p_76695_); - default: - return 14; - } - } else { - return p_76696_; - } -+ } -+ -+ private int getBiomeId(net.minecraftforge.common.BiomeManager.BiomeType type, Context context) { -+ return net.minecraft.data.BuiltinRegistries.f_123865_.m_7447_( -+ net.minecraft.data.BuiltinRegistries.f_123865_.m_6246_(getBiome(type, context))); -+ } -+ protected net.minecraft.resources.ResourceKey getBiome(net.minecraftforge.common.BiomeManager.BiomeType type, Context context) { -+ if (type == net.minecraftforge.common.BiomeManager.BiomeType.DESERT && this.legacyDesert) -+ type = net.minecraftforge.common.BiomeManager.BiomeType.DESERT_LEGACY; -+ java.util.List biomeList = biomes[type.ordinal()]; -+ int totalWeight = net.minecraft.util.WeighedRandom.m_14470_(biomeList); -+ int weight = net.minecraftforge.common.BiomeManager.isTypeListModded(type) ? context.m_5826_(totalWeight) : context.m_5826_(totalWeight / 10) * 10; -+ return net.minecraft.util.WeighedRandom.m_145031_(biomeList, weight).get().getKey(); - } - } diff --git a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch index bfd88f8288..5cc7bc8471 100644 --- a/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch +++ b/patches/minecraft/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java.patch @@ -4,7 +4,7 @@ protected static BlockPathTypes m_77643_(BlockGetter p_77644_, BlockPos p_77645_) { BlockState blockstate = p_77644_.m_8055_(p_77645_); -+ BlockPathTypes type = blockstate.getAiPathNodeType(p_77644_, p_77645_); ++ BlockPathTypes type = blockstate.getBlockPathType(p_77644_, p_77645_); + if (type != null) return type; Block block = blockstate.m_60734_(); Material material = blockstate.m_60767_(); diff --git a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 0376b4c72c..2ebdd08337 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/level/storage/LevelStorageSource.java +++ b/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -94,7 +_,7 @@ - } - } - -- Dynamic dynamic1 = p_78206_.update(References.f_16795_, dynamic, p_78207_, SharedConstants.m_136187_().getWorldVersion()); -+ Dynamic dynamic1 = net.minecraftforge.common.ForgeHooks.fixUpDimensionsData(p_78206_.update(References.f_16795_, dynamic, p_78207_, SharedConstants.m_136187_().getWorldVersion())); - DataResult dataresult = WorldGenSettings.f_64600_.parse(dynamic1); - return Pair.of(dataresult.resultOrPartial(Util.m_137489_("WorldGenSettings: ", f_78191_::error)).orElseGet(() -> { - Registry registry = RegistryLookupCodec.m_135622_(Registry.f_122818_).codec().parse(dynamic1).resultOrPartial(Util.m_137489_("Dimension type registry: ", f_78191_::error)).orElseThrow(() -> { -@@ -191,6 +_,10 @@ +@@ -178,6 +_,10 @@ } static BiFunction m_78247_(DynamicOps p_78248_, DataPackConfig p_78249_) { @@ -17,22 +8,22 @@ + } + + private static BiFunction getReader(DynamicOps p_78248_, DataPackConfig p_78249_, @Nullable LevelStorageAccess levelSave) { - return (p_78214_, p_78215_) -> { + return (p_193010_, p_193011_) -> { try { - CompoundTag compoundtag = NbtIo.m_128937_(p_78214_); -@@ -202,7 +_,10 @@ - Pair pair = m_78204_(dynamic, p_78215_, i); + CompoundTag compoundtag = NbtIo.m_128937_(p_193010_); +@@ -189,7 +_,10 @@ + Pair pair = m_78204_(dynamic, p_193011_, i); LevelVersion levelversion = LevelVersion.m_78390_(dynamic); LevelSettings levelsettings = LevelSettings.m_46924_(dynamic, p_78249_); -- return PrimaryLevelData.m_78530_(dynamic, p_78215_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), pair.getSecond()); -+ PrimaryLevelData info = PrimaryLevelData.m_78530_(dynamic, p_78215_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), pair.getSecond()); +- return PrimaryLevelData.m_78530_(dynamic, p_193011_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), pair.getSecond()); ++ PrimaryLevelData info = PrimaryLevelData.m_78530_(dynamic, p_193011_, i, compoundtag2, levelsettings, levelversion, pair.getFirst(), pair.getSecond()); + if (levelSave != null) -+ net.minecraftforge.fmllegacy.WorldPersistenceHooks.handleWorldDataLoad(levelSave, info, compoundtag); ++ net.minecraftforge.internal.WorldPersistenceHooks.handleWorldDataLoad(levelSave, info, compoundtag); + return info; } catch (Exception exception) { - f_78191_.error("Exception reading {}", p_78214_, exception); + f_78191_.error("Exception reading {}", p_193010_, exception); return null; -@@ -319,7 +_,7 @@ +@@ -296,7 +_,7 @@ @Nullable public WorldData m_78280_(DynamicOps p_78281_, DataPackConfig p_78282_) { this.m_78313_(); @@ -41,16 +32,16 @@ } @Nullable -@@ -338,6 +_,8 @@ +@@ -315,6 +_,8 @@ CompoundTag compoundtag1 = new CompoundTag(); compoundtag1.m_128365_("Data", compoundtag); -+ net.minecraftforge.fmllegacy.WorldPersistenceHooks.handleWorldDataSave(this, p_78292_, compoundtag1); ++ net.minecraftforge.internal.WorldPersistenceHooks.handleWorldDataSave(this, p_78292_, compoundtag1); + try { File file2 = File.createTempFile("level", ".dat", file1); NbtIo.m_128944_(compoundtag1, file2); -@@ -352,6 +_,10 @@ +@@ -329,6 +_,10 @@ public Optional m_182514_() { return !this.f_78270_.m_13639_() ? Optional.empty() : Optional.of(this.f_78271_.resolve("icon.png")); diff --git a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch index 265cee7b40..86525e895c 100644 --- a/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch +++ b/patches/minecraft/net/minecraft/world/level/storage/loot/LootPool.java.patch @@ -47,7 +47,7 @@ public LootPool.Builder m_165133_(NumberProvider p_165134_) { this.f_79070_ = p_165134_; -@@ -153,11 +_,22 @@ +@@ -153,11 +_,16 @@ return this; } @@ -55,12 +55,6 @@ + this.name = name; + return this; + } -+ -+ @Deprecated(forRemoval = true, since = "1.17.1") // FORGE: Use #setBonusRolls instead with UniformGenerator -+ public LootPool.Builder bonusRolls(float min, float max) { -+ this.f_79071_ = net.minecraft.world.level.storage.loot.providers.number.UniformGenerator.m_165780_(min, max); -+ return this; -+ } + public LootPool m_79082_() { if (this.f_79070_ == null) { diff --git a/src/main/java/net/minecraftforge/fmlclient/registry/ClientRegistry.java b/src/main/java/net/minecraftforge/client/ClientRegistry.java similarity index 97% rename from src/main/java/net/minecraftforge/fmlclient/registry/ClientRegistry.java rename to src/main/java/net/minecraftforge/client/ClientRegistry.java index e4bd2457f5..cd2e0c28cd 100644 --- a/src/main/java/net/minecraftforge/fmlclient/registry/ClientRegistry.java +++ b/src/main/java/net/minecraftforge/client/ClientRegistry.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.registry; +package net.minecraftforge.client; import net.minecraft.world.entity.Entity; import net.minecraft.resources.ResourceLocation; diff --git a/src/main/java/net/minecraftforge/fmlclient/ConfigGuiHandler.java b/src/main/java/net/minecraftforge/client/ConfigGuiHandler.java similarity index 97% rename from src/main/java/net/minecraftforge/fmlclient/ConfigGuiHandler.java rename to src/main/java/net/minecraftforge/client/ConfigGuiHandler.java index d6dc3c90c8..0b21f000af 100644 --- a/src/main/java/net/minecraftforge/fmlclient/ConfigGuiHandler.java +++ b/src/main/java/net/minecraftforge/client/ConfigGuiHandler.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient; +package net.minecraftforge.client; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; diff --git a/src/main/java/net/minecraftforge/fmlclient/ExtendedServerListData.java b/src/main/java/net/minecraftforge/client/ExtendedServerListData.java similarity index 97% rename from src/main/java/net/minecraftforge/fmlclient/ExtendedServerListData.java rename to src/main/java/net/minecraftforge/client/ExtendedServerListData.java index ce6e8fd1fb..d70eea4aaa 100644 --- a/src/main/java/net/minecraftforge/fmlclient/ExtendedServerListData.java +++ b/src/main/java/net/minecraftforge/client/ExtendedServerListData.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient; +package net.minecraftforge.client; public class ExtendedServerListData { public final String type; diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 6d247efa7e..1b9b2ea711 100755 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -19,7 +19,6 @@ package net.minecraftforge.client; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; @@ -65,7 +64,6 @@ import net.minecraft.client.resources.model.Material; import net.minecraft.client.renderer.texture.TextureAtlas; import com.mojang.blaze3d.platform.NativeImage; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import com.mojang.blaze3d.vertex.VertexFormatElement.Usage; import net.minecraft.client.resources.language.I18n; import net.minecraft.client.KeyMapping; import net.minecraft.world.entity.Entity; @@ -101,8 +99,7 @@ import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.*; import net.minecraftforge.client.event.sound.PlaySoundEvent; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.animation.Animation; +import net.minecraftforge.client.model.ForgeModelBakery; import net.minecraftforge.client.textures.ForgeTextureMetadata; import net.minecraftforge.common.ForgeMod; import net.minecraftforge.common.MinecraftForge; @@ -111,28 +108,22 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.*; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fmlclient.ExtendedServerListData; -import net.minecraftforge.fmlclient.registry.ClientRegistry; -import net.minecraftforge.fmllegacy.ForgeI18n; -import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; +import net.minecraftforge.common.ForgeI18n; +import net.minecraftforge.network.NetworkConstants; +import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.GameData; -import net.minecraftforge.resource.VanillaResourceType; import net.minecraftforge.versions.forge.ForgeVersion; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import org.lwjgl.opengl.GL13; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.io.File; import java.io.IOException; -import java.nio.Buffer; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -152,8 +143,6 @@ import java.util.stream.Stream; import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO; import static net.minecraftforge.fml.VersionChecker.Status.BETA; import static net.minecraftforge.fml.VersionChecker.Status.BETA_OUTDATED; -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.opengl.GL20.*; import net.minecraft.client.Camera; import net.minecraft.client.renderer.block.BlockRenderDispatcher; @@ -225,8 +214,7 @@ public class ForgeHooksClient return result != null ? result : _default; } - //TODO: Rename to onDrawHighlight - public static boolean onDrawBlockHighlight(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) + public static boolean onDrawHighlight(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) { switch (target.getType()) { case BLOCK: @@ -242,7 +230,7 @@ public class ForgeHooksClient public static void dispatchRenderLast(LevelRenderer context, PoseStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano) { - MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, mat, partialTicks, projectionMatrix, finishTimeNano)); + MinecraftForge.EVENT_BUS.post(new RenderLevelLastEvent(context, mat, partialTicks, projectionMatrix, finishTimeNano)); } public static boolean renderSpecificFirstPersonHand(InteractionHand hand, PoseStack mat, MultiBufferSource buffers, int light, float partialTicks, float interpPitch, float swingProgress, float equipProgress, ItemStack stack) @@ -275,11 +263,11 @@ public class ForgeHooksClient ModLoader.get().postEvent(new ColorHandlerEvent.Item(itemColors, blockColors)); } - static final ThreadLocal renderLayer = new ThreadLocal(); + static final ThreadLocal renderType = new ThreadLocal(); - public static void setRenderLayer(RenderType layer) + public static void setRenderType(RenderType layer) { - renderLayer.set(layer); + renderType.set(layer); } public static > A getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlot slot, A _default) @@ -308,21 +296,16 @@ public class ForgeHooksClient return base + name; } } -/* TODO mouse input - public static boolean postMouseEvent() + + public static float getFieldOfView(Player entity, float fov) { - return MinecraftForge.EVENT_BUS.post(new MouseEvent()); - } -*/ - public static float getOffsetFOV(Player entity, float fov) - { - FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov); - MinecraftForge.EVENT_BUS.post(fovUpdateEvent); - return fovUpdateEvent.getNewfov(); + FOVModifierEvent fovModifierEvent = new FOVModifierEvent(entity, fov); + MinecraftForge.EVENT_BUS.post(fovModifierEvent); + return fovModifierEvent.getNewfov(); } - public static double getFOVModifier(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) { - EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, info, renderPartialTicks, fov); + public static double getFieldOfView(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) { + EntityViewRenderEvent.FieldOfView event = new EntityViewRenderEvent.FieldOfView(renderer, info, renderPartialTicks, fov); MinecraftForge.EVENT_BUS.post(event); return event.getFOV(); } @@ -367,15 +350,7 @@ public class ForgeHooksClient { PlaySoundEvent e = new PlaySoundEvent(manager, sound); MinecraftForge.EVENT_BUS.post(e); - return e.getResultSound(); - } - - //static RenderBlocks VertexBufferRB; - static int worldRenderPass; - - public static int getWorldRenderPass() - { - return worldRenderPass; + return e.getSound(); } public static void drawScreen(Screen screen, PoseStack mStack, int mouseX, int mouseY, float partialTicks) @@ -392,9 +367,9 @@ public class ForgeHooksClient private static void drawScreenInternal(Screen screen, PoseStack mStack, int mouseX, int mouseY, float partialTicks) { - if (!MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Pre(screen, mStack, mouseX, mouseY, partialTicks))) + if (!MinecraftForge.EVENT_BUS.post(new ScreenEvent.DrawScreenEvent.Pre(screen, mStack, mouseX, mouseY, partialTicks))) screen.render(mStack, mouseX, mouseY, partialTicks); - MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mStack, mouseX, mouseY, partialTicks)); + MinecraftForge.EVENT_BUS.post(new ScreenEvent.DrawScreenEvent.Post(screen, mStack, mouseX, mouseY, partialTicks)); } public static float getFogDensity(FogMode type, Camera info, float partial, float density) @@ -416,7 +391,7 @@ public class ForgeHooksClient return event; } - public static void onModelBake(ModelManager modelManager, Map modelRegistry, ModelLoader modelLoader) + public static void onModelBake(ModelManager modelManager, Map modelRegistry, ForgeModelBakery modelLoader) { ModLoader.get().postEvent(new ModelBakeEvent(modelManager, modelRegistry, modelLoader)); modelLoader.onPostBakeEvent(modelRegistry); @@ -453,112 +428,6 @@ public class ForgeHooksClient return model; } - // moved and expanded from WorldVertexBufferUploader.draw - - public static void preDraw(Usage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer) - { - VertexFormatElement attr = format.getElements().get(element); - int count = attr.getElementCount(); - int constant = attr.getType().getGlType(); - ((Buffer)buffer).position(format.getOffset(element)); - switch(attrType) - { - case POSITION: - glVertexPointer(count, constant, stride, buffer); - glEnableClientState(GL_VERTEX_ARRAY); - break; - case NORMAL: - if(count != 3) - { - throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr); - } - glNormalPointer(constant, stride, buffer); - glEnableClientState(GL_NORMAL_ARRAY); - break; - case COLOR: - glColorPointer(count, constant, stride, buffer); - glEnableClientState(GL_COLOR_ARRAY); - break; - case UV: - GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + attr.getIndex()); - glTexCoordPointer(count, constant, stride, buffer); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - GL13.glClientActiveTexture(GL13.GL_TEXTURE0); - break; - case PADDING: - break; - case GENERIC: - glEnableVertexAttribArray(attr.getIndex()); - glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer); - break; - default: - LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getName()); - } - } - - public static void postDraw(Usage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer) - { - VertexFormatElement attr = format.getElements().get(element); - switch(attrType) - { - case POSITION: - glDisableClientState(GL_VERTEX_ARRAY); - break; - case NORMAL: - glDisableClientState(GL_NORMAL_ARRAY); - break; - case COLOR: - glDisableClientState(GL_COLOR_ARRAY); - break; - case UV: - GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + attr.getIndex()); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - GL13.glClientActiveTexture(GL13.GL_TEXTURE0); - break; - case PADDING: - break; - case GENERIC: - glDisableVertexAttribArray(attr.getIndex()); - break; - default: - LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getName()); - } - } - - public static int getColorIndex(VertexFormat fmt) - { - ImmutableList elements = fmt.getElements(); - for(int i=0;i>> 8) & 0xFF; - float vcb = (vc >>> 16) & 0xFF; - float vca = (vc >>> 24) & 0xFF; - int ncr = Math.min(0xFF, (int)(cr * vcr / 0xFF)); - int ncg = Math.min(0xFF, (int)(cg * vcg / 0xFF)); - int ncb = Math.min(0xFF, (int)(cb * vcb / 0xFF)); - int nca = Math.min(0xFF, (int)(ca * vca / 0xFF)); - renderer.putColorRGBA(renderer.getColorIndex(4 - i), ncr, ncg, ncb, nca); - } - }*/ - @SuppressWarnings("deprecation") public static TextureAtlasSprite[] getFluidSprites(BlockAndTintGetter world, BlockPos pos, FluidState fluidStateIn) { @@ -659,17 +528,17 @@ public class ForgeHooksClient return from.getItem().shouldCauseReequipAnimation(from, to, changed); } - public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(PoseStack mStack, Window res, LerpingBossEvent bossInfo, int x, int y, int increment) + public static RenderGameOverlayEvent.BossInfo renderBossEventPre(PoseStack mStack, Window res, LerpingBossEvent bossInfo, int x, int y, int increment) { - RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res), + RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(mStack, new RenderGameOverlayEvent(mStack, MinecraftForgeClient.getPartialTick(), res), BOSSINFO, bossInfo, x, y, increment); MinecraftForge.EVENT_BUS.post(evt); return evt; } - public static void bossBarRenderPost(PoseStack mStack, Window res) + public static void renderBossEventPost(PoseStack mStack, Window res) { - MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, new RenderGameOverlayEvent(mStack, Animation.getPartialTickTime(), res), BOSSINFO)); + MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(mStack, new RenderGameOverlayEvent(mStack, MinecraftForgeClient.getPartialTick(), res), BOSSINFO)); } public static ScreenshotEvent onScreenshot(NativeImage image, File screenshotFile) @@ -679,11 +548,11 @@ public class ForgeHooksClient return event; } - public static void onClientChangeGameMode(PlayerInfo info, GameType currentGameMode, GameType newGameMode) + public static void onClientChangeGameType(PlayerInfo info, GameType currentGameMode, GameType newGameMode) { if (currentGameMode != newGameMode) { - ClientPlayerChangeGameModeEvent evt = new ClientPlayerChangeGameModeEvent(info, currentGameMode, newGameMode); + ClientPlayerChangeGameTypeEvent evt = new ClientPlayerChangeGameTypeEvent(info, currentGameMode, newGameMode); MinecraftForge.EVENT_BUS.post(evt); } } @@ -698,110 +567,100 @@ public class ForgeHooksClient return model; } - public static void onInputUpdate(Player player, Input movementInput) + public static void onMovementInputUpdate(Player player, Input movementInput) { - MinecraftForge.EVENT_BUS.post(new InputUpdateEvent(player, movementInput)); + MinecraftForge.EVENT_BUS.post(new MovementInputUpdateEvent(player, movementInput)); } - /** - * @deprecated use {@link Minecraft#reloadResourcePacks()} instead - */ - @Deprecated(since="1.17.1", forRemoval = true) - public static void refreshResources(Minecraft mc, VanillaResourceType... types) { - mc.reloadResourcePacks(); - } - - public static boolean onGuiMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button) + public static boolean onScreenMouseClickedPre(Screen guiScreen, double mouseX, double mouseY, int button) { - Event event = new GuiScreenEvent.MouseClickedEvent.Pre(guiScreen, mouseX, mouseY, button); + Event event = new ScreenEvent.MouseClickedEvent.Pre(guiScreen, mouseX, mouseY, button); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) + public static boolean onScreenMouseClickedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) { - Event event = new GuiScreenEvent.MouseClickedEvent.Post(guiScreen, mouseX, mouseY, button, handled); - event.setCanceled(handled); + Event event = new ScreenEvent.MouseClickedEvent.Post(guiScreen, mouseX, mouseY, button, handled); MinecraftForge.EVENT_BUS.post(event); return event.getResult() == Event.Result.DEFAULT ? handled : event.getResult() == Event.Result.ALLOW; } - public static boolean onGuiMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button) + public static boolean onScreenMouseReleasedPre(Screen guiScreen, double mouseX, double mouseY, int button) { - Event event = new GuiScreenEvent.MouseReleasedEvent.Pre(guiScreen, mouseX, mouseY, button); + Event event = new ScreenEvent.MouseReleasedEvent.Pre(guiScreen, mouseX, mouseY, button); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) + public static boolean onScreenMouseReleasedPost(Screen guiScreen, double mouseX, double mouseY, int button, boolean handled) { - Event event = new GuiScreenEvent.MouseReleasedEvent.Post(guiScreen, mouseX, mouseY, button, handled); - event.setCanceled(handled); + Event event = new ScreenEvent.MouseReleasedEvent.Post(guiScreen, mouseX, mouseY, button, handled); MinecraftForge.EVENT_BUS.post(event); return event.getResult() == Event.Result.DEFAULT ? handled : event.getResult() == Event.Result.ALLOW; } - public static boolean onGuiMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) + public static boolean onScreenMouseDragPre(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - Event event = new GuiScreenEvent.MouseDragEvent.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY); + Event event = new ScreenEvent.MouseDragEvent.Pre(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) + public static boolean onScreenMouseDragPost(Screen guiScreen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - Event event = new GuiScreenEvent.MouseDragEvent.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY); + Event event = new ScreenEvent.MouseDragEvent.Post(guiScreen, mouseX, mouseY, mouseButton, dragX, dragY); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseScrollPre(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) + public static boolean onScreenMouseScrollPre(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) { Window mainWindow = guiScreen.getMinecraft().getWindow(); double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth(); double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight(); - Event event = new GuiScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta); + Event event = new ScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) + public static boolean onScreenMouseScrollPost(MouseHandler mouseHelper, Screen guiScreen, double scrollDelta) { Window mainWindow = guiScreen.getMinecraft().getWindow(); double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth(); double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight(); - Event event = new GuiScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta); + Event event = new ScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiKeyPressedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers) + public static boolean onScreenKeyPressedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers) { - Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Pre(guiScreen, keyCode, scanCode, modifiers); + Event event = new ScreenEvent.KeyboardKeyPressedEvent.Pre(guiScreen, keyCode, scanCode, modifiers); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiKeyPressedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers) + public static boolean onScreenKeyPressedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers) { - Event event = new GuiScreenEvent.KeyboardKeyPressedEvent.Post(guiScreen, keyCode, scanCode, modifiers); + Event event = new ScreenEvent.KeyboardKeyPressedEvent.Post(guiScreen, keyCode, scanCode, modifiers); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiKeyReleasedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers) + public static boolean onScreenKeyReleasedPre(Screen guiScreen, int keyCode, int scanCode, int modifiers) { - Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Pre(guiScreen, keyCode, scanCode, modifiers); + Event event = new ScreenEvent.KeyboardKeyReleasedEvent.Pre(guiScreen, keyCode, scanCode, modifiers); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiKeyReleasedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers) + public static boolean onScreenKeyReleasedPost(Screen guiScreen, int keyCode, int scanCode, int modifiers) { - Event event = new GuiScreenEvent.KeyboardKeyReleasedEvent.Post(guiScreen, keyCode, scanCode, modifiers); + Event event = new ScreenEvent.KeyboardKeyReleasedEvent.Post(guiScreen, keyCode, scanCode, modifiers); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiCharTypedPre(Screen guiScreen, char codePoint, int modifiers) + public static boolean onScreenCharTypedPre(Screen guiScreen, char codePoint, int modifiers) { - Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Pre(guiScreen, codePoint, modifiers); + Event event = new ScreenEvent.KeyboardCharTypedEvent.Pre(guiScreen, codePoint, modifiers); return MinecraftForge.EVENT_BUS.post(event); } - public static boolean onGuiCharTypedPost(Screen guiScreen, char codePoint, int modifiers) + public static boolean onScreenCharTypedPost(Screen guiScreen, char codePoint, int modifiers) { - Event event = new GuiScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers); + Event event = new ScreenEvent.KeyboardCharTypedEvent.Post(guiScreen, codePoint, modifiers); return MinecraftForge.EVENT_BUS.post(event); } @@ -846,7 +705,7 @@ public class ForgeHooksClient { BakedModel layer = layerModel.getFirst(); RenderType rendertype = layerModel.getSecond(); - net.minecraftforge.client.ForgeHooksClient.setRenderLayer(rendertype); // neded for compatibility with MultiLayerModels + net.minecraftforge.client.ForgeHooksClient.setRenderType(rendertype); // neded for compatibility with MultiLayerModels VertexConsumer ivertexbuilder; if (fabulous) { @@ -856,7 +715,7 @@ public class ForgeHooksClient } renderer.renderModelLists(layer, itemStackIn, combinedLightIn, combinedOverlayIn, matrixStackIn, ivertexbuilder); } - net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); + net.minecraftforge.client.ForgeHooksClient.setRenderType(null); } public static boolean isNameplateInRenderDistance(Entity entity, double squareDistance) { @@ -874,39 +733,39 @@ public class ForgeHooksClient .filter(t -> ItemBlockRenderTypes.canRenderInLayer(state, t)) .forEach(rendertype -> { - setRenderLayer(rendertype); + setRenderType(rendertype); VertexConsumer ivertexbuilder = buffer.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype); blockRenderer.getModelRenderer().tesselateBlock(world, blockRenderer.getBlockModel(state), state, pos, stack, ivertexbuilder, checkSides, new Random(), state.getSeed(pos), combinedOverlay); }); - setRenderLayer(null); + setRenderType(null); } - public static void registerForgeWorldTypeScreens() + public static void registerForgeWorldPresetScreens() { - ForgeWorldTypeScreens.registerTypes(); + ForgeWorldPresetScreens.registerPresets(); } - public static WorldPreset.PresetEditor getBiomeGeneratorTypeScreenFactory(Optional generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory) + public static WorldPreset.PresetEditor getPresetEditor(Optional generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory) { - return ForgeWorldTypeScreens.getGeneratorScreenFactory(generator, biomegeneratortypescreens$ifactory); + return ForgeWorldPresetScreens.getPresetEditor(generator, biomegeneratortypescreens$ifactory); } - public static boolean hasBiomeGeneratorSettingsOptionsScreen(Optional generator) + public static boolean hasPresetEditor(Optional generator) { - return getBiomeGeneratorTypeScreenFactory(generator, null) != null; + return getPresetEditor(generator, null) != null; } - public static Optional getWorldTypeFromGenerator(WorldGenSettings dimensionGeneratorSettings) + public static Optional getWorldPresetFromGenerator(WorldGenSettings dimensionGeneratorSettings) { return WorldPreset.of(dimensionGeneratorSettings); } - public static Optional getDefaultWorldType() + public static Optional getDefaultWorldPreset() { - return Optional.of(ForgeWorldTypeScreens.getDefaultGenerator()); + return Optional.of(ForgeWorldPresetScreens.getDefaultPreset()); } - public static boolean shouldRender(MobEffectInstance effectInstance) + public static boolean shouldRenderEffect(MobEffectInstance effectInstance) { return RenderProperties.getEffectRenderer(effectInstance).shouldRender(effectInstance); } @@ -944,7 +803,7 @@ public class ForgeHooksClient final Map> remoteChannels = packet.getForgeData().getRemoteChannels(); final int fmlver = packet.getForgeData().getFMLNetworkVersion(); - boolean fmlNetMatches = fmlver == FMLNetworkConstants.FMLNETVERSION; + boolean fmlNetMatches = fmlver == NetworkConstants.FMLNETVERSION; boolean channelsMatch = NetworkRegistry.checkListPingCompatibilityForClient(remoteChannels); AtomicBoolean result = new AtomicBoolean(true); final List extraClientMods = new ArrayList<>(); @@ -960,7 +819,7 @@ public class ForgeHooksClient boolean modsMatch = result.get(); final Map extraServerMods = mods.entrySet().stream(). - filter(e -> !Objects.equals(FMLNetworkConstants.IGNORESERVERONLY, e.getValue())). + filter(e -> !Objects.equals(NetworkConstants.IGNORESERVERONLY, e.getValue())). filter(e -> !ModList.get().isLoaded(e.getKey())). collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); @@ -982,10 +841,10 @@ public class ForgeHooksClient extraReason = "fml.menu.multiplayer.networkincompatible"; } - if (fmlver < FMLNetworkConstants.FMLNETVERSION) { + if (fmlver < NetworkConstants.FMLNETVERSION) { extraReason = "fml.menu.multiplayer.serveroutdated"; } - if (fmlver > FMLNetworkConstants.FMLNETVERSION) { + if (fmlver > NetworkConstants.FMLNETVERSION) { extraReason = "fml.menu.multiplayer.clientoutdated"; } target.forgeData = new ExtendedServerListData("FML", extraServerMods.isEmpty() && fmlNetMatches && channelsMatch && modsMatch, mods.size(), extraReason, packet.getForgeData().isTruncated()); @@ -1044,14 +903,14 @@ public class ForgeHooksClient } } - private static Connection getClientToServerNetworkManager() + private static Connection getClientConnection() { return Minecraft.getInstance().getConnection()!=null ? Minecraft.getInstance().getConnection().getConnection() : null; } - public static void handleClientWorldClosing(ClientLevel world) + public static void handleClientLevelClosing(ClientLevel world) { - Connection client = getClientToServerNetworkManager(); + Connection client = getClientConnection(); // ONLY revert a non-local connection if (client != null && !client.isMemoryConnection()) { @@ -1102,14 +961,14 @@ public class ForgeHooksClient return stackFont == null ? fallbackFont : stackFont; } - public static RenderTooltipEvent.Pre preTooltipEvent(@Nonnull ItemStack stack, PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, @Nonnull List components, @Nullable Font forcedFont, @Nonnull Font fallbackFont) + public static RenderTooltipEvent.Pre onRenderTooltipPre(@Nonnull ItemStack stack, PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, @Nonnull List components, @Nullable Font forcedFont, @Nonnull Font fallbackFont) { var preEvent = new RenderTooltipEvent.Pre(stack, matrixStack, x, y, screenWidth, screenHeight, getTooltipFont(forcedFont, stack, fallbackFont), components); MinecraftForge.EVENT_BUS.post(preEvent); return preEvent; } - public static RenderTooltipEvent.Color colorTooltipEvent(@Nonnull ItemStack stack, PoseStack matrixStack, int x, int y, @Nonnull Font font, @Nonnull List components) + public static RenderTooltipEvent.Color onRenderTooltipColor(@Nonnull ItemStack stack, PoseStack matrixStack, int x, int y, @Nonnull Font font, @Nonnull List components) { var colorEvent = new RenderTooltipEvent.Color(stack, matrixStack, x, y, font, 0xf0100010, 0x505000FF, 0x5028007f, components); MinecraftForge.EVENT_BUS.post(colorEvent); diff --git a/src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java b/src/main/java/net/minecraftforge/client/ForgeWorldPresetScreens.java similarity index 64% rename from src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java rename to src/main/java/net/minecraftforge/client/ForgeWorldPresetScreens.java index 5853333d94..418b3cde0e 100644 --- a/src/main/java/net/minecraftforge/client/ForgeWorldTypeScreens.java +++ b/src/main/java/net/minecraftforge/client/ForgeWorldPresetScreens.java @@ -27,7 +27,7 @@ import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.WorldGenSettings; -import net.minecraftforge.common.world.ForgeWorldType; +import net.minecraftforge.common.world.ForgeWorldPreset; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -37,14 +37,14 @@ import javax.annotation.Nullable; import java.util.Map; import java.util.Optional; -public class ForgeWorldTypeScreens +public class ForgeWorldPresetScreens { private static final Logger LOGGER = LogManager.getLogger(); - private static final Map GENERATORS = Maps.newHashMap(); - private static final Map GENERATOR_SCREEN_FACTORIES = Maps.newHashMap(); + private static final Map GENERATORS = Maps.newHashMap(); + private static final Map GENERATOR_SCREEN_FACTORIES = Maps.newHashMap(); - public static synchronized void registerFactory(ForgeWorldType type, WorldPreset.PresetEditor factory) + public static synchronized void registerPresetEditor(ForgeWorldPreset type, WorldPreset.PresetEditor factory) { if (GENERATOR_SCREEN_FACTORIES.containsKey(type)) throw new IllegalStateException("Factory has already been registered for: " + type); @@ -52,9 +52,9 @@ public class ForgeWorldTypeScreens GENERATOR_SCREEN_FACTORIES.put(type, factory); } - static WorldPreset getDefaultGenerator() + static WorldPreset getDefaultPreset() { - ForgeWorldType def = ForgeWorldType.getDefaultWorldType(); + ForgeWorldPreset def = ForgeWorldPreset.getDefaultWorldPreset(); if (def == null) { return WorldPreset.NORMAL; @@ -70,49 +70,47 @@ public class ForgeWorldTypeScreens return gen; } - static WorldPreset.PresetEditor getGeneratorScreenFactory(Optional generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory) + static WorldPreset.PresetEditor getPresetEditor(Optional generator, @Nullable WorldPreset.PresetEditor biomegeneratortypescreens$ifactory) { - return generator.filter(gen -> gen instanceof GeneratorType) - .map(type -> GENERATOR_SCREEN_FACTORIES.get(((GeneratorType)type).getWorldType())) + return generator.filter(gen -> gen instanceof GeneratorPreset) + .map(type -> GENERATOR_SCREEN_FACTORIES.get(((GeneratorPreset)type).getWorldPreset())) .orElse(biomegeneratortypescreens$ifactory); } - static void registerTypes() + static void registerPresets() { ForgeRegistries.WORLD_TYPES.forEach(wt -> { - GeneratorType gen = new GeneratorType(wt); + GeneratorPreset gen = new GeneratorPreset(wt); GENERATORS.put(wt, gen); WorldPreset.registerGenerator(gen); }); } - private static class GeneratorType extends WorldPreset + private static class GeneratorPreset extends WorldPreset { - private final ForgeWorldType worldType; + private final ForgeWorldPreset worldPreset; - public GeneratorType(ForgeWorldType wt) + public GeneratorPreset(ForgeWorldPreset wt) { super(wt.getDisplayName()); - worldType = wt; + worldPreset = wt; } - public ForgeWorldType getWorldType() + public ForgeWorldPreset getWorldPreset() { - return worldType; + return worldPreset; } @Nonnull @Override public WorldGenSettings create(@Nonnull RegistryAccess.RegistryHolder dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest) { - return worldType.createSettings(dynamicRegistries, seed, generateStructures, bonusChest, ""); + return worldPreset.createSettings(dynamicRegistries, seed, generateStructures, bonusChest, ""); } - @Nonnull @Override - protected ChunkGenerator generator(@Nonnull Registry p_241869_1_, @Nonnull Registry p_241869_2_, long p_241869_3_) - { - return worldType.createChunkGenerator(p_241869_1_, p_241869_2_, p_241869_3_, ""); + protected ChunkGenerator generator(RegistryAccess p_194083_, long p_194084_) { + return worldPreset.createChunkGenerator(p_194083_, p_194084_, ""); } } } diff --git a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java index 91d9ee4146..4eb5635544 100644 --- a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java +++ b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java @@ -54,9 +54,19 @@ import net.minecraftforge.client.textures.ITextureAtlasSpriteLoader; public class MinecraftForgeClient { - public static RenderType getRenderLayer() + public static RenderType getRenderType() { - return ForgeHooksClient.renderLayer.get(); + return ForgeHooksClient.renderType.get(); + } + + private static float partialTick; + + public static float getPartialTick() { + return partialTick; + } + + public static void setPartialTick(float partialTick) { + MinecraftForgeClient.partialTick = partialTick; } /** @@ -105,47 +115,6 @@ public class MinecraftForgeClient } } - private static final LoadingCache, Optional> regionCache = CacheBuilder.newBuilder() - .maximumSize(500) - .concurrencyLevel(5) - .expireAfterAccess(1, TimeUnit.SECONDS) - .build(new CacheLoader, Optional>() - { - @Override - public Optional load(Pair key) - { - return Optional.ofNullable(RenderChunkRegion.createIfNotEmpty(key.getLeft(), key.getRight().offset(-1, -1, -1), key.getRight().offset(16, 16, 16), 1)); - } - }); - - public static void onRebuildChunk(Level world, BlockPos position, RenderChunkRegion cache) - { - if (cache == null) - regionCache.invalidate(Pair.of(world, position)); - else - regionCache.put(Pair.of(world, position), Optional.of(cache)); - } - - @Nullable - public static RenderChunkRegion getRegionRenderCache(Level world, BlockPos pos) - { - return getRegionRenderCacheOptional(world, pos).orElse(null); - } - - public static Optional getRegionRenderCacheOptional(Level world, BlockPos pos) - { - int x = pos.getX() & ~0xF; - int y = pos.getY() & ~0xF; - int z = pos.getZ() & ~0xF; - return regionCache.getUnchecked(Pair.of(world, new BlockPos(x, y, z))); - } - - public static void clearRenderCache() - { - regionCache.invalidateAll(); - regionCache.cleanUp(); - } - private static HashMap> bufferedImageSuppliers = new HashMap>(); public static void registerImageLayerSupplier(ResourceLocation resourceLocation, Supplier supplier) { diff --git a/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java b/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameTypeEvent.java similarity index 71% rename from src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java rename to src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameTypeEvent.java index 5f003869cd..c6ca63c26b 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameModeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientPlayerChangeGameTypeEvent.java @@ -26,17 +26,17 @@ import net.minecraftforge.eventbus.api.Event; /** * Fired before the client player is notified of a change in game mode from the server. */ -public class ClientPlayerChangeGameModeEvent extends Event +public class ClientPlayerChangeGameTypeEvent extends Event { private final PlayerInfo info; - private final GameType currentGameMode; - private final GameType newGameMode; + private final GameType currentGameType; + private final GameType newGameType; - public ClientPlayerChangeGameModeEvent(PlayerInfo info, GameType currentGameMode, GameType newGameMode) + public ClientPlayerChangeGameTypeEvent(PlayerInfo info, GameType currentGameType, GameType newGameType) { this.info = info; - this.currentGameMode = currentGameMode; - this.newGameMode = newGameMode; + this.currentGameType = currentGameType; + this.newGameType = newGameType; } public PlayerInfo getInfo() @@ -44,13 +44,13 @@ public class ClientPlayerChangeGameModeEvent extends Event return info; } - public GameType getCurrentGameMode() + public GameType getCurrentGameType() { - return currentGameMode; + return currentGameType; } - public GameType getNewGameMode() + public GameType getNewGameType() { - return newGameMode; + return newGameType; } } diff --git a/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java b/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java index aa1dd06ead..9b5b4a6f70 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientPlayerNetworkEvent.java @@ -30,16 +30,16 @@ import javax.annotation.Nullable; * Client side player connectivity events. */ public class ClientPlayerNetworkEvent extends Event { - private final MultiPlayerGameMode controller; + private final MultiPlayerGameMode multiPlayerGameMode; private final LocalPlayer player; - private final Connection networkManager; + private final Connection connection; /** * @return the player controller for the client side */ @Nullable - public MultiPlayerGameMode getController() { - return controller; + public MultiPlayerGameMode getMultiPlayerGameMode() { + return multiPlayerGameMode; } /** @@ -51,17 +51,17 @@ public class ClientPlayerNetworkEvent extends Event { } /** - * @return the network connection (if present - may be null) + * @return the impl connection (if present - may be null) */ @Nullable - public Connection getNetworkManager() { - return networkManager; + public Connection getConnection() { + return connection; } - ClientPlayerNetworkEvent(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) { - this.controller = controller; + ClientPlayerNetworkEvent(final MultiPlayerGameMode multiPlayerGameMode, final LocalPlayer player, final Connection connection) { + this.multiPlayerGameMode = multiPlayerGameMode; this.player = player; - this.networkManager = networkManager; + this.connection = connection; } /** diff --git a/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java b/src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java similarity index 75% rename from src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java rename to src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java index b93e86dcfd..2d602b90e6 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiContainerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ContainerScreenEvent.java @@ -26,19 +26,19 @@ import net.minecraftforge.eventbus.api.Event; /** * Event class for handling GuiContainer specific events. */ -public class GuiContainerEvent extends Event +public class ContainerScreenEvent extends Event { - private final AbstractContainerScreen guiContainer; + private final AbstractContainerScreen containerScreen; - public GuiContainerEvent(AbstractContainerScreen guiContainer) + public ContainerScreenEvent(AbstractContainerScreen containerScreen) { - this.guiContainer = guiContainer; + this.containerScreen = containerScreen; } - public AbstractContainerScreen getGuiContainer() + public AbstractContainerScreen getContainerScreen() { - return guiContainer; + return containerScreen; } /** @@ -47,9 +47,9 @@ public class GuiContainerEvent extends Event * 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. */ - public static class DrawForeground extends GuiContainerEvent + public static class DrawForeground extends ContainerScreenEvent { - private final PoseStack mStack; + private final PoseStack poseStack; private final int mouseX; private final int mouseY; @@ -61,17 +61,17 @@ public class GuiContainerEvent extends Event * @param mouseX The current X position of the players mouse. * @param mouseY The current Y position of the players mouse. */ - public DrawForeground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY) + public DrawForeground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY) { super(guiContainer); - this.mStack = mStack; + this.poseStack = mStack; this.mouseX = mouseX; this.mouseY = mouseY; } - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return mStack; + return poseStack; } public int getMouseX() @@ -89,9 +89,9 @@ public class GuiContainerEvent extends Event * This event is fired directly after the GuiContainer has draw any background elements, * This is useful for drawing new background elements. */ - public static class DrawBackground extends GuiContainerEvent + public static class DrawBackground extends ContainerScreenEvent { - private final PoseStack mStack; + private final PoseStack poseStack; private final int mouseX; private final int mouseY; @@ -103,17 +103,17 @@ public class GuiContainerEvent extends Event * @param mouseX The current X position of the players mouse. * @param mouseY The current Y position of the players mouse. */ - public DrawBackground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY) + public DrawBackground(AbstractContainerScreen guiContainer, PoseStack mStack, int mouseX, int mouseY) { super(guiContainer); - this.mStack = mStack; + this.poseStack = mStack; this.mouseX = mouseX; this.mouseY = mouseY; } - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return mStack; + return poseStack; } public int getMouseX() diff --git a/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java b/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java index 146eb18503..cfa8df451f 100644 --- a/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java +++ b/src/main/java/net/minecraftforge/client/event/DrawSelectionEvent.java @@ -36,29 +36,29 @@ import net.minecraft.client.renderer.LevelRenderer; @Cancelable public class DrawSelectionEvent extends Event { - private final LevelRenderer context; - private final Camera info; + private final LevelRenderer levelRenderer; + private final Camera camera; private final HitResult target; private final float partialTicks; - private final PoseStack matrix; - private final MultiBufferSource buffers; + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; - public DrawSelectionEvent(LevelRenderer context, Camera info, HitResult target, float partialTicks, PoseStack matrix, MultiBufferSource buffers) + public DrawSelectionEvent(LevelRenderer levelRenderer, Camera camera, HitResult target, float partialTicks, PoseStack poseStack, MultiBufferSource multiBufferSource) { - this.context = context; - this.info = info; + this.levelRenderer = levelRenderer; + this.camera = camera; this.target = target; - this.partialTicks= partialTicks; - this.matrix = matrix; - this.buffers = buffers; + this.partialTicks = partialTicks; + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; } - public LevelRenderer getContext() { return context; } - public Camera getInfo() { return info; } + public LevelRenderer getLevelRenderer() { return levelRenderer; } + public Camera getCamera() { return camera; } public HitResult getTarget() { return target; } public float getPartialTicks() { return partialTicks; } - public PoseStack getMatrix() { return matrix; } - public MultiBufferSource getBuffers() { return buffers; } + public PoseStack getPoseStack() { return poseStack; } + public MultiBufferSource getMultiBufferSource() { return multiBufferSource; } /** * A variant of the DrawSelectionEvent only called when a block is highlighted. diff --git a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java index 42bfd6f9a5..1043af71e7 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java @@ -25,8 +25,6 @@ import net.minecraft.client.renderer.FogRenderer.FogMode; import net.minecraft.client.renderer.GameRenderer; import net.minecraftforge.eventbus.api.Cancelable; -import net.minecraftforge.eventbus.api.Event.HasResult; - /** * Event that hooks into GameRenderer, allowing any feature to customize visual attributes * the player sees. @@ -34,14 +32,14 @@ import net.minecraftforge.eventbus.api.Event.HasResult; public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus.api.Event { private final GameRenderer renderer; - private final Camera info; - private final double renderPartialTicks; + private final Camera camera; + private final double partialTicks; - public EntityViewRenderEvent(GameRenderer renderer, Camera info, double renderPartialTicks) + public EntityViewRenderEvent(GameRenderer renderer, Camera camera, double partialTicks) { this.renderer = renderer; - this.info = info; - this.renderPartialTicks = renderPartialTicks; + this.camera = camera; + this.partialTicks = partialTicks; } public GameRenderer getRenderer() @@ -49,27 +47,27 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. return renderer; } - public Camera getInfo() + public Camera getCamera() { - return info; + return camera; } - public double getRenderPartialTicks() + public double getPartialTicks() { - return renderPartialTicks; + return partialTicks; } private static class FogEvent extends EntityViewRenderEvent { - private final FogMode type; + private final FogMode mode; @SuppressWarnings("resource") - protected FogEvent(FogMode type, Camera info, double renderPartialTicks) + protected FogEvent(FogMode mode, Camera info, double renderPartialTicks) { super(Minecraft.getInstance().gameRenderer, info, renderPartialTicks); - this.type = type; + this.mode = mode; } - public FogMode getType() { return type; } + public FogMode getMode() { return mode; } } /** @@ -174,11 +172,11 @@ public abstract class EntityViewRenderEvent extends net.minecraftforge.eventbus. * Event that allows mods to alter the raw FOV itself. * This directly affects to the FOV without being modified. * */ - public static class FOVModifier extends EntityViewRenderEvent + public static class FieldOfView extends EntityViewRenderEvent { private double fov; - public FOVModifier(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) { + public FieldOfView(GameRenderer renderer, Camera info, double renderPartialTicks, double fov) { super(renderer, info, renderPartialTicks); this.setFOV(fov); } diff --git a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/FOVModifierEvent.java similarity index 93% rename from src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java rename to src/main/java/net/minecraftforge/client/event/FOVModifierEvent.java index bbd8345876..dd16ce1545 100644 --- a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/FOVModifierEvent.java @@ -24,13 +24,13 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.util.Mth; import net.minecraftforge.eventbus.api.Event; -public class FOVUpdateEvent extends Event +public class FOVModifierEvent extends Event { private final Player entity; private final float fov; private float newfov; - public FOVUpdateEvent(Player entity, float fov) + public FOVModifierEvent(Player entity, float fov) { this.entity = entity; this.fov = fov; diff --git a/src/main/java/net/minecraftforge/client/event/InputEvent.java b/src/main/java/net/minecraftforge/client/event/InputEvent.java index b73b46d74a..3c67bd69fc 100644 --- a/src/main/java/net/minecraftforge/client/event/InputEvent.java +++ b/src/main/java/net/minecraftforge/client/event/InputEvent.java @@ -36,13 +36,13 @@ public class InputEvent extends Event { private final int button; private final int action; - private final int mods; + private final int modifiers; - public RawMouseEvent(int button, int action, int mods) + public RawMouseEvent(int button, int action, int modifiers) { this.button = button; this.action = action; - this.mods = mods; + this.modifiers = modifiers; } /** @@ -76,9 +76,9 @@ public class InputEvent extends Event * @see GLFW#GLFW_MOD_ALT * @see GLFW#GLFW_MOD_SUPER */ - public int getMods() + public int getModifiers() { - return this.mods; + return this.modifiers; } } @@ -89,12 +89,12 @@ public class InputEvent extends Event { private final int button; private final int action; - private final int mods; - public MouseInputEvent(int button, int action, int mods) + private final int modifiers; + public MouseInputEvent(int button, int action, int modifiers) { this.button = button; this.action = action; - this.mods = mods; + this.modifiers = modifiers; } /** @@ -128,9 +128,9 @@ public class InputEvent extends Event * @see GLFW#GLFW_MOD_ALT * @see GLFW#GLFW_MOD_SUPER */ - public int getMods() + public int getModifiers() { - return this.mods; + return this.modifiers; } } @@ -266,13 +266,13 @@ public class InputEvent extends Event public static class ClickInputEvent extends InputEvent { private final int button; - private final KeyMapping keyBinding; + private final KeyMapping keyMapping; private final InteractionHand hand; private boolean handSwing = true; - public ClickInputEvent(int button, KeyMapping keyBinding, InteractionHand hand) + public ClickInputEvent(int button, KeyMapping keyMapping, InteractionHand hand) { this.button = button; - this.keyBinding = keyBinding; + this.keyMapping = keyMapping; this.hand = hand; } @@ -316,9 +316,9 @@ public class InputEvent extends Event return button == 2; } - public KeyMapping getKeyBinding() + public KeyMapping getKeyMapping() { - return keyBinding; + return keyMapping; } } } diff --git a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java index 08a68fa28e..cf6bd75cb1 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java @@ -24,7 +24,7 @@ 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.model.ModelLoader; +import net.minecraftforge.client.model.ForgeModelBakery; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.event.IModBusEvent; @@ -37,9 +37,9 @@ public class ModelBakeEvent extends Event implements IModBusEvent { private final ModelManager modelManager; private final Map modelRegistry; - private final ModelLoader modelLoader; + private final ForgeModelBakery modelLoader; - public ModelBakeEvent(ModelManager modelManager, Map modelRegistry, ModelLoader modelLoader) + public ModelBakeEvent(ModelManager modelManager, Map modelRegistry, ForgeModelBakery modelLoader) { this.modelManager = modelManager; this.modelRegistry = modelRegistry; @@ -56,7 +56,7 @@ public class ModelBakeEvent extends Event implements IModBusEvent return modelRegistry; } - public ModelLoader getModelLoader() + public ForgeModelBakery getModelLoader() { return modelLoader; } diff --git a/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java b/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java index 6dc8025eca..73dc652e21 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelRegistryEvent.java @@ -19,11 +19,12 @@ package net.minecraftforge.client.event; +import net.minecraftforge.client.model.ForgeModelBakery; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.event.IModBusEvent; /** - * Fired when the {@link net.minecraftforge.client.model.ModelLoader} is ready to register model loaders + * Fired when the {@link ForgeModelBakery} is ready to register model loaders */ public class ModelRegistryEvent extends Event implements IModBusEvent { diff --git a/src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java similarity index 81% rename from src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java rename to src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java index f03d5fde3d..7a03935579 100644 --- a/src/main/java/net/minecraftforge/client/event/InputUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/MovementInputUpdateEvent.java @@ -27,19 +27,19 @@ import net.minecraftforge.event.entity.player.PlayerEvent; * This event is fired after player movement inputs are updated.
* Handlers can freely manipulate {@link Input} to cancel movement.
*/ -public class InputUpdateEvent extends PlayerEvent +public class MovementInputUpdateEvent extends PlayerEvent { - private final Input movementInput; + private final Input input; - public InputUpdateEvent(Player player, Input movementInput) + public MovementInputUpdateEvent(Player player, Input input) { super(player); - this.movementInput = movementInput; + this.input = input; } - public Input getMovementInput() + public Input getInput() { - return movementInput; + return input; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java index 09f5d006a4..7df7dbdce9 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java @@ -39,17 +39,17 @@ public class RenderBlockOverlayEvent extends Event } private final Player player; - private final PoseStack mat; + private final PoseStack poseStack; private final OverlayType overlayType; - private final BlockState blockForOverlay; + private final BlockState blockState; private final BlockPos blockPos; - public RenderBlockOverlayEvent(Player player, PoseStack mat, OverlayType type, BlockState block, BlockPos blockPos) + public RenderBlockOverlayEvent(Player player, PoseStack poseStack, OverlayType type, BlockState block, BlockPos blockPos) { this.player = player; - this.mat = mat; + this.poseStack = poseStack; this.overlayType = type; - this.blockForOverlay = block; + this.blockState = block; this.blockPos = blockPos; } @@ -58,7 +58,7 @@ public class RenderBlockOverlayEvent extends Event * The player which the overlay will apply to */ public Player getPlayer() { return player; } - public PoseStack getMatrixStack() { return mat; } + public PoseStack getPoseStack() { return poseStack; } /** * The type of overlay to occur */ @@ -66,6 +66,6 @@ public class RenderBlockOverlayEvent extends Event /** * If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from */ - public BlockState getBlockForOverlay() { return blockForOverlay; } + public BlockState getBlockState() { return blockState; } public BlockPos getBlockPos() { return blockPos; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java index a93480378a..e71905106a 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -134,14 +134,14 @@ public class RenderGameOverlayEvent extends Event public static class BossInfo extends Pre { - private final LerpingBossEvent bossInfo; + private final LerpingBossEvent bossEvent; private final int x; private final int y; private int increment; - public BossInfo(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type, LerpingBossEvent bossInfo, int x, int y, int increment) + public BossInfo(PoseStack mStack, RenderGameOverlayEvent parent, ElementType type, LerpingBossEvent bossEvent, int x, int y, int increment) { super(mStack, parent, type); - this.bossInfo = bossInfo; + this.bossEvent = bossEvent; this.x = x; this.y = y; this.increment = increment; @@ -150,9 +150,9 @@ public class RenderGameOverlayEvent extends Event /** * @return The {@link LerpingBossEvent} currently being rendered */ - public LerpingBossEvent getBossInfo() + public LerpingBossEvent getBossEvent() { - return bossInfo; + return bossEvent; } /** diff --git a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java index 42f9130645..025227393b 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java @@ -38,9 +38,9 @@ import net.minecraftforge.eventbus.api.Event; public class RenderHandEvent extends Event { private final InteractionHand hand; - private final PoseStack mat; - private final MultiBufferSource buffers; - private final int light; + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; + private final int packedLight; private final float partialTicks; private final float interpolatedPitch; private final float swingProgress; @@ -48,14 +48,14 @@ public class RenderHandEvent extends Event @Nonnull private final ItemStack stack; - public RenderHandEvent(InteractionHand hand, PoseStack mat, MultiBufferSource buffers, int light, + public RenderHandEvent(InteractionHand hand, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, @Nonnull ItemStack stack) { this.hand = hand; - this.mat = mat; - this.buffers = buffers; - this.light = light; + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; + this.packedLight = packedLight; this.partialTicks = partialTicks; this.interpolatedPitch = interpolatedPitch; this.swingProgress = swingProgress; @@ -68,17 +68,17 @@ public class RenderHandEvent extends Event return hand; } - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return mat; + return poseStack; } - public MultiBufferSource getBuffers() { - return buffers; + public MultiBufferSource getMultiBufferSource() { + return multiBufferSource; } - public int getLight() { - return light; + public int getPackedLight() { + return packedLight; } public float getPartialTicks() diff --git a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java index 7da22f19d1..94b0490939 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java @@ -37,33 +37,33 @@ import javax.annotation.Nonnull; @Cancelable public class RenderItemInFrameEvent extends Event { - private final ItemStack item; - private final ItemFrame entityItemFrame; + private final ItemStack itemStack; + private final ItemFrame itemFrameEntity; private final ItemFrameRenderer renderer; - private final PoseStack matrix; - private final MultiBufferSource buffers; - private final int light; + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; + private final int packedLight; - public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack matrix, - MultiBufferSource buffers, int light) + public RenderItemInFrameEvent(ItemFrame itemFrame, ItemFrameRenderer renderItemFrame, PoseStack poseStack, + MultiBufferSource multiBufferSource, int packedLight) { - item = itemFrame.getItem(); - entityItemFrame = itemFrame; + itemStack = itemFrame.getItem(); + itemFrameEntity = itemFrame; renderer = renderItemFrame; - this.matrix = matrix; - this.buffers = buffers; - this.light = light; + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; + this.packedLight = packedLight; } @Nonnull - public ItemStack getItem() + public ItemStack getItemStack() { - return item; + return itemStack; } - public ItemFrame getEntityItemFrame() + public ItemFrame getItemFrameEntity() { - return entityItemFrame; + return itemFrameEntity; } public ItemFrameRenderer getRenderer() @@ -71,15 +71,15 @@ public class RenderItemInFrameEvent extends Event return renderer; } - public PoseStack getMatrix() { - return matrix; + public PoseStack getPoseStack() { + return poseStack; } - public MultiBufferSource getBuffers() { - return buffers; + public MultiBufferSource getMultiBufferSource() { + return multiBufferSource; } - public int getLight() { - return light; + public int getPackedLight() { + return packedLight; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java similarity index 60% rename from src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java rename to src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java index fda93493f6..6f9e91ac0a 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLevelLastEvent.java @@ -24,36 +24,36 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.LevelRenderer; import com.mojang.math.Matrix4f; -public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event +public class RenderLevelLastEvent extends net.minecraftforge.eventbus.api.Event { - private final LevelRenderer context; - private final PoseStack mat; - private final float partialTicks; + private final LevelRenderer levelRenderer; + private final PoseStack poseStack; + private final float partialTick; private final Matrix4f projectionMatrix; - private final long finishTimeNano; + private final long startNanos; - public RenderWorldLastEvent(LevelRenderer context, PoseStack mat, float partialTicks, Matrix4f projectionMatrix, long finishTimeNano) + public RenderLevelLastEvent(LevelRenderer levelRenderer, PoseStack poseStack, float partialTick, Matrix4f projectionMatrix, long startNanos) { - this.context = context; - this.mat = mat; - this.partialTicks = partialTicks; + this.levelRenderer = levelRenderer; + this.poseStack = poseStack; + this.partialTick = partialTick; this.projectionMatrix = projectionMatrix; - this.finishTimeNano = finishTimeNano; + this.startNanos = startNanos; } - public LevelRenderer getContext() + public LevelRenderer getLevelRenderer() { - return context; + return levelRenderer; } - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return mat; + return poseStack; } - public float getPartialTicks() + public float getPartialTick() { - return partialTicks; + return partialTick; } public Matrix4f getProjectionMatrix() @@ -61,8 +61,8 @@ public class RenderWorldLastEvent extends net.minecraftforge.eventbus.api.Event return projectionMatrix; } - public long getFinishTimeNano() + public long getStartNanos() { - return finishTimeNano; + return startNanos; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index ee839561e6..2bfad5e139 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -32,28 +32,28 @@ public abstract class RenderLivingEvent renderer; - private final float partialRenderTick; - private final PoseStack matrixStack; - private final MultiBufferSource buffers; - private final int light; + private final float partialTick; + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; + private final int packedLight; - public RenderLivingEvent(LivingEntity entity, LivingEntityRenderer renderer, float partialRenderTick, PoseStack matrixStack, - MultiBufferSource buffers, int light) + public RenderLivingEvent(LivingEntity entity, LivingEntityRenderer renderer, float partialTick, PoseStack poseStack, + MultiBufferSource multiBufferSource, int packedLight) { this.entity = entity; this.renderer = renderer; - this.partialRenderTick = partialRenderTick; - this.matrixStack = matrixStack; - this.buffers = buffers; - this.light = light; + this.partialTick = partialTick; + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; + this.packedLight = packedLight; } public LivingEntity getEntity() { return entity; } public LivingEntityRenderer getRenderer() { return renderer; } - public float getPartialRenderTick() { return partialRenderTick; } - public PoseStack getMatrixStack() { return matrixStack; } - public MultiBufferSource getBuffers() { return buffers; } - public int getLight() { return light; } + public float getPartialTick() { return partialTick; } + public PoseStack getPoseStack() { return poseStack; } + public MultiBufferSource getMultiBufferSource() { return multiBufferSource; } + public int getPackedLight() { return packedLight; } @Cancelable public static class Pre> extends RenderLivingEvent diff --git a/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java b/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java index b7392d8d4e..91a67974bc 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java @@ -36,12 +36,12 @@ import net.minecraftforge.eventbus.api.Event; * changed by mods.
* {@link #entityRenderer} contains the entity renderer instance that renders the name plate/tag. This cannot be * changed by mods.
- * {@link #matrixStack} contains the matrix stack instance involved in rendering the name plate/tag. This cannot + * {@link #poseStack} contains the matrix stack instance involved in rendering the name plate/tag. This cannot * be changed by mods.
- * {@link #renderTypeBuffer} contains the render type buffer instance involved in rendering the name plate/tag. + * {@link #multiBufferSource} contains the render type buffer instance involved in rendering the name plate/tag. * This cannot be changed by mods.
* {@link #packedLight} contains the sky and block light values used in rendering the name plate/tag.
- * {@link #partialTicks} contains the partial ticks used in rendering the name plate/tag. This cannot be changed by mods.
+ * {@link #partialTick} contains the partial ticks used in rendering the name plate/tag. This cannot be changed by mods.
*
* This event has a result. {@link HasResult}.
* ALLOW will force-render name plate/tag, DEFAULT will ignore the hook and continue using the vanilla check @@ -56,21 +56,21 @@ public class RenderNameplateEvent extends EntityEvent private Component nameplateContent; private final Component originalContent; private final EntityRenderer entityRenderer; - private final PoseStack matrixStack; - private final MultiBufferSource renderTypeBuffer; + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; private final int packedLight; - private final float partialTicks; + private final float partialTick; - public RenderNameplateEvent(Entity entity, Component content, EntityRenderer entityRenderer, PoseStack matrixStack, MultiBufferSource renderTypeBuffer, int packedLight, float partialTicks) + public RenderNameplateEvent(Entity entity, Component content, EntityRenderer entityRenderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, float partialTick) { super(entity); this.originalContent = content; this.setContent(this.originalContent); this.entityRenderer = entityRenderer; - this.matrixStack = matrixStack; - this.renderTypeBuffer = renderTypeBuffer; + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; this.packedLight = packedLight; - this.partialTicks = partialTicks; + this.partialTick = partialTick; } /** @@ -108,17 +108,17 @@ public class RenderNameplateEvent extends EntityEvent /** * The matrix stack used during the rendering of the name plate/tag */ - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return this.matrixStack; + return this.poseStack; } /** * The render type buffer used during the rendering of the name plate/tag */ - public MultiBufferSource getRenderTypeBuffer() + public MultiBufferSource getMultiBufferSource() { - return this.renderTypeBuffer; + return this.multiBufferSource; } /** @@ -132,8 +132,8 @@ public class RenderNameplateEvent extends EntityEvent /** * The partial ticks used during the rendering of the name plate/tag */ - public float getPartialTicks() + public float getPartialTick() { - return this.partialTicks; + return this.partialTick; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java index 1cbac73774..ddc334cafd 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -29,26 +29,26 @@ import net.minecraftforge.event.entity.player.PlayerEvent; public abstract class RenderPlayerEvent extends PlayerEvent { private final PlayerRenderer renderer; - private final float partialRenderTick; - private final PoseStack stack; - private final MultiBufferSource buffers; - private final int light; + private final float partialTick; + private final PoseStack poseStack; + private final MultiBufferSource multiBufferSource; + private final int packedLight; - public RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialRenderTick, PoseStack stack, MultiBufferSource buffers, int light) + public RenderPlayerEvent(Player player, PlayerRenderer renderer, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) { super(player); this.renderer = renderer; - this.partialRenderTick = partialRenderTick; - this.stack = stack; - this.buffers = buffers; - this.light = light; + this.partialTick = partialTick; + this.poseStack = poseStack; + this.multiBufferSource = multiBufferSource; + this.packedLight = packedLight; } public PlayerRenderer getRenderer() { return renderer; } - public float getPartialRenderTick() { return partialRenderTick; } - public PoseStack getMatrixStack() { return stack; } - public MultiBufferSource getBuffers() { return buffers; } - public int getLight() { return light; } + public float getPartialTick() { return partialTick; } + public PoseStack getPoseStack() { return poseStack; } + public MultiBufferSource getMultiBufferSource() { return multiBufferSource; } + public int getPackedLight() { return packedLight; } @Cancelable public static class Pre extends RenderPlayerEvent diff --git a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java index f5d86eb053..17338dde78 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderTooltipEvent.java @@ -42,65 +42,36 @@ import net.minecraftforge.eventbus.api.Event; * Do not use this event directly, use one of the subclasses: *

*/ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api.Event { @Nonnull - protected final ItemStack stack; - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - protected final List lines; - protected final PoseStack matrixStack; // TODO: rename in 1.18 + protected final ItemStack itemStack; protected int x; protected int y; - protected Font fr; + protected Font font; protected final List components; - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public RenderTooltipEvent(@Nonnull ItemStack stack, @Nonnull List lines, PoseStack matrixStack, int x, int y, @Nonnull Font fr) - { - this.stack = stack; - this.lines = Collections.unmodifiableList(lines); - this.matrixStack = matrixStack; - this.x = x; - this.y = y; - this.fr = fr; - this.components = List.of(); - } - public RenderTooltipEvent(@Nonnull ItemStack stack, PoseStack poseStack, int x, int y, @Nonnull Font font, @Nonnull List components) + public RenderTooltipEvent(@Nonnull ItemStack itemStack, PoseStack poseStack, int x, int y, @Nonnull Font font, @Nonnull List components) { - this.stack = stack; - this.lines = List.of(); + this.itemStack = itemStack; this.components = Collections.unmodifiableList(components); - this.matrixStack = poseStack; this.x = x; this.y = y; - this.fr = font; + this.font = font; } /** * @return The stack which the tooltip is being rendered for. As tooltips can be drawn without itemstacks, this stack may be empty. */ @Nonnull - public ItemStack getStack() + public ItemStack getItemStack() { - return stack; - } - - /** - * The lines to be drawn. May change between {@link RenderTooltipEvent.Pre} and {@link RenderTooltipEvent.Post}. - * - * @return An unmodifiable list of strings. Use {@link net.minecraftforge.event.entity.player.ItemTooltipEvent} to modify tooltip text. - * @deprecated use {@link #getComponents()} - */ - @Nonnull - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public List getLines() - { - return lines; + return itemStack; } /** @@ -114,14 +85,6 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api return components; } - /** - * @return The MatrixStack of the current rendering context - */ - public PoseStack getMatrixStack() - { - return matrixStack; - } - /** * @return The X position of the tooltip box. By default, the mouse X position. */ @@ -142,9 +105,9 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api * @return The {@link Font} instance the current render is using. */ @Nonnull - public Font getFontRenderer() + public Font getFont() { - return fr; + return font; } /** @@ -156,15 +119,15 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api @Cancelable public static class GatherComponents extends Event { - private final ItemStack stack; + private final ItemStack itemStack; private final int screenWidth; private final int screenHeight; private final List> tooltipElements; private int maxWidth; - public GatherComponents(ItemStack stack, int screenWidth, int screenHeight, List> tooltipElements, int maxWidth) + public GatherComponents(ItemStack itemStack, int screenWidth, int screenHeight, List> tooltipElements, int maxWidth) { - this.stack = stack; + this.itemStack = itemStack; this.screenWidth = screenWidth; this.screenHeight = screenHeight; this.tooltipElements = tooltipElements; @@ -174,9 +137,9 @@ 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 */ - public ItemStack getStack() + public ItemStack getItemStack() { - return stack; + return itemStack; } /** @@ -231,23 +194,12 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api { private int screenWidth; private int screenHeight; - private int maxWidth; - - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public Pre(@Nonnull ItemStack stack, @Nonnull List lines, PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull Font fr) - { - super(stack, lines, matrixStack, x, y, fr); - this.screenWidth = screenWidth; - this.screenHeight = screenHeight; - this.maxWidth = maxWidth; - } public Pre(@Nonnull ItemStack stack, PoseStack matrixStack, int x, int y, int screenWidth, int screenHeight, @Nonnull Font font, @Nonnull List components) { super(stack, matrixStack, x, y, font, components); this.screenWidth = screenWidth; this.screenHeight = screenHeight; - this.maxWidth = -1; } public int getScreenWidth() @@ -255,49 +207,17 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api return screenWidth; } - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public void setScreenWidth(int screenWidth) - { - this.screenWidth = screenWidth; - } - public int getScreenHeight() { return screenHeight; } - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public void setScreenHeight(int screenHeight) - { - this.screenHeight = screenHeight; - } - - /** - * @return The max width the tooltip can be. Defaults to -1 (unlimited). - * @deprecated use {@link GatherComponents} - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public int getMaxWidth() - { - return maxWidth; - } - - /** - * Sets the max width of the tooltip. Use -1 for unlimited. - * @deprecated use {@link GatherComponents} - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public void setMaxWidth(int maxWidth) - { - this.maxWidth = maxWidth; - } - /** * Sets the {@link Font} to be used to render text. */ - public void setFontRenderer(@Nonnull Font fr) + public void setFont(@Nonnull Font fr) { - this.fr = fr; + this.font = fr; } /** @@ -317,65 +237,6 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api } } - /** - * Events inheriting from this class are fired at different stages during the tooltip rendering. - *

- * Do not use this event directly, use one of its subclasses: - *

    - *
  • {@link RenderTooltipEvent.PostBackground}
  • - *
  • {@link RenderTooltipEvent.PostText}
  • - *
- */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - protected static abstract class Post extends RenderTooltipEvent - { - private final int width; - private final int height; - - public Post(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack,int x, int y, @Nonnull Font fr, int width, int height) - { - super(stack, textLines, matrixStack, x, y, fr); - this.width = width; - this.height = height; - } - - /** - * @return The width of the tooltip box. This is the width of the inner box, not including the border. - */ - public int getWidth() - { - return width; - } - - /** - * @return The height of the tooltip box. This is the height of the inner box, not including the border. - */ - public int getHeight() - { - return height; - } - } - - /** - * This event is fired directly after the tooltip background is drawn, but before any text is drawn. - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static class PostBackground extends Post - { - public PostBackground(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int width, int height) - { super(stack, textLines, matrixStack, x, y, fr, width, height); } - } - - /** - * This event is fired directly after the tooltip text is drawn, but before the GL state is reset. - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static class PostText extends Post - { - public PostText(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int width, int height) - { super(stack, textLines, matrixStack, x, y, fr, width, height); } - } - /** * This event is fired when the colours for the tooltip background are determined. */ @@ -389,19 +250,6 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api private int borderStart; private int borderEnd; - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public Color(@Nonnull ItemStack stack, @Nonnull List textLines, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int background, int borderStart, int borderEnd) - { - super(stack, textLines, matrixStack, x, y, fr); - this.originalBackground = background; - this.originalBorderStart = borderStart; - this.originalBorderEnd = borderEnd; - this.backgroundStart = background; - this.backgroundEnd = background; - this.borderStart = borderStart; - this.borderEnd = borderEnd; - } - public Color(@Nonnull ItemStack stack, PoseStack matrixStack, int x, int y, @Nonnull Font fr, int background, int borderStart, int borderEnd, @Nonnull List components) { super(stack, matrixStack, x, y, fr, components); @@ -414,15 +262,6 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api this.borderEnd = borderEnd; } - /** - * @deprecated use {@link #getBackgroundStart()} and {@link #getBackgroundEnd} - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public int getBackground() - { - return backgroundStart; - } - public int getBackgroundStart() { return backgroundStart; @@ -469,12 +308,6 @@ public abstract class RenderTooltipEvent extends net.minecraftforge.eventbus.api this.borderEnd = borderEnd; } - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public int getOriginalBackground() - { - return originalBackground; - } - public int getOriginalBackgroundStart() { return originalBackground; diff --git a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java similarity index 69% rename from src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java rename to src/main/java/net/minecraftforge/client/event/ScreenEvent.java index 94974ab838..1e20172d71 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenEvent.java @@ -41,52 +41,52 @@ import org.lwjgl.glfw.GLFW; * @author bspkrs */ @OnlyIn(Dist.CLIENT) -public class GuiScreenEvent extends Event +public class ScreenEvent extends Event { - private final Screen gui; + private final Screen screen; - public GuiScreenEvent(Screen gui) + public ScreenEvent(Screen screen) { - this.gui = gui; + this.screen = screen; } /** * The GuiScreen object generating this event. */ - public Screen getGui() + public Screen getScreen() { - return gui; + return screen; } - public static class InitGuiEvent extends GuiScreenEvent + public static class InitScreenEvent extends ScreenEvent { private Consumer add; private Consumer remove; - private List list; + private List listenerList; - public InitGuiEvent(Screen gui, List list, Consumer add, Consumer remove) + public InitScreenEvent(Screen screen, List listenerList, Consumer add, Consumer remove) { - super(gui); - this.list = Collections.unmodifiableList(list); + super(screen); + this.listenerList = Collections.unmodifiableList(listenerList); this.add = add; this.remove = remove; } /** - * Unmodifiable reference to the list of buttons on the {@link #gui}. + * Unmodifiable reference to the list of buttons on the {@link #screen}. */ - public List getWidgetList() + public List getListenersList() { - return list; + return listenerList; } - public void addWidget(GuiEventListener button) + public void addListener(GuiEventListener button) { add.accept(button); } - public void removeWidget(GuiEventListener button) + public void removeListener(GuiEventListener button) { remove.accept(button); } @@ -101,11 +101,11 @@ public class GuiScreenEvent extends Event * {@code this.initGui();}
*/ @Cancelable - public static class Pre extends InitGuiEvent + public static class Pre extends InitScreenEvent { - public Pre(Screen gui, List list, Consumer add, Consumer remove) + public Pre(Screen screen, List list, Consumer add, Consumer remove) { - super(gui, list, add, remove); + super(screen, list, add, remove); } } @@ -113,37 +113,37 @@ public class GuiScreenEvent extends Event * This event fires right after {@code Screen#init()}. * This is a good place to alter a GuiScreen's component layout if desired. */ - public static class Post extends InitGuiEvent + public static class Post extends InitScreenEvent { - public Post(Screen gui, List list, Consumer add, Consumer remove) + public Post(Screen screen, List list, Consumer add, Consumer remove) { - super(gui, list, add, remove); + super(screen, list, add, remove); } } } - public static class DrawScreenEvent extends GuiScreenEvent + public static class DrawScreenEvent extends ScreenEvent { - private final PoseStack mStack; + private final PoseStack poseStack; private final int mouseX; private final int mouseY; - private final float renderPartialTicks; + private final float partialTicks; - public DrawScreenEvent(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) + public DrawScreenEvent(Screen screen, PoseStack poseStack, int mouseX, int mouseY, float partialTicks) { - super(gui); - this.mStack = mStack; + super(screen); + this.poseStack = poseStack; this.mouseX = mouseX; this.mouseY = mouseY; - this.renderPartialTicks = renderPartialTicks; + this.partialTicks = partialTicks; } /** * The MatrixStack to render with. */ - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return mStack; + return poseStack; } /** @@ -165,9 +165,9 @@ public class GuiScreenEvent extends Event /** * Partial render ticks elapsed. */ - public float getRenderPartialTicks() + public float getPartialTicks() { - return renderPartialTicks; + return partialTicks; } /** @@ -177,9 +177,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends DrawScreenEvent { - public Pre(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) + public Pre(Screen screen, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) { - super(gui, mStack, mouseX, mouseY, renderPartialTicks); + super(screen, mStack, mouseX, mouseY, renderPartialTicks); } } @@ -188,9 +188,9 @@ public class GuiScreenEvent extends Event */ public static class Post extends DrawScreenEvent { - public Post(Screen gui, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) + public Post(Screen screen, PoseStack mStack, int mouseX, int mouseY, float renderPartialTicks) { - super(gui, mStack, mouseX, mouseY, renderPartialTicks); + super(screen, mStack, mouseX, mouseY, renderPartialTicks); } } } @@ -199,22 +199,22 @@ public class GuiScreenEvent extends Event * This event fires at the end of {@link Screen#renderBackground(PoseStack, int)} and before the rest of the Gui draws. * This allows drawing next to Guis, above the background but below any tooltips. */ - public static class BackgroundDrawnEvent extends GuiScreenEvent + public static class BackgroundDrawnEvent extends ScreenEvent { - private final PoseStack mStack; + private final PoseStack poseStack; - public BackgroundDrawnEvent(Screen gui, PoseStack mStack) + public BackgroundDrawnEvent(Screen screen, PoseStack poseStack) { - super(gui); - this.mStack = mStack; + super(screen); + this.poseStack = poseStack; } /** * The MatrixStack to render with. */ - public PoseStack getMatrixStack() + public PoseStack getPoseStack() { - return mStack; + return poseStack; } } @@ -224,22 +224,22 @@ public class GuiScreenEvent extends Event * Cancel this event to prevent the Gui from being moved. */ @Cancelable - public static class PotionShiftEvent extends GuiScreenEvent + public static class PotionShiftEvent extends ScreenEvent { - public PotionShiftEvent(Screen gui) + public PotionShiftEvent(Screen screen) { - super(gui); + super(screen); } } - public static abstract class MouseInputEvent extends GuiScreenEvent + public static abstract class MouseInputEvent extends ScreenEvent { private final double mouseX; private final double mouseY; - public MouseInputEvent(Screen gui, double mouseX, double mouseY) + public MouseInputEvent(Screen screen, double mouseX, double mouseY) { - super(gui); + super(screen); this.mouseX = mouseX; this.mouseY = mouseY; } @@ -259,9 +259,9 @@ public class GuiScreenEvent extends Event { private final int button; - public MouseClickedEvent(Screen gui, double mouseX, double mouseY, int button) + public MouseClickedEvent(Screen screen, double mouseX, double mouseY, int button) { - super(gui, mouseX, mouseY); + super(screen, mouseX, mouseY); this.button = button; } @@ -277,9 +277,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends MouseClickedEvent { - public Pre(Screen gui, double mouseX, double mouseY, int button) + public Pre(Screen screen, double mouseX, double mouseY, int button) { - super(gui, mouseX, mouseY, button); + super(screen, mouseX, mouseY, button); } } @@ -297,28 +297,17 @@ public class GuiScreenEvent extends Event *

Note that this event is currently pre-cancelled if {@link Screen#mouseClicked} returns {@code true} * to retain old behavior. This will be changed in 1.18 when the event is made non-cancellable.

*/ - @Cancelable // TODO: Make non-cancellable in 1.18. @HasResult public static class Post extends MouseClickedEvent { private final boolean handled; - public Post(Screen gui, double mouseX, double mouseY, int button, boolean handled) + public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) { - super(gui, mouseX, mouseY, button); + super(screen, mouseX, mouseY, button); this.handled = handled; } - /** - * @deprecated event now has a result instead and will no longer be cancellable in 1.18; use {@link #setResult(Result)} - */ - @Override - @Deprecated - public void setCanceled(boolean cancel) - { - this.setResult(cancel ? Result.ALLOW : Result.DEFAULT); - } - /** * @return {@code true} if the mouse click was already handled by its screen */ @@ -333,9 +322,9 @@ public class GuiScreenEvent extends Event { private final int button; - public MouseReleasedEvent(Screen gui, double mouseX, double mouseY, int button) + public MouseReleasedEvent(Screen screen, double mouseX, double mouseY, int button) { - super(gui, mouseX, mouseY); + super(screen, mouseX, mouseY); this.button = button; } @@ -351,9 +340,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends MouseReleasedEvent { - public Pre(Screen gui, double mouseX, double mouseY, int button) + public Pre(Screen screen, double mouseX, double mouseY, int button) { - super(gui, mouseX, mouseY, button); + super(screen, mouseX, mouseY, button); } } @@ -368,31 +357,18 @@ public class GuiScreenEvent extends Event * *

* - *

Note that this event is currently pre-cancelled if {@link Screen#mouseReleased} returns {@code true} - * to retain old behavior. This will be changed in 1.18 when the event is made non-cancellable.

*/ - @Cancelable // TODO: Make non-cancellable in 1.18. @HasResult public static class Post extends MouseReleasedEvent { private final boolean handled; - public Post(Screen gui, double mouseX, double mouseY, int button, boolean handled) + public Post(Screen screen, double mouseX, double mouseY, int button, boolean handled) { - super(gui, mouseX, mouseY, button); + super(screen, mouseX, mouseY, button); this.handled = handled; } - /** - * @deprecated event now has a result instead and will no longer be cancellable in 1.18; use {@link #setResult(Result)} - */ - @Override - @Deprecated - public void setCanceled(boolean cancel) - { - this.setResult(cancel ? Result.ALLOW : Result.DEFAULT); - } - /** * @return {@code true} if the mouse release was already handled by its screen */ @@ -409,9 +385,9 @@ public class GuiScreenEvent extends Event private final double dragX; private final double dragY; - public MouseDragEvent(Screen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) + public MouseDragEvent(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - super(gui, mouseX, mouseY); + super(screen, mouseX, mouseY); this.mouseButton = mouseButton; this.dragX = dragX; this.dragY = dragY; @@ -439,9 +415,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends MouseDragEvent { - public Pre(Screen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) + public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - super(gui, mouseX, mouseY, mouseButton, dragX, dragY); + super(screen, mouseX, mouseY, mouseButton, dragX, dragY); } } @@ -452,9 +428,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Post extends MouseDragEvent { - public Post(Screen gui, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) + public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) { - super(gui, mouseX, mouseY, mouseButton, dragX, dragY); + super(screen, mouseX, mouseY, mouseButton, dragX, dragY); } } } @@ -463,9 +439,9 @@ public class GuiScreenEvent extends Event { private final double scrollDelta; - public MouseScrollEvent(Screen gui, double mouseX, double mouseY, double scrollDelta) + public MouseScrollEvent(Screen screen, double mouseX, double mouseY, double scrollDelta) { - super(gui, mouseX, mouseY); + super(screen, mouseX, mouseY); this.scrollDelta = scrollDelta; } @@ -481,9 +457,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends MouseScrollEvent { - public Pre(Screen gui, double mouseX, double mouseY, double scrollDelta) + public Pre(Screen screen, double mouseX, double mouseY, double scrollDelta) { - super(gui, mouseX, mouseY, scrollDelta); + super(screen, mouseX, mouseY, scrollDelta); } } @@ -494,22 +470,22 @@ public class GuiScreenEvent extends Event @Cancelable public static class Post extends MouseScrollEvent { - public Post(Screen gui, double mouseX, double mouseY, double scrollDelta) + public Post(Screen screen, double mouseX, double mouseY, double scrollDelta) { - super(gui, mouseX, mouseY, scrollDelta); + super(screen, mouseX, mouseY, scrollDelta); } } } - public static abstract class KeyboardKeyEvent extends GuiScreenEvent + public static abstract class KeyboardKeyEvent extends ScreenEvent { private final int keyCode; private final int scanCode; private final int modifiers; - public KeyboardKeyEvent(Screen gui, int keyCode, int scanCode, int modifiers) + public KeyboardKeyEvent(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui); + super(screen); this.keyCode = keyCode; this.scanCode = scanCode; this.modifiers = modifiers; @@ -556,9 +532,9 @@ public class GuiScreenEvent extends Event public static abstract class KeyboardKeyPressedEvent extends KeyboardKeyEvent { - public KeyboardKeyPressedEvent(Screen gui, int keyCode, int scanCode, int modifiers) + public KeyboardKeyPressedEvent(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui, keyCode, scanCode, modifiers); + super(screen, keyCode, scanCode, modifiers); } /** @@ -568,9 +544,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends KeyboardKeyPressedEvent { - public Pre(Screen gui, int keyCode, int scanCode, int modifiers) + public Pre(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui, keyCode, scanCode, modifiers); + super(screen, keyCode, scanCode, modifiers); } } @@ -581,18 +557,18 @@ public class GuiScreenEvent extends Event @Cancelable public static class Post extends KeyboardKeyPressedEvent { - public Post(Screen gui, int keyCode, int scanCode, int modifiers) + public Post(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui, keyCode, scanCode, modifiers); + super(screen, keyCode, scanCode, modifiers); } } } public static abstract class KeyboardKeyReleasedEvent extends KeyboardKeyEvent { - public KeyboardKeyReleasedEvent(Screen gui, int keyCode, int scanCode, int modifiers) + public KeyboardKeyReleasedEvent(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui, keyCode, scanCode, modifiers); + super(screen, keyCode, scanCode, modifiers); } /** @@ -602,9 +578,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends KeyboardKeyReleasedEvent { - public Pre(Screen gui, int keyCode, int scanCode, int modifiers) + public Pre(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui, keyCode, scanCode, modifiers); + super(screen, keyCode, scanCode, modifiers); } } @@ -615,21 +591,21 @@ public class GuiScreenEvent extends Event @Cancelable public static class Post extends KeyboardKeyReleasedEvent { - public Post(Screen gui, int keyCode, int scanCode, int modifiers) + public Post(Screen screen, int keyCode, int scanCode, int modifiers) { - super(gui, keyCode, scanCode, modifiers); + super(screen, keyCode, scanCode, modifiers); } } } - public static class KeyboardCharTypedEvent extends GuiScreenEvent + public static class KeyboardCharTypedEvent extends ScreenEvent { private final char codePoint; private final int modifiers; - public KeyboardCharTypedEvent(Screen gui, char codePoint, int modifiers) + public KeyboardCharTypedEvent(Screen screen, char codePoint, int modifiers) { - super(gui); + super(screen); this.codePoint = codePoint; this.modifiers = modifiers; } @@ -662,9 +638,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Pre extends KeyboardCharTypedEvent { - public Pre(Screen gui, char codePoint, int modifiers) + public Pre(Screen screen, char codePoint, int modifiers) { - super(gui, codePoint, modifiers); + super(screen, codePoint, modifiers); } } @@ -675,9 +651,9 @@ public class GuiScreenEvent extends Event @Cancelable public static class Post extends KeyboardCharTypedEvent { - public Post(Screen gui, char codePoint, int modifiers) + public Post(Screen screen, char codePoint, int modifiers) { - super(gui, codePoint, modifiers); + super(screen, codePoint, modifiers); } } } diff --git a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java b/src/main/java/net/minecraftforge/client/event/ScreenOpenEvent.java similarity index 72% rename from src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java rename to src/main/java/net/minecraftforge/client/event/ScreenOpenEvent.java index b4cdd014b0..3591bbaf81 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ScreenOpenEvent.java @@ -24,27 +24,27 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraft.client.gui.screens.Screen; /** - * This event is called before any Gui will open. + * 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 Gui, simply set the gui variable to your own Gui. + * If you want to override this Screen, simply set the screen variable to your own Screen. * */ @Cancelable -public class GuiOpenEvent extends Event +public class ScreenOpenEvent extends Event { - private Screen gui; - public GuiOpenEvent(Screen gui) + private Screen screen; + public ScreenOpenEvent(Screen screen) { - this.setGui(gui); + this.setScreen(screen); } - public Screen getGui() + public Screen getScreen() { - return gui; + return screen; } - public void setGui(Screen gui) + public void setScreen(Screen screen) { - this.gui = gui; + this.screen = screen; } } diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 067182c313..fdd3a3a0bb 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -29,16 +29,16 @@ import java.util.Set; public class TextureStitchEvent extends Event implements IModBusEvent { - private final TextureAtlas map; + private final TextureAtlas atlas; - public TextureStitchEvent(TextureAtlas map) + public TextureStitchEvent(TextureAtlas atlas) { - this.map = map; + this.atlas = atlas; } - public TextureAtlas getMap() + public TextureAtlas getAtlas() { - return map; + return atlas; } /** diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java index 57661ebefa..6bed89885a 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java @@ -31,15 +31,15 @@ import net.minecraft.client.sounds.SoundEngine; public class PlaySoundEvent extends SoundEvent { private final String name; - private final SoundInstance sound; - private SoundInstance result; + private final SoundInstance originalSound; + private SoundInstance sound; public PlaySoundEvent(SoundEngine manager, SoundInstance sound) { super(manager); - this.sound = sound; + this.originalSound = sound; this.name = sound.getLocation().getPath(); - this.setResultSound(sound); + this.setSound(sound); } public String getName() @@ -47,18 +47,18 @@ public class PlaySoundEvent extends SoundEvent return name; } + public SoundInstance getOriginalSound() + { + return originalSound; + } + public SoundInstance getSound() { return sound; } - public SoundInstance getResultSound() + public void setSound(SoundInstance result) { - return result; - } - - public void setResultSound(SoundInstance result) - { - this.result = result; + this.sound = result; } } diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java index 13a6e783fb..a59bf4ea42 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -25,29 +25,29 @@ import com.mojang.blaze3d.audio.Channel; public class SoundEvent extends net.minecraftforge.eventbus.api.Event { - private final SoundEngine manager; - public SoundEvent(SoundEngine manager) + private final SoundEngine engine; + public SoundEvent(SoundEngine engine) { - this.manager = manager; + this.engine = engine; } - public SoundEngine getManager() + public SoundEngine getEngine() { - return manager; + return engine; } public static class SoundSourceEvent extends SoundEvent { private final SoundInstance sound; - private final Channel source; + private final Channel channel; private final String name; - public SoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel source) + public SoundSourceEvent(SoundEngine manager, SoundInstance sound, Channel channel) { super(manager); this.name = sound.getLocation().getPath(); this.sound = sound; - this.source = source; + this.channel = channel; } public SoundInstance getSound() @@ -55,9 +55,9 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event return sound; } - public Channel getSource() + public Channel getChannel() { - return source; + return channel; } public String getName() diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java index 3ddc5bc280..2bead9768a 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeBakedModel.java @@ -55,7 +55,7 @@ public interface IForgeBakedModel return self().getQuads(state, side, rand); } - default boolean isAmbientOcclusion(BlockState state) { return self().useAmbientOcclusion(); } + default boolean useAmbientOcclusion(BlockState state) { return self().useAmbientOcclusion(); } /** * Override to tell the new model loader that it shouldn't wrap this model diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java b/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java index eed9afbf95..5fdd7677ac 100644 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java +++ b/src/main/java/net/minecraftforge/client/extensions/IForgeKeyMapping.java @@ -42,14 +42,14 @@ public interface IForgeKeyMapping default void setToDefault() { - setKeyModifierAndCode(getKeyModifierDefault(), self().getDefaultKey()); + setKeyModifierAndCode(getDefaultKeyModifier(), self().getDefaultKey()); } void setKeyConflictContext(IKeyConflictContext keyConflictContext); IKeyConflictContext getKeyConflictContext(); - KeyModifier getKeyModifierDefault(); + KeyModifier getDefaultKeyModifier(); KeyModifier getKeyModifier(); @@ -63,7 +63,7 @@ public interface IForgeKeyMapping /** * Returns true when one of the bindings' key codes conflicts with the other's modifier. */ - default boolean hasKeyCodeModifierConflict(KeyMapping other) + default boolean hasKeyModifierConflict(KeyMapping other) { if (getKeyConflictContext().conflicts(other.getKeyConflictContext()) || other.getKeyConflictContext().conflicts(getKeyConflictContext())) { diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java b/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java deleted file mode 100644 index 2fa02779f5..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeRenderChunk.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.extensions; - -import net.minecraft.client.renderer.chunk.RenderChunkRegion; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; - -public interface IForgeRenderChunk -{ - /** - * Creates a new RegionRenderCache instance.
- * Extending classes can change the behavior of the cache, allowing to visually change - * blocks (schematics etc). - * - * @see RenderChunkRegion - * @param world The world to cache. - * @param from The starting position of the chunk minus one on each axis. - * @param to The ending position of the chunk plus one on each axis. - * @param subtract Padding used internally by the RegionRenderCache constructor to make - * the cache a 20x20x20 cube, for a total of 8000 states in the cache. - * @return new RegionRenderCache instance - */ - default RenderChunkRegion createRegionRenderCache(Level world, BlockPos from, BlockPos to, int subtract) - { - return RenderChunkRegion.createIfNotEmpty(world, from, to, subtract); - } -} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java b/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java deleted file mode 100644 index 10034ff91b..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeTextureAtlasSprite.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.extensions; - -import java.util.Collection; -import java.util.function.Function; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.resources.ResourceLocation; - -public interface IForgeTextureAtlasSprite -{ - - /** - * @deprecated See {@link net.minecraftforge.client.textures.ITextureAtlasSpriteLoader} - */ - @Deprecated - default boolean hasCustomLoader(ResourceManager manager, ResourceLocation location) - { - return false; - } - - /** - * @deprecated See {@link net.minecraftforge.client.textures.ITextureAtlasSpriteLoader} - */ - @Deprecated - default boolean load(ResourceManager manager, ResourceLocation location, Function textureGetter) - { - return true; - } - - @Deprecated - default Collection getDependencies() - { - return ImmutableList.of(); - } -} diff --git a/src/main/java/net/minecraftforge/client/extensions/IForgeUnbakedModel.java b/src/main/java/net/minecraftforge/client/extensions/IForgeUnbakedModel.java deleted file mode 100644 index 995015a9a5..0000000000 --- a/src/main/java/net/minecraftforge/client/extensions/IForgeUnbakedModel.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.extensions; - -import net.minecraftforge.common.model.animation.IClip; - -import java.util.Optional; - -public interface IForgeUnbakedModel -{ - /** - * Retrieves information about an animation clip in the model. - * @param name The clip name - * @return - */ - default Optional getClip(String name) { - return Optional.empty(); - } -} diff --git a/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java b/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java index 0dd222eb18..631d5b63b3 100644 --- a/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java +++ b/src/main/java/net/minecraftforge/client/gui/ForgeIngameGui.java @@ -80,10 +80,10 @@ public class ForgeIngameGui extends Gui public int left_height = 39; public int right_height = 39; - private Font fontrenderer = null; + private Font font = null; private RenderGameOverlayEvent eventParent; - private GuiOverlayDebugForge debugOverlay; + private ForgeDebugScreenOverlay debugOverlay; public void setupOverlayRenderState(boolean blend, boolean depthText) { @@ -164,7 +164,7 @@ public class ForgeIngameGui extends Gui gui.setupOverlayRenderState(true, false); if (gui.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) { - gui.spectatorGui.renderHotbar(mStack, partialTicks); + gui.spectatorGui.renderHotbar(mStack); } else { @@ -335,7 +335,7 @@ public class ForgeIngameGui extends Gui public ForgeIngameGui(Minecraft mc) { super(mc); - debugOverlay = new GuiOverlayDebugForge(mc); + debugOverlay = new ForgeDebugScreenOverlay(mc); } @Override @@ -350,7 +350,7 @@ public class ForgeIngameGui extends Gui if (pre(ALL, pStack)) return; - fontrenderer = minecraft.font; + font = minecraft.font; this.random.setSeed(tickCount * 312871L); @@ -689,20 +689,20 @@ public class ForgeIngameGui extends Gui for (String msg : listL) { if (msg == null) continue; - fill(mStack, 1, top - 1, 2 + fontrenderer.width(msg) + 1, top + fontrenderer.lineHeight - 1, -1873784752); - fontrenderer.draw(mStack, msg, 2, top, 14737632); - top += fontrenderer.lineHeight; + fill(mStack, 1, top - 1, 2 + font.width(msg) + 1, top + font.lineHeight - 1, -1873784752); + font.draw(mStack, msg, 2, top, 14737632); + top += font.lineHeight; } top = 2; for (String msg : listR) { if (msg == null) continue; - int w = fontrenderer.width(msg); + int w = font.width(msg); int left = width - 2 - w; - fill(mStack, left - 1, top - 1, left + w + 1, top + fontrenderer.lineHeight - 1, -1873784752); - fontrenderer.draw(mStack, msg, left, top, 14737632); - top += fontrenderer.lineHeight; + fill(mStack, left - 1, top - 1, left + w + 1, top + font.lineHeight - 1, -1873784752); + font.draw(mStack, msg, left, top, 14737632); + top += font.lineHeight; } } @@ -734,8 +734,8 @@ public class ForgeIngameGui extends Gui RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); int color = (animateOverlayMessageColor ? Mth.hsvToRgb(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE); - drawBackdrop(pStack, fontrenderer, -4, fontrenderer.width(overlayMessageString), 16777215 | (opacity << 24)); - fontrenderer.draw(pStack, overlayMessageString.getVisualOrderText(), -fontrenderer.width(overlayMessageString) / 2, -4, color | (opacity << 24)); + drawBackdrop(pStack, font, -4, font.width(overlayMessageString), 16777215 | (opacity << 24)); + font.draw(pStack, overlayMessageString.getVisualOrderText(), -font.width(overlayMessageString) / 2, -4, color | (opacity << 24)); RenderSystem.disableBlend(); pStack.popPose(); } @@ -892,10 +892,10 @@ public class ForgeIngameGui extends Gui RenderSystem.setShaderTexture(0, res); } - private class GuiOverlayDebugForge extends DebugScreenOverlay + private class ForgeDebugScreenOverlay extends DebugScreenOverlay { private Minecraft mc; - private GuiOverlayDebugForge(Minecraft mc) + private ForgeDebugScreenOverlay(Minecraft mc) { super(mc); this.mc = mc; diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/GuiUtils.java b/src/main/java/net/minecraftforge/client/gui/GuiUtils.java similarity index 57% rename from src/main/java/net/minecraftforge/fmlclient/gui/GuiUtils.java rename to src/main/java/net/minecraftforge/client/gui/GuiUtils.java index a7da2b9b22..bde8bb1062 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/GuiUtils.java +++ b/src/main/java/net/minecraftforge/client/gui/GuiUtils.java @@ -17,10 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui; +package net.minecraftforge.client.gui; import com.mojang.blaze3d.vertex.VertexFormat; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.Font; import net.minecraft.client.renderer.GameRenderer; @@ -37,8 +36,6 @@ import net.minecraft.network.chat.Style; import net.minecraftforge.client.event.RenderTooltipEvent; import net.minecraftforge.common.MinecraftForge; -import org.lwjgl.opengl.GL11; - import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.systems.RenderSystem; @@ -229,215 +226,6 @@ public class GuiUtils tessellator.end(); } - @Nonnull - private static ItemStack cachedTooltipStack = ItemStack.EMPTY; - - /** - * Must be called from {@code GuiScreen.renderToolTip} before {@code GuiScreen.drawHoveringText} is called. - * - * @param stack The stack for which a tooltip is about to be drawn. - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static void preItemToolTip(@Nonnull ItemStack stack) - { - cachedTooltipStack = stack; - } - - /** - * Must be called from {@code GuiScreen.renderToolTip} after {@code GuiScreen.drawHoveringText} is called. - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static void postItemToolTip() - { - cachedTooltipStack = ItemStack.EMPTY; - } - - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static void drawHoveringText(PoseStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) - { - drawHoveringText(mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font); - } - - /** - * Draws a tooltip box on the screen with text in it. - * Automatically positions the box relative to the mouse to match Mojang's implementation. - * Automatically wraps text when there is not enough space on the screen to display the text without wrapping. - * Can have a maximum width set to avoid creating very wide tooltips. - * - * @param textLines the lines of text to be drawn in a hovering tooltip box. - * @param mouseX the mouse X position - * @param mouseY the mouse Y position - * @param screenWidth the available screen width for the tooltip to drawn in - * @param screenHeight the available screen height for the tooltip to drawn in - * @param maxTextWidth the maximum width of the text in the tooltip box. - * Set to a negative number to have no max width. - * @param backgroundColor The background color of the box - * @param borderColorStart The starting color of the box border - * @param borderColorEnd The ending color of the box border. The border color will be smoothly interpolated - * between the start and end values. - * @param font the font for drawing the text in the tooltip box - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static void drawHoveringText(PoseStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, - int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, Font font) - { - drawHoveringText(cachedTooltipStack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, backgroundColor, borderColorStart, borderColorEnd, font); - } - - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack mStack, List textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, Font font) - { - drawHoveringText(stack, mStack, textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, DEFAULT_BACKGROUND_COLOR, DEFAULT_BORDER_COLOR_START, DEFAULT_BORDER_COLOR_END, font); - } - - /** - * Use this version if calling from somewhere where ItemStack context is available. - * - * @see #drawHoveringText(PoseStack, List, int, int, int, int, int, int, int, int, Font) - */ - @Deprecated(since = "1.18", forRemoval = true) // TODO: remove in 1.18 - public static void drawHoveringText(@Nonnull final ItemStack stack, PoseStack pStack, List textLines, int mouseX, int mouseY, - int screenWidth, int screenHeight, int maxTextWidth, - int backgroundColor, int borderColorStart, int borderColorEnd, Font font) - { - if (!textLines.isEmpty()) - { - RenderTooltipEvent.Pre event = new RenderTooltipEvent.Pre(stack, textLines, pStack, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font); - if (MinecraftForge.EVENT_BUS.post(event)) - return; - mouseX = event.getX(); - mouseY = event.getY(); - screenWidth = event.getScreenWidth(); - screenHeight = event.getScreenHeight(); - maxTextWidth = event.getMaxWidth(); - font = event.getFontRenderer(); - - // RenderSystem.disableRescaleNormal(); - RenderSystem.disableDepthTest(); - int tooltipTextWidth = 0; - - for (FormattedText textLine : textLines) - { - int textLineWidth = font.width(textLine); - if (textLineWidth > tooltipTextWidth) - tooltipTextWidth = textLineWidth; - } - - boolean needsWrap = false; - - int titleLinesCount = 1; - int tooltipX = mouseX + 12; - if (tooltipX + tooltipTextWidth + 4 > screenWidth) - { - tooltipX = mouseX - 16 - tooltipTextWidth; - if (tooltipX < 4) // if the tooltip doesn't fit on the screen - { - if (mouseX > screenWidth / 2) - tooltipTextWidth = mouseX - 12 - 8; - else - tooltipTextWidth = screenWidth - 16 - mouseX; - needsWrap = true; - } - } - - if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) - { - tooltipTextWidth = maxTextWidth; - needsWrap = true; - } - - if (needsWrap) - { - int wrappedTooltipWidth = 0; - List wrappedTextLines = new ArrayList<>(); - for (int i = 0; i < textLines.size(); i++) - { - FormattedText textLine = textLines.get(i); - List wrappedLine = font.getSplitter().splitLines(textLine, tooltipTextWidth, Style.EMPTY); - if (i == 0) - titleLinesCount = wrappedLine.size(); - - for (FormattedText line : wrappedLine) - { - int lineWidth = font.width(line); - if (lineWidth > wrappedTooltipWidth) - wrappedTooltipWidth = lineWidth; - wrappedTextLines.add(line); - } - } - tooltipTextWidth = wrappedTooltipWidth; - textLines = wrappedTextLines; - - if (mouseX > screenWidth / 2) - tooltipX = mouseX - 16 - tooltipTextWidth; - else - tooltipX = mouseX + 12; - } - - int tooltipY = mouseY - 12; - int tooltipHeight = 8; - - if (textLines.size() > 1) - { - tooltipHeight += (textLines.size() - 1) * 10; - if (textLines.size() > titleLinesCount) - tooltipHeight += 2; // gap between title lines and next lines - } - - if (tooltipY < 4) - tooltipY = 4; - else if (tooltipY + tooltipHeight + 4 > screenHeight) - tooltipY = screenHeight - tooltipHeight - 4; - - final int zLevel = 400; - RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, textLines, pStack, tooltipX, tooltipY, font, backgroundColor, borderColorStart, borderColorEnd); - MinecraftForge.EVENT_BUS.post(colorEvent); - backgroundColor = colorEvent.getBackground(); - borderColorStart = colorEvent.getBorderStart(); - borderColorEnd = colorEvent.getBorderEnd(); - - pStack.pushPose(); - Matrix4f mat = pStack.last().pose(); - //TODO, lots of unnessesary GL calls here, we can buffer all these together. - drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor); - drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor); - drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor); - drawGradientRect(mat, zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor); - drawGradientRect(mat, zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor); - drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd); - drawGradientRect(mat, zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd); - drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart); - drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 2, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, borderColorEnd, borderColorEnd); - - MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostBackground(stack, textLines, pStack, tooltipX, tooltipY, font, tooltipTextWidth, tooltipHeight)); - - MultiBufferSource.BufferSource renderType = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - pStack.translate(0.0D, 0.0D, zLevel); - - int tooltipTop = tooltipY; - - for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) - { - FormattedText line = textLines.get(lineNumber); - if (line != null) - font.drawInBatch(Language.getInstance().getVisualOrder(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880); - - if (lineNumber + 1 == titleLinesCount) - tooltipY += 2; - - tooltipY += 10; - } - - renderType.endBatch(); - pStack.popPose(); - - MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(stack, textLines, pStack, tooltipX, tooltipTop, font, tooltipTextWidth, tooltipHeight)); - - RenderSystem.enableDepthTest(); - // RenderSystem.enableRescaleNormal(); - } - } - public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor) { float startAlpha = (float)(startColor >> 24 & 255) / 255.0F; diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/screen/LoadingErrorScreen.java b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java similarity index 97% rename from src/main/java/net/minecraftforge/fmlclient/gui/screen/LoadingErrorScreen.java rename to src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java index 167beec07b..d60f929d25 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/screen/LoadingErrorScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/LoadingErrorScreen.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui.screen; +package net.minecraftforge.client.gui; import com.google.common.base.Strings; import com.mojang.blaze3d.vertex.PoseStack; @@ -31,12 +31,11 @@ import net.minecraft.Util; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.ChatFormatting; -import net.minecraftforge.fmllegacy.ForgeI18n; +import net.minecraftforge.common.ForgeI18n; import net.minecraftforge.fml.LoadingFailedException; import net.minecraftforge.fml.ModLoadingException; import net.minecraftforge.fml.ModLoadingWarning; -import net.minecraftforge.fmlclient.ClientHooks; -import net.minecraftforge.fmlclient.gui.widget.ExtendedButton; +import net.minecraftforge.client.gui.widget.ExtendedButton; import net.minecraftforge.fml.loading.FMLPaths; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java similarity index 97% rename from src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java rename to src/main/java/net/minecraftforge/client/gui/ModListScreen.java index 36c3735baf..131df54b0d 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/screen/ModListScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/ModListScreen.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui.screen; +package net.minecraftforge.client.gui; import java.io.IOException; import java.io.InputStream; @@ -33,8 +33,7 @@ import java.util.stream.Collectors; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.narration.NarrationElementOutput; import net.minecraft.client.renderer.GameRenderer; -import net.minecraftforge.fmlclient.gui.GuiUtils; -import net.minecraftforge.fmlclient.gui.widget.ModListWidget; +import net.minecraftforge.client.gui.widget.ModListWidget; import net.minecraftforge.resource.PathResourcePack; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -56,18 +55,17 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.FormattedCharSequence; import net.minecraft.resources.ResourceLocation; import net.minecraft.Util; -import net.minecraftforge.client.gui.ScrollPanel; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Size2i; -import net.minecraftforge.fmllegacy.ForgeI18n; -import net.minecraftforge.fmllegacy.MavenVersionStringHelper; +import net.minecraftforge.common.ForgeI18n; +import net.minecraftforge.common.util.MavenVersionStringHelper; import net.minecraftforge.fml.ModContainer; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.fmlclient.ConfigGuiHandler; +import net.minecraftforge.client.ConfigGuiHandler; import net.minecraftforge.fml.loading.FMLPaths; import net.minecraftforge.fml.loading.StringUtils; -import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; +import net.minecraftforge.resource.ResourcePackLoader; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraft.locale.Language; @@ -256,10 +254,6 @@ public class ModListScreen extends Screen return super.mouseClicked(mouseX, mouseY, button); } - @Override - protected void drawBackground() { - } - @Override public NarrationPriority narrationPriority() { return NarrationPriority.NONE; diff --git a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java index 1f89813639..883ddcb067 100644 --- a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java +++ b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java @@ -31,7 +31,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.loading.FMLConfig; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.fml.VersionChecker; -import net.minecraftforge.fmlclient.ClientModLoader; +import net.minecraftforge.client.loading.ClientModLoader; import net.minecraftforge.api.distmarker.Dist; @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java b/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java index 0c3b21c116..c27c5e4bbc 100644 --- a/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java +++ b/src/main/java/net/minecraftforge/client/gui/ScrollPanel.java @@ -37,7 +37,6 @@ import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.components.Widget; -import net.minecraftforge.fmlclient.gui.GuiUtils; /** * Abstract scroll panel class. @@ -171,9 +170,6 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen protected abstract int getContentHeight(); - // TODO: 1.18 rename and add PoseStack parameter - protected void drawBackground() {} - /** * Draws the background of the scroll panel. This runs AFTER Scissors are enabled. */ @@ -314,8 +310,6 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen @Override public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks) { - this.drawBackground(); - Tesselator tess = Tesselator.getInstance(); BufferBuilder worldr = tess.getBuilder(); diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/widget/ExtendedButton.java b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java similarity index 92% rename from src/main/java/net/minecraftforge/fmlclient/gui/widget/ExtendedButton.java rename to src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java index bb27e135a5..5c9f343095 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/widget/ExtendedButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ExtendedButton.java @@ -17,16 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui.widget; +package net.minecraftforge.client.gui.widget; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; -import net.minecraftforge.fmlclient.gui.GuiUtils; - -import net.minecraft.client.gui.components.Button.OnPress; +import net.minecraftforge.client.gui.GuiUtils; /** * This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code. @@ -52,7 +50,7 @@ public class ExtendedButton extends Button public void renderButton(PoseStack mStack, int mouseX, int mouseY, float partial) { Minecraft mc = Minecraft.getInstance(); - int k = this.getYImage(this.isHovered()); + int k = this.getYImage(this.isHovered); GuiUtils.drawContinuousTexturedBox(mStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(mStack, mc, mouseX, mouseY); diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/widget/ModListWidget.java b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java similarity index 96% rename from src/main/java/net/minecraftforge/fmlclient/gui/widget/ModListWidget.java rename to src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java index 744e56999b..553af7591d 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/widget/ModListWidget.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/ModListWidget.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui.widget; +package net.minecraftforge.client.gui.widget; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.gui.Font; @@ -29,9 +29,9 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.locale.Language; import net.minecraft.network.chat.TextComponent; -import net.minecraftforge.fmlclient.gui.screen.ModListScreen; +import net.minecraftforge.client.gui.ModListScreen; import net.minecraftforge.versions.forge.ForgeVersion; -import net.minecraftforge.fmllegacy.MavenVersionStringHelper; +import net.minecraftforge.common.util.MavenVersionStringHelper; import net.minecraftforge.fml.VersionChecker; import net.minecraftforge.forgespi.language.IModInfo; diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/widget/Slider.java b/src/main/java/net/minecraftforge/client/gui/widget/Slider.java similarity index 97% rename from src/main/java/net/minecraftforge/fmlclient/gui/widget/Slider.java rename to src/main/java/net/minecraftforge/client/gui/widget/Slider.java index e644242a5a..90c5b89aa0 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/widget/Slider.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/Slider.java @@ -17,18 +17,16 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui.widget; +package net.minecraftforge.client.gui.widget; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; -import net.minecraftforge.fmlclient.gui.GuiUtils; +import net.minecraftforge.client.gui.GuiUtils; import javax.annotation.Nullable; -import net.minecraft.client.gui.components.Button.OnPress; - /** * This class is blatantly stolen from iChunUtils with permission. * diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/widget/UnicodeGlyphButton.java b/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java similarity index 94% rename from src/main/java/net/minecraftforge/fmlclient/gui/widget/UnicodeGlyphButton.java rename to src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java index f748837914..3920a23640 100644 --- a/src/main/java/net/minecraftforge/fmlclient/gui/widget/UnicodeGlyphButton.java +++ b/src/main/java/net/minecraftforge/client/gui/widget/UnicodeGlyphButton.java @@ -17,17 +17,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient.gui.widget; +package net.minecraftforge.client.gui.widget; import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; -import net.minecraftforge.fmlclient.gui.GuiUtils; - -import net.minecraft.client.gui.components.Button.OnPress; +import net.minecraftforge.client.gui.GuiUtils; /** * This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter. diff --git a/src/main/java/net/minecraftforge/fmlclient/ClientModLoader.java b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java similarity index 92% rename from src/main/java/net/minecraftforge/fmlclient/ClientModLoader.java rename to src/main/java/net/minecraftforge/client/loading/ClientModLoader.java index a4a55b4a83..1d83668a99 100644 --- a/src/main/java/net/minecraftforge/fmlclient/ClientModLoader.java +++ b/src/main/java/net/minecraftforge/client/loading/ClientModLoader.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient; +package net.minecraftforge.client.loading; import static net.minecraftforge.fml.Logging.CORE; import static net.minecraftforge.fml.Logging.LOADING; @@ -26,7 +26,6 @@ import java.io.File; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.*; -import java.util.function.BiConsumer; import java.util.function.Consumer; import net.minecraft.server.packs.repository.RepositorySource; @@ -38,11 +37,10 @@ import net.minecraft.server.packs.repository.Pack; import net.minecraft.server.packs.repository.PackRepository; import net.minecraft.world.level.DataPackConfig; import net.minecraftforge.event.AddPackFindersEvent; -import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.*; -import net.minecraftforge.fmllegacy.BrandingControl; -import net.minecraftforge.fmllegacy.CrashReportExtender; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.internal.BrandingControl; +import net.minecraftforge.logging.CrashReportExtender; +import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.resource.PathResourcePack; import org.apache.logging.log4j.LogManager; @@ -62,10 +60,10 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fmlclient.gui.screen.LoadingErrorScreen; -import net.minecraftforge.fmllegacy.packs.DelegatingResourcePack; -import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; -import net.minecraftforge.fmllegacy.server.LanguageHook; +import net.minecraftforge.client.gui.LoadingErrorScreen; +import net.minecraftforge.resource.DelegatingResourcePack; +import net.minecraftforge.resource.ResourcePackLoader; +import net.minecraftforge.server.LanguageHook; import net.minecraftforge.forgespi.language.IModInfo; @OnlyIn(Dist.CLIENT) @@ -101,16 +99,16 @@ public class ClientModLoader // force log4j to shutdown logging in a shutdown hook. This is because we disable default shutdown hook so the server properly logs it's shutdown Runtime.getRuntime().addShutdownHook(new Thread(LogManager::shutdown)); loading = true; - net.minecraftforge.fmlclient.ClientModLoader.mc = minecraft; + ClientModLoader.mc = minecraft; LogicalSidedProvider.setClient(()->minecraft); LanguageHook.loadForgeAndMCLangs(); earlyLoaderGUI = new EarlyLoaderGUI(minecraft); createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), new SpacedRunnable(earlyLoaderGUI::renderTick))).run(); if (error == null) { - ResourcePackLoader.loadResourcePacks(defaultResourcePacks, net.minecraftforge.fmlclient.ClientModLoader::buildPackFinder); + ResourcePackLoader.loadResourcePacks(defaultResourcePacks, ClientModLoader::buildPackFinder); ModLoader.get().postEvent(new AddPackFindersEvent(PackType.CLIENT_RESOURCES, defaultResourcePacks::addPackFinder)); DataPackConfig.DEFAULT.addModPacks(ResourcePackLoader.getPackNames()); - mcResourceManager.registerReloadListener(net.minecraftforge.fmlclient.ClientModLoader::onResourceReload); + mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload); mcResourceManager.registerReloadListener(BrandingControl.resourceManagerReloadListener()); ModelLoaderRegistry.init(); } diff --git a/src/main/java/net/minecraftforge/fmlclient/EarlyLoaderGUI.java b/src/main/java/net/minecraftforge/client/loading/EarlyLoaderGUI.java similarity index 99% rename from src/main/java/net/minecraftforge/fmlclient/EarlyLoaderGUI.java rename to src/main/java/net/minecraftforge/client/loading/EarlyLoaderGUI.java index 61664ef2ef..2ab1c09d2f 100644 --- a/src/main/java/net/minecraftforge/fmlclient/EarlyLoaderGUI.java +++ b/src/main/java/net/minecraftforge/client/loading/EarlyLoaderGUI.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlclient; +package net.minecraftforge.client.loading; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; diff --git a/src/main/java/net/minecraftforge/fmllegacy/NoVizFallback.java b/src/main/java/net/minecraftforge/client/loading/NoVizFallback.java similarity index 96% rename from src/main/java/net/minecraftforge/fmllegacy/NoVizFallback.java rename to src/main/java/net/minecraftforge/client/loading/NoVizFallback.java index cb27cd715e..4b03af90b6 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/NoVizFallback.java +++ b/src/main/java/net/minecraftforge/client/loading/NoVizFallback.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.client.loading; import java.util.function.IntSupplier; import java.util.function.LongSupplier; diff --git a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java index e420655abd..61d870df41 100644 --- a/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java +++ b/src/main/java/net/minecraftforge/client/model/BakedModelWrapper.java @@ -58,9 +58,9 @@ public abstract class BakedModelWrapper implements BakedMo } @Override - public boolean isAmbientOcclusion(BlockState state) + public boolean useAmbientOcclusion(BlockState state) { - return originalModel.isAmbientOcclusion(state); + return originalModel.useAmbientOcclusion(state); } @Override diff --git a/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java b/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java index caf4630a75..c6ca33710d 100644 --- a/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java +++ b/src/main/java/net/minecraftforge/client/model/DynamicBucketModel.java @@ -263,7 +263,7 @@ public final class DynamicBucketModel implements IModelGeometry loadingExceptions = Maps.newHashMap(); @@ -55,10 +55,10 @@ public final class ModelLoader extends ModelBakery private boolean isLoading = false; - private static ModelLoader instance; + private static ForgeModelBakery instance; @Nullable - public static ModelLoader instance() + public static ForgeModelBakery instance() { return instance; } @@ -68,7 +68,7 @@ public final class ModelLoader extends ModelBakery return isLoading; } - public ModelLoader(ResourceManager manager, BlockColors colours, ProfilerFiller profiler, int maxMipmapLevel) + public ForgeModelBakery(ResourceManager manager, BlockColors colours, ProfilerFiller profiler, int maxMipmapLevel) { super(manager, colours, false); instance = this; @@ -261,7 +261,7 @@ public final class ModelLoader extends ModelBakery } */ - private static final Function DEFAULT_MODEL_GETTER = (rl) -> ModelLoader.instance().getModelOrMissing(rl); + private static final Function DEFAULT_MODEL_GETTER = (rl) -> ForgeModelBakery.instance().getModelOrMissing(rl); /** * Get the default texture getter the models will be baked with. diff --git a/src/main/java/net/minecraftforge/client/model/ModelDataManager.java b/src/main/java/net/minecraftforge/client/model/ModelDataManager.java index ea6e8b554b..cc3c34ac38 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelDataManager.java +++ b/src/main/java/net/minecraftforge/client/model/ModelDataManager.java @@ -45,7 +45,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @EventBusSubscriber(modid = "forge", bus = Bus.FORGE, value = Dist.CLIENT) public class ModelDataManager { - private static WeakReference currentWorld = new WeakReference<>(null); + private static WeakReference currentLevel = new WeakReference<>(null); private static final Map> needModelDataRefresh = new ConcurrentHashMap<>(); @@ -55,9 +55,9 @@ public class ModelDataManager { Preconditions.checkNotNull(world, "World must not be null"); Preconditions.checkArgument(world == Minecraft.getInstance().level, "Cannot use model data for a world other than the current client world"); - if (world != currentWorld.get()) + if (world != currentLevel.get()) { - currentWorld = new WeakReference<>(world); + currentLevel = new WeakReference<>(world); needModelDataRefresh.clear(); modelDataCache.clear(); } diff --git a/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java b/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java index 6991b087d9..df611684ee 100644 --- a/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java @@ -149,7 +149,7 @@ public final class MultiLayerModel implements IModelGeometry @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) { - RenderType layer = MinecraftForgeClient.getRenderLayer(); + RenderType layer = MinecraftForgeClient.getRenderType(); if (layer == null) { ImmutableList.Builder builder = ImmutableList.builder(); @@ -175,7 +175,7 @@ public final class MultiLayerModel implements IModelGeometry } @Override - public boolean isAmbientOcclusion(BlockState state) + public boolean useAmbientOcclusion(BlockState state) { return ambientOcclusion; } diff --git a/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java b/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java index b97e852228..7d964f9f62 100644 --- a/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java +++ b/src/main/java/net/minecraftforge/client/model/PerspectiveMapWrapper.java @@ -131,7 +131,7 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel } @Override public boolean useAmbientOcclusion() { return parent.useAmbientOcclusion(); } - @Override public boolean isAmbientOcclusion(BlockState state) { return parent.isAmbientOcclusion(state); } + @Override public boolean useAmbientOcclusion(BlockState state) { return parent.useAmbientOcclusion(state); } @Override public boolean isGui3d() { return parent.isGui3d(); } @Override public boolean usesBlockLight() { return parent.usesBlockLight(); } @Override public boolean isCustomRenderer() { return parent.isCustomRenderer(); } diff --git a/src/main/java/net/minecraftforge/client/model/animation/Animation.java b/src/main/java/net/minecraftforge/client/model/animation/Animation.java deleted file mode 100644 index 2cf1fd1c08..0000000000 --- a/src/main/java/net/minecraftforge/client/model/animation/Animation.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.model.animation; - -import net.minecraft.world.level.Level; - -import java.lang.ref.WeakReference; - -public enum Animation -{ - INSTANCE; - - private float clientPartialTickTime; - - private static long epochTime; - private static WeakReference worldRef; - - /** - * Get the global world time for the current tick, in seconds. - */ - public static float getWorldTime(Level world) - { - return getWorldTime(world, 0); - } - - /** - * Get the global world time for the current tick + partial tick progress, in seconds. - */ - public static float getWorldTime(Level world, float tickProgress) - { - if (worldRef == null || worldRef.get() != world) - { - epochTime = world.getGameTime(); - worldRef = new WeakReference<>(world); - } - return (world.getGameTime() - epochTime + tickProgress) / 20; - } - - /** - * Get current partialTickTime. - */ - public static float getPartialTickTime() - { - return INSTANCE.clientPartialTickTime; - } - - /** - * Internal hook, do not use. - */ - public static void setClientPartialTickTime(float clientPartialTickTime) { - Animation.INSTANCE.clientPartialTickTime = clientPartialTickTime; - } -} diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationBlockEntityRenderer.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationBlockEntityRenderer.java deleted file mode 100644 index 427ea07a20..0000000000 --- a/src/main/java/net/minecraftforge/client/model/animation/AnimationBlockEntityRenderer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.model.animation; - -import java.util.Random; - -import com.mojang.blaze3d.vertex.PoseStack; - -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Sheets; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; -import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.client.model.ModelDataManager; -import net.minecraftforge.client.model.data.IModelData; -import net.minecraftforge.common.animation.Event; -import net.minecraftforge.common.animation.IEventHandler; -import net.minecraftforge.common.model.animation.CapabilityAnimation; -import net.minecraftforge.common.model.animation.IAnimationStateMachine; -import net.minecraftforge.common.property.Properties; -import net.minecraftforge.common.util.LazyOptional; - -/** - * Generic {@link BlockEntityRenderer} that works with the Forge model system and animations. - */ -public class AnimationBlockEntityRenderer implements BlockEntityRenderer, IEventHandler -{ - protected static BlockRenderDispatcher blockRenderer; - - @Override - public void render(T te, float partialTick, PoseStack mat, MultiBufferSource renderer, int light, int otherlight) - { - LazyOptional cap = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY); - if(!cap.isPresent()) - { - return; - } - if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRenderer(); - BlockPos pos = te.getBlockPos(); - BlockAndTintGetter world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos) - .map(BlockAndTintGetter.class::cast).orElseGet(() -> te.getLevel()); - BlockState state = world.getBlockState(pos); - BakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state); - IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getLevel(), pos)); - if (data.hasProperty(Properties.AnimationProperty)) - { - @SuppressWarnings("resource") - float time = Animation.getWorldTime(Minecraft.getInstance().level, partialTick); - cap - .map(asm -> asm.apply(time)) - .ifPresent(pair -> { - handleEvents(te, time, pair.getRight()); - - // TODO: caching? - data.setData(Properties.AnimationProperty, pair.getLeft()); - blockRenderer.getModelRenderer().tesselateBlock(world, model, state, pos, mat, renderer.getBuffer(Sheets.solidBlockSheet()), false, new Random(), 42, light, data); - }); - } - } - - @Override - public void handleEvents(T te, float time, Iterable pastEvents) {} -} diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java deleted file mode 100644 index 2bb53ba3c6..0000000000 --- a/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.model.animation; - -import java.util.List; -import java.util.function.Function; - -import javax.annotation.Nullable; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.Level; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.CompositeModelState; -import net.minecraftforge.common.model.animation.CapabilityAnimation; - -import net.minecraft.client.renderer.block.model.ItemOverride; -import net.minecraft.client.renderer.block.model.ItemOverrides; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; - -public final class AnimationItemOverrideList extends ItemOverrides -{ - private final ModelBakery bakery; - private final UnbakedModel model; - private final ResourceLocation modelLoc; - private final ModelState state; - - - private final Function bakedTextureGetter; - - //TODO, Mojang now bakes overrides, figure out how to reverse them. -/* - public AnimationItemOverrideList(ModelBakery bakery, UnbakedModel model, ResourceLocation modelLoc, ModelState state, Function bakedTextureGetter, ItemOverrides overrides) - { - this(bakery, model, modelLoc, state, bakedTextureGetter, overrides.getOverrides().reverse()); - } -*/ - - public AnimationItemOverrideList(ModelBakery bakery, UnbakedModel model, ResourceLocation modelLoc, ModelState state, Function bakedTextureGetter, List overrides) - { - super(bakery, model, ModelLoader.defaultModelGetter(), bakedTextureGetter, overrides); - this.bakery = bakery; - this.model = model; - this.modelLoc = modelLoc; - this.state = state; - this.bakedTextureGetter = bakedTextureGetter; - } - - @SuppressWarnings("resource") - @Override - public BakedModel resolve(BakedModel originalModel, ItemStack stack, @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed) - { - return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null) - .map(asm -> - { - Level w = world; - // TODO caching? - if(w == null && entity != null) - { - w = entity.level; - } - if(world == null) - { - w = Minecraft.getInstance().level; - } - return asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft(); - }) - // TODO where should uvlock data come from? - .map(state -> model.bake(bakery, bakedTextureGetter, new CompositeModelState(state, this.state), modelLoc)) - .orElseGet(() -> super.resolve(originalModel, stack, world, entity, seed)); - } -} diff --git a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java deleted file mode 100644 index 9f9d1e08b7..0000000000 --- a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.model.animation; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Optional; -import java.util.TreeMap; - -import javax.annotation.Nullable; - -import net.minecraft.client.resources.model.ModelState; -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; -import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import net.minecraft.client.renderer.block.model.BlockElement; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Interpolation; -import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Type; -import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Variable; -import net.minecraftforge.common.animation.Event; -import net.minecraftforge.common.model.animation.IClip; -import net.minecraftforge.common.model.animation.IJoint; -import net.minecraftforge.common.model.animation.IJointClip; -import net.minecraftforge.common.model.animation.JointClips; -import net.minecraftforge.common.util.JsonUtils; - -import com.google.common.collect.ImmutableCollection; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import com.google.common.collect.UnmodifiableIterator; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; -import com.google.gson.annotations.SerializedName; - -public class ModelBlockAnimation -{ - private static final Logger LOGGER = LogManager.getLogger(); - - private final ImmutableMap> joints; - private final ImmutableMap clips; - private transient ImmutableMultimap jointIndexMap; - - public ModelBlockAnimation(ImmutableMap> joints, ImmutableMap clips) - { - this.joints = joints; - this.clips = clips; - } - - public ImmutableMap getClips() - { - return clips; - } - - public ImmutableCollection getJoint(int i) - { - if(jointIndexMap == null) - { - ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); - for(Map.Entry> info : joints.entrySet()) - { - ImmutableMap.Builder weightBuilder = ImmutableMap.builder(); - for(Map.Entry e : info.getValue().entrySet()) - { - weightBuilder.put(Integer.parseInt(e.getKey()), e.getValue()); - } - ImmutableMap weightMap = weightBuilder.build(); - for(Map.Entry e : weightMap.entrySet()) - { - builder.put(e.getKey(), new MBJointWeight(info.getKey(), weightMap)); - } - } - jointIndexMap = builder.build(); - } - return jointIndexMap.get(i); - } - - protected static class MBVariableClip - { - private final Variable variable; - @SuppressWarnings("unused") - private final Type type; - private final Interpolation interpolation; - private final float[] samples; - - public MBVariableClip(Variable variable, Type type, Interpolation interpolation, float[] samples) - { - this.variable = variable; - this.type = type; - this.interpolation = interpolation; - this.samples = samples; - } - } - - protected static class MBClip implements IClip - { - private final boolean loop; - @SerializedName("joint_clips") - private final ImmutableMap> jointClipsFlat; - private transient ImmutableMap jointClips; - @SerializedName("events") - private final ImmutableMap eventsRaw; - private transient TreeMap events; - - public MBClip(boolean loop, ImmutableMap> clips, ImmutableMap events) - { - this.loop = loop; - this.jointClipsFlat = clips; - this.eventsRaw = events; - } - - private void initialize() - { - if(jointClips == null) - { - ImmutableMap.Builder builder = ImmutableMap.builder(); - for (Map.Entry> e : jointClipsFlat.entrySet()) - { - builder.put(e.getKey(), new MBJointClip(loop, e.getValue())); - } - jointClips = builder.build(); - events = Maps.newTreeMap(); - if (!eventsRaw.isEmpty()) - { - TreeMap times = Maps.newTreeMap(); - for (String time : eventsRaw.keySet()) - { - times.put(Float.parseFloat(time), time); - } - float lastTime = Float.POSITIVE_INFINITY; - if (loop) - { - lastTime = times.firstKey(); - } - for (Map.Entry entry : times.descendingMap().entrySet()) - { - float time = entry.getKey(); - float offset = lastTime - time; - if (loop) - { - offset = 1 - (1 - offset) % 1; - } - events.put(time, new Event(eventsRaw.get(entry.getValue()), offset)); - } - } - } - } - - @Override - public IJointClip apply(IJoint joint) - { - initialize(); - if(joint instanceof MBJoint) - { - MBJoint mbJoint = (MBJoint)joint; - //MBJointInfo = jointInfos. - MBJointClip clip = jointClips.get(mbJoint.getName()); - if(clip != null) return clip; - } - return JointClips.IdentityJointClip.INSTANCE; - } - - @Override - public Iterable pastEvents(final float lastPollTime, final float time) - { - initialize(); - return new Iterable() - { - @Override - public Iterator iterator() - { - return new UnmodifiableIterator() - { - private Float curKey; - private Event firstEvent; - private float stopTime; - { - if(lastPollTime >= time) - { - curKey = null; - } - else - { - float fractTime = time - (float)Math.floor(time); - float fractLastTime = lastPollTime - (float)Math.floor(lastPollTime); - // swap if not in order - if(fractLastTime > fractTime) - { - float tmp = fractTime; - fractTime = fractLastTime; - fractLastTime = tmp; - } - // need to wrap around, swap again - if(fractTime - fractLastTime > .5f) - { - float tmp = fractTime; - fractTime = fractLastTime; - fractLastTime = tmp; - } - - stopTime = fractLastTime; - - curKey = events.floorKey(fractTime); - if(curKey == null && loop && !events.isEmpty()) - { - curKey = events.lastKey(); - } - if(curKey != null) - { - float checkCurTime = curKey; - float checkStopTime = stopTime; - if(checkCurTime >= fractTime) checkCurTime--; - if(checkStopTime >= fractTime) checkStopTime--; - float offset = fractTime - checkCurTime; - Event event = events.get(curKey); - if(checkCurTime < checkStopTime) - { - curKey = null; - } - else if(offset != event.offset()) - { - firstEvent = new Event(event.event(), offset); - } - } - } - } - - @Override - public boolean hasNext() - { - return curKey != null; - } - - @Override - public Event next() - { - if(curKey == null) - { - throw new NoSuchElementException(); - } - Event event; - if(firstEvent == null) - { - event = events.get(curKey); - } - else - { - event = firstEvent; - firstEvent = null; - } - curKey = events.lowerKey(curKey); - if(curKey == null && loop) - { - curKey = events.lastKey(); - } - if(curKey != null) - { - float checkStopTime = stopTime; - while(curKey + events.get(curKey).offset() < checkStopTime) checkStopTime--; - while(curKey + events.get(curKey).offset() >= checkStopTime + 1) checkStopTime++; - if(curKey <= checkStopTime) - { - curKey = null; - } - } - return event; - } - }; - } - }; - } - - protected static class MBJointClip implements IJointClip - { - private final boolean loop; - private final ImmutableList variables; - - public MBJointClip(boolean loop, ImmutableList variables) - { - this.loop = loop; - this.variables = variables; - EnumSet hadVar = Sets.newEnumSet(Collections.emptyList(), Variable.class); - for(MBVariableClip var : variables) - { - if(hadVar.contains(var.variable)) - { - throw new IllegalArgumentException("duplicate variable: " + var); - } - hadVar.add(var.variable); - } - } - - @Override - public Transformation apply(float time) - { - time -= Math.floor(time); - Vector3f translation = new Vector3f(0, 0, 0); - Vector3f scale = new Vector3f(1, 1, 1); - Vector3f origin = new Vector3f(0, 0, 0); - Vector3f rotation_axis = new Vector3f(0, 0, 0); - float rotation_angle = 0; - for(MBVariableClip var : variables) - { - int length = loop ? var.samples.length : (var.samples.length - 1); - float timeScaled = time * length; - int s1 = Mth.clamp((int)Math.round(Math.floor(timeScaled)), 0, length - 1); - float progress = timeScaled - s1; - int s2 = s1 + 1; - if(s2 == length && loop) s2 = 0; - float value = 0; - switch(var.interpolation) - { - case LINEAR: - if(var.variable == Variable.ANGLE) - { - float v1 = var.samples[s1]; - float v2 = var.samples[s2]; - float diff = ((v2 - v1) % 360 + 540) % 360 - 180; - value = v1 + diff * progress; - } - else - { - value = var.samples[s1] * (1 - progress) + var.samples[s2] * progress; - } - break; - case NEAREST: - value = var.samples[progress < .5f ? s1 : s2]; - break; - } - switch(var.variable) - { - case X: - translation.setX(value); - break; - case Y: - translation.setY(value); - break; - case Z: - translation.setZ(value); - break; - case XROT: - rotation_axis.setX(value); - break; - case YROT: - rotation_axis.setY(value); - break; - case ZROT: - rotation_axis.setZ(value); - break; - case ANGLE: - rotation_angle = (float)Math.toRadians(value); - break; - case SCALE: - scale.set(value, value, value); - break; - case XS: - scale.setX(value); - break; - case YS: - scale.setY(value); - break; - case ZS: - scale.setX(value); - break; - case XORIGIN: - origin.setX(value - 0.5F); - break; - case YORIGIN: - origin.setY(value - 0.5F); - break; - case ZORIGIN: - origin.setX(value - 0.5F); - break; - } - } - Quaternion rot = new Quaternion(rotation_axis, rotation_angle, false); - Transformation base = new Transformation(translation, rot, scale, null); - Vector3f negOrigin = origin.copy(); - negOrigin.mul(-1,-1,-1); - base = new Transformation(origin, null, null, null).compose(base).compose(new Transformation(negOrigin, null, null, null)); - return base.blockCenterToCorner(); - } - } - } - - protected static class MBJoint implements IJoint - { - private final String name; - - public MBJoint(String name) - { - this.name = name; - } - - @Override - public Transformation getInvBindPose() - { - return Transformation.identity(); - } - - @Override - public Optional getParent() - { - return Optional.empty(); - } - - public String getName() - { - return name; - } - } - - protected static class MBJointWeight - { - private final String name; - private final ImmutableMap weights; - - public MBJointWeight(String name, ImmutableMap weights) - { - this.name = name; - this.weights = weights; - } - - public String getName() - { - return name; - } - - public ImmutableMap getWeights() - { - return weights; - } - } - - protected static class Parameter - { - public static enum Variable - { - @SerializedName("offset_x") - X, - @SerializedName("offset_y") - Y, - @SerializedName("offset_z") - Z, - @SerializedName("axis_x") - XROT, - @SerializedName("axis_y") - YROT, - @SerializedName("axis_z") - ZROT, - @SerializedName("angle") - ANGLE, - @SerializedName("scale") - SCALE, - @SerializedName("scale_x") - XS, - @SerializedName("scale_y") - YS, - @SerializedName("scale_z") - ZS, - @SerializedName("origin_x") - XORIGIN, - @SerializedName("origin_y") - YORIGIN, - @SerializedName("origin_z") - ZORIGIN; - } - - public static enum Type - { - @SerializedName("uniform") - UNIFORM; - } - - public static enum Interpolation - { - @SerializedName("linear") - LINEAR, - @SerializedName("nearest") - NEAREST; - } - } - - @Nullable - public Transformation getPartTransform(ModelState state, BlockElement part, int i) - { - return getPartTransform(state, i); - } - - @Nullable - public Transformation getPartTransform(ModelState state, int i) - { - ImmutableCollection infos = getJoint(i); - if(!infos.isEmpty()) - { - Matrix4f m = new Matrix4f(), tmp; - float weight = 0; - for(MBJointWeight info : infos) - { - if(info.getWeights().containsKey(i)) - { - ModelBlockAnimation.MBJoint joint = new ModelBlockAnimation.MBJoint(info.getName()); - Transformation trOp = state.getPartTransformation(joint); - if(!trOp.isIdentity()) - { - float w = info.getWeights().get(i)[0]; - tmp = trOp.getMatrix(); - tmp.multiply(w); - m.add(tmp); - weight += w; - } - } - } - if(weight > 1e-5) - { - m.multiply(1f / weight); - return new Transformation(m); - } - } - return null; - } - - /** - * Load armature associated with a vanilla model. - */ - public static ModelBlockAnimation loadVanillaAnimation(ResourceManager manager, ResourceLocation armatureLocation) - { - try - { - try (Resource resource = manager.getResource(armatureLocation)) - { - ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), ModelBlockAnimation.class); - //String json = mbaGson.toJson(mba); - return mba; - } - catch(FileNotFoundException e) - { - // this is normal. FIXME: error reporting? - return defaultModelBlockAnimation; - } - } - catch(IOException | JsonParseException e) - { - LOGGER.error("Exception loading vanilla model animation {}, skipping", armatureLocation, e); - return defaultModelBlockAnimation; - } - } - - private static final Gson mbaGson = new GsonBuilder() - .registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE) - .registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE) - .setPrettyPrinting() - .enableComplexMapKeySerialization() - .disableHtmlEscaping() - .create(); - - private static final ModelBlockAnimation defaultModelBlockAnimation = new ModelBlockAnimation(ImmutableMap.>of(), ImmutableMap.of()); -} diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java deleted file mode 100644 index f8e0f60119..0000000000 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.client.model.b3d; - -import com.mojang.math.Transformation; -import net.minecraftforge.client.model.b3d.B3DLoader.NodeJoint; -import net.minecraftforge.client.model.b3d.B3DModel.Key; -import net.minecraftforge.client.model.b3d.B3DModel.Node; -import net.minecraftforge.common.animation.Event; -import net.minecraftforge.common.model.TransformationHelper; -import net.minecraftforge.common.model.animation.IClip; -import net.minecraftforge.common.model.animation.IJoint; -import net.minecraftforge.common.model.animation.IJointClip; -import net.minecraftforge.common.model.animation.JointClips; - -import com.google.common.collect.ImmutableSet; - -// FIXME: is this fast enough? -public enum B3DClip implements IClip -{ - INSTANCE; - - @Override - public IJointClip apply(final IJoint joint) - { - if(!(joint instanceof NodeJoint)) - { - return JointClips.IdentityJointClip.INSTANCE; - } - return new NodeClip(((NodeJoint)joint).getNode()); - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - return ImmutableSet.of(); - } - - protected static class NodeClip implements IJointClip - { - private final Node node; - - public NodeClip(Node node) - { - this.node = node; - } - - @Override - public Transformation apply(float time) - { - Transformation ret = Transformation.identity(); - if(node.getAnimation() == null) - { - return ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null)); - } - int start = Math.max(1, (int)Math.round(Math.floor(time))); - int end = Math.min(start + 1, (int)Math.round(Math.ceil(time))); - float progress = time - (float)Math.floor(time); - Key keyStart = node.getAnimation().getKeys().get(start, node); - Key keyEnd = node.getAnimation().getKeys().get(end, node); - Transformation startTr = keyStart == null ? null : new Transformation(keyStart.getPos(), keyStart.getRot(),keyStart.getScale(), null); - Transformation endTr = keyEnd == null ? null : new Transformation(keyEnd.getPos(), keyEnd.getRot(),keyEnd.getScale(), null); - if(keyStart == null) - { - if(keyEnd == null) - { - ret = ret.compose(new Transformation(node.getPos(), node.getRot(), node.getScale(), null)); - } - // TODO animated TRSRTransformation for speed? - else - { - ret = ret.compose(endTr); - } - } - else if(progress < 1e-5 || keyEnd == null) - { - ret = ret.compose(startTr); - } - else - { - ret = ret.compose(TransformationHelper.slerp(startTr, endTr, progress)); - } - return ret; - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java index a3a9765dd8..f4f804af43 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java @@ -19,38 +19,6 @@ package net.minecraftforge.client.model.b3d; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import javax.annotation.Nullable; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import com.mojang.math.Transformation; -import com.mojang.math.Vector3f; -import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; -import com.mojang.blaze3d.vertex.VertexFormatElement; -import net.minecraftforge.client.model.*; -import net.minecraftforge.common.model.*; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.tuple.Triple; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import com.google.common.base.Objects; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -60,37 +28,47 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.gson.JsonElement; import com.google.gson.JsonParser; - -import net.minecraft.world.level.block.state.BlockState; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexFormatElement; +import com.mojang.math.Matrix4f; +import com.mojang.math.Transformation; +import com.mojang.math.Vector3f; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemTransforms.TransformType; +import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.client.resources.model.*; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.Mth; -import net.minecraftforge.client.model.b3d.B3DModel.Animation; -import net.minecraftforge.client.model.b3d.B3DModel.Face; -import net.minecraftforge.client.model.b3d.B3DModel.Key; -import net.minecraftforge.client.model.b3d.B3DModel.Mesh; -import net.minecraftforge.client.model.b3d.B3DModel.Node; -import net.minecraftforge.client.model.b3d.B3DModel.Texture; -import net.minecraftforge.client.model.b3d.B3DModel.Vertex; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.client.model.CompositeModelState; +import net.minecraftforge.client.model.ForgeModelBakery; +import net.minecraftforge.client.model.ModelLoadingException; +import net.minecraftforge.client.model.PerspectiveMapWrapper; +import net.minecraftforge.client.model.b3d.B3DModel.*; import net.minecraftforge.client.model.data.IDynamicBakedModel; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.client.model.pipeline.IVertexConsumer; -import net.minecraftforge.common.model.animation.IClip; -import net.minecraftforge.common.model.animation.IJoint; +import net.minecraftforge.common.model.TransformationHelper; import net.minecraftforge.common.property.Properties; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.tuple.Triple; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemOverrides; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.Material; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; +import javax.annotation.Nullable; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; /* * Loader for Blitz3D models. @@ -341,7 +319,7 @@ public enum B3DLoader } } - static final class NodeJoint implements IJoint + static final class NodeJoint { private final Node node; @@ -350,7 +328,6 @@ public enum B3DLoader this.node = node; } - @Override public Transformation getInvBindPose() { Matrix4f m = new Transformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix(); @@ -365,7 +342,6 @@ public enum B3DLoader return pose; } - @Override public Optional getParent() { // FIXME cache? @@ -378,13 +354,11 @@ public enum B3DLoader return node; } - @Override public int hashCode() { return node.hashCode(); } - @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -558,16 +532,6 @@ public enum B3DLoader return hasChanged ? new ModelWrapper(modelLocation, model, newMeshes, smooth, gui3d, isSideLit, newDefaultKey, textures) : this; } - @Override - public Optional getClip(String name) - { - if(name.equals("main")) - { - return Optional.of(B3DClip.INSTANCE); - } - return Optional.empty(); - } - public ModelState getDefaultState() { return new B3DState(model.getRoot().getAnimation(), defaultKey, defaultKey, 0); @@ -605,6 +569,8 @@ public enum B3DLoader private ImmutableList quads; + public record HiddenModelPart(ImmutableList path) { } + public BakedWrapper(final Node node, final ModelState state, final boolean smooth, final boolean gui3d, boolean isSideLit, final ImmutableSet meshes, final ImmutableMap textures) { this(node, state, smooth, gui3d, isSideLit, meshes, textures, CacheBuilder.newBuilder() @@ -689,7 +655,7 @@ public enum B3DLoader { generateQuads(builder, child, state, newPath); } - if(node.getKind() instanceof Mesh && meshes.contains(node.getName()) && state.getPartTransformation(Models.getHiddenModelPart(newPath)).isIdentity()) + if(node.getKind() instanceof Mesh && meshes.contains(node.getName()) && state.getPartTransformation(new HiddenModelPart(newPath)).isIdentity()) { Mesh mesh = (Mesh)node.getKind(); Collection faces = mesh.bake(new Function, Matrix4f>() @@ -718,7 +684,7 @@ public enum B3DLoader if(f.getBrush() != null) textures = f.getBrush().getTextures(); TextureAtlasSprite sprite; if(textures == null || textures.isEmpty()) sprite = this.textures.get("missingno"); - else if(textures.get(0) == B3DModel.Texture.White) sprite = ModelLoader.White.instance(); + else if(textures.get(0) == B3DModel.Texture.White) sprite = ForgeModelBakery.White.instance(); else sprite = this.textures.get(textures.get(0).getPath()); BakedQuadBuilder quadBuilder = new BakedQuadBuilder(sprite); quadBuilder.setContractUVs(true); diff --git a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java index 4c60bd7080..50344b4747 100644 --- a/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java +++ b/src/main/java/net/minecraftforge/client/model/generators/ModelBuilder.java @@ -62,7 +62,6 @@ import net.minecraftforge.common.data.ExistingFileHelper; * * @param Self type, for simpler chaining of methods. */ -@SuppressWarnings("deprecation") public class ModelBuilder> extends ModelFile { @Nullable @@ -165,16 +164,6 @@ public class ModelBuilder> extends ModelFile { return self(); } - /** - * @param gui3d - * @return this builder - * @deprecated Unused in 1.15, use {@link #guiLight(GuiLight)} instead. - */ - @Deprecated - public T gui3d(boolean gui3d) { - return self(); - } - public T guiLight(GuiLight light) { this.guiLight = light; return self(); diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java index 6baab67489..ce4773eac6 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java @@ -35,7 +35,7 @@ public class BlockInfo private static final Direction[] SIDES = Direction.values(); private final BlockColors colors; - private BlockAndTintGetter world; + private BlockAndTintGetter level; private BlockState state; private BlockPos blockPos; @@ -62,18 +62,13 @@ public class BlockInfo { if(cachedTint == tint) return cachedMultiplier; cachedTint = tint; - cachedMultiplier = colors.getColor(state, world, blockPos, tint); + cachedMultiplier = colors.getColor(state, level, blockPos, tint); return cachedMultiplier; } - @Deprecated - public void updateShift() + public void setLevel(BlockAndTintGetter level) { - } - - public void setWorld(BlockAndTintGetter world) - { - this.world = world; + this.level = level; cachedTint = -1; cachedMultiplier = -1; } @@ -94,7 +89,7 @@ public class BlockInfo public void reset() { - this.world = null; + this.level = null; this.state = null; this.blockPos = null; cachedTint = -1; @@ -119,24 +114,24 @@ public class BlockInfo for(int z = 0; z <= 2; z++) { BlockPos pos = blockPos.offset(x - 1, y - 1, z - 1); - BlockState state = world.getBlockState(pos); - t[x][y][z] = state.getLightBlock(world, pos) < 15; - int brightness = LevelRenderer.getLightColor(world, pos); + BlockState state = level.getBlockState(pos); + t[x][y][z] = state.getLightBlock(level, pos) < 15; + int brightness = LevelRenderer.getLightColor(level, pos); s[x][y][z] = LightTexture.sky(brightness); b[x][y][z] = LightTexture.block(brightness); - ao[x][y][z] = state.getShadeBrightness(world, pos); + ao[x][y][z] = state.getShadeBrightness(level, pos); } } } for(Direction side : SIDES) { BlockPos pos = blockPos.relative(side); - BlockState state = world.getBlockState(pos); + BlockState state = level.getBlockState(pos); BlockState thisStateShape = this.state.canOcclude() && this.state.useShapeForLightOcclusion() ? this.state : Blocks.AIR.defaultBlockState(); BlockState otherStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState(); - if(state.getLightBlock(world, pos) == 15 || Shapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite()))) + if(state.getLightBlock(level, pos) == 15 || Shapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(level, blockPos, side), otherStateShape.getFaceOcclusionShape(level, pos, side.getOpposite()))) { int x = side.getStepX() + 1; int y = side.getStepY() + 1; @@ -188,19 +183,19 @@ public class BlockInfo public void updateFlatLighting() { - full = Block.isShapeFullBlock(state.getCollisionShape(world, blockPos)); - packed[0] = LevelRenderer.getLightColor(world, blockPos); + full = Block.isShapeFullBlock(state.getCollisionShape(level, blockPos)); + packed[0] = LevelRenderer.getLightColor(level, blockPos); for (Direction side : SIDES) { int i = side.ordinal() + 1; - packed[i] = LevelRenderer.getLightColor(world, blockPos.relative(side)); + packed[i] = LevelRenderer.getLightColor(level, blockPos.relative(side)); } } - public BlockAndTintGetter getWorld() + public BlockAndTintGetter getLevel() { - return world; + return level; } public BlockState getState() @@ -243,24 +238,6 @@ public class BlockInfo return full; } - @Deprecated - public float getShx() - { - return 0; - } - - @Deprecated - public float getShy() - { - return 0; - } - - @Deprecated - public float getShz() - { - return 0; - } - public int getCachedTint() { return cachedTint; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java b/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java index 53c77847d0..b6e9aeb56e 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java @@ -117,7 +117,6 @@ public class LightUtil } } - // TODO: probably useless now, remove? private static final VertexFormat DEFAULT_FROM = VertexLighterFlat.withNormal(DefaultVertexFormat.BLOCK); private static final VertexFormat DEFAULT_TO = DefaultVertexFormat.BLOCK; private static final int[] DEFAULT_MAPPING = generateMapping(DEFAULT_FROM, DEFAULT_TO); diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java index 62bec781b9..671aacf8f5 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java @@ -19,13 +19,10 @@ package net.minecraftforge.client.model.pipeline; -import java.util.List; import java.util.Map; import java.util.Objects; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.blaze3d.vertex.PoseStack; @@ -314,7 +311,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer public void setWorld(BlockAndTintGetter world) { - blockInfo.setWorld(world); + blockInfo.setLevel(world); } public void setState(BlockState state) diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java index df06477701..94a75260e0 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java @@ -171,7 +171,6 @@ public class VertexLighterSmoothAo extends VertexLighterFlat @Override public void updateBlockInfo() { - blockInfo.updateShift(); blockInfo.updateLightMatrix(); } } diff --git a/src/main/java/net/minecraftforge/common/BasicTrade.java b/src/main/java/net/minecraftforge/common/BasicItemListing.java similarity index 82% rename from src/main/java/net/minecraftforge/common/BasicTrade.java rename to src/main/java/net/minecraftforge/common/BasicItemListing.java index d6ec355f3a..fadc2a87f6 100644 --- a/src/main/java/net/minecraftforge/common/BasicTrade.java +++ b/src/main/java/net/minecraftforge/common/BasicItemListing.java @@ -33,7 +33,7 @@ import net.minecraft.world.item.trading.MerchantOffer; * A default, exposed implementation of ITrade. All of the other implementations of ITrade (in VillagerTrades) are not public. * This class contains everything needed to make a MerchantOffer, the actual "trade" object shown in trading guis. */ -public class BasicTrade implements ItemListing +public class BasicItemListing implements ItemListing { protected final ItemStack price; @@ -43,7 +43,7 @@ public class BasicTrade implements ItemListing protected final int xp; protected final float priceMult; - public BasicTrade(ItemStack price, ItemStack price2, ItemStack forSale, int maxTrades, int xp, float priceMult) + public BasicItemListing(ItemStack price, ItemStack price2, ItemStack forSale, int maxTrades, int xp, float priceMult) { this.price = price; this.price2 = price2; @@ -53,17 +53,17 @@ public class BasicTrade implements ItemListing this.priceMult = priceMult; } - public BasicTrade(ItemStack price, ItemStack forSale, int maxTrades, int xp, float priceMult) + public BasicItemListing(ItemStack price, ItemStack forSale, int maxTrades, int xp, float priceMult) { this(price, ItemStack.EMPTY, forSale, maxTrades, xp, priceMult); } - public BasicTrade(int emeralds, ItemStack forSale, int maxTrades, int xp, float mult) + public BasicItemListing(int emeralds, ItemStack forSale, int maxTrades, int xp, float mult) { this(new ItemStack(Items.EMERALD, emeralds), forSale, maxTrades, xp, mult); } - public BasicTrade(int emeralds, ItemStack forSale, int maxTrades, int xp) + public BasicItemListing(int emeralds, ItemStack forSale, int maxTrades, int xp) { this(new ItemStack(Items.EMERALD, emeralds), forSale, maxTrades, xp, 1); } diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java index d1225a48a5..5563f34f22 100644 --- a/src/main/java/net/minecraftforge/common/BiomeDictionary.java +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -302,7 +302,6 @@ public class BiomeDictionary addTypes(Biomes.OCEAN, OCEAN, OVERWORLD); addTypes(Biomes.PLAINS, PLAINS, OVERWORLD); addTypes(Biomes.DESERT, HOT, DRY, SANDY, OVERWORLD); - addTypes(Biomes.MOUNTAINS, MOUNTAIN, HILLS, OVERWORLD); addTypes(Biomes.FOREST, FOREST, OVERWORLD); addTypes(Biomes.TAIGA, COLD, CONIFEROUS, FOREST, OVERWORLD); addTypes(Biomes.SWAMP, WET, SWAMP, OVERWORLD); @@ -311,34 +310,17 @@ public class BiomeDictionary addTypes(Biomes.THE_END, COLD, DRY, END); addTypes(Biomes.FROZEN_OCEAN, COLD, OCEAN, SNOWY, OVERWORLD); addTypes(Biomes.FROZEN_RIVER, COLD, RIVER, SNOWY, OVERWORLD); - addTypes(Biomes.SNOWY_TUNDRA, COLD, SNOWY, WASTELAND, OVERWORLD); - addTypes(Biomes.SNOWY_MOUNTAINS, COLD, SNOWY, MOUNTAIN, OVERWORLD); addTypes(Biomes.MUSHROOM_FIELDS, MUSHROOM, RARE, OVERWORLD); - addTypes(Biomes.MUSHROOM_FIELD_SHORE, MUSHROOM, BEACH, RARE, OVERWORLD); addTypes(Biomes.BEACH, BEACH, OVERWORLD); - addTypes(Biomes.DESERT_HILLS, HOT, DRY, SANDY, HILLS, OVERWORLD); - addTypes(Biomes.WOODED_HILLS, FOREST, HILLS, OVERWORLD); - addTypes(Biomes.TAIGA_HILLS, COLD, CONIFEROUS, FOREST, HILLS, OVERWORLD); - addTypes(Biomes.MOUNTAIN_EDGE, MOUNTAIN, OVERWORLD); addTypes(Biomes.JUNGLE, HOT, WET, DENSE, JUNGLE, OVERWORLD); - addTypes(Biomes.JUNGLE_HILLS, HOT, WET, DENSE, JUNGLE, HILLS, OVERWORLD); - addTypes(Biomes.JUNGLE_EDGE, HOT, WET, JUNGLE, FOREST, RARE, OVERWORLD); addTypes(Biomes.DEEP_OCEAN, OCEAN, OVERWORLD); - addTypes(Biomes.STONE_SHORE, BEACH, OVERWORLD); addTypes(Biomes.SNOWY_BEACH, COLD, BEACH, SNOWY, OVERWORLD); addTypes(Biomes.BIRCH_FOREST, FOREST, OVERWORLD); - addTypes(Biomes.BIRCH_FOREST_HILLS, FOREST, HILLS, OVERWORLD); addTypes(Biomes.DARK_FOREST, SPOOKY, DENSE, FOREST, OVERWORLD); addTypes(Biomes.SNOWY_TAIGA, COLD, CONIFEROUS, FOREST, SNOWY, OVERWORLD); - addTypes(Biomes.SNOWY_TAIGA_HILLS, COLD, CONIFEROUS, FOREST, SNOWY, HILLS, OVERWORLD); - addTypes(Biomes.GIANT_TREE_TAIGA, COLD, CONIFEROUS, FOREST, OVERWORLD); - addTypes(Biomes.GIANT_TREE_TAIGA_HILLS, COLD, CONIFEROUS, FOREST, HILLS, OVERWORLD); - addTypes(Biomes.WOODED_MOUNTAINS, MOUNTAIN, FOREST, SPARSE, OVERWORLD); addTypes(Biomes.SAVANNA, HOT, SAVANNA, PLAINS, SPARSE, OVERWORLD); addTypes(Biomes.SAVANNA_PLATEAU, HOT, SAVANNA, PLAINS, SPARSE, RARE, OVERWORLD, PLATEAU); addTypes(Biomes.BADLANDS, MESA, SANDY, DRY, OVERWORLD); - addTypes(Biomes.WOODED_BADLANDS_PLATEAU, MESA, SANDY, DRY, SPARSE, OVERWORLD, PLATEAU); - addTypes(Biomes.BADLANDS_PLATEAU, MESA, SANDY, DRY, OVERWORLD, PLATEAU); addTypes(Biomes.SMALL_END_ISLANDS, END); addTypes(Biomes.END_MIDLANDS, END); addTypes(Biomes.END_HIGHLANDS, END); @@ -346,34 +328,15 @@ public class BiomeDictionary addTypes(Biomes.WARM_OCEAN, OCEAN, HOT, OVERWORLD); addTypes(Biomes.LUKEWARM_OCEAN, OCEAN, OVERWORLD); addTypes(Biomes.COLD_OCEAN, OCEAN, COLD, OVERWORLD); - addTypes(Biomes.DEEP_WARM_OCEAN, OCEAN, HOT, OVERWORLD); addTypes(Biomes.DEEP_LUKEWARM_OCEAN, OCEAN, OVERWORLD); addTypes(Biomes.DEEP_COLD_OCEAN, OCEAN, COLD, OVERWORLD); addTypes(Biomes.DEEP_FROZEN_OCEAN, OCEAN, COLD, OVERWORLD); addTypes(Biomes.THE_VOID, VOID); addTypes(Biomes.SUNFLOWER_PLAINS, PLAINS, RARE, OVERWORLD); - addTypes(Biomes.DESERT_LAKES, HOT, DRY, SANDY, RARE, OVERWORLD); - addTypes(Biomes.GRAVELLY_MOUNTAINS, MOUNTAIN, SPARSE, RARE, OVERWORLD); addTypes(Biomes.FLOWER_FOREST, FOREST, HILLS, RARE, OVERWORLD); - addTypes(Biomes.TAIGA_MOUNTAINS, COLD, CONIFEROUS, FOREST, MOUNTAIN, RARE, OVERWORLD); - addTypes(Biomes.SWAMP_HILLS, WET, SWAMP, HILLS, RARE, OVERWORLD); addTypes(Biomes.ICE_SPIKES, COLD, SNOWY, HILLS, RARE, OVERWORLD); - addTypes(Biomes.MODIFIED_JUNGLE, HOT, WET, DENSE, JUNGLE, MOUNTAIN, RARE, OVERWORLD, MODIFIED); - addTypes(Biomes.MODIFIED_JUNGLE_EDGE, HOT, SPARSE, JUNGLE, HILLS, RARE, OVERWORLD, MODIFIED); - addTypes(Biomes.TALL_BIRCH_FOREST, FOREST, DENSE, HILLS, RARE, OVERWORLD); - addTypes(Biomes.TALL_BIRCH_HILLS, FOREST, DENSE, MOUNTAIN, RARE, OVERWORLD); - addTypes(Biomes.DARK_FOREST_HILLS, SPOOKY, DENSE, FOREST, MOUNTAIN, RARE, OVERWORLD); - addTypes(Biomes.SNOWY_TAIGA_MOUNTAINS, COLD, CONIFEROUS, FOREST, SNOWY, MOUNTAIN, RARE, OVERWORLD); - addTypes(Biomes.GIANT_SPRUCE_TAIGA, DENSE, FOREST, RARE, OVERWORLD); - addTypes(Biomes.GIANT_SPRUCE_TAIGA_HILLS, DENSE, FOREST, HILLS, RARE, OVERWORLD); - addTypes(Biomes.MODIFIED_GRAVELLY_MOUNTAINS, MOUNTAIN, SPARSE, RARE, OVERWORLD, MODIFIED); - addTypes(Biomes.SHATTERED_SAVANNA, HOT, DRY, SPARSE, SAVANNA, MOUNTAIN, RARE, OVERWORLD); - addTypes(Biomes.SHATTERED_SAVANNA_PLATEAU, HOT, DRY, SPARSE, SAVANNA, HILLS, RARE, OVERWORLD, PLATEAU); addTypes(Biomes.ERODED_BADLANDS, HOT, DRY, SPARSE, MOUNTAIN, RARE, OVERWORLD); - addTypes(Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, HOT, DRY, SPARSE, HILLS, RARE, OVERWORLD, PLATEAU, MODIFIED); - addTypes(Biomes.MODIFIED_BADLANDS_PLATEAU, HOT, DRY, SPARSE, MOUNTAIN, RARE, OVERWORLD, PLATEAU, MODIFIED); addTypes(Biomes.BAMBOO_JUNGLE, HOT, WET, RARE, JUNGLE, OVERWORLD); - addTypes(Biomes.BAMBOO_JUNGLE_HILLS, HOT, WET, RARE, JUNGLE, HILLS, OVERWORLD); addTypes(Biomes.SOUL_SAND_VALLEY, HOT, DRY, NETHER); addTypes(Biomes.CRIMSON_FOREST, HOT, DRY, NETHER, FOREST); addTypes(Biomes.WARPED_FOREST, HOT, DRY, NETHER, FOREST); diff --git a/src/main/java/net/minecraftforge/common/BiomeManager.java b/src/main/java/net/minecraftforge/common/BiomeManager.java index 8a3f479ea7..7fdaa66b47 100644 --- a/src/main/java/net/minecraftforge/common/BiomeManager.java +++ b/src/main/java/net/minecraftforge/common/BiomeManager.java @@ -27,9 +27,10 @@ import java.util.List; import com.google.common.collect.ImmutableList; +import net.minecraft.util.random.WeightedRandom; +import net.minecraft.world.entity.ai.behavior.ShufflingList; import net.minecraft.world.level.biome.Biomes; import net.minecraft.resources.ResourceKey; -import net.minecraft.util.WeighedRandom; import net.minecraft.world.level.biome.Biome; public class BiomeManager @@ -46,7 +47,6 @@ public class BiomeManager currentBiomes[BiomeType.DESERT_LEGACY.ordinal()] = new TrackedList<>( new BiomeEntry(Biomes.DESERT, 10), new BiomeEntry(Biomes.FOREST, 10), - new BiomeEntry(Biomes.MOUNTAINS, 10), new BiomeEntry(Biomes.SWAMP, 10), new BiomeEntry(Biomes.PLAINS, 10), new BiomeEntry(Biomes.TAIGA, 10) @@ -61,7 +61,6 @@ public class BiomeManager currentBiomes[BiomeType.WARM.ordinal()] = new TrackedList<>( new BiomeEntry(Biomes.FOREST, 10), new BiomeEntry(Biomes.DARK_FOREST, 10), - new BiomeEntry(Biomes.MOUNTAINS, 10), new BiomeEntry(Biomes.PLAINS, 10), new BiomeEntry(Biomes.BIRCH_FOREST, 10), new BiomeEntry(Biomes.SWAMP, 10) @@ -69,37 +68,17 @@ public class BiomeManager currentBiomes[BiomeType.COOL.ordinal()] = new TrackedList<>( new BiomeEntry(Biomes.FOREST, 10), - new BiomeEntry(Biomes.MOUNTAINS, 10), new BiomeEntry(Biomes.TAIGA, 10), new BiomeEntry(Biomes.PLAINS, 10) ); currentBiomes[BiomeType.ICY.ordinal()] = new TrackedList<>( - new BiomeEntry(Biomes.SNOWY_TUNDRA, 30), new BiomeEntry(Biomes.SNOWY_TAIGA, 10) ); return currentBiomes; } - /* - public static void addSpawnBiome(Biome biome) - { - if (!BiomeProvider.BIOMES_TO_SPAWN_IN.contains(biome)) - { - BiomeProvider.BIOMES_TO_SPAWN_IN.add(biome); - } - } - - public static void removeSpawnBiome(Biome biome) - { - if (BiomeProvider.BIOMES_TO_SPAWN_IN.contains(biome)) - { - BiomeProvider.BIOMES_TO_SPAWN_IN.remove(biome); - } - } - */ - /** * Add biomes that you add to the overworld without using {@link BiomeManager#addBiome(BiomeType, BiomeEntry)} */ @@ -157,13 +136,12 @@ public class BiomeManager DESERT, DESERT_LEGACY, WARM, COOL, ICY; } - public static class BiomeEntry extends WeighedRandom.WeighedRandomItem + public static class BiomeEntry { private final ResourceKey key; public BiomeEntry(ResourceKey key, int weight) { - super(weight); this.key = key; } diff --git a/src/main/java/net/minecraftforge/common/DungeonHooks.java b/src/main/java/net/minecraftforge/common/DungeonHooks.java index c583bf429d..cfbec224b9 100644 --- a/src/main/java/net/minecraftforge/common/DungeonHooks.java +++ b/src/main/java/net/minecraftforge/common/DungeonHooks.java @@ -23,8 +23,9 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Random; +import net.minecraft.util.random.WeightedEntry; +import net.minecraft.util.random.WeightedRandom; import net.minecraft.world.entity.EntityType; -import net.minecraft.util.WeighedRandom; public class DungeonHooks { @@ -58,7 +59,7 @@ public class DungeonHooks if (type == mob.type) { itr.remove(); - rarity = mob.weight + rarity; + rarity = /* mob.weight */ 0 + rarity; break; } } @@ -80,7 +81,7 @@ public class DungeonHooks if (name == mob.type) { dungeonMobs.remove(mob); - return mob.weight; + return 0; // mob.weight; } } return 0; @@ -93,12 +94,12 @@ public class DungeonHooks */ public static EntityType getRandomDungeonMob(Random rand) { - DungeonMob mob = WeighedRandom.getRandomItem(rand, dungeonMobs).orElseThrow(); - return mob.type; + DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs).orElseThrow(); + return null; // mob.type; } - public static class DungeonMob extends WeighedRandom.WeighedRandomItem + public static class DungeonMob extends WeightedEntry.IntrusiveBase { public final EntityType type; public DungeonMob(int weight, EntityType type) diff --git a/src/main/java/net/minecraftforge/common/ForgeConfig.java b/src/main/java/net/minecraftforge/common/ForgeConfig.java index e95013acdb..a78e2c3900 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfig.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfig.java @@ -113,10 +113,6 @@ public class ForgeConfig { public final BooleanValue experimentalForgeLightPipelineEnabled; - /** @deprecated Selective reloading is no longer supported due to vanilla now reloading resources in parallel */ - @Deprecated(since="1.17.1", forRemoval = true) - public final BooleanValue selectiveResourceReloadEnabled; - public final BooleanValue showLoadWarnings; public final BooleanValue useCombinedDepthStencilAttachment; @@ -139,11 +135,6 @@ public class ForgeConfig { .translation("forge.configgui.forgeLightPipelineEnabled") .define("experimentalForgeLightPipelineEnabled", false); - selectiveResourceReloadEnabled = builder - .comment("When enabled, makes specific reload tasks such as language changing quicker to run.") - .translation("forge.configgui.selectiveResourceReloadEnabled") - .define("selectiveResourceReloadEnabled", true); - showLoadWarnings = builder .comment("When enabled, Forge will show any warnings that occurred during loading.") .translation("forge.configgui.showLoadWarnings") diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index de16df496b..788bfa2074 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -43,7 +43,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.VisibleForTesting; import net.minecraftforge.fml.config.IConfigSpec; import net.minecraftforge.fml.loading.FMLEnvironment; import org.apache.commons.lang3.tuple.Pair; diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index cedf4f5e03..72d0f315fc 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -28,13 +28,11 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.function.Function; import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import com.google.common.base.Suppliers; import com.google.common.collect.Lists; @@ -45,9 +43,7 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; -import com.mojang.serialization.Dynamic; import com.mojang.serialization.Lifecycle; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -83,7 +79,6 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.inventory.AnvilMenu; import net.minecraft.world.Container; import net.minecraft.world.item.context.UseOnContext; @@ -97,16 +92,11 @@ import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.stats.Stats; import net.minecraft.world.phys.Vec3; -import net.minecraft.core.RegistryAccess; import net.minecraft.core.Registry; import net.minecraft.core.MappedRegistry; -import net.minecraft.resources.RegistryReadOps; -import net.minecraft.resources.RegistryWriteOps; import net.minecraft.world.*; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.feature.StructureFeature; -import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.block.entity.FurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; @@ -126,8 +116,8 @@ import net.minecraftforge.common.loot.LootModifierManager; import net.minecraftforge.common.loot.LootTableIdCondition; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder; -import net.minecraftforge.common.world.ForgeWorldType; -import net.minecraftforge.common.world.MobSpawnInfoBuilder; +import net.minecraftforge.common.world.ForgeWorldPreset; +import net.minecraftforge.common.world.MobSpawnSettingsBuilder; import net.minecraftforge.event.AnvilUpdateEvent; import net.minecraftforge.event.DifficultyChangeEvent; import net.minecraftforge.event.ForgeEventFactory; @@ -162,13 +152,12 @@ import net.minecraftforge.event.world.NoteBlockEvent; import net.minecraftforge.eventbus.api.Event.Result; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fml.ModLoader; -import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; +import net.minecraftforge.resource.ResourcePackLoader; import net.minecraftforge.registries.DataSerializerEntry; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.IRegistryDelegate; -import net.minecraftforge.versions.mcp.MCPVersion; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -184,17 +173,13 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.state.pattern.BlockInWorld; -import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.material.EmptyFluid; import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.LavaFluid; import net.minecraft.world.level.material.WaterFluid; @@ -242,7 +227,7 @@ public class ForgeHooks if (isCreative && Screen.hasControlDown() && state.hasBlockEntity()) te = world.getBlockEntity(pos); - result = state.getPickBlock(target, world, pos, player); + result = state.getCloneItemStack(target, world, pos, player); if (result.isEmpty()) LOGGER.warn("Picking on: [{}] {} gave null item", target.getType(), state.getBlock().getRegistryName()); @@ -846,9 +831,9 @@ public class ForgeHooks throw new RuntimeException("Mod fluids must override createAttributes."); } - public static String getDefaultWorldType() + public static String getDefaultWorldPreset() { - ForgeWorldType def = ForgeWorldType.getDefaultWorldType(); + ForgeWorldPreset def = ForgeWorldPreset.getDefaultWorldPreset(); if (def != null) return def.getRegistryName().toString(); return "default"; @@ -870,16 +855,16 @@ public class ForgeHooks @FunctionalInterface public interface BiomeCallbackFunction { - Biome apply(final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final Float depth, final Float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns); + Biome apply(final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns); } - public static Biome enhanceBiome(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final Float depth, final Float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns, final RecordCodecBuilder.Instance codec, final BiomeCallbackFunction callback) + public static Biome enhanceBiome(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final BiomeSpecialEffects effects, final BiomeGenerationSettings gen, final MobSpawnSettings spawns, final RecordCodecBuilder.Instance codec, final BiomeCallbackFunction callback) { BiomeGenerationSettingsBuilder genBuilder = new BiomeGenerationSettingsBuilder(gen); - MobSpawnInfoBuilder spawnBuilder = new MobSpawnInfoBuilder(spawns); - BiomeLoadingEvent event = new BiomeLoadingEvent(name, climate, category, depth, scale, effects, genBuilder, spawnBuilder); + MobSpawnSettingsBuilder spawnBuilder = new MobSpawnSettingsBuilder(spawns); + BiomeLoadingEvent event = new BiomeLoadingEvent(name, climate, category, effects, genBuilder, spawnBuilder); MinecraftForge.EVENT_BUS.post(event); - return callback.apply(event.getClimate(), event.getCategory(), event.getDepth(), event.getScale(), event.getEffects(), event.getGeneration().build(), event.getSpawns().build()).setRegistryName(name); + return callback.apply(event.getClimate(), event.getCategory(), event.getEffects(), event.getGeneration().build(), event.getSpawns().build()).setRegistryName(name); } private static class LootTableContext @@ -1226,76 +1211,6 @@ public class ForgeHooks //No to static init! private static final Supplier>> CODEC = Suppliers.memoize(() -> MappedRegistry.dataPackCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), LevelStem.CODEC).xmap(LevelStem::sortMap, Function.identity())); - /** - * Restores previously "deleted" dimensions to the world. - * The {@link LenientUnboundedMapCodec} prevents this from happening, this is to fix any world from before the fix. - * TODO: Remove in 1.18 - */ - public static Dynamic fixUpDimensionsData(Dynamic data) - { - if (!"1.17.1".equals(MCPVersion.getMCVersion())) - throw new IllegalStateException("Calling deprecated code that was scheduled for removal after 1.17.1 in version: " + MCPVersion.getMCVersion()); - - if(!(data.getOps() instanceof RegistryReadOps)) - return data; - - RegistryReadOps ops = (RegistryReadOps) data.getOps(); - Dynamic dymData = data.get(DIMENSIONS_KEY).orElseEmptyMap(); - Dynamic withInjected = dymData.asMapOpt().map(current -> - { - List> currentList = current.map(p -> p.mapFirst(dyn -> dyn.asString().result().orElse("")).mapSecond(Dynamic::getValue)).collect(Collectors.toList()); - Set currentDimNames = currentList.stream().map(Pair::getFirst).collect(Collectors.toSet()); - - // FixUp deleted vanilla dims. - if (!currentDimNames.containsAll(VANILLA_DIMS)) - { - LOGGER.warn("Detected missing vanilla dimensions from the world!"); - RegistryAccess regs = ops.registryAccess; - if (regs == null) // should not happen, but it could after a MC version update. - throw new RuntimeException("Could not access dynamic registries using reflection. " + - "The world was detected to have missing vanilla dimensions and the attempted fix did not work."); - - long seed = data.get(SEED_KEY).get().result().map(d -> d.asLong(0L)).orElse(0L); - Registry biomeReg = regs.registryOrThrow(Registry.BIOME_REGISTRY); - Registry typeReg = regs.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - Registry noiseReg = regs.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); - - //Loads the default nether and end - MappedRegistry dimReg = DimensionType.defaultDimensions(typeReg, biomeReg, noiseReg, seed); - //Loads the default overworld - dimReg = WorldGenSettings.withOverworld(typeReg, dimReg, WorldGenSettings.makeDefaultOverworld(biomeReg, noiseReg, seed)); - - // Encode and decode the registry. This adds any dimensions from datapacks (see SimpleRegistryCodec#decode), but only the vanilla overrides are needed. - // This assumes that the datapacks for the vanilla dimensions have not changed since they were "deleted" - // If they did, this will be seen in newly generated chunks. - // Since this is to fix an older world, from before the fixes by forge, there is no way to know the state of the dimension when it was "deleted". - dimReg = CODEC.get().encodeStart(RegistryWriteOps.create(ops, regs), dimReg).flatMap(t -> CODEC.get().parse(ops, t)).result().orElse(dimReg); - for (String name : VANILLA_DIMS) - { - if (currentDimNames.contains(name)) - continue; - LevelStem dim = dimReg.get(new ResourceLocation(name)); - if (dim == null) - { - LOGGER.error("The world is missing dimension: " + name + ", but the attempt to re-inject it failed."); - continue; - } - LOGGER.info("Fixing world: re-injected dimension: " + name); - Optional dimT = LevelStem.CODEC.encodeStart(RegistryWriteOps.create(ops, regs), dim).resultOrPartial(s->{}); - if (dimT.isPresent()) - currentList.add(Pair.of(name, dimT.get())); - else - LOGGER.error("Could not re-encode dimension " + name + ", can not be re-injected."); - } - } - else - return dymData; - - return new Dynamic<>(ops, ops.createMap(currentList.stream().map(p -> p.mapFirst(ops::createString)))); - }).result().orElse(dymData); - return data.set(DIMENSIONS_KEY, withInjected); - } - private static final Map, AttributeSupplier> FORGE_ATTRIBUTES = new HashMap<>(); /** FOR INTERNAL USE ONLY, DO NOT CALL DIRECTLY */ @Deprecated diff --git a/src/main/java/net/minecraftforge/fmllegacy/ForgeI18n.java b/src/main/java/net/minecraftforge/common/ForgeI18n.java similarity index 97% rename from src/main/java/net/minecraftforge/fmllegacy/ForgeI18n.java rename to src/main/java/net/minecraftforge/common/ForgeI18n.java index 97a33f9469..3265cdb80a 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/ForgeI18n.java +++ b/src/main/java/net/minecraftforge/common/ForgeI18n.java @@ -17,9 +17,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.common; import com.google.common.base.CharMatcher; +import net.minecraftforge.common.util.MavenVersionStringHelper; import net.minecraftforge.fml.loading.StringUtils; import net.minecraftforge.forgespi.language.IModInfo; import org.apache.commons.lang3.text.ExtendedMessageFormat; @@ -62,7 +63,7 @@ public class ForgeI18n { // {0,exc,cls} -> class of exception; {0,exc,msg} -> message from exception customFactories.put("exc", (name, formatString, locale) -> new CustomReadOnlyFormat((stringBuffer, objectToParse) -> parseException(formatString, stringBuffer, objectToParse))); // {0,vr} -> transform VersionRange into cleartext string using fml.messages.version.restriction.* strings - customFactories.put("vr", (name, formatString, locale) -> new CustomReadOnlyFormat(((stringBuffer, o) -> MavenVersionStringHelper.parseVersionRange(formatString, stringBuffer, o)))); + customFactories.put("vr", (name, formatString, locale) -> new CustomReadOnlyFormat(MavenVersionStringHelper::parseVersionRange)); // {0,i18n,fml.message} -> pass object to i18n string 'fml.message' customFactories.put("i18n", (name, formatString, locale) -> new CustomReadOnlyFormat((stringBuffer, o) -> stringBuffer.append(ForgeI18n.parseMessage(formatString, o)))); // {0,ornull,fml.absent} -> append String value of o, or i18n string 'fml.absent' (message format transforms nulls into the string literal "null") diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index 5e83693b90..f0063c0b0f 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -41,7 +41,7 @@ import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent.ClientTickEvent; import net.minecraftforge.event.TickEvent.ServerTickEvent; import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.server.command.ForgeCommand; import net.minecraftforge.server.command.ConfigCommand; @@ -62,7 +62,7 @@ public class ForgeInternalHandler { entity.discard(); event.setCanceled(true); - BlockableEventLoop executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); + var executor = LogicalSidedProvider.WORKQUEUE.get(event.getWorld().isClientSide ? LogicalSide.CLIENT : LogicalSide.SERVER); executor.tell(new TickTask(0, () -> event.getWorld().addFreshEntity(newEntity))); } } @@ -74,7 +74,7 @@ public class ForgeInternalHandler public void onDimensionUnload(WorldEvent.Unload event) { if (event.getWorld() instanceof ServerLevel) - FakePlayerFactory.unloadWorld((ServerLevel) event.getWorld()); + FakePlayerFactory.unloadLevel((ServerLevel) event.getWorld()); } @SubscribeEvent diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index ee7b396c28..7dda4c9e6d 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -19,9 +19,11 @@ package net.minecraftforge.common; +import com.google.common.collect.Multimap; import net.minecraft.commands.synchronization.EmptyArgumentSerializer; import net.minecraft.commands.synchronization.ArgumentTypes; import net.minecraft.commands.synchronization.ArgumentSerializer; +import net.minecraft.nbt.ListTag; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.RangedAttribute; import net.minecraft.world.item.crafting.Ingredient; @@ -39,6 +41,7 @@ import net.minecraftforge.common.data.ForgeFluidTagsProvider; import net.minecraftforge.common.loot.CanToolPerformAction; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.LootTableIdCondition; +import net.minecraftforge.common.util.MavenVersionStringHelper; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fluids.FluidAttributes; @@ -46,20 +49,16 @@ import net.minecraftforge.fluids.ForgeFlowingFluid; import net.minecraftforge.fml.*; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.*; -import net.minecraftforge.fmllegacy.FMLWorldPersistenceHook; -import net.minecraftforge.fmllegacy.RegistryObject; -import net.minecraftforge.fmllegacy.WorldPersistenceHooks; -import net.minecraftforge.fmllegacy.event.lifecycle.FMLModIdMappingEvent; -import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; -import net.minecraftforge.fmlserverevents.FMLServerStoppingEvent; +import net.minecraftforge.registries.*; +import net.minecraftforge.internal.WorldPersistenceHooks; +import net.minecraftforge.network.NetworkConstants; +import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; -import net.minecraftforge.network.VanillaPacketSplitter; -import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.network.filters.VanillaPacketSplitter; import net.minecraftforge.server.command.EnumArgument; import net.minecraftforge.server.command.ModIdArgument; -import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.versions.mcp.MCPVersion; @@ -88,7 +87,6 @@ import net.minecraftforge.common.data.ForgeBlockTagsProvider; import net.minecraftforge.common.data.ForgeItemTagsProvider; import net.minecraftforge.common.data.ForgeLootTableProvider; import net.minecraftforge.common.data.ForgeRecipeProvider; -import net.minecraftforge.common.model.animation.CapabilityAnimation; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; @@ -97,9 +95,7 @@ import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; +import java.util.*; @Mod("forge") public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook @@ -145,7 +141,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook return uuid.toString(); }); - LOGGER.debug(FORGEMOD, "Loading Network data for FML net version: {}", FMLNetworkConstants.init()); + LOGGER.debug(FORGEMOD, "Loading Network data for FML net version: {}", NetworkConstants.init()); CrashReportCallables.registerCrashCallable("FML", ForgeVersion::getSpec); CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion()); @@ -178,7 +174,6 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook { CapabilityItemHandler.register(event); CapabilityFluidHandler.register(event); - CapabilityAnimation.register(event); CapabilityEnergy.register(event); } @@ -200,10 +195,10 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook public void loadComplete(FMLLoadCompleteEvent event) { if (FMLEnvironment.dist == Dist.CLIENT) - ForgeHooksClient.registerForgeWorldTypeScreens(); + ForgeHooksClient.registerForgeWorldPresetScreens(); } - public void serverStopping(FMLServerStoppingEvent evt) + public void serverStopping(ServerStoppingEvent evt) { WorldWorkerManager.clear(); } @@ -229,7 +224,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook // DimensionManager.processScheduledDeletions(levelSave); } - public void mappingChanged(FMLModIdMappingEvent evt) + public void mappingChanged(RegistryEvent.IdMappingEvent evt) { Ingredient.invalidateAll(); } @@ -317,4 +312,98 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook Registry.register(Registry.LOOT_CONDITION_TYPE, new ResourceLocation("forge:loot_table_id"), LootTableIdCondition.LOOT_TABLE_ID); Registry.register(Registry.LOOT_CONDITION_TYPE, new ResourceLocation("forge:can_tool_perform_action"), CanToolPerformAction.LOOT_CONDITION_TYPE); } + + private static final class FMLWorldPersistenceHook implements WorldPersistenceHooks.WorldPersistenceHook + { + + private static final Logger LOGGER = LogManager.getLogger(); + private static final Marker WORLDPERSISTENCE = MarkerManager.getMarker("WP"); + + @Override + public String getModId() + { + return "fml"; + } + + @Override + public CompoundTag getDataForWriting(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo) + { + CompoundTag fmlData = new CompoundTag(); + ListTag modList = new ListTag(); + ModList.get().getMods().forEach(mi-> + { + final CompoundTag mod = new CompoundTag(); + mod.putString("ModId", mi.getModId()); + mod.putString("ModVersion", MavenVersionStringHelper.artifactVersionToString(mi.getVersion())); + modList.add(mod); + }); + fmlData.put("LoadingModList", modList); + + CompoundTag registries = new CompoundTag(); + fmlData.put("Registries", registries); + LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", serverInfo.getLevelName()); + + for (Map.Entry e : RegistryManager.ACTIVE.takeSnapshot(true).entrySet()) + { + registries.put(e.getKey().toString(), e.getValue().write()); + } + LOGGER.debug(WORLDPERSISTENCE,"ID Map collection complete {}", serverInfo.getLevelName()); + return fmlData; + } + + @Override + public void readData(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo, CompoundTag tag) + { + if (tag.contains("LoadingModList")) + { + ListTag modList = tag.getList("LoadingModList", (byte)10); + for (int i = 0; i < modList.size(); i++) + { + CompoundTag mod = modList.getCompound(i); + String modId = mod.getString("ModId"); + if (Objects.equals("minecraft", modId)) { + continue; + } + String modVersion = mod.getString("ModVersion"); + Optional container = ModList.get().getModContainerById(modId); + if (!container.isPresent()) + { + LOGGER.error(WORLDPERSISTENCE,"This world was saved with mod {} which appears to be missing, things may not work well", modId); + continue; + } + if (!Objects.equals(modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion()))) + { + LOGGER.warn(WORLDPERSISTENCE,"This world was saved with mod {} version {} and it is now at version {}, things may not work well", modId, modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion())); + } + } + } + + Multimap failedElements = null; + + if (tag.contains("Registries")) // 1.8, genericed out the 'registries' list + { + Map snapshot = new HashMap<>(); + CompoundTag regs = tag.getCompound("Registries"); + for (String key : regs.getAllKeys()) + { + snapshot.put(new ResourceLocation(key), ForgeRegistry.Snapshot.read(regs.getCompound(key))); + } + failedElements = GameData.injectSnapshot(snapshot, true, true); + } + + if (failedElements != null && !failedElements.isEmpty()) + { + StringBuilder buf = new StringBuilder(); + buf.append("Forge Mod Loader could not load this save.\n\n") + .append("There are ").append(failedElements.size()).append(" unassigned registry entries in this save.\n") + .append("You will not be able to load until they are present again.\n\n"); + + failedElements.asMap().forEach((name, entries) -> + { + buf.append("Missing ").append(name).append(":\n"); + entries.forEach(rl -> buf.append(" ").append(rl).append("\n")); + }); + } + } + } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/ForgeStatesProvider.java b/src/main/java/net/minecraftforge/common/ForgeStatesProvider.java similarity index 61% rename from src/main/java/net/minecraftforge/fmllegacy/ForgeStatesProvider.java rename to src/main/java/net/minecraftforge/common/ForgeStatesProvider.java index 2b1e9686d8..5c27bd60fb 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/ForgeStatesProvider.java +++ b/src/main/java/net/minecraftforge/common/ForgeStatesProvider.java @@ -17,34 +17,26 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.common; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.*; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; +import net.minecraftforge.fml.event.IModBusEvent; +import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.registries.GameData; import net.minecraftforge.registries.ObjectHolderRegistry; +import java.util.Collections; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.BiFunction; +import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Stream; -/* - dispatchAndHandleError(ModLoadingStage.CONSTRUCT, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Creating registries")); - dispatchAndHandleError(ModLoadingStage.CREATE_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); - ObjectHolderRegistry.findObjectHolders(); - CapabilityManager.INSTANCE.injectCapabilities(modList.getAllScanData()); - statusConsumer.ifPresent(c->c.accept("Adding custom tag types")); - GameData.setCustomTagTypesFromRegistries(); - statusConsumer.ifPresent(c->c.accept("Populating registries")); - dispatchAndHandleError(ModLoadingStage.LOAD_REGISTRIES, syncExecutor, parallelExecutor, periodicTask); - statusConsumer.ifPresent(c->c.accept("Early mod loading complete")); - - statusConsumer.ifPresent(c->c.accept("Freezing data")); - GameData.freezeData(); - NetworkRegistry.lock(); -*/ public class ForgeStatesProvider implements IModStateProvider { final ModLoadingState CREATE_REGISTRIES = ModLoadingState.withTransition("CREATE_REGISTRIES", "CONSTRUCT", ModLoadingPhase.GATHER, SerialTransition.of(()-> Stream.of(IModStateTransition.EventGenerator.fromFunction(RegistryEvent.NewRegistry::new)))); final ModLoadingState OBJECT_HOLDERS = ModLoadingState.withInline("OBJECT_HOLDERS", "CREATE_REGISTRIES", ModLoadingPhase.GATHER, ml-> ObjectHolderRegistry.findObjectHolders()); @@ -57,4 +49,25 @@ public class ForgeStatesProvider implements IModStateProvider { public List getAllStates() { return List.of(CREATE_REGISTRIES, OBJECT_HOLDERS, INJECT_CAPABILITIES, CUSTOM_TAGS, LOAD_REGISTRIES, FREEZE, NETLOCK); } + + static record SerialTransition(Supplier>> eventStream, BiFunction, CompletableFuture>> preDispatchHook, BiFunction, CompletableFuture>> postDispatchHook, BiFunction>, CompletableFuture>> finalActivityGenerator) implements IModStateTransition { + public static SerialTransition of(Supplier>> eventStream) { + return new SerialTransition(eventStream, (t, f)->CompletableFuture.completedFuture(Collections.emptyList()), (t, f)->CompletableFuture.completedFuture(Collections.emptyList()), (e, prev) ->prev.thenApplyAsync(Function.identity(), e)); + } + @Override + public Supplier>> eventFunctionStream() { + return eventStream; + } + + @Override + public ThreadSelector threadSelector() { + return ThreadSelector.SYNC; + } + + // These never progress the ModLoadingStage.. + @Override + public BiFunction nextModLoadingStage() { + return ModLoadingStage::currentState; + } + } } diff --git a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java index fe37ab1308..a43d533665 100644 --- a/src/main/java/net/minecraftforge/common/IExtensibleEnum.java +++ b/src/main/java/net/minecraftforge/common/IExtensibleEnum.java @@ -19,7 +19,10 @@ package net.minecraftforge.common; +import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; +import net.minecraft.util.ExtraCodecs; import net.minecraft.util.StringRepresentable; import java.util.function.Function; @@ -58,6 +61,18 @@ public interface IExtensibleEnum * Use this instead of {@link StringRepresentable#fromEnum(Supplier, Function)} for extensible enums because this not cache the enum values on construction */ static & StringRepresentable> Codec createCodecForExtensibleEnum(Supplier valuesSupplier, Function enumValueFromNameFunction) { - return StringRepresentable.fromStringResolver(Enum::ordinal, (id) -> valuesSupplier.get()[id], enumValueFromNameFunction); + return Codec.either(Codec.STRING, Codec.INT).comapFlatMap( + either -> either.map( + str -> { + var val = enumValueFromNameFunction.apply(str); + return val != null ? DataResult.success(val) : DataResult.error("Unknown enum value name: " + str); + }, + num -> { + var values = valuesSupplier.get(); + return num >= 0 && num < values.length ? DataResult.success(values[num]) : DataResult.error("Unknown enum id: " + num); + } + ), + value -> Either.left(value.getSerializedName()) + ); } } diff --git a/src/main/java/net/minecraftforge/common/TierSortingRegistry.java b/src/main/java/net/minecraftforge/common/TierSortingRegistry.java index e1f009c3d6..139ca061a7 100644 --- a/src/main/java/net/minecraftforge/common/TierSortingRegistry.java +++ b/src/main/java/net/minecraftforge/common/TierSortingRegistry.java @@ -25,7 +25,6 @@ import com.google.common.graph.GraphBuilder; import com.google.common.graph.MutableGraph; import com.google.gson.*; import it.unimi.dsi.fastutil.booleans.BooleanConsumer; -import net.minecraft.client.player.LocalPlayer; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; @@ -48,12 +47,12 @@ import net.minecraftforge.client.event.ClientPlayerNetworkEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.fml.loading.FMLEnvironment; import net.minecraftforge.fml.loading.toposort.TopologicalSort; -import net.minecraftforge.fmllegacy.network.NetworkDirection; -import net.minecraftforge.fmllegacy.network.NetworkEvent; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; -import net.minecraftforge.fmllegacy.network.PacketDistributor; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.network.NetworkDirection; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.network.NetworkRegistry; +import net.minecraftforge.network.PacketDistributor; +import net.minecraftforge.network.simple.SimpleChannel; +import net.minecraftforge.server.ServerLifecycleHooks; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -406,7 +405,7 @@ public class TierSortingRegistry private static void clientLogInToServer(ClientPlayerNetworkEvent.LoggedInEvent event) { - if (event.getNetworkManager() == null || !event.getNetworkManager().isMemoryConnection()) + if (event.getConnection() == null || !event.getConnection().isMemoryConnection()) recalculateItemTiers(); } } diff --git a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java index 839f163c3b..7e53debda2 100644 --- a/src/main/java/net/minecraftforge/common/VillagerTradingManager.java +++ b/src/main/java/net/minecraftforge/common/VillagerTradingManager.java @@ -32,7 +32,7 @@ import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; import net.minecraft.core.NonNullList; import net.minecraftforge.event.village.VillagerTradesEvent; import net.minecraftforge.event.village.WandererTradesEvent; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; +import net.minecraftforge.event.server.ServerAboutToStartEvent; import net.minecraftforge.registries.ForgeRegistries; public class VillagerTradingManager @@ -52,7 +52,7 @@ public class VillagerTradingManager VillagerTrades.WANDERING_TRADER_TRADES.int2ObjectEntrySet().forEach(e -> WANDERER_TRADES.put(e.getIntKey(), Arrays.copyOf(e.getValue(), e.getValue().length))); } - static void loadTrades(FMLServerAboutToStartEvent e) + static void loadTrades(ServerAboutToStartEvent e) { postWandererEvent(); postVillagerEvents(); diff --git a/src/main/java/net/minecraftforge/common/animation/Event.java b/src/main/java/net/minecraftforge/common/animation/Event.java deleted file mode 100644 index a587327426..0000000000 --- a/src/main/java/net/minecraftforge/common/animation/Event.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.animation; - -import com.google.common.base.MoreObjects; - - -/** - * Event stored in the clip - */ -public final class Event implements Comparable -{ - private final String event; - private final float offset; - - public Event(String event, float offset) - { - this.event = event; - this.offset = offset; - } - - /** - * @return the name of the event. - */ - public String event() - { - return event; - } - - /** - * @return how long ago the event happened, relative to the next event / first query time - */ - public float offset() - { - return offset; - } - - @Override - public int compareTo(Event event) - { - return Float.compare(offset, event.offset); - } - - @Override - public String toString() - { - return MoreObjects.toStringHelper(getClass()).add("event", event).add("offset", offset).toString(); - } -} diff --git a/src/main/java/net/minecraftforge/common/animation/IEventHandler.java b/src/main/java/net/minecraftforge/common/animation/IEventHandler.java deleted file mode 100644 index 659c80c904..0000000000 --- a/src/main/java/net/minecraftforge/common/animation/IEventHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.animation; - - - -/** - * Handler for animation events; - */ -public interface IEventHandler -{ - void handleEvents(T instance, float time, Iterable pastEvents); -} diff --git a/src/main/java/net/minecraftforge/common/animation/ITimeValue.java b/src/main/java/net/minecraftforge/common/animation/ITimeValue.java deleted file mode 100644 index 07f2592791..0000000000 --- a/src/main/java/net/minecraftforge/common/animation/ITimeValue.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.animation; - -/** - * Time-varying value associated with the animation. - * Return value should be constant with the respect to the input and reasonable context (current render frame). - * Simplest example is the input time itself. - * Unity calls them Parameters, Unreal calls them Variables. - */ -public interface ITimeValue -{ - float apply(float input); -} diff --git a/src/main/java/net/minecraftforge/common/animation/TimeValues.java b/src/main/java/net/minecraftforge/common/animation/TimeValues.java deleted file mode 100644 index fe240e91ae..0000000000 --- a/src/main/java/net/minecraftforge/common/animation/TimeValues.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.animation; - -import java.io.IOException; -import java.util.regex.Pattern; - -import net.minecraft.util.StringRepresentable; - -import java.util.function.Function; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; -import com.google.gson.Gson; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import javax.annotation.Nullable; - -/** - * Various implementations of ITimeValue. - */ -public final class TimeValues -{ - public static enum IdentityValue implements ITimeValue, StringRepresentable - { - INSTANCE; - - @Override - public float apply(float input) - { - return input; - } - - @Override - public String getSerializedName() - { - return "identity"; - } - } - - public static final class ConstValue implements ITimeValue - { - private final float output; - - public ConstValue(float output) - { - this.output = output; - } - - @Override - public float apply(float input) - { - return output; - } - - @Override - public int hashCode() - { - return Objects.hashCode(output); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ConstValue other = (ConstValue) obj; - return output == other.output; - } - } - - /** - * Simple value holder. - */ - public static final class VariableValue implements ITimeValue - { - private float output; - - public VariableValue(float initialValue) - { - this.output = initialValue; - } - - public void setValue(float newValue) - { - this.output = newValue; - } - - @Override - public float apply(float input) - { - return output; - } - - @Override - public int hashCode() - { - return Objects.hashCode(output); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VariableValue other = (VariableValue) obj; - return output == other.output; - } - } - - public static final class SimpleExprValue implements ITimeValue - { - private static final Pattern opsPattern = Pattern.compile("[+\\-*/mMrRfF]+"); - - private final String operators; - private final ImmutableList args; - - public SimpleExprValue(String operators, ImmutableList args) - { - this.operators = operators; - this.args = args; - } - - @Override - public float apply(float input) - { - float ret = input; - for(int i = 0; i < operators.length(); i++) - { - float arg = args.get(i).apply(input); - switch(operators.charAt(i)) - { - case '+': ret += arg; break; - case '-': ret -= arg; break; - case '*': ret *= arg; break; - case '/': ret /= arg; break; - case 'm': ret = Math.min(ret, arg); break; - case 'M': ret = Math.max(ret, arg); break; - case 'r': ret = (float)Math.floor(ret / arg) * arg; break; - case 'R': ret = (float)Math.ceil(ret / arg) * arg; break; - case 'f': ret -= Math.floor(ret / arg) * arg; break; - case 'F': ret = (float)Math.ceil(ret / arg) * arg - ret; break; - } - } - return ret; - } - - @Override - public int hashCode() - { - return Objects.hashCode(operators, args); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SimpleExprValue other = (SimpleExprValue) obj; - return Objects.equal(operators, other.operators) && Objects.equal(args, other.args); - } - } - - public static final class CompositionValue implements ITimeValue - { - private final ITimeValue g; - private final ITimeValue f; - - public CompositionValue(ITimeValue g, ITimeValue f) - { - super(); - this.g = g; - this.f = f; - } - - @Override - public float apply(float input) - { - return g.apply(f.apply(input)); - } - - @Override - public int hashCode() - { - return Objects.hashCode(g, f); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CompositionValue other = (CompositionValue) obj; - return Objects.equal(g, other.g) && Objects.equal(f, other.f); - } - } - - public static final class ParameterValue implements ITimeValue, StringRepresentable - { - private final String parameterName; - private final Function valueResolver; - private ITimeValue parameter; - - public ParameterValue(String parameterName, Function valueResolver) - { - this.parameterName = parameterName; - this.valueResolver = valueResolver; - } - - @Override - public String getSerializedName() - { - return parameterName; - } - - private void resolve() - { - if(parameter == null) - { - if(valueResolver != null) - { - parameter = valueResolver.apply(parameterName); - } - if(parameter == null) - { - throw new IllegalArgumentException("Couldn't resolve parameter value " + parameterName); - } - } - } - - @Override - public float apply(float input) - { - resolve(); - return parameter.apply(input); - } - - @Override - public int hashCode() - { - resolve(); - return parameter.hashCode(); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ParameterValue other = (ParameterValue) obj; - resolve(); - other.resolve(); - return Objects.equal(parameter, other.parameter); - } - } - - public static enum CommonTimeValueTypeAdapterFactory implements TypeAdapterFactory - { - INSTANCE; - - private final ThreadLocal> valueResolver = new ThreadLocal>(); - - public void setValueResolver(@Nullable Function valueResolver) - { - this.valueResolver.set(valueResolver); - } - - @Override - @SuppressWarnings("unchecked") - @Nullable - public TypeAdapter create(Gson gson, TypeToken type) - { - if(type.getRawType() != ITimeValue.class) - { - return null; - } - - return (TypeAdapter)new TypeAdapter() - { - @Override - public void write(JsonWriter out, ITimeValue parameter) throws IOException - { - if(parameter instanceof ConstValue) - { - out.value(((ConstValue)parameter).output); - } - else if(parameter instanceof SimpleExprValue) - { - SimpleExprValue p = (SimpleExprValue)parameter; - out.beginArray(); - out.value(p.operators); - for(ITimeValue v : p.args) - { - write(out, v); - } - out.endArray(); - } - else if(parameter instanceof CompositionValue) - { - CompositionValue p = (CompositionValue)parameter; - out.beginArray(); - out.value("compose"); - write(out, p.g); - write(out, p.f); - out.endArray(); - } - else if(parameter instanceof StringRepresentable) - { - out.value("#" + ((StringRepresentable)parameter).getSerializedName()); - } - } - - @Override - public ITimeValue read(JsonReader in) throws IOException - { - switch(in.peek()) - { - case NUMBER: - return new ConstValue((float)in.nextDouble()); - case BEGIN_ARRAY: - in.beginArray(); - String type = in.nextString(); - ITimeValue p; - if(SimpleExprValue.opsPattern.matcher(type).matches()) - { - ImmutableList.Builder builder = ImmutableList.builder(); - while(in.hasNext()) - { - builder.add(read(in)); - } - p = new SimpleExprValue(type, builder.build()); - } - else if("compose".equals(type)) - { - p = new CompositionValue(read(in), read(in)); - } - else - { - throw new IOException("Unknown TimeValue type \"" + type + "\""); - } - in.endArray(); - return p; - case STRING: - String string = in.nextString(); - if(string.equals("#identity")) - { - return IdentityValue.INSTANCE; - } - if(!string.startsWith("#")) - { - throw new IOException("Expected TimeValue reference, got \"" + string + "\""); - } - // User Parameter TimeValue - return new ParameterValue(string.substring(1), valueResolver.get()); - default: - throw new IOException("Expected TimeValue, got " + in.peek()); - } - } - }; - } - } -} diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityInject.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityInject.java deleted file mode 100644 index 11660546f9..0000000000 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityInject.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.capabilities; - -import java.lang.annotation.*; - -/** - * When placed on a FIELD, the field will be set to an - * instance of Capability once that capability is registered. - * That field must be static and be able to hold a instance - * of 'Capability' - * - * Example: - *
{@code
- * @CapabilityInject(IExampleCapability.class)
- * private static final Capability TEST_CAP = null;
- * }
- * - * When placed on a METHOD, the method will be invoked once the - * capability is registered. This allows you to have a 'enable features' - * callback. It MUST have one parameter of type 'Capability; - * - * Example: - *
{@code
- * @CapabilityInject(IExampleCapability.class)
- * private static void capRegistered(Capability cap) {}
- * }
- * - * Warning: Capability injections are run in the thread that the capablity is registered. - * Due to parallel mod loading, this can potentially be off of the main thread. - * - * @deprecated Use {@link CapabilityManager#get(CapabilityToken)} - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD, ElementType.METHOD}) -@Deprecated(since = "1.18", forRemoval = true) -public @interface CapabilityInject -{ - /** - * The capability interface to listen for registration. - * Note: - * When reading annotations, DO NOT call this function as it will cause a hard dependency on the class. - */ - Class value(); -} diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java index a6e5344fa7..930b57fc0a 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java @@ -19,23 +19,13 @@ package net.minecraftforge.common.capabilities; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Collection; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - import net.minecraftforge.fml.ModLoader; import net.minecraftforge.forgespi.language.ModFileScanData; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.objectweb.asm.Type; -import java.util.function.Function; -import java.util.stream.Collectors; +import java.util.IdentityHashMap; +import java.util.List; import static net.minecraftforge.fml.Logging.CAPABILITIES; @@ -43,23 +33,6 @@ public enum CapabilityManager { INSTANCE; static final Logger LOGGER = LogManager.getLogger(); - private static final Type CAP_INJECT = Type.getType(CapabilityInject.class); - - /** - * Registers a capability to be consumed by others. - * APIs who define the capability should call this. - * To retrieve the Capability instance, use the @CapabilityInject annotation. - * This method is safe to call during parallel mod loading. - * - * @param type The class type to be registered - * @deprecated use {@link RegisterCapabilitiesEvent} - */ - @Deprecated(since = "1.18", forRemoval = true) - public void register(Class type) - { - Objects.requireNonNull(type,"Attempted to register a capability with invalid type"); - get(Type.getInternalName(type), true); - } public static Capability get(CapabilityToken type) @@ -103,81 +76,7 @@ public enum CapabilityManager private final IdentityHashMap> providers = new IdentityHashMap<>(); public void injectCapabilities(List data) { - final List elementsToInject = data.stream() - .map(ModFileScanData::getAnnotations) - .flatMap(Collection::stream) - .filter(a -> CAP_INJECT.equals(a.annotationType())) - .collect(Collectors.toList()); - final IdentityHashMap, Object>>> callbacks = new IdentityHashMap<>(); - elementsToInject.forEach(entry -> gatherCallbacks(callbacks, entry)); - var event = new RegisterCapabilitiesEvent(); ModLoader.get().postEvent(event); } - - private void gatherCallbacks(Map, Object>>> callbacks, ModFileScanData.AnnotationData annotationData) - { - final String targetClass = annotationData.clazz().getClassName(); - final String targetName = annotationData.memberName(); - Type type = (Type)annotationData.annotationData().get("value"); - if (type == null) - { - LOGGER.warn(CAPABILITIES,"Unable to inject capability at {}.{} (Invalid Annotation)", targetClass, targetName); - return; - } - final String capabilityName = type.getInternalName(); - - final Capability cap = get(capabilityName, false); - - if (annotationData.memberName().indexOf('(') > 0) - { - cap.addListener(input -> - { - try - { - for (Method mtd : Class.forName(targetClass).getDeclaredMethods()) - { - if (targetName.equals(mtd.getName() + Type.getMethodDescriptor(mtd))) - { - if ((mtd.getModifiers() & Modifier.STATIC) != Modifier.STATIC) - { - LOGGER.warn(CAPABILITIES,"Unable to inject capability {} at {}.{} (Non-Static)", capabilityName, targetClass, targetName); - return; - } - - mtd.setAccessible(true); - mtd.invoke(null, input); - return; - } - } - LOGGER.warn(CAPABILITIES,"Unable to inject capability {} at {}.{} (Method Not Found)", capabilityName, targetClass, targetName); - } - catch (Exception e) - { - LOGGER.warn(CAPABILITIES,"Unable to inject capability {} at {}.{}", capabilityName, targetClass, targetName, e); - } - }); - } - else - { - cap.addListener(input -> - { - try - { - Field field = Class.forName(targetClass).getDeclaredField(targetName); - if ((field.getModifiers() & Modifier.STATIC) != Modifier.STATIC) - { - LOGGER.warn(CAPABILITIES,"Unable to inject capability {} at {}.{} (Non-Static)", capabilityName, targetClass, targetName); - return; - } - field.setAccessible(true); - field.set(null, input); - } - catch (Exception e) - { - LOGGER.warn(CAPABILITIES,"Unable to inject capability {} at {}.{}", capabilityName, targetClass, targetName, e); - } - }); - } - } } diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java index 1418106405..84c7c2ece3 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityProvider.java @@ -27,6 +27,7 @@ import com.google.common.annotations.VisibleForTesting; import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.nbt.CompoundTag; import net.minecraft.core.Direction; +import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.ForgeEventFactory; @@ -34,7 +35,7 @@ import java.util.function.Supplier; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public abstract class CapabilityProvider> implements ICapabilityProvider +public abstract class CapabilityProvider> implements ICapabilityProviderImpl { @VisibleForTesting static boolean SUPPORTS_LAZY_CAPABILITIES = true; @@ -188,4 +189,38 @@ public abstract class CapabilityProvider> implem final CapabilityDispatcher disp = getCapabilities(); return !valid || disp == null ? LazyOptional.empty() : disp.getCapability(cap, side); } + + /** + * Special implementation for cases which have a superclass and can't extend CapabilityProvider directly. + * See {@link LevelChunk} + */ + public static class AsField> extends CapabilityProvider + { + public AsField(Class baseClass) + { + super(baseClass); + } + + public AsField(Class baseClass, boolean isLazy) + { + super(baseClass, isLazy); + } + + public void initInternal() + { + gatherCapabilities(); + } + + @Nullable + public CompoundTag serializeInternal() + { + return serializeCaps(); + } + + public void deserializeInternal(CompoundTag tag) + { + deserializeCaps(tag); + } + }; + } diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityToken.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityToken.java index ac720ab4a9..3c2c22362a 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityToken.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityToken.java @@ -19,9 +19,11 @@ package net.minecraftforge.common.capabilities; +import net.minecraftforge.fml.common.asm.CapabilityTokenSubclass; + /** * Inspired by {@link com.google.common.reflect.TypeToken TypeToken}, use a subclass to capture - * generic types. Then uses {@link net.minecraftforge.common.asm.CapabilityTokenSubclass a transformer} + * generic types. Then uses {@link CapabilityTokenSubclass a transformer} * to convert that generic into a string returned by {@link #getType} * This allows us to know the generic type, without having a hard reference to the * class. diff --git a/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProviderImpl.java b/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProviderImpl.java new file mode 100644 index 0000000000..0248dc9c2c --- /dev/null +++ b/src/main/java/net/minecraftforge/common/capabilities/ICapabilityProviderImpl.java @@ -0,0 +1,11 @@ +package net.minecraftforge.common.capabilities; + +import javax.annotation.Nullable; + +public interface ICapabilityProviderImpl> extends ICapabilityProvider +{ + boolean areCapsCompatible(CapabilityProvider other); + boolean areCapsCompatible(@Nullable CapabilityDispatcher other); + void invalidateCaps(); + void reviveCaps(); +} diff --git a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java index 12d3c77270..075d088e43 100644 --- a/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java +++ b/src/main/java/net/minecraftforge/common/crafting/ConditionalAdvancement.java @@ -43,11 +43,6 @@ public class ConditionalAdvancement return new Builder(); } - @Deprecated - public static boolean processConditions(JsonObject json) { - return processConditional(json) != null; - } - /** * Processes the conditional advancement during loading. * @param json The incoming json from the advancement file. diff --git a/src/main/java/net/minecraftforge/common/crafting/StackList.java b/src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java similarity index 95% rename from src/main/java/net/minecraftforge/common/crafting/StackList.java rename to src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java index ec9fed6dcd..3c331f5e09 100644 --- a/src/main/java/net/minecraftforge/common/crafting/StackList.java +++ b/src/main/java/net/minecraftforge/common/crafting/MultiItemValue.java @@ -28,10 +28,10 @@ import com.google.gson.JsonObject; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient.Value; -public class StackList implements Value +public class MultiItemValue implements Value { private Collection items; - public StackList(Collection items) + public MultiItemValue(Collection items) { this.items = Collections.unmodifiableCollection(items); } diff --git a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java index 8ad70bfa18..9cfd7ac33f 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java @@ -82,9 +82,9 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider tag(Tags.Items.GEMS_PRISMARINE).add(Items.PRISMARINE_CRYSTALS); tag(Tags.Items.GEMS_QUARTZ).add(Items.QUARTZ); copy(Tags.Blocks.GLASS, Tags.Items.GLASS); - func_240521_a_Colored(Tags.Blocks.GLASS, Tags.Items.GLASS); + copyColored(Tags.Blocks.GLASS, Tags.Items.GLASS); copy(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); - func_240521_a_Colored(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); + copyColored(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); copy(Tags.Blocks.GRAVEL, Tags.Items.GRAVEL); tag(Tags.Items.GUNPOWDER).add(Items.GUNPOWDER); tag(Tags.Items.HEADS).add(Items.CREEPER_HEAD, Items.DRAGON_HEAD, Items.PLAYER_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.ZOMBIE_HEAD); @@ -157,7 +157,7 @@ public final class ForgeItemTagsProvider extends ItemTagsProvider } } - private void func_240521_a_Colored(Tag.Named blockGroup, Tag.Named itemGroup) + private void copyColored(Tag.Named blockGroup, Tag.Named itemGroup) { String blockPre = blockGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_'; String itemPre = itemGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_'; diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java index bd05ee0a4c..92361933b7 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlock.java @@ -174,7 +174,7 @@ public interface IForgeBlock * @param fluid The current fluid state at current position * @return True if the block is actually destroyed. */ - default boolean removedByPlayer(BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) + default boolean onDestroyedByPlayer(BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { self().playerWillDestroy(world, pos, state, player); return world.setBlock(pos, fluid.createLegacyBlock(), world.isClientSide ? 11 : 3); @@ -227,7 +227,7 @@ public interface IForgeBlock * @param type The Mob Category Type * @return True to allow a mob of the specified category to spawn, false to prevent it. */ - default boolean canCreatureSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, EntityType entityType) + default boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, EntityType entityType) { return state.isValidSpawn(world, pos, entityType); } @@ -280,7 +280,7 @@ public interface IForgeBlock * @param target The full target the player is looking at * @return A ItemStack to add to the player's inventory, empty itemstack if nothing should be added. */ - default ItemStack getPickBlock(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) + default ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) { return self().getCloneItemStack(world, pos, state); } @@ -574,7 +574,7 @@ public interface IForgeBlock * @param face The face that the fire is coming from * @param igniter The entity that lit the fire */ - default void catchFire(BlockState state, Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {} + default void onCaughtFire(BlockState state, Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {} /** * Called when fire is updating on a neighbor block. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java index c2ea57392f..e22f8c9d0f 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockEntity.java @@ -23,6 +23,8 @@ import javax.annotation.Nonnull; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -66,7 +68,13 @@ public interface IForgeBlockEntity extends ICapabilitySerializable * @param net The NetworkManager the packet originated from * @param pkt The data packet */ - default void onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket pkt){ } + default void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) + { + CompoundTag compoundtag = pkt.getTag(); + if (compoundtag != null) { + self().load(compoundtag); + } + } /** * Called when the chunk's TE update tag, gotten from {@link BlockEntity#getUpdateTag()}, is received on the client. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java index 598048f6b4..35558e27b4 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeBlockState.java @@ -131,9 +131,9 @@ public interface IForgeBlockState * @param fluid The current fluid and block state for the position in the world. * @return True if the block is actually destroyed. */ - default boolean removedByPlayer(Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) + default boolean onDestroyedByPlayer(Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) { - return self().getBlock().removedByPlayer(self(), world, pos, player, willHarvest, fluid); + return self().getBlock().onDestroyedByPlayer(self(), world, pos, player, willHarvest, fluid); } /** @@ -160,9 +160,9 @@ public interface IForgeBlockState * @param type The Mob Category Type * @return True to allow a mob of the specified category to spawn, false to prevent it. */ - default boolean canCreatureSpawn(LevelReader world, BlockPos pos, Type type, EntityType entityType) + default boolean isValidSpawn(LevelReader world, BlockPos pos, Type type, EntityType entityType) { - return self().getBlock().canCreatureSpawn(self(), world, pos, type, entityType); + return self().getBlock().isValidSpawn(self(), world, pos, type, entityType); } /** @@ -227,9 +227,9 @@ public interface IForgeBlockState * @param target The full target the player is looking at * @return A ItemStack to add to the player's inventory, empty itemstack if nothing should be added. */ - default ItemStack getPickBlock(HitResult target, BlockGetter world, BlockPos pos, Player player) + default ItemStack getCloneItemStack(HitResult target, BlockGetter world, BlockPos pos, Player player) { - return self().getBlock().getPickBlock(self(), target, world, pos, player); + return self().getBlock().getCloneItemStack(self(), target, world, pos, player); } /** @@ -490,9 +490,9 @@ public interface IForgeBlockState * @param face The face that the fire is coming from * @param igniter The entity that lit the fire */ - default void catchFire(Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) + default void onCaughtFire(Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) { - self().getBlock().catchFire(self(), world, pos, face, igniter); + self().getBlock().onCaughtFire(self(), world, pos, face, igniter); } /** @@ -550,14 +550,14 @@ public interface IForgeBlockState } /** - * Get the {@code PathNodeType} for this block. Return {@code null} for vanilla behavior. + * Get the {@code BlockPathTypes} for this block. Return {@code null} for vanilla behavior. * * @return the PathNodeType */ @Nullable - default BlockPathTypes getAiPathNodeType(BlockGetter world, BlockPos pos) + default BlockPathTypes getBlockPathType(BlockGetter world, BlockPos pos) { - return getAiPathNodeType(world, pos, null); + return getBlockPathType(world, pos, null); } /** @@ -566,7 +566,7 @@ public interface IForgeBlockState * @return the PathNodeType */ @Nullable - default BlockPathTypes getAiPathNodeType(BlockGetter world, BlockPos pos, @Nullable Mob entity) + default BlockPathTypes getBlockPathType(BlockGetter world, BlockPos pos, @Nullable Mob entity) { return self().getBlock().getAiPathNodeType(self(), world, pos, entity); } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java index 5071c9006f..2198da0155 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluid.java @@ -100,7 +100,7 @@ public interface IForgeFluid /** * Queries if this fluid should render in a given layer. - * A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer. + * A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderType()} to alter the model based on layer. */ /* TODO: reimplement default boolean canRenderInLayer(IFluidState state, BlockRenderLayer layer) diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java index ab14be80bd..6817ad7886 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeFluidState.java @@ -52,8 +52,6 @@ public interface IForgeFluidState return self().getType().isEntityInside(self(), world, pos, entity, yToTest, tag, testingHead); } - - /** * Location sensitive version of getExplosionResistance * @@ -67,13 +65,4 @@ public interface IForgeFluidState return self().getType().getExplosionResistance(self(), world, pos, explosion); } - /** - * Queries if this fluidstate should render in a given layer. - * A custom {@link IBakedModel} can use {@link net.minecraftforge.client.MinecraftForgeClient#getRenderLayer()} to alter the model based on layer. - */ - /* TODO: reimplement - default boolean canRenderInLayer(BlockRenderLayer layer) - { - return getFluidState().getFluid().canRenderInLayer(getFluidState(), layer); - }*/ } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index f0c9610f33..c810a9e969 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -55,7 +55,7 @@ import net.minecraftforge.common.ToolAction; import net.minecraftforge.common.ToolActions; import net.minecraftforge.registries.IForgeRegistryEntry; -// TODO review most of the methods in this "patch" +// TODO systemic review of all extension functions. lots of unused -C public interface IForgeItem { private Item self() @@ -324,19 +324,6 @@ public interface IForgeItem return java.util.Collections.singletonList(self().getItemCategory()); } - /** - * Determines the base experience for a player when they remove this item from a - * furnace slot. This number must be between 0 and 1 for it to be valid. This - * number will be multiplied by the stack size to get the total experience. - * - * @param item The item stack the player is picking up. - * @return The amount to award for each item. - */ - default float getSmeltingExperience(ItemStack item) - { - return -1; // -1 will default to the old lookups. - } - /** * * Should this item, when held, allow sneak-clicks to pass through to the @@ -443,51 +430,6 @@ public interface IForgeItem return !stack.hasTag() ? 0 : stack.getTag().getInt("Damage"); } - /** - * Determines if the durability bar should be rendered for this item. Defaults - * to vanilla stack.isDamaged behavior. But modders can use this for any data - * they wish. - * - * @param stack The current Item Stack - * @return True if it should render the 'durability' bar. - * @deprecated To be removed in 1.18. Override {@link Item#isBarVisible(ItemStack)} instead. - */ - @Deprecated(forRemoval = true, since = "1.17.1") - default boolean showDurabilityBar(ItemStack stack) - { - return stack.isDamaged(); - } - - /** - * Queries the percentage of the 'Durability' bar that should be drawn. - * - * @param stack The current ItemStack - * @return 0.0 for 100% (no damage / full bar), 1.0 for 0% (fully damaged / - * empty bar) - * @deprecated To be removed in 1.18. Override {@link Item#getBarWidth(ItemStack)} instead, with the notable difference - * that the new method returns the width of the colored bar in pixels (where a full bar is 13px wide). - */ - @Deprecated(forRemoval = true, since = "1.17.1") - default double getDurabilityForDisplay(ItemStack stack) - { - return (double) stack.getDamageValue() / (double) stack.getMaxDamage(); - } - - /** - * Returns the packed int RGB value used to render the durability bar in the - * GUI. Defaults to a value based on the hue scaled based on - * {@link #getDurabilityForDisplay}, but can be overriden. - * - * @param stack Stack to get durability from - * @return A packed RGB value for the durability colour (0x00RRGGBB) - * @deprecated To be removed in 1.18. Override {@link Item#getBarColor(ItemStack)} instead. - */ - @Deprecated(forRemoval = true, since = "1.17.1") - default int getRGBDurabilityForDisplay(ItemStack stack) - { - return Mth.hsvToRgb(Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack))) / 3.0F, 1.0F, 1.0F); - } - /** * Return the maxDamage for this ItemStack. Defaults to the maxDamage field in * this item, but can be overridden here for other sources such as NBT. @@ -534,8 +476,7 @@ public interface IForgeItem */ default boolean canPerformAction(ItemStack stack, ToolAction toolAction) { - // Temporary patch to keep #isShield working until its removed; change to `return false` once removed - return isShield(stack, null) && ToolActions.DEFAULT_SHIELD_ACTIONS.contains(toolAction); + return false; } /** @@ -676,14 +617,6 @@ public interface IForgeItem return null; } - //TODO, properties dont exist anymore -// default ImmutableMap getAnimationParameters(final ItemStack stack, final World world, final LivingEntity entity) -// { -// com.google.common.collect.ImmutableMap.Builder builder = ImmutableMap.builder(); -// getItem().properties.forEach((k,v) -> builder.put(k.toString(), input -> v.call(stack, world, entity))); -// return builder.build(); -// } - /** * Can this Item disable a shield * @@ -698,21 +631,6 @@ public interface IForgeItem return this instanceof AxeItem; } - /** - * {@return {@code true} if this item is considered a shield} - * - * @param stack the item stack - * @param entity the entity holding the item stack - * @deprecated To be removed in 1.18. Override {@link #canPerformAction(ItemStack, ToolAction)} and return - * {@code true} if the passed in tool action is contained in {@link ToolActions#DEFAULT_SHIELD_ACTIONS} or is - * equals to {@link ToolActions#SHIELD_BLOCK}. - */ - @Deprecated(since = "1.17.1", forRemoval = true) - default boolean isShield(ItemStack stack, @Nullable LivingEntity entity) - { - return stack.getItem() == Items.SHIELD; - } - /** * @return the fuel burn time for this itemStack in a furnace. Return 0 to make * it not act as a fuel. Return -1 to let the default vanilla logic diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index c45c012416..72fba7cd6b 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -206,20 +206,6 @@ public interface IForgeItemStack extends ICapabilitySerializable return self().getItem().canDisableShield(self(), shield, entity, attacker); } - /** - * {@return {@code true} if this item is considered a shield} - * - * @param entity the entity holding the item stack - * @deprecated To be removed in 1.18. Call {@link #canPerformAction(ToolAction)} with - * {@link ToolActions#SHIELD_BLOCK} instead. - */ - @SuppressWarnings("removal") - @Deprecated(since = "1.17.1", forRemoval = true) - default boolean isShield(@Nullable LivingEntity entity) - { - return self().getItem().isShield(self(), entity); - } - /** * Called when a entity tries to play the 'swing' animation. * diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java b/src/main/java/net/minecraftforge/common/extensions/IForgeMenuType.java similarity index 92% rename from src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java rename to src/main/java/net/minecraftforge/common/extensions/IForgeMenuType.java index f8d41881a6..eb8fc1a845 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeContainerType.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeMenuType.java @@ -23,9 +23,9 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.MenuType; import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.fmllegacy.network.IContainerFactory; +import net.minecraftforge.network.IContainerFactory; -public interface IForgeContainerType +public interface IForgeMenuType { static MenuType create(IContainerFactory factory) { diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java b/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java index ed3d2a31dc..6ec927cb40 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeMobEffect.java @@ -51,7 +51,7 @@ public interface IForgeMobEffect * @param potionEffect the {@code PotionEffect} instance containing the potion * @return a value used to sort {@code PotionEffect}s in GUIs */ - default int getGuiSortColor(MobEffectInstance potionEffect) { + default int getSortOrder(MobEffectInstance potionEffect) { return self().getColor(); } } diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java b/src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java index 97f7792246..74692994e5 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeStructureFeature.java @@ -40,36 +40,6 @@ public interface IForgeStructureFeature */ @SuppressWarnings("incomplete-switch") default List getDefaultSpawnList(MobCategory category) - { - if (category == MobCategory.MONSTER) - return getDefaultSpawnList(); - else if (category == MobCategory.CREATURE) - return getDefaultCreatureSpawnList(); - return Collections.emptyList(); - } - - /** - * Gets the default list of {@link MobCategory#MONSTER} spawns for this structure. - * - * @apiNote Implement this over {@link StructureFeature#getSpecialEnemies()} - * - * @deprecated Use {@link IForgeStructureFeature#getDefaultSpawnList(MobCategory)} - * TODO: Remove in 1.18 - */ - default List getDefaultSpawnList() - { - return Collections.emptyList(); - } - - /** - * Gets the default list of {@link MobCategory#CREATURE} spawns for this structure. - * - * @apiNote Implement this over {@link StructureFeature#getSpecialAnimals()} - * - * @deprecated Use {@link IForgeStructureFeature#getDefaultSpawnList(MobCategory)} - * TODO: Remove in 1.18 - */ - default List getDefaultCreatureSpawnList() { return Collections.emptyList(); } diff --git a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java index 7e4ff922d6..6733806388 100644 --- a/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java +++ b/src/main/java/net/minecraftforge/common/loot/LootModifierManager.java @@ -128,15 +128,7 @@ public class LootModifierManager extends SimpleJsonResourceReloadListener { JsonObject object = element.getAsJsonObject(); LootItemCondition[] lootConditions = GSON_INSTANCE.fromJson(object.get("conditions"), LootItemCondition[].class); - // For backward compatibility with the initial implementation, fall back to using the location as the type. - // TODO: Remove fallback in 1.16 - ResourceLocation serializer = location; - if (object.has("type")) - { - serializer = new ResourceLocation(GsonHelper.getAsString(object, "type")); - } - - return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(serializer).read(location, object, lootConditions); + return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(location).read(location, object, lootConditions); } public static GlobalLootModifierSerializer getSerializerForName(ResourceLocation resourcelocation) { diff --git a/src/main/java/net/minecraftforge/common/model/HiddenModelPart.java b/src/main/java/net/minecraftforge/common/model/HiddenModelPart.java deleted file mode 100644 index 6d4723a497..0000000000 --- a/src/main/java/net/minecraftforge/common/model/HiddenModelPart.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model; - -import com.google.common.collect.ImmutableList; - -final class HiddenModelPart -{ - private final ImmutableList path; - - HiddenModelPart(ImmutableList path) - { - this.path = path; - } - - ImmutableList getPath() - { - return path; - } -} diff --git a/src/main/java/net/minecraftforge/common/model/Models.java b/src/main/java/net/minecraftforge/common/model/Models.java deleted file mode 100644 index ad8446216a..0000000000 --- a/src/main/java/net/minecraftforge/common/model/Models.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.UnmodifiableIterator; - -public enum Models -{ - ; - - public static Object getHiddenModelPart(ImmutableList path) - { - return new HiddenModelPart(path); - } - - public static UnmodifiableIterator getParts(Object part) - { - if(part instanceof HiddenModelPart) - { - return ((HiddenModelPart) part).getPath().iterator(); - } - ImmutableSet ret = ImmutableSet.of(); - return ret.iterator(); - } -} diff --git a/src/main/java/net/minecraftforge/common/model/TransformationHelper.java b/src/main/java/net/minecraftforge/common/model/TransformationHelper.java index 92635d6681..aa7213ea55 100644 --- a/src/main/java/net/minecraftforge/common/model/TransformationHelper.java +++ b/src/main/java/net/minecraftforge/common/model/TransformationHelper.java @@ -39,6 +39,7 @@ public final class TransformationHelper { @Deprecated @OnlyIn(Dist.CLIENT) + // TODO: this is used in 3 places, not a trivial refactor. Needs investigating. -C public static Transformation toTransformation(ItemTransform transform) { if (transform.equals(ItemTransform.NO_TRANSFORM)) return Transformation.identity(); @@ -177,7 +178,7 @@ public final class TransformationHelper Quaternion rightRot = null; // TODO: Default origin is opposing corner, due to a mistake. // This should probably be replaced with center in future versions. - Vector3f origin = ORIGIN_OPPOSING_CORNER; + Vector3f origin = ORIGIN_OPPOSING_CORNER; // TODO: Changing this to ORIGIN_CENTER breaks models, function content needs changing too -C if (obj.has("translation")) { translation = new Vector3f(parseFloatArray(obj.get("translation"), 3, "Translation")); diff --git a/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java b/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java deleted file mode 100644 index e774b16051..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import com.google.common.base.Predicate; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Iterables; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.server.packs.resources.Resource; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.animation.Event; -import net.minecraftforge.common.animation.ITimeValue; -import net.minecraftforge.common.animation.TimeValues; -import net.minecraftforge.common.util.JsonUtils; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.commons.lang3.tuple.Triple; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import javax.annotation.Nullable; -import java.io.IOException; -import java.io.InputStreamReader; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.nio.charset.StandardCharsets; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; - -public final class AnimationStateMachine implements IAnimationStateMachine -{ - private static final Logger LOGGER = LogManager.getLogger(); - private final ImmutableMap parameters; - private final ImmutableMap clips; - private final ImmutableList states; - private final ImmutableMultimap transitions; - @SerializedName("start_state") - private final String startState; - - private transient boolean shouldHandleSpecialEvents; - private transient String currentStateName; - private transient IClip currentState; - private transient float lastPollTime; - - private static final LoadingCache, Pair>> clipCache = CacheBuilder.newBuilder() - .maximumSize(100) - .expireAfterWrite(100, TimeUnit.MILLISECONDS) - .build(new CacheLoader, Pair>>() - { - @Override - public Pair> load(Triple key) throws Exception - { - return Clips.apply(key.getLeft(), key.getMiddle(), key.getRight()); - } - }); - - public AnimationStateMachine(ImmutableMap parameters, ImmutableMap clips, ImmutableList states, ImmutableMultimap transitions, String startState) - { - this.parameters = parameters; - this.clips = clips; - this.states = states; - this.transitions = transitions; - this.startState = startState; - } - - /** - * post-loading initialization hook. - */ - void initialize() - { - if(parameters == null) - { - throw new JsonParseException("Animation State Machine should contain \"parameters\" key."); - } - if(clips == null) - { - throw new JsonParseException("Animation State Machine should contain \"clips\" key."); - } - if(states == null) - { - throw new JsonParseException("Animation State Machine should contain \"states\" key."); - } - if(transitions == null) - { - throw new JsonParseException("Animation State Machine should contain \"transitions\" key."); - } - shouldHandleSpecialEvents = true; - lastPollTime = Float.NEGATIVE_INFINITY; - // setting the starting state - IClip state = clips.get(startState); - if(!clips.containsKey(startState) || !states.contains(startState)) - { - throw new IllegalStateException("unknown state: " + startState); - } - currentStateName = startState; - currentState = state; - } - - @Override - public Pair> apply(float time) - { - if(lastPollTime == Float.NEGATIVE_INFINITY) - { - lastPollTime = time; - } - Pair> pair = clipCache.getUnchecked(Triple.of(currentState, lastPollTime, time)); - lastPollTime = time; - boolean shouldFilter = false; - if(shouldHandleSpecialEvents) - { - for(Event event : ImmutableList.copyOf(pair.getRight()).reverse()) - { - if(event.event().startsWith("!")) - { - shouldFilter = true; - if(event.event().startsWith("!transition:")) - { - String newState = event.event().substring("!transition:".length()); - transition(newState); - } - else - { - LOGGER.error("Unknown special event \"{}\", ignoring.", event.event()); - } - } - } - } - if(!shouldFilter) - { - return pair; - } - return Pair.of(pair.getLeft(), Iterables.filter(pair.getRight(), new Predicate() - { - @Override - public boolean apply(Event event) - { - return !event.event().startsWith("!"); - } - })); - } - - @Override - public void transition(String newState) - { - IClip nc = clips.get(newState); - if(!clips.containsKey(newState) || !states.contains(newState)) - { - throw new IllegalStateException("unknown state: " + newState); - } - if(!transitions.containsEntry(currentStateName, newState)) - { - throw new IllegalArgumentException("no transition from current clip \"" + currentStateName + "\" to the clip \"" + newState + "\" found."); - } - currentStateName = newState; - currentState = nc; - } - - @Override - public String currentState() - { - return currentStateName; - } - - @Override - public void shouldHandleSpecialEvents(boolean value) - { - shouldHandleSpecialEvents = true; - } - - /** - * Load a new instance if AnimationStateMachine at specified location, with specified custom parameters. - */ - @OnlyIn(Dist.CLIENT) - public static IAnimationStateMachine load(ResourceManager manager, ResourceLocation location, ImmutableMap customParameters) - { - try (Resource resource = manager.getResource(location)) - { - ClipResolver clipResolver = new ClipResolver(); - ParameterResolver parameterResolver = new ParameterResolver(customParameters); - Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver); - TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver); - AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), AnimationStateMachine.class); - clipResolver.asm = asm; - parameterResolver.asm = asm; - asm.initialize(); - //String json = asmGson.toJson(asm); - //System.out.println(location + ": " + json); - return asm; - } - catch(IOException | JsonParseException e) - { - LOGGER.error("Exception loading Animation State Machine {}, skipping", location, e); - return missing; - } - finally - { - Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null); - TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null); - } - } - - private static final AnimationStateMachine missing = new AnimationStateMachine( - ImmutableMap.of(), - ImmutableMap.of("missingno", (IClip)Clips.IdentityClip.INSTANCE), - ImmutableList.of("missingno"), - ImmutableMultimap.of(), - "missingno"); - - static - { - missing.initialize(); - } - - public static AnimationStateMachine getMissing() - { - return missing; - } - - private static final class ClipResolver implements Function - { - private AnimationStateMachine asm; - - @Override - public IClip apply(String name) - { - return asm.clips.get(name); - } - } - - private static final class ParameterResolver implements Function - { - private final ImmutableMap customParameters; - private AnimationStateMachine asm; - - public ParameterResolver(ImmutableMap customParameters) - { - this.customParameters = customParameters; - } - - @Override - public ITimeValue apply(String name) - { - if(asm.parameters.containsKey(name)) - { - return asm.parameters.get(name); - } - return customParameters.get(name); - } - } - - private static final Gson asmGson = new GsonBuilder() - .registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE) - .registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE) - .registerTypeAdapterFactory(Clips.CommonClipTypeAdapterFactory.INSTANCE) - //.registerTypeAdapterFactory(ClipProviders.CommonClipProviderTypeAdapterFactory.INSTANCE) - .registerTypeAdapterFactory(TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE) - .registerTypeAdapterFactory(TransitionsAdapterFactory.INSTANCE) - .setPrettyPrinting() - .enableComplexMapKeySerialization() - .disableHtmlEscaping() - .create(); - - private enum TransitionsAdapterFactory implements TypeAdapterFactory - { - INSTANCE; - - @Override - @SuppressWarnings("unchecked") - @Nullable - public TypeAdapter create(Gson gson, TypeToken type) - { - if(type.getRawType() != ImmutableMultimap.class || !(type.getType() instanceof ParameterizedType)) - { - return null; - } - final Type[] typeArguments = ((ParameterizedType) type.getType()).getActualTypeArguments(); - if(typeArguments.length != 2 || typeArguments[0] != String.class || typeArguments[1] != String.class) - { - return null; - } - final TypeAdapter>> mapAdapter = gson.getAdapter(new TypeToken>>(){}); - final TypeAdapter> collectionAdapter = gson.getAdapter(new TypeToken>(){}); - return (TypeAdapter)new TypeAdapter>() - { - @Override - public void write(JsonWriter out, ImmutableMultimap value) throws IOException - { - mapAdapter.write(out, value.asMap()); - } - - @Override - public ImmutableMultimap read(JsonReader in) throws IOException - { - ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); - in.beginObject(); - while(in.hasNext()) - { - String key = in.nextName(); - switch(in.peek()) - { - case STRING: - builder.put(key, in.nextString()); - break; - case BEGIN_ARRAY: - builder.putAll(key, collectionAdapter.read(in)); - break; - default: - throw new JsonParseException("Expected String or Array, got " + in.peek()); - } - } - in.endObject(); - return builder.build(); - } - }; - } - } -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java b/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java deleted file mode 100644 index 9d860ccd83..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import net.minecraft.core.Direction; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.common.util.LazyOptional; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -public class CapabilityAnimation -{ - public static Capability ANIMATION_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); - - public static void register(RegisterCapabilitiesEvent event) - { - event.register(IAnimationStateMachine.class); - } - - public static class DefaultItemAnimationCapabilityProvider implements ICapabilityProvider - { - @Nonnull - private final LazyOptional asm; - - public DefaultItemAnimationCapabilityProvider(@Nonnull LazyOptional asm) - { - this.asm = asm; - } - - @Override - @Nonnull - public LazyOptional getCapability(@Nonnull Capability capability, @Nullable Direction facing) - { - return ANIMATION_CAPABILITY.orEmpty(capability, asm); - } - } -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/Clips.java b/src/main/java/net/minecraftforge/common/model/animation/Clips.java deleted file mode 100644 index 94e496c709..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/Clips.java +++ /dev/null @@ -1,588 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import java.io.IOException; - -import com.mojang.math.Transformation; -import net.minecraft.client.resources.model.ModelState; -import net.minecraft.client.resources.model.UnbakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.util.StringRepresentable; -import net.minecraft.util.Mth; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.common.animation.Event; -import net.minecraftforge.common.animation.ITimeValue; -import net.minecraftforge.api.distmarker.Dist; - -import net.minecraftforge.common.model.TransformationHelper; -import org.apache.commons.lang3.NotImplementedException; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.util.function.Function; -import com.google.common.base.Objects; -import java.util.Optional; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Ordering; -import com.google.gson.Gson; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import javax.annotation.Nullable; - -/** - * Various implementations of IClip, and utility methods. - */ -public final class Clips -{ - private static final Logger LOGGER = LogManager.getLogger(); - - /** - * Clip that does nothing. - */ - public static enum IdentityClip implements IClip, StringRepresentable - { - INSTANCE; - - @Override - public IJointClip apply(IJoint joint) - { - return JointClips.IdentityJointClip.INSTANCE; - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - return ImmutableSet.of(); - } - - @Override - public String getSerializedName() - { - return "identity"; - } - } - - /** - * Retrieves the clip from the model. - */ - @OnlyIn(Dist.CLIENT) - public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName) - { - UnbakedModel model = ModelLoader.defaultModelGetter().apply(modelLocation); - Optional clip = model.getClip(clipName); - if (clip.isPresent()) - { - return new ModelClip(clip.get(), modelLocation, clipName); - } - LOGGER.error("Unable to find clip {} in the model {}", clipName, modelLocation); - // FIXME: missing clip? - return new ModelClip(IdentityClip.INSTANCE, modelLocation, clipName); - } - - /** - * Wrapper for model clips; useful for debugging and serialization; - */ - public static final class ModelClip implements IClip - { - private final IClip childClip; - private final ResourceLocation modelLocation; - private final String clipName; - - public ModelClip(IClip childClip, ResourceLocation modelLocation, String clipName) - { - this.childClip = childClip; - this.modelLocation = modelLocation; - this.clipName = clipName; - } - - @Override - public IJointClip apply(IJoint joint) - { - return childClip.apply(joint); - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - return childClip.pastEvents(lastPollTime, time); - } - - @Override - public int hashCode() - { - return Objects.hashCode(modelLocation, clipName); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ModelClip other = (ModelClip) obj; - return Objects.equal(modelLocation, other.modelLocation) && Objects.equal(clipName, other.clipName); - } - } - - /** - * Clip with custom parameterization of the time. - */ - public static final class TimeClip implements IClip - { - private final IClip childClip; - private final ITimeValue time; - - public TimeClip(IClip childClip, ITimeValue time) - { - this.childClip = childClip; - this.time = time; - } - - @Override - public IJointClip apply(final IJoint joint) - { - return new IJointClip() - { - private final IJointClip parent = childClip.apply(joint); - @Override - public Transformation apply(float time) - { - return parent.apply(TimeClip.this.time.apply(time)); - } - }; - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - return childClip.pastEvents(this.time.apply(lastPollTime), this.time.apply(time)); - } - - @Override - public int hashCode() - { - return Objects.hashCode(childClip, time); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TimeClip other = (TimeClip) obj; - return Objects.equal(childClip, other.childClip) && Objects.equal(time, other.time); - } - } - - /** - * Spherical linear blend between 2 clips. - */ - public static final class SlerpClip implements IClip - { - private final IClip from; - private final IClip to; - private final ITimeValue input; - private final ITimeValue progress; - - public SlerpClip(IClip from, IClip to, ITimeValue input, ITimeValue progress) - { - this.from = from; - this.to = to; - this.input = input; - this.progress = progress; - } - - @Override - public IJointClip apply(IJoint joint) - { - IJointClip fromClip = from.apply(joint); - IJointClip toClip = to.apply(joint); - return blendClips(joint, fromClip, toClip, input, progress); - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - float clipLastPollTime = input.apply(lastPollTime); - float clipTime = input.apply(time); - return Iterables.mergeSorted(ImmutableSet.of( - from.pastEvents(clipLastPollTime, clipTime), - to.pastEvents(clipLastPollTime, clipTime) - ), Ordering.natural()); - } - - @Override - public int hashCode() - { - return Objects.hashCode(from, to, input, progress); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - SlerpClip other = (SlerpClip) obj; - return Objects.equal(from, other.from) && - Objects.equal(to, other.to) && - Objects.equal(input, other.input) && - Objects.equal(progress, other.progress); - } - } - - /*public static class AdditiveLerpClip implements IClip - { - private final IClip base; - private final IClip add; - private final IParameter progress; - - public AdditiveLerpClip(IClip base, IClip add, IParameter progress) - { - this.base = base; - this.add = add; - this.progress = progress; - } - - public IJointClip apply(IJoint joint) - { - throw new NotImplementedException("AdditiveLerpClip.apply"); - } - }*/ - - private static IJointClip blendClips(final IJoint joint, final IJointClip fromClip, final IJointClip toClip, final ITimeValue input, final ITimeValue progress) - { - return new IJointClip() - { - @Override - public Transformation apply(float time) - { - float clipTime = input.apply(time); - return TransformationHelper.slerp(fromClip.apply(clipTime), toClip.apply(clipTime), Mth.clamp(progress.apply(time), 0, 1)); - } - }; - } - - /** - * IModelState wrapper for a Clip, sampled at specified time. - */ - public static Pair> apply(final IClip clip, final float lastPollTime, final float time) - { - return Pair.of(new ModelState() - { - @Override - public Transformation getRotation() - { - return Transformation.identity(); - } - - @Override - public Transformation getPartTransformation(Object part) - { - if(!(part instanceof IJoint)) - { - return Transformation.identity(); - } - IJoint joint = (IJoint)part; - // TODO: Cache clip application? - Transformation jointTransform = clip.apply(joint).apply(time).compose(joint.getInvBindPose()); - Optional parent = joint.getParent(); - while(parent.isPresent()) - { - Transformation parentTransform = clip.apply(parent.get()).apply(time); - jointTransform = parentTransform.compose(jointTransform); - parent = parent.get().getParent(); - } - return jointTransform; - } - }, clip.pastEvents(lastPollTime, time)); - } - - /** - * Clip + Event, triggers when parameter becomes non-negative. - */ - public static final class TriggerClip implements IClip - { - private final IClip clip; - private final ITimeValue parameter; - private final String event; - - public TriggerClip(IClip clip, ITimeValue parameter, String event) - { - this.clip = clip; - this.parameter = parameter; - this.event = event; - } - - @Override - public IJointClip apply(IJoint joint) - { - return clip.apply(joint); - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - if(parameter.apply(lastPollTime) < 0 && parameter.apply(time) >= 0) - { - return Iterables.mergeSorted(ImmutableSet.of( - clip.pastEvents(lastPollTime, time), - ImmutableSet.of(new Event(event, 0)) - ), Ordering.natural()); - } - return clip.pastEvents(lastPollTime, time); - } - } - - /** - * Reference to another clip. - * Should only exist during debugging. - */ - public static final class ClipReference implements IClip, StringRepresentable - { - private final String clipName; - private final Function clipResolver; - private IClip clip; - - public ClipReference(String clipName, Function clipResolver) - { - this.clipName = clipName; - this.clipResolver = clipResolver; - } - - private void resolve() - { - if(clip == null) - { - if(clipResolver != null) - { - clip = clipResolver.apply(clipName); - } - if(clip == null) - { - throw new IllegalArgumentException("Couldn't resolve clip " + clipName); - } - } - } - - @Override - public IJointClip apply(final IJoint joint) - { - resolve(); - return clip.apply(joint); - } - - @Override - public Iterable pastEvents(float lastPollTime, float time) - { - resolve(); - return clip.pastEvents(lastPollTime, time); - } - - @Override - public String getSerializedName() - { - return clipName; - } - - @Override - public int hashCode() - { - resolve(); - return clip.hashCode(); - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ClipReference other = (ClipReference) obj; - resolve(); - other.resolve(); - return Objects.equal(clip, other.clip); - } - } - - public static enum CommonClipTypeAdapterFactory implements TypeAdapterFactory - { - INSTANCE; - - private final ThreadLocal> clipResolver = new ThreadLocal>(); - - public void setClipResolver(@Nullable Function clipResolver) - { - this.clipResolver.set(clipResolver); - } - - @Override - @SuppressWarnings("unchecked") - @Nullable - public TypeAdapter create(Gson gson, TypeToken type) - { - if(type.getRawType() != IClip.class) - { - return null; - } - - final TypeAdapter parameterAdapter = gson.getAdapter(ITimeValue.class); - - return (TypeAdapter)new TypeAdapter() - { - @Override - public void write(JsonWriter out, IClip clip) throws IOException - { - // IdentityClip + ClipReference - if(clip instanceof StringRepresentable) - { - out.value("#" + ((StringRepresentable)clip).getSerializedName()); - return; - } - else if(clip instanceof TimeClip) - { - out.beginArray(); - out.value("apply"); - TimeClip timeClip = (TimeClip)clip; - write(out, timeClip.childClip); - parameterAdapter.write(out, timeClip.time); - out.endArray(); - return; - } - else if(clip instanceof SlerpClip) - { - out.beginArray(); - out.value("slerp"); - SlerpClip slerpClip = (SlerpClip)clip; - write(out, slerpClip.from); - write(out, slerpClip.to); - parameterAdapter.write(out, slerpClip.input); - parameterAdapter.write(out, slerpClip.progress); - out.endArray(); - return; - } - else if(clip instanceof TriggerClip) - { - out.beginArray(); - out.value("trigger_positive"); - TriggerClip triggerClip = (TriggerClip)clip; - write(out, triggerClip.clip); - parameterAdapter.write(out, triggerClip.parameter); - out.value(triggerClip.event); - out.endArray(); - return; - } - else if(clip instanceof ModelClip) - { - ModelClip modelClip = (ModelClip)clip; - out.value(modelClip.modelLocation + "@" + modelClip.clipName); - return; - } - // TODO custom clip writing? - throw new NotImplementedException("unknown Clip to json: " + clip); - } - - @Override - public IClip read(JsonReader in) throws IOException - { - switch(in.peek()) - { - case BEGIN_ARRAY: - in.beginArray(); - String type = in.nextString(); - IClip clip; - // TimeClip - if("apply".equals(type)) - { - clip = new TimeClip(read(in), parameterAdapter.read(in)); - } - else if("slerp".equals(type)) - { - clip = new SlerpClip(read(in), read(in), parameterAdapter.read(in), parameterAdapter.read(in)); - } - else if("trigger_positive".equals(type)) - { - clip = new TriggerClip(read(in), parameterAdapter.read(in), in.nextString()); - } - else - { - throw new IOException("Unknown Clip type \"" + type + "\""); - } - in.endArray(); - return clip; - case STRING: - String string = in.nextString(); - // IdentityClip - if(string.equals("#identity")) - { - return IdentityClip.INSTANCE; - } - // Clip reference - if(string.startsWith("#")) - { - return new ClipReference(string.substring(1), clipResolver.get()); - } - // ModelClip - else - { - int at = string.lastIndexOf('@'); - String location = string.substring(0, at); - String clipName = string.substring(at + 1, string.length()); - ResourceLocation model; - if(location.indexOf('#') != -1) - { - model = new ModelResourceLocation(location); - } - else - { - model = new ResourceLocation(location); - } - return getModelClipNode(model, clipName); - } - default: - throw new IOException("expected Clip, got " + in.peek()); - } - } - }; - } - } -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java b/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java deleted file mode 100644 index d1fa2c0c8e..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import net.minecraft.client.resources.model.ModelState; -import net.minecraftforge.common.animation.Event; - -import org.apache.commons.lang3.tuple.Pair; - -/** - * State machine representing the model animation. - */ -public interface IAnimationStateMachine -{ - /** - * Sample the state and events at the current time. - * Event iterable will contain all events that happened from the last invocation of this method, from most to least recent. - * Event offset is relative to the previous event, and for the first event it's relative to the current time. - */ - Pair> apply(float time); - - /** - * Transition to a new state. - */ - void transition(String newState); - - /** - * Get current state name. - */ - String currentState(); - - /** - * Set to true if the machine should handle special events that come from the clips (they start with '!'). - * Right now only implemented event is {@literal "!transition:"}. - * Default value is true. - */ - void shouldHandleSpecialEvents(boolean value); -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/IClip.java b/src/main/java/net/minecraftforge/common/model/animation/IClip.java deleted file mode 100644 index eceff45f83..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/IClip.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import net.minecraftforge.common.animation.Event; - - -/** - * Clip for a rigged model. - */ -public interface IClip -{ - IJointClip apply(IJoint joint); - - Iterable pastEvents(float lastPollTime, float time); -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/IJoint.java b/src/main/java/net/minecraftforge/common/model/animation/IJoint.java deleted file mode 100644 index 51a263187f..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/IJoint.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import com.mojang.math.Transformation; - -import java.util.Optional; - -/** - * Model part that's a part of the hierarchical skeleton. - */ -public interface IJoint -{ - Transformation getInvBindPose(); - - Optional getParent(); -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java b/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java deleted file mode 100644 index 274b65b03d..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import com.mojang.math.Transformation; - -/** - * Returns Local joint pose; animation clip for specific model part. - */ -public interface IJointClip -{ - Transformation apply(float time); -} diff --git a/src/main/java/net/minecraftforge/common/model/animation/JointClips.java b/src/main/java/net/minecraftforge/common/model/animation/JointClips.java deleted file mode 100644 index 92e990ab05..0000000000 --- a/src/main/java/net/minecraftforge/common/model/animation/JointClips.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.model.animation; - -import com.mojang.math.Transformation; - -/** - * Various implementations of IJointClip. - */ -public final class JointClips -{ - public static enum IdentityJointClip implements IJointClip - { - INSTANCE; - - @Override - public Transformation apply(float time) - { - return Transformation.identity(); - } - } - - public static class NodeJointClip implements IJointClip - { - private final IJoint child; - private final IClip clip; - - public NodeJointClip(IJoint joint, IClip clip) - { - this.child = joint; - this.clip = clip; - } - - @Override - public Transformation apply(float time) - { - return clip.apply(child).apply(time); - } - } -} diff --git a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java index 898fae5efd..16e9dc1802 100644 --- a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java +++ b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java @@ -31,7 +31,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.core.BlockPos; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.Level; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.server.ServerLifecycleHooks; import javax.annotation.Nullable; @@ -54,10 +54,10 @@ public class BlockSnapshot private final CompoundTag nbt; @Nullable - private WeakReference world; + private WeakReference level; private String toString = null; - private BlockSnapshot(ResourceKey dim, LevelAccessor world, BlockPos pos, BlockState state, @Nullable CompoundTag nbt, int flags) + private BlockSnapshot(ResourceKey dim, LevelAccessor level, BlockPos pos, BlockState state, @Nullable CompoundTag nbt, int flags) { this.dim = dim; this.pos = pos.immutable(); @@ -65,7 +65,7 @@ public class BlockSnapshot this.flags = flags; this.nbt = nbt; - this.world = new WeakReference<>(world); + this.level = new WeakReference<>(level); if (DEBUG) System.out.println("Created " + this.toString()); @@ -78,29 +78,29 @@ public class BlockSnapshot public static BlockSnapshot create(ResourceKey dim, LevelAccessor world, BlockPos pos, int flag) { - return new BlockSnapshot(dim, world, pos, world.getBlockState(pos), getTileNBT(world.getBlockEntity(pos)), flag); + return new BlockSnapshot(dim, world, pos, world.getBlockState(pos), getBlockEntityTag(world.getBlockEntity(pos)), flag); } @Nullable - private static CompoundTag getTileNBT(@Nullable BlockEntity te) + private static CompoundTag getBlockEntityTag(@Nullable BlockEntity te) { return te == null ? null : te.save(new CompoundTag()); } public BlockState getCurrentBlock() { - LevelAccessor world = getWorld(); + LevelAccessor world = getLevel(); return world == null ? Blocks.AIR.defaultBlockState() : world.getBlockState(this.pos); } @Nullable - public LevelAccessor getWorld() + public LevelAccessor getLevel() { - LevelAccessor world = this.world != null ? this.world.get() : null; + LevelAccessor world = this.level != null ? this.level.get() : null; if (world == null) { world = ServerLifecycleHooks.getCurrentServer().getLevel(this.dim); - this.world = new WeakReference(world); + this.level = new WeakReference(world); } return world; } @@ -113,7 +113,7 @@ public class BlockSnapshot @Nullable public BlockEntity getBlockEntity() { - return getNbt() != null ? BlockEntity.loadStatic(getPos(), getReplacedBlock(), getNbt()) : null; + return getTag() != null ? BlockEntity.loadStatic(getPos(), getReplacedBlock(), getTag()) : null; } public boolean restore() @@ -128,7 +128,7 @@ public class BlockSnapshot public boolean restore(boolean force, boolean notifyNeighbors) { - return restoreToLocation(getWorld(), getPos(), force, notifyNeighbors); + return restoreToLocation(getLevel(), getPos(), force, notifyNeighbors); } public boolean restoreToLocation(LevelAccessor world, BlockPos pos, boolean force, boolean notifyNeighbors) @@ -151,12 +151,12 @@ public class BlockSnapshot ((Level)world).sendBlockUpdated(pos, current, replaced, flags); BlockEntity te = null; - if (getNbt() != null) + if (getTag() != null) { te = world.getBlockEntity(pos); if (te != null) { - te.load(getNbt()); + te.load(getTag()); te.setChanged(); } } @@ -190,7 +190,7 @@ public class BlockSnapshot hash = 73 * hash + this.pos.hashCode(); hash = 73 * hash + this.block.hashCode(); hash = 73 * hash + this.flags; - hash = 73 * hash + Objects.hashCode(this.getNbt()); + hash = 73 * hash + Objects.hashCode(this.getTag()); return hash; } @@ -217,6 +217,6 @@ public class BlockSnapshot public int getFlag() { return flags; } @Nullable - public CompoundTag getNbt() { return nbt; } + public CompoundTag getTag() { return nbt; } } diff --git a/src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java b/src/main/java/net/minecraftforge/common/util/CenterChunkPosComparator.java similarity index 93% rename from src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java rename to src/main/java/net/minecraftforge/common/util/CenterChunkPosComparator.java index 62b706937c..107f257b28 100644 --- a/src/main/java/net/minecraftforge/common/util/ChunkCoordComparator.java +++ b/src/main/java/net/minecraftforge/common/util/CenterChunkPosComparator.java @@ -23,12 +23,12 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.ChunkPos; // Sorter to load nearby chunks first -public class ChunkCoordComparator implements java.util.Comparator +public class CenterChunkPosComparator implements java.util.Comparator { private int x; private int z; - public ChunkCoordComparator(ServerPlayer entityplayer) + public CenterChunkPosComparator(ServerPlayer entityplayer) { x = (int) entityplayer.getX() >> 4; z = (int) entityplayer.getZ() >> 4; diff --git a/src/main/java/net/minecraftforge/common/util/Constants.java b/src/main/java/net/minecraftforge/common/util/Constants.java deleted file mode 100644 index 791b32abdf..0000000000 --- a/src/main/java/net/minecraftforge/common/util/Constants.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.common.util; - -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; -import net.minecraft.nbt.TagType; -import net.minecraft.nbt.TagTypes; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.LevelWriter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.LevelEvent; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.LevelChunk; - -/** - * A class containing constants for magic numbers used in the minecraft codebase. - * Everything here should be checked each update, and have a comment relating to where to check it. - * - * @deprecated No longer needed. See inner classes for replacements. - * TODO Remove in 1.18 - */ -@Deprecated(since = "1.17", forRemoval = true) -public class Constants -{ - /** - * NBT Tag type IDS, used when storing the nbt to disc, Should align with {@link TagTypes#getType(int)} - * and {@link TagType#getPrettyName()} - * - * Main use is checking tag type in {@link CompoundTag#contains(String, int)} - * - * @deprecated Replaced by the constants in {@link net.minecraft.nbt.Tag}. - * TODO Remove in 1.18 - */ - @Deprecated(since = "1.17", forRemoval = true) - public static class NBT - { - public static final int TAG_END = Tag.TAG_END; - public static final int TAG_BYTE = Tag.TAG_BYTE; - public static final int TAG_SHORT = Tag.TAG_SHORT; - public static final int TAG_INT = Tag.TAG_INT; - public static final int TAG_LONG = Tag.TAG_LONG; - public static final int TAG_FLOAT = Tag.TAG_FLOAT; - public static final int TAG_DOUBLE = Tag.TAG_DOUBLE; - public static final int TAG_BYTE_ARRAY = Tag.TAG_BYTE_ARRAY; - public static final int TAG_STRING = Tag.TAG_STRING; - public static final int TAG_LIST = Tag.TAG_LIST; - public static final int TAG_COMPOUND = Tag.TAG_COMPOUND; - public static final int TAG_INT_ARRAY = Tag.TAG_INT_ARRAY; - public static final int TAG_LONG_ARRAY = Tag.TAG_LONG_ARRAY; - public static final int TAG_ANY_NUMERIC = Tag.TAG_ANY_NUMERIC; - } - - /** - * The world event IDS, used when calling {@link Level#globalLevelEvent(int, BlockPos, int)}.
- * Can be found from {@link LevelRenderer#globalLevelEvent(int, BlockPos, int)}
- * Some of the events use the {@code data} parameter. If this is the case, an explanation of what {@code data} does is also provided - * - * @deprecated Replaced by the constants in {@link net.minecraft.world.level.block.LevelEvent}. - * TODO Remove in 1.18 - */ - @Deprecated(since = "1.17", forRemoval = true) - public static class WorldEvents { - public static final int DISPENSER_DISPENSE_SOUND = LevelEvent.SOUND_DISPENSER_DISPENSE; - public static final int DISPENSER_FAIL_SOUND = LevelEvent.SOUND_DISPENSER_FAIL; - /** - * Like DISPENSER_DISPENSE_SOUND, but for items that are fired (arrows, eggs, snowballs) - */ - public static final int DISPENSER_LAUNCH_SOUND = LevelEvent.SOUND_DISPENSER_PROJECTILE_LAUNCH; - public static final int ENDEREYE_LAUNCH_SOUND = LevelEvent.SOUND_ENDER_EYE_LAUNCH; - public static final int FIREWORK_SHOOT_SOUND = LevelEvent.SOUND_FIREWORK_SHOOT; - public static final int IRON_DOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_IRON_DOOR; - public static final int WOODEN_DOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_WOODEN_DOOR; - public static final int WOODEN_TRAPDOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_WOODEN_TRAP_DOOR; - public static final int FENCE_GATE_OPEN_SOUND = LevelEvent.SOUND_OPEN_FENCE_GATE; - public static final int FIRE_EXTINGUISH_SOUND = LevelEvent.SOUND_EXTINGUISH_FIRE; - /** - * {@code data} is the item ID of the record you want to play - */ - public static final int PLAY_RECORD_SOUND = LevelEvent.SOUND_PLAY_RECORDING; - public static final int IRON_DOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_IRON_DOOR; - public static final int WOODEN_DOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_WOODEN_DOOR; - public static final int WOODEN_TRAPDOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_WOODEN_TRAP_DOOR; - public static final int FENCE_GATE_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_FENCE_GATE; - public static final int GHAST_WARN_SOUND = LevelEvent.SOUND_GHAST_WARNING; - public static final int GHAST_SHOOT_SOUND = LevelEvent.SOUND_GHAST_FIREBALL; - public static final int ENDERDRAGON_SHOOT_SOUND = LevelEvent.SOUND_DRAGON_FIREBALL; - public static final int BLAZE_SHOOT_SOUND = LevelEvent.SOUND_BLAZE_FIREBALL; - public static final int ZOMBIE_ATTACK_DOOR_WOOD_SOUND = LevelEvent.SOUND_ZOMBIE_WOODEN_DOOR; - public static final int ZOMBIE_ATTACK_DOOR_IRON_SOUND = LevelEvent.SOUND_ZOMBIE_IRON_DOOR; - public static final int ZOMBIE_BREAK_DOOR_WOOD_SOUND = LevelEvent.SOUND_ZOMBIE_DOOR_CRASH; - public static final int WITHER_BREAK_BLOCK_SOUND = LevelEvent.SOUND_WITHER_BLOCK_BREAK; - public static final int WITHER_BREAK_BLOCK = LevelEvent.SOUND_WITHER_BOSS_SPAWN; - public static final int WITHER_SHOOT_SOUND = LevelEvent.SOUND_WITHER_BOSS_SHOOT; - public static final int BAT_TAKEOFF_SOUND = LevelEvent.SOUND_BAT_LIFTOFF; - public static final int ZOMBIE_INFECT_SOUND = LevelEvent.SOUND_ZOMBIE_INFECTED; - public static final int ZOMBIE_VILLAGER_CONVERTED_SOUND = LevelEvent.SOUND_ZOMBIE_CONVERTED; - public static final int ANVIL_DESTROYED_SOUND = LevelEvent.SOUND_ANVIL_BROKEN; - public static final int ANVIL_USE_SOUND = LevelEvent.SOUND_ANVIL_USED; - public static final int ANVIL_LAND_SOUND = LevelEvent.SOUND_ANVIL_LAND; - public static final int PORTAL_TRAVEL_SOUND = LevelEvent.SOUND_PORTAL_TRAVEL; - public static final int CHORUS_FLOWER_GROW_SOUND = LevelEvent.SOUND_CHORUS_GROW; - public static final int CHORUS_FLOWER_DEATH_SOUND = LevelEvent.SOUND_CHORUS_DEATH; - public static final int BREWING_STAND_BREW_SOUND = LevelEvent.SOUND_BREWING_STAND_BREW; - public static final int IRON_TRAPDOOR_CLOSE_SOUND = LevelEvent.SOUND_CLOSE_IRON_TRAP_DOOR; - public static final int IRON_TRAPDOOR_OPEN_SOUND = LevelEvent.SOUND_OPEN_IRON_TRAP_DOOR; - public static final int PHANTOM_BITE_SOUND = LevelEvent.SOUND_PHANTOM_BITE; - public static final int ZOMBIE_CONVERT_TO_DROWNED_SOUND = LevelEvent.SOUND_ZOMBIE_TO_DROWNED; - public static final int HUSK_CONVERT_TO_ZOMBIE_SOUND = LevelEvent.SOUND_HUSK_TO_ZOMBIE; - public static final int GRINDSTONE_USE_SOUND = LevelEvent.SOUND_GRINDSTONE_USED; - public static final int ITEM_BOOK_TURN_PAGE_SOUND = LevelEvent.SOUND_PAGE_TURN; - /** - * Spawns the composter particles and plays the sound event sound event
- * {@code data} is bigger than 0 when the composter can still be filled up, and is smaller or equal to 0 when the composter is full. (This only effects the sound event) - */ - public static final int COMPOSTER_FILLED_UP = LevelEvent.COMPOSTER_FILL; - public static final int LAVA_EXTINGUISH = LevelEvent.LAVA_FIZZ; - public static final int REDSTONE_TORCH_BURNOUT = LevelEvent.REDSTONE_TORCH_BURNOUT; - public static final int END_PORTAL_FRAME_FILL = LevelEvent.END_PORTAL_FRAME_FILL; - /** - * {@code data} is the {@link Direction#get3DDataValue()} of the direction the smoke is to come out of. - */ - public static final int DISPENSER_SMOKE = LevelEvent.PARTICLES_SHOOT; - - /** - * {@code data} is the {@link Block#getId(BlockState)} state id} of the block broken - */ - public static final int BREAK_BLOCK_EFFECTS = LevelEvent.PARTICLES_DESTROY_BLOCK; - /** - * {@code data} is the rgb color int that should be used for the potion particles
- * This is the same as {@link Constants.WorldEvents#POTION_IMPACT} but uses the particle type {@link ParticleTypes#EFFECT} - */ - public static final int POTION_IMPACT_INSTANT = LevelEvent.PARTICLES_SPELL_POTION_SPLASH; - public static final int ENDER_EYE_SHATTER = LevelEvent.PARTICLES_EYE_OF_ENDER_DEATH; - public static final int MOB_SPAWNER_PARTICLES = LevelEvent.PARTICLES_MOBBLOCK_SPAWN; - /** - * {@code data} is the amount of particles to spawn. If {@code data} is 0 then there will be 15 particles spawned - */ - public static final int BONEMEAL_PARTICLES = LevelEvent.PARTICLES_PLANT_GROWTH; - public static final int DRAGON_FIREBALL_HIT = LevelEvent.PARTICLES_DRAGON_FIREBALL_SPLASH; - /** - * {@code data} is the rgb color int that should be used for the potion particles
- * This is the same as {@link Constants.WorldEvents#POTION_IMPACT_INSTANT} but uses the particle type {@link ParticleTypes#INSTANT_EFFECT} - */ - public static final int POTION_IMPACT = LevelEvent.PARTICLES_INSTANT_POTION_SPLASH; - public static final int SPAWN_EXPLOSION_PARTICLE = LevelEvent.PARTICLES_DRAGON_BLOCK_BREAK; - public static final int GATEWAY_SPAWN_EFFECTS = LevelEvent.ANIMATION_END_GATEWAY_SPAWN; - public static final int ENDERMAN_GROWL_SOUND = LevelEvent.ANIMATION_DRAGON_SUMMON_ROAR; - } - - - /** - * The flags used when calling - * {@link LevelWriter#setBlock(BlockPos, BlockState, int)}
- * Can be found from {@link Level#setBlock(BlockPos, BlockState, int)} , - * {@link Level#markAndNotifyBlock(BlockPos, LevelChunk, BlockState, BlockState, int, int)}, and - * {@link LevelRenderer#blockChanged(BlockGetter, BlockPos, BlockState, BlockState, int)}
- * Flags can be combined with bitwise OR - * - * @deprecated Replaced by the constants in {@link net.minecraft.world.level.block.Block}. - * TODO Remove in 1.18 - */ - @Deprecated(since = "1.17", forRemoval = true) - public static class BlockFlags { - /** - * Calls {@link Block#neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean) - * neighborChanged} on surrounding blocks (with isMoving as false). Also updates comparator output state. - */ - public static final int NOTIFY_NEIGHBORS = Block.UPDATE_NEIGHBORS; - /** - * Calls {@link Level#sendBlockUpdated(BlockPos, BlockState, BlockState, int)}.
- * Server-side, this updates all the path-finding navigators. - */ - public static final int BLOCK_UPDATE = Block.UPDATE_CLIENTS; - /** - * Stops the blocks from being marked for a render update - */ - public static final int NO_RERENDER = Block.UPDATE_INVISIBLE; - /** - * Makes the block be re-rendered immediately, on the main thread. - * If NO_RERENDER is set, then this will be ignored - */ - public static final int RERENDER_MAIN_THREAD = Block.UPDATE_IMMEDIATE; - /** - * Causes neighbor updates to be sent to all surrounding blocks (including - * diagonals). This in turn will call - * {@link Block#updateIndirectNeighbourShapes(BlockState, LevelAccessor, BlockPos, int, int)} - * on both old and new states, and - * {@link Block#updateOrDestroy(BlockState, BlockState, LevelAccessor, BlockPos, int, int)} on the new state. - */ - public static final int UPDATE_NEIGHBORS = Block.UPDATE_KNOWN_SHAPE; - - /** - * Prevents neighbor changes from spawning item drops, used by - * {@link Block#updateOrDestroy(BlockState, BlockState, LevelAccessor, BlockPos, int)}. - */ - public static final int NO_NEIGHBOR_DROPS = Block.UPDATE_SUPPRESS_DROPS; - - /** - * Tell the block being changed that it was moved, rather than removed/replaced, - * the boolean value is eventually passed to - * {@link Block#onRemove(BlockState, Level, BlockPos, BlockState, boolean)} - * as the last parameter. - */ - public static final int IS_MOVING = Block.UPDATE_MOVE_BY_PISTON; - - public static final int DEFAULT = Block.UPDATE_ALL; - public static final int DEFAULT_AND_RERENDER = Block.UPDATE_ALL_IMMEDIATE; - } -} diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayer.java b/src/main/java/net/minecraftforge/common/util/FakePlayer.java index 30052dcc65..51d42bb922 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayer.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayer.java @@ -80,7 +80,7 @@ import net.minecraft.stats.Stat; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.server.ServerLifecycleHooks; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java index 3e40efb1f4..456076e44f 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java @@ -36,12 +36,12 @@ public class FakePlayerFactory private static Map fakePlayers = Maps.newHashMap(); private static WeakReference MINECRAFT_PLAYER = null; - public static FakePlayer getMinecraft(ServerLevel world) + public static FakePlayer getMinecraft(ServerLevel level) { FakePlayer ret = MINECRAFT_PLAYER != null ? MINECRAFT_PLAYER.get() : null; if (ret == null) { - ret = FakePlayerFactory.get(world, MINECRAFT); + ret = FakePlayerFactory.get(level, MINECRAFT); MINECRAFT_PLAYER = new WeakReference(ret); } return ret; @@ -52,24 +52,24 @@ public class FakePlayerFactory * Mods should either hold weak references to the return value, or listen for a * WorldEvent.Unload and kill all references to prevent worlds staying in memory. */ - public static FakePlayer get(ServerLevel world, GameProfile username) + public static FakePlayer get(ServerLevel level, GameProfile username) { if (!fakePlayers.containsKey(username)) { - FakePlayer fakePlayer = new FakePlayer(world, username); + FakePlayer fakePlayer = new FakePlayer(level, username); fakePlayers.put(username, fakePlayer); } return fakePlayers.get(username); } - public static void unloadWorld(ServerLevel world) + public static void unloadLevel(ServerLevel level) { - fakePlayers.entrySet().removeIf(entry -> entry.getValue().level == world); - if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().level == world) // This shouldn't be strictly necessary, but lets be aggressive. + fakePlayers.entrySet().removeIf(entry -> entry.getValue().level == level); + if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().level == level) // This shouldn't be strictly necessary, but lets be aggressive. { FakePlayer mc = MINECRAFT_PLAYER.get(); - if (mc != null && mc.level == world) + if (mc != null && mc.level == level) { MINECRAFT_PLAYER = null; } diff --git a/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java b/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java index 226797ebf9..661d9997de 100644 --- a/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java +++ b/src/main/java/net/minecraftforge/common/util/ForgeSoundType.java @@ -22,7 +22,7 @@ package net.minecraftforge.common.util; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.sounds.SoundEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import javax.annotation.Nonnull; diff --git a/src/main/java/net/minecraftforge/fmllegacy/LogicalSidedProvider.java b/src/main/java/net/minecraftforge/common/util/LogicalSidedProvider.java similarity index 61% rename from src/main/java/net/minecraftforge/fmllegacy/LogicalSidedProvider.java rename to src/main/java/net/minecraftforge/common/util/LogicalSidedProvider.java index fb85eaea1a..4475b14dd7 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/LogicalSidedProvider.java +++ b/src/main/java/net/minecraftforge/common/util/LogicalSidedProvider.java @@ -17,10 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.common.util; import net.minecraft.client.Minecraft; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.TickTask; +import net.minecraft.util.thread.BlockableEventLoop; import net.minecraft.world.level.Level; import net.minecraftforge.fml.LogicalSide; @@ -28,21 +30,15 @@ import java.util.Optional; import java.util.function.Function; import java.util.function.Supplier; -public enum LogicalSidedProvider +public class LogicalSidedProvider { - WORKQUEUE((c)->c.get(), (s)->s.get()), - INSTANCE((c)->c.get(), (s)->s.get()), - CLIENTWORLD((c)-> Optional.of(c.get().level), (s)->Optional.empty()) - ; + public static final LogicalSidedProvider> WORKQUEUE = new LogicalSidedProvider<>(Supplier::get, Supplier::get); + public static final LogicalSidedProvider> CLIENTWORLD = new LogicalSidedProvider<>((c)-> Optional.of(c.get().level), (s)->Optional.empty()); + private static Supplier client; private static Supplier server; - LogicalSidedProvider(Function, ?> clientSide, Function, ?> serverSide) - { - this.clientSide = clientSide; - this.serverSide = serverSide; - } - + // INTERNAL, DO NOT CALL public static void setClient(Supplier client) { LogicalSidedProvider.client = client; @@ -52,12 +48,16 @@ public enum LogicalSidedProvider LogicalSidedProvider.server = server; } + private LogicalSidedProvider(Function, T> clientSide, Function, T> serverSide) + { + this.clientSide = clientSide; + this.serverSide = serverSide; + } - private final Function, ?> clientSide; - private final Function, ?> serverSide; + private final Function, T> clientSide; + private final Function, T> serverSide; - @SuppressWarnings("unchecked") - public T get(final LogicalSide side) { - return (T)(side==LogicalSide.CLIENT ? clientSide.apply(client) : serverSide.apply(server)); + public T get(final LogicalSide side) { + return side==LogicalSide.CLIENT ? clientSide.apply(client) : serverSide.apply(server); } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/MavenVersionStringHelper.java b/src/main/java/net/minecraftforge/common/util/MavenVersionStringHelper.java similarity index 95% rename from src/main/java/net/minecraftforge/fmllegacy/MavenVersionStringHelper.java rename to src/main/java/net/minecraftforge/common/util/MavenVersionStringHelper.java index d44271a9f9..672ff4f2f7 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/MavenVersionStringHelper.java +++ b/src/main/java/net/minecraftforge/common/util/MavenVersionStringHelper.java @@ -17,8 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.common.util; +import net.minecraftforge.common.ForgeI18n; import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.Restriction; import org.apache.maven.artifact.versioning.VersionRange; @@ -90,7 +91,7 @@ public class MavenVersionStringHelper { } } - public static void parseVersionRange(final String formatString, final StringBuffer stringBuffer, final Object range) { + public static void parseVersionRange(final StringBuffer stringBuffer, final Object range) { stringBuffer.append(versionRangeToString((VersionRange) range)); } } diff --git a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java index 91231c00ed..bfe46dc2d9 100644 --- a/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/BiomeGenerationSettingsBuilder.java @@ -22,39 +22,26 @@ package net.minecraftforge.common.world; import net.minecraft.world.level.biome.BiomeGenerationSettings; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; -import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; -import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; -import net.minecraft.world.level.levelgen.surfacebuilders.ConfiguredSurfaceBuilder; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.function.Supplier; public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Builder { public BiomeGenerationSettingsBuilder(BiomeGenerationSettings orig) { - surfaceBuilder = Optional.of(orig.getSurfaceBuilder()); orig.getCarvingStages().forEach(k -> carvers.put(k, new ArrayList<>(orig.getCarvers(k)))); orig.features().forEach(l -> features.add(new ArrayList<>(l))); - structureStarts.addAll(orig.structures()); } - public List>> getFeatures(GenerationStep.Decoration stage) { + public List> getFeatures(GenerationStep.Decoration stage) { addFeatureStepsUpTo(stage.ordinal()); return features.get(stage.ordinal()); } - public Optional>> getSurfaceBuilder() { - return surfaceBuilder; - } - public List>> getCarvers(GenerationStep.Carving stage) { return carvers.computeIfAbsent(stage, key -> new ArrayList<>()); } - - public List>> getStructures() { - return structureStarts; - } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/ForgeWorldType.java b/src/main/java/net/minecraftforge/common/world/ForgeWorldPreset.java similarity index 62% rename from src/main/java/net/minecraftforge/common/world/ForgeWorldType.java rename to src/main/java/net/minecraftforge/common/world/ForgeWorldPreset.java index a0fc274ec8..d39a766c9d 100644 --- a/src/main/java/net/minecraftforge/common/world/ForgeWorldType.java +++ b/src/main/java/net/minecraftforge/common/world/ForgeWorldPreset.java @@ -37,18 +37,18 @@ import net.minecraftforge.registries.ForgeRegistryEntry; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class ForgeWorldType extends ForgeRegistryEntry +public class ForgeWorldPreset extends ForgeRegistryEntry { private static final Logger LOGGER = LogManager.getLogger(); - public static ForgeWorldType getDefaultWorldType() + public static ForgeWorldPreset getDefaultWorldPreset() { String defaultWorldType = ForgeConfig.COMMON.defaultWorldType.get(); if (StringUtil.isNullOrEmpty(defaultWorldType) || "default".equals(defaultWorldType)) return null; // use vanilla - ForgeWorldType def = ForgeRegistries.WORLD_TYPES.getValue(new ResourceLocation(defaultWorldType)); + ForgeWorldPreset def = ForgeRegistries.WORLD_TYPES.getValue(new ResourceLocation(defaultWorldType)); if (def == null) { LOGGER.error("The defaultWorldType '{}' specified in the forge config has not been registered. The vanilla default generator will be used.", defaultWorldType); @@ -59,12 +59,12 @@ public class ForgeWorldType extends ForgeRegistryEntry private final IChunkGeneratorFactory factory; - public ForgeWorldType(IChunkGeneratorFactory factory) + public ForgeWorldPreset(IChunkGeneratorFactory factory) { this.factory = factory; } - public ForgeWorldType(IBasicChunkGeneratorFactory factory) + public ForgeWorldPreset(IBasicChunkGeneratorFactory factory) { this.factory = factory; } @@ -84,38 +84,36 @@ public class ForgeWorldType extends ForgeRegistryEntry * to construct the DimensionGEneratorSettings: * @return The constructed chunk generator. */ - public ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings) + public ChunkGenerator createChunkGenerator(RegistryAccess registryAccess, long seed, String generatorSettings) { - return this.factory.createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed, generatorSettings); + return this.factory.createChunkGenerator(registryAccess, seed, generatorSettings); } - public WorldGenSettings createSettings(RegistryAccess dynamicRegistries, long seed, boolean generateStructures, boolean generateLoot, String generatorSettings) + public WorldGenSettings createSettings(RegistryAccess registryAccess, long seed, boolean generateStructures, boolean generateLoot, String generatorSettings) { - return this.factory.createSettings(dynamicRegistries, seed, generateStructures, generateLoot, generatorSettings); + return this.factory.createSettings(registryAccess, seed, generateStructures, generateLoot, generatorSettings); } public interface IChunkGeneratorFactory { - ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings); + ChunkGenerator createChunkGenerator(RegistryAccess dynamicRegistries, long seed, String generatorSettings); default WorldGenSettings createSettings(RegistryAccess dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest, String generatorSettings) { - Registry biomeRegistry = dynamicRegistries.registryOrThrow(Registry.BIOME_REGISTRY); Registry dimensionTypeRegistry = dynamicRegistries.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY); - Registry dimensionSettingsRegistry = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY); return new WorldGenSettings(seed, generateStructures, bonusChest, WorldGenSettings.withOverworld(dimensionTypeRegistry, - DimensionType.defaultDimensions(dimensionTypeRegistry, biomeRegistry, dimensionSettingsRegistry, seed), - createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed, generatorSettings))); + DimensionType.defaultDimensions(dynamicRegistries, seed), + createChunkGenerator(dynamicRegistries, seed, generatorSettings))); } } public interface IBasicChunkGeneratorFactory extends IChunkGeneratorFactory { - ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed); + ChunkGenerator createChunkGenerator(RegistryAccess registryAccess, long seed); - default ChunkGenerator createChunkGenerator(Registry biomeRegistry, Registry dimensionSettingsRegistry, long seed, String generatorSettings) + default ChunkGenerator createChunkGenerator(RegistryAccess registryAccess, long seed, String generatorSettings) { - return createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed); + return createChunkGenerator(registryAccess, seed); } } } diff --git a/src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java b/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java similarity index 89% rename from src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java rename to src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java index 9d3cd7f665..28a6875311 100644 --- a/src/main/java/net/minecraftforge/common/world/MobSpawnInfoBuilder.java +++ b/src/main/java/net/minecraftforge/common/world/MobSpawnSettingsBuilder.java @@ -29,12 +29,12 @@ import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.biome.MobSpawnSettings; -public class MobSpawnInfoBuilder extends MobSpawnSettings.Builder +public class MobSpawnSettingsBuilder extends MobSpawnSettings.Builder { private final Set typesView = Collections.unmodifiableSet(this.spawners.keySet()); private final Set> costView = Collections.unmodifiableSet(this.mobSpawnCosts.keySet()); - public MobSpawnInfoBuilder(MobSpawnSettings orig) + public MobSpawnSettingsBuilder(MobSpawnSettings orig) { orig.getSpawnerTypes().forEach(k -> { spawners.get(k).clear(); @@ -42,7 +42,6 @@ public class MobSpawnInfoBuilder extends MobSpawnSettings.Builder }); orig.getEntityTypes().forEach(k -> mobSpawnCosts.put(k, orig.getMobSpawnCost(k))); creatureGenerationProbability = orig.getCreatureProbability(); - playerCanSpawn = orig.playerSpawnFriendly(); } public Set getSpawnerTypes() @@ -71,9 +70,8 @@ public class MobSpawnInfoBuilder extends MobSpawnSettings.Builder return this.creatureGenerationProbability; } - public MobSpawnInfoBuilder disablePlayerSpawn() + public MobSpawnSettingsBuilder disablePlayerSpawn() { - this.playerCanSpawn = false; return this; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java b/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java index 759f61de6c..ecf61869f8 100644 --- a/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java +++ b/src/main/java/net/minecraftforge/common/world/StructureSpawnManager.java @@ -98,7 +98,7 @@ public class StructureSpawnManager StructureFeature structure = entry.getKey(); StructureSpawnInfo spawnInfo = entry.getValue(); //Note: We check if the structure has spawns for a type first before looking at the world as it should be a cheaper check - if (spawnInfo.spawns.containsKey(classification) && structureManager.getStructureAt(pos, spawnInfo.insideOnly, structure).isValid()) + if (spawnInfo.spawns.containsKey(classification) && structureManager.getStructureAt(pos, structure).isValid()) return spawnInfo.spawns.get(classification); } return null; diff --git a/src/main/java/net/minecraftforge/fmllegacy/DatagenModLoader.java b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java similarity index 98% rename from src/main/java/net/minecraftforge/fmllegacy/DatagenModLoader.java rename to src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java index 9554d22330..20e17d9338 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/DatagenModLoader.java +++ b/src/main/java/net/minecraftforge/data/loading/DatagenModLoader.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.data.loading; import java.util.Collections; import net.minecraft.server.Bootstrap; diff --git a/src/main/java/net/minecraftforge/fmllegacy/common/registry/IEntityAdditionalSpawnData.java b/src/main/java/net/minecraftforge/entity/IEntityAdditionalSpawnData.java similarity index 96% rename from src/main/java/net/minecraftforge/fmllegacy/common/registry/IEntityAdditionalSpawnData.java rename to src/main/java/net/minecraftforge/entity/IEntityAdditionalSpawnData.java index 9baa02aea5..7ea49b7973 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/common/registry/IEntityAdditionalSpawnData.java +++ b/src/main/java/net/minecraftforge/entity/IEntityAdditionalSpawnData.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.common.registry; +package net.minecraftforge.entity; import net.minecraft.network.FriendlyByteBuf; diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index a115e495b0..3338162993 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -31,6 +31,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.brigadier.CommandDispatcher; import net.minecraft.server.players.PlayerList; +import net.minecraft.world.Container; import net.minecraft.world.entity.projectile.FireworkRocketEntity; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ThrownEnderpearl; @@ -88,6 +89,7 @@ import net.minecraft.world.level.storage.ServerLevelData; import net.minecraft.world.level.storage.PlayerDataStorage; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.ClientChatEvent; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderBlockOverlayEvent; @@ -148,6 +150,7 @@ import net.minecraftforge.event.world.SleepFinishedTimeEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.Event.Result; +import net.minecraftforge.fml.LogicalSide; public class ForgeEventFactory { @@ -155,14 +158,14 @@ public class ForgeEventFactory public static boolean onMultiBlockPlace(@Nullable Entity entity, List blockSnapshots, Direction direction) { BlockSnapshot snap = blockSnapshots.get(0); - BlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().relative(direction.getOpposite())); + BlockState placedAgainst = snap.getLevel().getBlockState(snap.getPos().relative(direction.getOpposite())); EntityMultiPlaceEvent event = new EntityMultiPlaceEvent(blockSnapshots, placedAgainst, entity); return MinecraftForge.EVENT_BUS.post(event); } public static boolean onBlockPlace(@Nullable Entity entity, @Nonnull BlockSnapshot blockSnapshot, @Nonnull Direction direction) { - BlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().relative(direction.getOpposite())); + BlockState placedAgainst = blockSnapshot.getLevel().getBlockState(blockSnapshot.getPos().relative(direction.getOpposite())); EntityPlaceEvent event = new BlockEvent.EntityPlaceEvent(blockSnapshot, placedAgainst, entity); return MinecraftForge.EVENT_BUS.post(event); } @@ -796,4 +799,90 @@ public class ForgeEventFactory } return false; } + + public static void firePlayerChangedDimensionEvent(Player player, ResourceKey fromDim, ResourceKey toDim) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); + } + + public static void firePlayerLoggedIn(Player player) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedInEvent(player)); + } + + public static void firePlayerLoggedOut(Player player) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedOutEvent(player)); + } + + public static void firePlayerRespawnEvent(Player player, boolean endConquered) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerRespawnEvent(player, endConquered)); + } + + public static void firePlayerItemPickupEvent(Player player, ItemEntity item, ItemStack clone) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemPickupEvent(player, item, clone)); + } + + public static void firePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); + } + + public static void firePlayerSmeltedEvent(Player player, ItemStack smelted) + { + MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); + } + + public static void onRenderTickStart(float timer) + { + MinecraftForgeClient.setPartialTick(timer); + MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.START, timer)); + } + + public static void onRenderTickEnd(float timer) + { + MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.END, timer)); + } + + public static void onPlayerPreTick(Player player) + { + MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.START, player)); + } + + public static void onPlayerPostTick(Player player) + { + MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.END, player)); + } + + public static void onPreWorldTick(Level world) + { + MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.START, world)); + } + + public static void onPostWorldTick(Level world) + { + MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.END, world)); + } + + public static void onPreClientTick() + { + MinecraftForge.EVENT_BUS.post(new TickEvent.ClientTickEvent(TickEvent.Phase.START)); + } + + public static void onPostClientTick() + { + MinecraftForge.EVENT_BUS.post(new TickEvent.ClientTickEvent(TickEvent.Phase.END)); + } + + public static void onPreServerTick() + { + MinecraftForge.EVENT_BUS.post(new TickEvent.ServerTickEvent(TickEvent.Phase.START)); + } + + public static void onPostServerTick() + { + MinecraftForge.EVENT_BUS.post(new TickEvent.ServerTickEvent(TickEvent.Phase.END)); + } } diff --git a/src/main/java/net/minecraftforge/event/RegistryEvent.java b/src/main/java/net/minecraftforge/event/RegistryEvent.java index b3074e18e3..e3236e160e 100644 --- a/src/main/java/net/minecraftforge/event/RegistryEvent.java +++ b/src/main/java/net/minecraftforge/event/RegistryEvent.java @@ -20,8 +20,15 @@ package net.minecraftforge.event; import java.util.Collection; +import java.util.Comparator; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.event.IModBusEvent; import net.minecraftforge.registries.RegistryBuilder; import org.apache.commons.lang3.Validate; @@ -253,4 +260,63 @@ public class RegistryEvent> extends GenericEven } } } + + /** + * Called whenever the ID mapping might have changed. If you register for this event, you + * will be called back whenever the client or server loads an ID set. This includes both + * when the ID maps are loaded from disk, as well as when the ID maps revert to the initial + * state. + * + * Note: you cannot change the IDs that have been allocated, but you might want to use + * this event to update caches or other in-mod artifacts that might be impacted by an ID + * change. + * + * Fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} + */ + public static class IdMappingEvent extends Event + { + public static class ModRemapping + { + public final ResourceLocation registry; + public final ResourceLocation key; + public final int oldId; + public final int newId; + + private ModRemapping(ResourceLocation registry, ResourceLocation key, int oldId, int newId) + { + this.registry = registry; + this.key = key; + this.oldId = oldId; + this.newId = newId; + } + } + + private final Map> remaps; + private final ImmutableSet keys; + + public final boolean isFrozen; + public IdMappingEvent(Map> remaps, boolean isFrozen) + { + this.isFrozen = isFrozen; + this.remaps = Maps.newHashMap(); + remaps.forEach((name, rm) -> + { + List tmp = Lists.newArrayList(); + rm.forEach((key, value) -> tmp.add(new ModRemapping(name, key, value[0], value[1]))); + tmp.sort(Comparator.comparingInt(o -> o.newId)); + this.remaps.put(name, ImmutableList.copyOf(tmp)); + }); + this.keys = ImmutableSet.copyOf(this.remaps.keySet()); + } + + public ImmutableSet getRegistries() + { + return this.keys; + } + + public ImmutableList getRemaps(ResourceLocation registry) + { + return this.remaps.get(registry); + } + } } diff --git a/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java b/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java index 5ef757691d..0c814c6c0f 100644 --- a/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java +++ b/src/main/java/net/minecraftforge/event/TagsUpdatedEvent.java @@ -42,7 +42,7 @@ public class TagsUpdatedEvent extends Event } /** - * @return The network tag manager that has been updated with newly received tags. + * @return The impl tag manager that has been updated with newly received tags. */ public TagContainer getTagManager() { diff --git a/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java b/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java index a812cd0be4..172c60b56a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/PotionEvent.java @@ -129,12 +129,6 @@ public class PotionEvent extends LivingEvent private final MobEffectInstance oldEffect; private final Entity source; - @Deprecated(forRemoval = true, since = "1.17.1") - public PotionAddedEvent(LivingEntity living, MobEffectInstance oldEffect, MobEffectInstance newEffect) - { - this(living, oldEffect, newEffect, null); - } - public PotionAddedEvent(LivingEntity living, MobEffectInstance oldEffect, MobEffectInstance newEffect, Entity source) { super(living, newEffect); diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java index 4dcd68b9ca..da1a447888 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -219,7 +219,7 @@ public class PlayerEvent extends LivingEvent } /** - * Fired when the EntityPlayer is cloned, typically caused by the network sending a RESPAWN_PLAYER event. + * Fired when the EntityPlayer is cloned, typically caused by the impl sending a RESPAWN_PLAYER event. * Either caused by death, or by traveling from the End to the overworld. */ public static class Clone extends PlayerEvent diff --git a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerAboutToStartEvent.java b/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java similarity index 83% rename from src/main/java/net/minecraftforge/fmlserverevents/FMLServerAboutToStartEvent.java rename to src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java index e61de3397d..fddfd3fbef 100644 --- a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerAboutToStartEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerAboutToStartEvent.java @@ -17,21 +17,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlserverevents; +package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; /** * Called before the server begins loading anything. Called after {@link InterModProcessEvent} on the dedicated - * server, and after the player has hit "Play Selected World" in the client. Called before {@link FMLServerStartingEvent}. + * server, and after the player has hit "Play Selected World" in the client. Called before {@link ServerStartingEvent}. * * You can obtain a reference to the server with this event. * @author cpw */ -public class FMLServerAboutToStartEvent extends ServerLifecycleEvent { +public class ServerAboutToStartEvent extends ServerLifecycleEvent { - public FMLServerAboutToStartEvent(MinecraftServer server) + public ServerAboutToStartEvent(MinecraftServer server) { super(server); } diff --git a/src/main/java/net/minecraftforge/fmlserverevents/ServerLifecycleEvent.java b/src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java similarity index 96% rename from src/main/java/net/minecraftforge/fmlserverevents/ServerLifecycleEvent.java rename to src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java index 47fe9a03a7..27bccaf2aa 100644 --- a/src/main/java/net/minecraftforge/fmlserverevents/ServerLifecycleEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerLifecycleEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlserverevents; +package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; import net.minecraftforge.eventbus.api.Event; diff --git a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartedEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java similarity index 76% rename from src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartedEvent.java rename to src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java index 39283fb957..265245c22d 100644 --- a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartedEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStartedEvent.java @@ -17,19 +17,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlserverevents; +package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; /** - * Called after {@link FMLServerStartingEvent} when the server is available and ready to play. + * Called after {@link ServerStartingEvent} when the server is available and ready to play. * * @author cpw */ -public class FMLServerStartedEvent extends ServerLifecycleEvent +public class ServerStartedEvent extends ServerLifecycleEvent { - public FMLServerStartedEvent(final MinecraftServer server) + public ServerStartedEvent(final MinecraftServer server) { super(server); } diff --git a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartingEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java similarity index 79% rename from src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartingEvent.java rename to src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java index ab2b99a32f..e0fd7e5a25 100644 --- a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStartingEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStartingEvent.java @@ -17,21 +17,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlserverevents; +package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; /** - * Called after {@link FMLServerAboutToStartEvent} and before {@link FMLServerStartedEvent}. + * Called after {@link ServerAboutToStartEvent} and before {@link ServerStartedEvent}. * This event allows for customizations of the server. * * If you need to add commands use {@link net.minecraftforge.event.RegisterCommandsEvent}. * * @author cpw */ -public class FMLServerStartingEvent extends ServerLifecycleEvent +public class ServerStartingEvent extends ServerLifecycleEvent { - public FMLServerStartingEvent(final MinecraftServer server) + public ServerStartingEvent(final MinecraftServer server) { super(server); } diff --git a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppedEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java similarity index 79% rename from src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppedEvent.java rename to src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java index 760d5bfbc1..3be3b679ed 100644 --- a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppedEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStoppedEvent.java @@ -17,19 +17,19 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlserverevents; +package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; /** - * Called after {@link FMLServerStoppingEvent} when the server has completely shut down. + * Called after {@link ServerStoppingEvent} when the server has completely shut down. * Called immediately before shutting down, on the dedicated server, and before returning * to the main menu on the client. * * @author cpw */ -public class FMLServerStoppedEvent extends ServerLifecycleEvent { - public FMLServerStoppedEvent(MinecraftServer server) +public class ServerStoppedEvent extends ServerLifecycleEvent { + public ServerStoppedEvent(MinecraftServer server) { super(server); } diff --git a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppingEvent.java b/src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java similarity index 82% rename from src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppingEvent.java rename to src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java index f6d60c2649..c82f70fef9 100644 --- a/src/main/java/net/minecraftforge/fmlserverevents/FMLServerStoppingEvent.java +++ b/src/main/java/net/minecraftforge/event/server/ServerStoppingEvent.java @@ -17,18 +17,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmlserverevents; +package net.minecraftforge.event.server; import net.minecraft.server.MinecraftServer; /** - * Called when the server begins an orderly shutdown, before {@link FMLServerStoppedEvent}. + * Called when the server begins an orderly shutdown, before {@link ServerStoppedEvent}. * * @author cpw */ -public class FMLServerStoppingEvent extends ServerLifecycleEvent +public class ServerStoppingEvent extends ServerLifecycleEvent { - public FMLServerStoppingEvent(MinecraftServer server) + public ServerStoppingEvent(MinecraftServer server) { super(server); } diff --git a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java index 1ba57ac57c..6f49f82a2a 100644 --- a/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/VillagerTradesEvent.java @@ -25,20 +25,20 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.world.entity.npc.VillagerData; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; -import net.minecraftforge.common.BasicTrade; +import net.minecraftforge.common.BasicItemListing; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; +import net.minecraftforge.event.server.ServerAboutToStartEvent; /** - * VillagerTradesEvent is fired during the {@link FMLServerAboutToStartEvent}. It is used to gather the trade lists for each profession. + * VillagerTradesEvent is fired during the {@link ServerAboutToStartEvent}. It is used to gather the trade lists for each profession. * It is fired on the {@link MinecraftForge#EVENT_BUS}. * It is fired once for each registered villager profession. * Villagers pick two trades from their trade map, based on their level. * Villager level is increased by successful trades. * The map is populated for levels 1-5 (inclusive), so Map#get will never return null for those keys. * Levels outside of this range do nothing, as specified by {@link VillagerData#canLevelUp(int)} which is called before attempting to level up. - * To add trades to the merchant, simply add new trades to the list. {@link BasicTrade} provides a default implementation. + * To add trades to the merchant, simply add new trades to the list. {@link BasicItemListing} provides a default implementation. */ public class VillagerTradesEvent extends Event { diff --git a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java index d7e8b530bc..da6055d8cd 100644 --- a/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java +++ b/src/main/java/net/minecraftforge/event/village/WandererTradesEvent.java @@ -22,16 +22,16 @@ package net.minecraftforge.event.village; import java.util.List; import net.minecraft.world.entity.npc.VillagerTrades.ItemListing; -import net.minecraftforge.common.BasicTrade; +import net.minecraftforge.common.BasicItemListing; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; +import net.minecraftforge.event.server.ServerAboutToStartEvent; /** - * WandererTradesEvent is fired during the {@link FMLServerAboutToStartEvent}. It is used to gather the trade lists for the wandering merchant. + * WandererTradesEvent is fired during the {@link ServerAboutToStartEvent}. It is used to gather the trade lists for the wandering merchant. * It is fired on the {@link MinecraftForge#EVENT_BUS}. * The wandering merchant picks a few trades from {@code generic} and a single trade from {@code rare}. - * To add trades to the merchant, simply add new trades to the list. {@link BasicTrade} provides a default implementation. + * To add trades to the merchant, simply add new trades to the list. {@link BasicItemListing} provides a default implementation. */ public class WandererTradesEvent extends Event { diff --git a/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java b/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java index b89ea2bdd1..41e396daf1 100644 --- a/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BiomeLoadingEvent.java @@ -23,7 +23,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeSpecialEffects; import net.minecraftforge.common.world.BiomeGenerationSettingsBuilder; -import net.minecraftforge.common.world.MobSpawnInfoBuilder; +import net.minecraftforge.common.world.MobSpawnSettingsBuilder; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.EventPriority; @@ -48,19 +48,15 @@ public class BiomeLoadingEvent extends Event private final ResourceLocation name; private Biome.ClimateSettings climate; private Biome.BiomeCategory category; - private float depth; - private float scale; private BiomeSpecialEffects effects; private final BiomeGenerationSettingsBuilder gen; - private final MobSpawnInfoBuilder spawns; + private final MobSpawnSettingsBuilder spawns; - public BiomeLoadingEvent(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final float depth, final float scale, final BiomeSpecialEffects effects, final BiomeGenerationSettingsBuilder gen, final MobSpawnInfoBuilder spawns) + public BiomeLoadingEvent(@Nullable final ResourceLocation name, final Biome.ClimateSettings climate, final Biome.BiomeCategory category, final BiomeSpecialEffects effects, final BiomeGenerationSettingsBuilder gen, final MobSpawnSettingsBuilder spawns) { this.name = name; this.climate = climate; this.category = category; - this.depth = depth; - this.scale = scale; this.effects = effects; this.gen = gen; this.spawns = spawns; @@ -97,26 +93,6 @@ public class BiomeLoadingEvent extends Event this.category = value; } - public float getDepth() - { - return depth; - } - - public void setDepth(final float value) - { - this.depth = value; - } - - public float getScale() - { - return scale; - } - - public void setScale(final float value) - { - this.scale = value; - } - public BiomeSpecialEffects getEffects() { return effects; @@ -132,7 +108,7 @@ public class BiomeLoadingEvent extends Event return gen; } - public MobSpawnInfoBuilder getSpawns() + public MobSpawnSettingsBuilder getSpawns() { return spawns; } diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index 45b9cc5fa6..4e5bf4bad1 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -143,7 +143,7 @@ public class BlockEvent extends Event public EntityPlaceEvent(@Nonnull BlockSnapshot blockSnapshot, @Nonnull BlockState placedAgainst, @Nullable Entity entity) { - super(blockSnapshot.getWorld(), blockSnapshot.getPos(), !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock()); + super(blockSnapshot.getLevel(), blockSnapshot.getPos(), !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock()); this.entity = entity; this.blockSnapshot = blockSnapshot; this.placedBlock = !(entity instanceof Player) ? blockSnapshot.getReplacedBlock() : blockSnapshot.getCurrentBlock(); diff --git a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java index 99f79d8df8..1e7a5163ed 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java @@ -24,7 +24,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkBiomeContainer; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraftforge.common.MinecraftForge; @@ -66,7 +65,7 @@ public class ChunkEvent extends WorldEvent /** * ChunkEvent.Load is fired when vanilla Minecraft attempts to load a Chunk into the world.
* This event is fired during chunk loading in
- * {@link ClientChunkCache#replaceWithPacketData(int, int, ChunkBiomeContainer, FriendlyByteBuf, CompoundTag, BitSet)},
+ * * Chunk.onChunkLoad().
* Note: This event may be called before the underlying {@link LevelChunk} is promoted to {@link ChunkStatus#FULL}. You will cause chunk loading deadlocks if you don't delay your world interactions.
*
diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index a852bdd658..5007396544 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -56,7 +56,7 @@ public class FluidStack public static final Codec CODEC = RecordCodecBuilder.create( instance -> instance.group( - Registry.FLUID.fieldOf("FluidName").forGetter(FluidStack::getFluid), + Registry.FLUID.byNameCodec().fieldOf("FluidName").forGetter(FluidStack::getFluid), Codec.INT.fieldOf("Amount").forGetter(FluidStack::getAmount), CompoundTag.CODEC.optionalFieldOf("Tag").forGetter(stack -> Optional.ofNullable(stack.getTag())) ).apply(instance, (fluid, amount, tag) -> { diff --git a/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java b/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java index 74845e2e12..fd7601b427 100644 --- a/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/capability/TileFluidHandler.java @@ -54,7 +54,7 @@ public class TileFluidHandler extends BlockEntity @Override public CompoundTag save(CompoundTag tag) { - tag = super.save(tag); + super.save(tag); tank.writeToNBT(tag); return tag; } diff --git a/src/main/java/net/minecraftforge/fmlclient/ClientHooks.java b/src/main/java/net/minecraftforge/fmlclient/ClientHooks.java deleted file mode 100644 index db68da180e..0000000000 --- a/src/main/java/net/minecraftforge/fmlclient/ClientHooks.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmlclient; - -import com.mojang.blaze3d.vertex.PoseStack; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; -import net.minecraft.client.multiplayer.MultiPlayerGameMode; -import net.minecraftforge.client.ForgeHooksClient; - -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.network.Connection; -import net.minecraft.network.protocol.status.ServerStatus; -import net.minecraft.resources.ResourceLocation; - -@Deprecated(since="1.18", forRemoval = true) -public class ClientHooks -{ - @Deprecated(since="1.18", forRemoval = true) - public static void processForgeListPingData(ServerStatus packet, ServerData target) - { - ForgeHooksClient.processForgeListPingData(packet, target); - } - - @Deprecated(since="1.18", forRemoval = true) - public static void drawForgePingInfo(JoinMultiplayerScreen gui, ServerData target, PoseStack mStack, int x, int y, int width, int relativeMouseX, int relativeMouseY) - { - ForgeHooksClient.drawForgePingInfo(gui, target, mStack, x, y, width, relativeMouseX, relativeMouseY); - } - - @Deprecated(since="1.18", forRemoval = true) - public static String fixDescription(String description) - { - return description.endsWith(":NOFML§r") ? description.substring(0, description.length() - 8)+"§r" : description; - } - - @Deprecated(since="1.18", forRemoval = true) - public static void handleClientWorldClosing(ClientLevel world) - { - ForgeHooksClient.handleClientWorldClosing(world); - } - - @Deprecated(since="1.18", forRemoval = true) - public static void trackMissingTexture(ResourceLocation resourceLocation) - { - } - - @Deprecated(since="1.18", forRemoval = true) - public static void trackBrokenTexture(ResourceLocation resourceLocation, String error) - { - } - - @Deprecated(since="1.18", forRemoval = true) - public static void logMissingTextureErrors() - { - } - - @Deprecated(since="1.18", forRemoval = true) - public static void firePlayerLogin(MultiPlayerGameMode pc, LocalPlayer player, Connection networkManager) { - ForgeHooksClient.firePlayerLogin(pc, player, networkManager); - } - - @Deprecated(since="1.18", forRemoval = true) - public static void firePlayerLogout(MultiPlayerGameMode pc, LocalPlayer player) { - ForgeHooksClient.firePlayerLogout(pc, player); - } - - @Deprecated(since="1.18", forRemoval = true) - public static void firePlayerRespawn(MultiPlayerGameMode pc, LocalPlayer oldPlayer, LocalPlayer newPlayer, Connection networkManager) { - ForgeHooksClient.firePlayerRespawn(pc, oldPlayer, newPlayer, networkManager); - } - - -} diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/screen/ConfirmationScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/ConfirmationScreen.java deleted file mode 100644 index ea1c5e990d..0000000000 --- a/src/main/java/net/minecraftforge/fmlclient/gui/screen/ConfirmationScreen.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* -package net.minecraftforge.fml.client.gui.screen; - -public class ConfirmationScreen extends NotificationScreen -{ - public ConfirmationScreen(StartupQuery query) - { - super(query); - } - - @Override - protected void addConfirmationButtons() - { - this.addButton(new Button(this.width / 2 - 104, this.height - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.yes")), b -> - { - ConfirmationScreen.this.minecraft.currentScreen = null; - query.setResult(true); - query.finish(); - } - )); - this.addButton(new Button(this.width / 2 + 4, this.height - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.no")), b -> - { - ConfirmationScreen.this.minecraft.currentScreen = null; - query.setResult(false); - query.finish(); - } - )); - } -} -*/ diff --git a/src/main/java/net/minecraftforge/fmlclient/gui/screen/NotificationScreen.java b/src/main/java/net/minecraftforge/fmlclient/gui/screen/NotificationScreen.java deleted file mode 100644 index 6df13826aa..0000000000 --- a/src/main/java/net/minecraftforge/fmlclient/gui/screen/NotificationScreen.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* -package net.minecraftforge.fml.client.gui.screen; - -public class NotificationScreen extends Screen -{ - private class TextPanel extends ScrollPanel - { - TextPanel(Minecraft client, int width, int height, int top, int left) - { - super(client, width, height, top, left); - } - - @Override - protected int getContentHeight() - { - int height = 0; - height += (textLines.length * font.FONT_HEIGHT) + 4; - if (height < this.height - 50) - height = this.height - 50; - return height; - } - - @Override - protected void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY) - { - drawCenteredLines(mStack, relativeY, textLines); - } - - @Override - protected int getScrollAmount() - { - return font.FONT_HEIGHT * 3; - } - } - - protected static final int PADDING = 6; - - protected final StartupQuery query; - - private final String[] headerLines; - private final String[] textLines; - private final String action; - - private ScrollPanel textPanel; - - public NotificationScreen(StartupQuery query) - { - super(new TranslationTextComponent("fml.menu.notification.title")); - this.query = query; - this.headerLines = query.getHeader().isEmpty() ? new String[0] : query.getHeader().split("\n"); - this.textLines = query.getText().split("\n"); - this.action = query.getAction(); - } - - @Override - public void init() - { - super.init(); - int panelY = PADDING + headerLines.length * font.FONT_HEIGHT + PADDING; - int panelHeight = this.height - PADDING - 20 - panelY; - if (!action.isEmpty()) { - panelHeight = panelHeight - font.FONT_HEIGHT - PADDING; - } - textPanel = new TextPanel(this.minecraft, this.width - (PADDING * 2), panelHeight, panelY, PADDING); - this.children.add(textPanel); - addConfirmationButtons(); - } - - protected void addConfirmationButtons() { - this.buttons.add(new Button(this.width / 2 - 100, this.height - PADDING - 20, 200, 20, new TranslationTextComponent("gui.done"), b -> { - NotificationScreen.this.minecraft.displayGuiScreen(null); - query.finish(); - })); - } - - @Override - public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks) - { - this.renderBackground(mStack); - - drawCenteredLines(mStack, PADDING, headerLines); - - if (textPanel != null) - { - textPanel.render(mStack, mouseX, mouseY, partialTicks); - } - - if (!action.isEmpty()) - { - drawCenteredString(mStack, font, action, this.width / 2, this.height - PADDING - 20 - font.FONT_HEIGHT, -1); - } - - super.render(mStack, mouseX, mouseY, partialTicks); - } - - protected void drawCenteredLines(MatrixStack mStack, int yStart, String... lines) - { - for (String line : lines) - { - if (!line.isEmpty()) - this.drawCenteredString(mStack, font, line, this.width / 2, yStart, 0xFFFFFF); - yStart += font.FONT_HEIGHT; - } - } -} -*/ diff --git a/src/main/java/net/minecraftforge/fmllegacy/FMLWorldPersistenceHook.java b/src/main/java/net/minecraftforge/fmllegacy/FMLWorldPersistenceHook.java deleted file mode 100644 index bd32265bd4..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/FMLWorldPersistenceHook.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -import com.google.common.collect.Multimap; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.storage.WorldData; -import net.minecraft.world.level.storage.LevelStorageSource; -import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.RegistryManager; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.Marker; -import org.apache.logging.log4j.MarkerManager; - -/** - * @author cpw - * - */ -public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.WorldPersistenceHook -{ - - private static final Logger LOGGER = LogManager.getLogger(); - private static final Marker WORLDPERSISTENCE = MarkerManager.getMarker("WP"); - - @Override - public String getModId() - { - return "fml"; - } - - @Override - public CompoundTag getDataForWriting(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo) - { - CompoundTag fmlData = new CompoundTag(); - ListTag modList = new ListTag(); - ModList.get().getMods().forEach(mi-> - { - final CompoundTag mod = new CompoundTag(); - mod.putString("ModId", mi.getModId()); - mod.putString("ModVersion", MavenVersionStringHelper.artifactVersionToString(mi.getVersion())); - modList.add(mod); - }); - fmlData.put("LoadingModList", modList); - - CompoundTag registries = new CompoundTag(); - fmlData.put("Registries", registries); - LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", serverInfo.getLevelName()); - - for (Map.Entry e : RegistryManager.ACTIVE.takeSnapshot(true).entrySet()) - { - registries.put(e.getKey().toString(), e.getValue().write()); - } - LOGGER.debug(WORLDPERSISTENCE,"ID Map collection complete {}", serverInfo.getLevelName()); - return fmlData; - } - - @Override - public void readData(LevelStorageSource.LevelStorageAccess levelSave, WorldData serverInfo, CompoundTag tag) - { - if (tag.contains("LoadingModList")) - { - ListTag modList = tag.getList("LoadingModList", (byte)10); - for (int i = 0; i < modList.size(); i++) - { - CompoundTag mod = modList.getCompound(i); - String modId = mod.getString("ModId"); - if (Objects.equals("minecraft", modId)) { - continue; - } - String modVersion = mod.getString("ModVersion"); - Optional container = ModList.get().getModContainerById(modId); - if (!container.isPresent()) - { - LOGGER.error(WORLDPERSISTENCE,"This world was saved with mod {} which appears to be missing, things may not work well", modId); - continue; - } - if (!Objects.equals(modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion()))) - { - LOGGER.warn(WORLDPERSISTENCE,"This world was saved with mod {} version {} and it is now at version {}, things may not work well", modId, modVersion, MavenVersionStringHelper.artifactVersionToString(container.get().getModInfo().getVersion())); - } - } - } - - Multimap failedElements = null; - - if (tag.contains("Registries")) // 1.8, genericed out the 'registries' list - { - Map snapshot = new HashMap<>(); - CompoundTag regs = tag.getCompound("Registries"); - for (String key : regs.getAllKeys()) - { - snapshot.put(new ResourceLocation(key), ForgeRegistry.Snapshot.read(regs.getCompound(key))); - } - failedElements = GameData.injectSnapshot(snapshot, true, true); - } - - if (failedElements != null && !failedElements.isEmpty()) - { - StringBuilder buf = new StringBuilder(); - buf.append("Forge Mod Loader could not load this save.\n\n") - .append("There are ").append(failedElements.size()).append(" unassigned registry entries in this save.\n") - .append("You will not be able to load until they are present again.\n\n"); - - failedElements.asMap().forEach((name, entries) -> - { - buf.append("Missing ").append(name).append(":\n"); - entries.forEach(rl -> buf.append(" ").append(rl).append("\n")); - }); - } - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/SerialTransition.java b/src/main/java/net/minecraftforge/fmllegacy/SerialTransition.java deleted file mode 100644 index 4496a3d6bb..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/SerialTransition.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy; - -import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fml.IModStateTransition; -import net.minecraftforge.fml.ModLoadingStage; -import net.minecraftforge.fml.ThreadSelector; -import net.minecraftforge.fml.event.IModBusEvent; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.function.BiFunction; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Stream; - -record SerialTransition(Supplier>> eventStream, BiFunction, CompletableFuture>> preDispatchHook, BiFunction, CompletableFuture>> postDispatchHook, BiFunction>, CompletableFuture>> finalActivityGenerator) implements IModStateTransition { - public static SerialTransition of(Supplier>> eventStream) { - return new SerialTransition(eventStream, (t,f)->CompletableFuture.completedFuture(Collections.emptyList()), (t, f)->CompletableFuture.completedFuture(Collections.emptyList()), (e, prev) ->prev.thenApplyAsync(Function.identity(), e)); - } - @Override - public Supplier>> eventFunctionStream() { - return eventStream; - } - - @Override - public ThreadSelector threadSelector() { - return ThreadSelector.SYNC; - } - - // These never progress the ModLoadingStage.. - @Override - public BiFunction nextModLoadingStage() { - return ModLoadingStage::currentState; - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/common/network/PacketLoggingHandler.java b/src/main/java/net/minecraftforge/fmllegacy/common/network/PacketLoggingHandler.java deleted file mode 100644 index f080df015f..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/common/network/PacketLoggingHandler.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.common.network; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelPromise; -import io.netty.channel.SimpleChannelInboundHandler; - -import java.util.Iterator; -import java.util.List; - - -import net.minecraft.network.protocol.PacketFlow; -import net.minecraft.network.Varint21FrameDecoder; -import net.minecraft.network.Varint21LengthFieldPrepender; -import net.minecraft.network.Connection; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.FriendlyByteBuf; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class PacketLoggingHandler -{ - private static final Logger LOGGER = LogManager.getLogger(); - public static void register(Connection manager) - { - ChannelPipeline pipeline = manager.channel().pipeline(); - final PacketFlow direction = manager.getDirection(); - if (manager.isMemoryConnection()) - { - pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler>() - { - String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); - @Override - protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception - { - FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); - msg.write(buf); - LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf)); - ctx.fireChannelRead(msg); - } - }); - pipeline.addBefore("splitter", "prepender", new ChannelOutboundHandlerAdapter() - { - String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception - { - if (msg instanceof Packet) - { - FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); - ((Packet)msg).write(buf); - LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf)); - } - ctx.write(msg, promise); - } - }); - } - else - { - pipeline.replace("splitter", "splitter", new Varint21FrameDecoder() - { - String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); - @Override - protected void decode(ChannelHandlerContext context, ByteBuf input, List output) - { - super.decode(context, input, output); - Iterator itr = output.iterator(); - while (itr.hasNext()) - { - ByteBuf pkt = (ByteBuf)itr.next(); - pkt.markReaderIndex(); - LOGGER.debug("{}:\n{}", prefix, ByteBufUtils.getContentDump(pkt)); - pkt.resetReaderIndex(); - } - } - }); - pipeline.replace("prepender", "prepender", new Varint21LengthFieldPrepender() - { - String prefix = (direction == PacketFlow.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); - @Override - protected void encode(ChannelHandlerContext context, ByteBuf input, ByteBuf output) - { - input.markReaderIndex(); - LOGGER.debug("{}:\n{}", prefix, ByteBufUtils.getContentDump(input)); - input.resetReaderIndex(); - super.encode(context, input, output); - } - }); - } - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/common/registry/GameRegistry.java b/src/main/java/net/minecraftforge/fmllegacy/common/registry/GameRegistry.java deleted file mode 100644 index 2f8f24330e..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/common/registry/GameRegistry.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.common.registry; - -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -import net.minecraftforge.registries.RegistryManager; - - -public class GameRegistry -{ - /** - * Retrieves the registry associated with this super class type. - * If the return is non-null it is HIGHLY recommended that modders cache this - * value as the return will never change for a given type in a single run of Minecraft once set. - * - * @param registryType The base class of items in this registry. - * @return The registry, Null if none is registered. - */ - public static > IForgeRegistry findRegistry(Class registryType) - { - return RegistryManager.ACTIVE.getRegistry(registryType); - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/event/lifecycle/FMLModIdMappingEvent.java b/src/main/java/net/minecraftforge/fmllegacy/event/lifecycle/FMLModIdMappingEvent.java deleted file mode 100644 index 37b8408688..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/event/lifecycle/FMLModIdMappingEvent.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.event.lifecycle; - -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent; - -/** - * Called whenever the ID mapping might have changed. If you register for this event, you - * will be called back whenever the client or server loads an ID set. This includes both - * when the ID maps are loaded from disk, as well as when the ID maps revert to the initial - * state. - * - * Note: you cannot change the IDs that have been allocated, but you might want to use - * this event to update caches or other in-mod artifacts that might be impacted by an ID - * change. - * - * Fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} - */ -public class FMLModIdMappingEvent extends ModLifecycleEvent -{ - public class ModRemapping - { - public final ResourceLocation registry; - public final ResourceLocation key; - public final int oldId; - public final int newId; - - private ModRemapping(ResourceLocation registry, ResourceLocation key, int oldId, int newId) - { - this.registry = registry; - this.key = key; - this.oldId = oldId; - this.newId = newId; - } - } - - private final Map> remaps; - private final ImmutableSet keys; - - public final boolean isFrozen; - public FMLModIdMappingEvent(Map> remaps, boolean isFrozen) - { - super(null); - this.isFrozen = isFrozen; - this.remaps = Maps.newHashMap(); - remaps.forEach((name, rm) -> - { - List tmp = Lists.newArrayList(); - rm.forEach((key, value) -> tmp.add(new ModRemapping(name, key, value[0], value[1]))); - tmp.sort(Comparator.comparingInt(o -> o.newId)); - this.remaps.put(name, ImmutableList.copyOf(tmp)); - }); - this.keys = ImmutableSet.copyOf(this.remaps.keySet()); - } - - public ImmutableSet getRegistries() - { - return this.keys; - } - - public ImmutableList getRemaps(ResourceLocation registry) - { - return this.remaps.get(registry); - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/hooks/BasicEventHooks.java b/src/main/java/net/minecraftforge/fmllegacy/hooks/BasicEventHooks.java deleted file mode 100644 index 5411dc6cca..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/hooks/BasicEventHooks.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.hooks; - -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.Container; -import net.minecraft.world.item.ItemStack; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.Level; -import net.minecraftforge.client.model.animation.Animation; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerEvent; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.event.TickEvent; - -public class BasicEventHooks -{ - - public static void firePlayerChangedDimensionEvent(Player player, ResourceKey fromDim, ResourceKey toDim) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); - } - - public static void firePlayerLoggedIn(Player player) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedInEvent(player)); - } - - public static void firePlayerLoggedOut(Player player) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerLoggedOutEvent(player)); - } - - public static void firePlayerRespawnEvent(Player player, boolean endConquered) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.PlayerRespawnEvent(player, endConquered)); - } - - public static void firePlayerItemPickupEvent(Player player, ItemEntity item, ItemStack clone) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemPickupEvent(player, item, clone)); - } - - public static void firePlayerCraftingEvent(Player player, ItemStack crafted, Container craftMatrix) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); - } - - public static void firePlayerSmeltedEvent(Player player, ItemStack smelted) - { - MinecraftForge.EVENT_BUS.post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); - } - - public static void onRenderTickStart(float timer) - { - Animation.setClientPartialTickTime(timer); - MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.START, timer)); - } - - public static void onRenderTickEnd(float timer) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.RenderTickEvent(TickEvent.Phase.END, timer)); - } - - public static void onPlayerPreTick(Player player) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.START, player)); - } - - public static void onPlayerPostTick(Player player) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.PlayerTickEvent(TickEvent.Phase.END, player)); - } - - public static void onPreWorldTick(Level world) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.START, world)); - } - - public static void onPostWorldTick(Level world) - { - MinecraftForge.EVENT_BUS.post(new TickEvent.WorldTickEvent(LogicalSide.SERVER, TickEvent.Phase.END, world)); - } - - public static void onPreClientTick() - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ClientTickEvent(TickEvent.Phase.START)); - } - - public static void onPostClientTick() - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ClientTickEvent(TickEvent.Phase.END)); - } - - public static void onPreServerTick() - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ServerTickEvent(TickEvent.Phase.START)); - } - - public static void onPostServerTick() - { - MinecraftForge.EVENT_BUS.post(new TickEvent.ServerTickEvent(TickEvent.Phase.END)); - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInitialization.java b/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInitialization.java deleted file mode 100644 index 708ca4f6db..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInitialization.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.network; - -import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; -import net.minecraftforge.registries.RegistryManager; - -import java.util.Arrays; -import java.util.List; - -class NetworkInitialization { - - public static SimpleChannel getHandshakeChannel() { - SimpleChannel handshakeChannel = NetworkRegistry.ChannelBuilder. - named(FMLNetworkConstants.FML_HANDSHAKE_RESOURCE). - clientAcceptedVersions(a -> true). - serverAcceptedVersions(a -> true). - networkProtocolVersion(() -> FMLNetworkConstants.NETVERSION). - simpleChannel(); - - handshakeChannel.messageBuilder(FMLHandshakeMessages.C2SAcknowledge.class, 99, NetworkDirection.LOGIN_TO_SERVER). - loginIndex(FMLHandshakeMessages.LoginIndexedMessage::getLoginIndex, FMLHandshakeMessages.LoginIndexedMessage::setLoginIndex). - decoder(FMLHandshakeMessages.C2SAcknowledge::decode). - encoder(FMLHandshakeMessages.C2SAcknowledge::encode). - consumer(FMLHandshakeHandler.indexFirst(FMLHandshakeHandler::handleClientAck)). - add(); - - handshakeChannel.messageBuilder(FMLHandshakeMessages.S2CModList.class, 1, NetworkDirection.LOGIN_TO_CLIENT). - loginIndex(FMLHandshakeMessages.LoginIndexedMessage::getLoginIndex, FMLHandshakeMessages.LoginIndexedMessage::setLoginIndex). - decoder(FMLHandshakeMessages.S2CModList::decode). - encoder(FMLHandshakeMessages.S2CModList::encode). - markAsLoginPacket(). - consumer(FMLHandshakeHandler.biConsumerFor(FMLHandshakeHandler::handleServerModListOnClient)). - add(); - - handshakeChannel.messageBuilder(FMLHandshakeMessages.C2SModListReply.class, 2, NetworkDirection.LOGIN_TO_SERVER). - loginIndex(FMLHandshakeMessages.LoginIndexedMessage::getLoginIndex, FMLHandshakeMessages.LoginIndexedMessage::setLoginIndex). - decoder(FMLHandshakeMessages.C2SModListReply::decode). - encoder(FMLHandshakeMessages.C2SModListReply::encode). - consumer(FMLHandshakeHandler.indexFirst(FMLHandshakeHandler::handleClientModListOnServer)). - add(); - - handshakeChannel.messageBuilder(FMLHandshakeMessages.S2CRegistry.class, 3, NetworkDirection.LOGIN_TO_CLIENT). - loginIndex(FMLHandshakeMessages.LoginIndexedMessage::getLoginIndex, FMLHandshakeMessages.LoginIndexedMessage::setLoginIndex). - decoder(FMLHandshakeMessages.S2CRegistry::decode). - encoder(FMLHandshakeMessages.S2CRegistry::encode). - buildLoginPacketList(RegistryManager::generateRegistryPackets). //TODO: Make this non-static, and store a cache on the client. - consumer(FMLHandshakeHandler.biConsumerFor(FMLHandshakeHandler::handleRegistryMessage)). - add(); - - handshakeChannel.messageBuilder(FMLHandshakeMessages.S2CConfigData.class, 4, NetworkDirection.LOGIN_TO_CLIENT). - loginIndex(FMLHandshakeMessages.LoginIndexedMessage::getLoginIndex, FMLHandshakeMessages.LoginIndexedMessage::setLoginIndex). - decoder(FMLHandshakeMessages.S2CConfigData::decode). - encoder(FMLHandshakeMessages.S2CConfigData::encode). - buildLoginPacketList(ConfigSync.INSTANCE::syncConfigs). - consumer(FMLHandshakeHandler.biConsumerFor(FMLHandshakeHandler::handleConfigSync)). - add(); - - return handshakeChannel; - } - - public static SimpleChannel getPlayChannel() { - SimpleChannel playChannel = NetworkRegistry.ChannelBuilder. - named(FMLNetworkConstants.FML_PLAY_RESOURCE). - clientAcceptedVersions(a -> true). - serverAcceptedVersions(a -> true). - networkProtocolVersion(() -> FMLNetworkConstants.NETVERSION). - simpleChannel(); - - playChannel.messageBuilder(FMLPlayMessages.SpawnEntity.class, 0). - decoder(FMLPlayMessages.SpawnEntity::decode). - encoder(FMLPlayMessages.SpawnEntity::encode). - consumer(FMLPlayMessages.SpawnEntity::handle). - add(); - - playChannel.messageBuilder(FMLPlayMessages.OpenContainer.class,1). - decoder(FMLPlayMessages.OpenContainer::decode). - encoder(FMLPlayMessages.OpenContainer::encode). - consumer(FMLPlayMessages.OpenContainer::handle). - add(); - - return playChannel; - } - - public static List buildMCRegistrationChannels() { - final EventNetworkChannel mcRegChannel = NetworkRegistry.ChannelBuilder. - named(FMLNetworkConstants.MC_REGISTER_RESOURCE). - clientAcceptedVersions(a -> true). - serverAcceptedVersions(a -> true). - networkProtocolVersion(() -> FMLNetworkConstants.NETVERSION). - eventNetworkChannel(); - mcRegChannel.addListener(FMLMCRegisterPacketHandler.INSTANCE::registerListener); - final EventNetworkChannel mcUnregChannel = NetworkRegistry.ChannelBuilder. - named(FMLNetworkConstants.MC_UNREGISTER_RESOURCE). - clientAcceptedVersions(a -> true). - serverAcceptedVersions(a -> true). - networkProtocolVersion(() -> FMLNetworkConstants.NETVERSION). - eventNetworkChannel(); - mcUnregChannel.addListener(FMLMCRegisterPacketHandler.INSTANCE::unregisterListener); - return Arrays.asList(mcRegChannel, mcUnregChannel); - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/PacketDispatcher.java b/src/main/java/net/minecraftforge/fmllegacy/network/PacketDispatcher.java deleted file mode 100644 index 87cf3554c3..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/network/PacketDispatcher.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.network; - -import net.minecraft.network.Connection; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import org.apache.commons.lang3.tuple.Pair; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; - -/** - * Dispatcher for sending packets in response to a received packet. Abstracts out the difference between wrapped packets - * and unwrapped packets. - */ -public class PacketDispatcher { - BiConsumer packetSink; - - PacketDispatcher(final BiConsumer packetSink) { - this.packetSink = packetSink; - } - - private PacketDispatcher() { - - } - - public void sendPacket(ResourceLocation resourceLocation, FriendlyByteBuf buffer) { - packetSink.accept(resourceLocation, buffer); - } - - static class NetworkManagerDispatcher extends PacketDispatcher { - private final Connection manager; - private final int packetIndex; - private final BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier; - - NetworkManagerDispatcher(Connection manager, int packetIndex, BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier) { - super(); - this.packetSink = this::dispatchPacket; - this.manager = manager; - this.packetIndex = packetIndex; - this.customPacketSupplier = customPacketSupplier; - } - - private void dispatchPacket(final ResourceLocation resourceLocation, final FriendlyByteBuf buffer) { - final ICustomPacket packet = this.customPacketSupplier.apply(Pair.of(buffer, packetIndex), resourceLocation); - this.manager.send(packet.getThis()); - } - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/packs/ModFileResourcePack.java b/src/main/java/net/minecraftforge/fmllegacy/packs/ModFileResourcePack.java deleted file mode 100644 index c83da44111..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/packs/ModFileResourcePack.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.packs; - -import net.minecraft.server.packs.repository.Pack; -import net.minecraftforge.forgespi.locating.IModFile; -import net.minecraftforge.resource.PathResourcePack; - -import javax.annotation.Nonnull; -import java.nio.file.Path; - -@Deprecated(since="1.18", forRemoval = true) // TODO 1.18: Replace usages with PathResourcePack -public class ModFileResourcePack extends PathResourcePack -{ - private final IModFile modFile; - private Pack packInfo; - - public ModFileResourcePack(final IModFile modFile) - { - super(modFile.getFileName(), modFile.getFilePath()); - this.modFile = modFile; - } - - public IModFile getModFile() { - return this.modFile; - } - - @Nonnull - @Override - protected Path resolve(@Nonnull String... paths) - { - return modFile.findResource(paths); - } - - @Override - public String toString() - { - return String.format("%s: %s", getClass().getName(), getModFile().getFileName()); - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/util/ThreeConsumer.java b/src/main/java/net/minecraftforge/fmllegacy/util/ThreeConsumer.java deleted file mode 100644 index 3c973c0223..0000000000 --- a/src/main/java/net/minecraftforge/fmllegacy/util/ThreeConsumer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.fmllegacy.util; - -import java.util.function.Consumer; - -/** - * Three-consumer version of consumer. Allows wrapping methods with three arguments. - */ -public interface ThreeConsumer -{ - - /** - * Bind arguments to the three consumer to generate a consumer. - * - *
-     * {@code
-     * ThreeConsumer.bindArgs(MyClass::instanceMethodReference, arg1, arg2).apply(myClassInstance)
-     * }
-     * 
- * - * @return a Consumer which has the second and third arguments bound. - */ - static Consumer bindArgs(ThreeConsumer c, U arg2, V arg3) - { - return (arg1) -> c.accept(arg1, arg2, arg3); - } - - void accept(T t, U u, V v); -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/BrandingControl.java b/src/main/java/net/minecraftforge/internal/BrandingControl.java similarity index 97% rename from src/main/java/net/minecraftforge/fmllegacy/BrandingControl.java rename to src/main/java/net/minecraftforge/internal/BrandingControl.java index 5bb457a4fc..a1b2cd4b31 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/BrandingControl.java +++ b/src/main/java/net/minecraftforge/internal/BrandingControl.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.internal; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -28,6 +28,7 @@ import java.util.stream.IntStream; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManagerReloadListener; import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.common.ForgeI18n; import net.minecraftforge.fml.ModList; import net.minecraftforge.versions.forge.ForgeVersion; import net.minecraftforge.versions.mcp.MCPVersion; diff --git a/src/main/java/net/minecraftforge/fmllegacy/ForgeBindings.java b/src/main/java/net/minecraftforge/internal/ForgeBindings.java similarity index 93% rename from src/main/java/net/minecraftforge/fmllegacy/ForgeBindings.java rename to src/main/java/net/minecraftforge/internal/ForgeBindings.java index f21c4a3b9f..53be10133f 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/ForgeBindings.java +++ b/src/main/java/net/minecraftforge/internal/ForgeBindings.java @@ -17,8 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.internal; +import net.minecraftforge.common.ForgeI18n; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.I18NParser; @@ -26,10 +27,7 @@ import net.minecraftforge.fml.IBindingsProvider; import net.minecraftforge.fml.config.IConfigEvent; import net.minecraftforge.fml.event.config.ModConfigEvent; -import java.util.Arrays; -import java.util.Objects; import java.util.function.Supplier; -import java.util.stream.Collectors; public class ForgeBindings implements IBindingsProvider { @Override diff --git a/src/main/java/net/minecraftforge/fmllegacy/TextComponentMessageFormatHandler.java b/src/main/java/net/minecraftforge/internal/TextComponentMessageFormatHandler.java similarity index 87% rename from src/main/java/net/minecraftforge/fmllegacy/TextComponentMessageFormatHandler.java rename to src/main/java/net/minecraftforge/internal/TextComponentMessageFormatHandler.java index 8da807afab..728eee2793 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/TextComponentMessageFormatHandler.java +++ b/src/main/java/net/minecraftforge/internal/TextComponentMessageFormatHandler.java @@ -17,16 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.internal; import net.minecraft.network.chat.FormattedText; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; +import net.minecraftforge.common.ForgeI18n; -import java.util.List; +import java.util.function.Consumer; public class TextComponentMessageFormatHandler { - public static int handle(final TranslatableComponent parent, final List children, final Object[] formatArgs, final String format) { + public static int handle(final TranslatableComponent parent, final Consumer addChild, final Object[] formatArgs, final String format) { try { final String formattedString = ForgeI18n.parseFormat(format, formatArgs); @@ -42,7 +43,7 @@ public class TextComponentMessageFormatHandler { TextComponent component = new TextComponent(formattedString); component.getStyle().applyTo(parent.getStyle()); - children.add(component); + addChild.accept(component); return format.length(); } catch (IllegalArgumentException ex) { return 0; diff --git a/src/main/java/net/minecraftforge/fmllegacy/WorldPersistenceHooks.java b/src/main/java/net/minecraftforge/internal/WorldPersistenceHooks.java similarity index 98% rename from src/main/java/net/minecraftforge/fmllegacy/WorldPersistenceHooks.java rename to src/main/java/net/minecraftforge/internal/WorldPersistenceHooks.java index 371fa7b636..ee9b16b8a5 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/WorldPersistenceHooks.java +++ b/src/main/java/net/minecraftforge/internal/WorldPersistenceHooks.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.internal; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.storage.WorldData; diff --git a/src/main/java/net/minecraftforge/fmllegacy/CrashReportExtender.java b/src/main/java/net/minecraftforge/logging/CrashReportExtender.java similarity index 99% rename from src/main/java/net/minecraftforge/fmllegacy/CrashReportExtender.java rename to src/main/java/net/minecraftforge/logging/CrashReportExtender.java index ad1dba2ee2..a89be2a338 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/CrashReportExtender.java +++ b/src/main/java/net/minecraftforge/logging/CrashReportExtender.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.logging; import cpw.mods.modlauncher.log.TransformingThrowablePatternConverter; import joptsimple.internal.Strings; diff --git a/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java b/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java index 6a38d0dcc8..5e0ab71aac 100644 --- a/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java +++ b/src/main/java/net/minecraftforge/logging/ModelLoaderErrorMessage.java @@ -25,14 +25,14 @@ import com.google.common.collect.Multimap; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.client.renderer.block.BlockModelShaper; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.client.model.ForgeModelBakery; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.message.SimpleMessage; import java.util.Collection; -import static net.minecraftforge.client.model.ModelLoader.getInventoryVariant; +import static net.minecraftforge.client.model.ForgeModelBakery.getInventoryVariant; public class ModelLoaderErrorMessage extends SimpleMessage { @@ -93,9 +93,9 @@ public class ModelLoaderErrorMessage extends SimpleMessage errorMsg += " for items [\"" + Joiner.on("\", \"").join(items) + "\"]"; } } - if(exception instanceof ModelLoader.ItemLoadingException) + if(exception instanceof ForgeModelBakery.ItemLoadingException) { - ModelLoader.ItemLoadingException ex = (ModelLoader.ItemLoadingException)exception; + ForgeModelBakery.ItemLoadingException ex = (ForgeModelBakery.ItemLoadingException)exception; // LOGGER.error("{}, normal location exception: ", errorMsg, ex.normalException); // LOGGER.error("{}, blockstate location exception: ", errorMsg, ex.blockstateException); } diff --git a/src/main/java/net/minecraftforge/fmllegacy/common/network/ByteBufUtils.java b/src/main/java/net/minecraftforge/logging/PacketDump.java similarity index 95% rename from src/main/java/net/minecraftforge/fmllegacy/common/network/ByteBufUtils.java rename to src/main/java/net/minecraftforge/logging/PacketDump.java index 903516a5a6..2a7fcafab9 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/common/network/ByteBufUtils.java +++ b/src/main/java/net/minecraftforge/logging/PacketDump.java @@ -17,16 +17,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.common.network; +package net.minecraftforge.logging; import io.netty.buffer.ByteBuf; -/** - * Utilities for interacting with {@link ByteBuf}. - * @author cpw - * - */ -public class ByteBufUtils { +public class PacketDump +{ public static String getContentDump(ByteBuf buffer) { diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/ConfigSync.java b/src/main/java/net/minecraftforge/network/ConfigSync.java similarity index 83% rename from src/main/java/net/minecraftforge/fmllegacy/network/ConfigSync.java rename to src/main/java/net/minecraftforge/network/ConfigSync.java index 6099046297..74e5bf2326 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/ConfigSync.java +++ b/src/main/java/net/minecraftforge/network/ConfigSync.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.config.ConfigTracker; @@ -40,7 +40,7 @@ public class ConfigSync { this.tracker = tracker; } - public List> syncConfigs(boolean isLocal) { + public List> syncConfigs(boolean isLocal) { final Map configData = tracker.configSets().get(ModConfig.Type.SERVER).stream().collect(Collectors.toMap(ModConfig::getFileName, mc -> { try { return Files.readAllBytes(mc.getFullPath()); @@ -48,10 +48,10 @@ public class ConfigSync { throw new RuntimeException(e); } })); - return configData.entrySet().stream().map(e->Pair.of("Config "+e.getKey(), new FMLHandshakeMessages.S2CConfigData(e.getKey(), e.getValue()))).collect(Collectors.toList()); + return configData.entrySet().stream().map(e->Pair.of("Config "+e.getKey(), new HandshakeMessages.S2CConfigData(e.getKey(), e.getValue()))).collect(Collectors.toList()); } - public void receiveSyncedConfig(final FMLHandshakeMessages.S2CConfigData s2CConfigData, final Supplier contextSupplier) { + public void receiveSyncedConfig(final HandshakeMessages.S2CConfigData s2CConfigData, final Supplier contextSupplier) { if (!Minecraft.getInstance().isLocalServer()) { Optional.ofNullable(tracker.fileMap().get(s2CConfigData.getFileName())).ifPresent(mc-> mc.acceptSyncedConfig(s2CConfigData.getBytes())); } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLConnectionData.java b/src/main/java/net/minecraftforge/network/ConnectionData.java similarity index 90% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLConnectionData.java rename to src/main/java/net/minecraftforge/network/ConnectionData.java index 955e5a3a3c..33ae05366a 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLConnectionData.java +++ b/src/main/java/net/minecraftforge/network/ConnectionData.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -26,12 +26,12 @@ import net.minecraft.resources.ResourceLocation; import java.util.List; import java.util.Map; -public class FMLConnectionData +public class ConnectionData { private ImmutableList modList; private ImmutableMap channels; - /* package private */ FMLConnectionData(List modList, Map channels) + /* package private */ ConnectionData(List modList, Map channels) { this.modList = ImmutableList.copyOf(modList); this.channels = ImmutableMap.copyOf(channels); @@ -53,7 +53,7 @@ public class FMLConnectionData } /** - * Returns the list of network channels present in the remote. + * Returns the list of impl channels present in the remote. * WARNING: This list is not authoritative. * A channel missing from the list does not mean the remote won't accept packets with that channel ID, * and similarly a channel present in the list does not mean the remote won't ignore it. diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/ConnectionType.java b/src/main/java/net/minecraftforge/network/ConnectionType.java similarity index 84% rename from src/main/java/net/minecraftforge/fmllegacy/network/ConnectionType.java rename to src/main/java/net/minecraftforge/network/ConnectionType.java index 0d051ad2d3..87529d5376 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/ConnectionType.java +++ b/src/main/java/net/minecraftforge/network/ConnectionType.java @@ -17,13 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import java.util.function.Function; public enum ConnectionType { - MODDED(s->Integer.valueOf(s.substring(FMLNetworkConstants.FMLNETMARKER.length()))), VANILLA(s->0); + MODDED(s->Integer.valueOf(s.substring(NetworkConstants.FMLNETMARKER.length()))), VANILLA(s->0); private final Function versionExtractor; @@ -34,7 +34,7 @@ public enum ConnectionType public static ConnectionType forVersionFlag(String vers) { - return vers.startsWith(FMLNetworkConstants.FMLNETMARKER) ? MODDED : VANILLA; + return vers.startsWith(NetworkConstants.FMLNETMARKER) ? MODDED : VANILLA; } public int getFMLVersionNumber(final String fmlVersion) diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeHandler.java b/src/main/java/net/minecraftforge/network/HandshakeHandler.java similarity index 75% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeHandler.java rename to src/main/java/net/minecraftforge/network/HandshakeHandler.java index 36e16ca5fe..2861103408 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeHandler.java +++ b/src/main/java/net/minecraftforge/network/HandshakeHandler.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import com.google.common.collect.Multimap; import net.minecraft.network.Connection; @@ -28,8 +28,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.network.chat.TextComponent; import net.minecraft.server.network.ServerLoginPacketListenerImpl; import net.minecraftforge.common.util.LogMessageAdapter; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; -import net.minecraftforge.fmllegacy.util.ThreeConsumer; +import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.GameData; import org.apache.logging.log4j.LogManager; @@ -49,12 +48,12 @@ import java.util.function.Supplier; import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES; /** - * Instance responsible for handling the overall FML network handshake. + * Instance responsible for handling the overall FML impl handshake. * *

An instance is created during {@link ClientIntentionPacket} handling, and attached - * to the {@link Connection#channel()} via {@link FMLNetworkConstants#FML_HANDSHAKE_HANDLER}. + * to the {@link Connection#channel()} via {@link NetworkConstants#FML_HANDSHAKE_HANDLER}. * - *

The {@link FMLNetworkConstants#handshakeChannel} is a {@link SimpleChannel} with standard messages flowing in both directions. + *

The {@link NetworkConstants#handshakeChannel} is a {@link SimpleChannel} with standard messages flowing in both directions. * *

The {@link #loginWrapper} transforms these messages into {@link ServerboundCustomQueryPacket} * and {@link ClientboundCustomQueryPacket} compatible messages, by means of wrapping. @@ -67,22 +66,23 @@ import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES; * {@link NetworkRegistry.LoginPayload} they wish to supply. * *

The collected {@link NetworkRegistry.LoginPayload} are sent, one per tick, via - * the {@code FMLLoginWrapper#wrapPacket(ResourceLocation, net.minecraft.network.FriendlyByteBuf)} mechanism to the incoming client connection. Each + * the {@code FMLLoginWrapper#wrapPacket(ResourceLocation, net.minecraft.impl.FriendlyByteBuf)} mechanism to the incoming client connection. Each * packet is indexed via {@link ServerboundCustomQueryPacket#getTransactionId()}, which is * the only mechanism available for tracking request/response pairs. * *

Each packet sent from the server should be replied by the client, though not necessarily in sent order. The reply - * should contain the index of the server's packet it is replying to. The {@link FMLLoginWrapper} class handles indexing + * should contain the index of the server's packet it is replying to. The {@link LoginWrapper} class handles indexing * replies correctly automatically. * *

Once all packets have been dispatched, we wait for all replies to be received. Once all replies are received, the * final login phase will commence. */ -public class FMLHandshakeHandler { - static final Marker FMLHSMARKER = MarkerManager.getMarker("FMLHANDSHAKE").setParents(FMLNetworkConstants.NETWORK); +public class HandshakeHandler +{ + static final Marker FMLHSMARKER = MarkerManager.getMarker("FMLHANDSHAKE").setParents(NetworkConstants.NETWORK); private static final Logger LOGGER = LogManager.getLogger(); - private static final FMLLoginWrapper loginWrapper = new FMLLoginWrapper(); + private static final LoginWrapper loginWrapper = new LoginWrapper(); static { } @@ -91,16 +91,16 @@ public class FMLHandshakeHandler { * Create a new handshake instance. Called when connection is first created during the {@link ClientIntentionPacket} * handling. * - * @param manager The network manager for this connection + * @param manager The impl manager for this connection * @param direction The {@link NetworkDirection} for this connection: {@link NetworkDirection#LOGIN_TO_SERVER} or {@link NetworkDirection#LOGIN_TO_CLIENT} */ static void registerHandshake(Connection manager, NetworkDirection direction) { - manager.channel().attr(FMLNetworkConstants.FML_HANDSHAKE_HANDLER).compareAndSet(null, new FMLHandshakeHandler(manager, direction)); + manager.channel().attr(NetworkConstants.FML_HANDSHAKE_HANDLER).compareAndSet(null, new HandshakeHandler(manager, direction)); } static boolean tickLogin(Connection networkManager) { - return networkManager.channel().attr(FMLNetworkConstants.FML_HANDSHAKE_HANDLER).get().tickServer(); + return networkManager.channel().attr(NetworkConstants.FML_HANDSHAKE_HANDLER).get().tickServer(); } private List messageList; @@ -114,22 +114,27 @@ public class FMLHandshakeHandler { private Set registriesToReceive; private Map registryHashes; - private FMLHandshakeHandler(Connection networkManager, NetworkDirection side) + private HandshakeHandler(Connection networkManager, NetworkDirection side) { this.direction = side; this.manager = networkManager; if (networkManager.isMemoryConnection()) { this.messageList = NetworkRegistry.gatherLoginPayloads(this.direction, true); LOGGER.debug(FMLHSMARKER, "Starting local connection."); - } else if (NetworkHooks.getConnectionType(()->this.manager)==ConnectionType.VANILLA) { + } else if (NetworkHooks.getConnectionType(()->this.manager)== ConnectionType.VANILLA) { this.messageList = Collections.emptyList(); - LOGGER.debug(FMLHSMARKER, "Starting new vanilla network connection."); + LOGGER.debug(FMLHSMARKER, "Starting new vanilla impl connection."); } else { this.messageList = NetworkRegistry.gatherLoginPayloads(this.direction, false); - LOGGER.debug(FMLHSMARKER, "Starting new modded network connection. Found {} messages to dispatch.", this.messageList.size()); + LOGGER.debug(FMLHSMARKER, "Starting new modded impl connection. Found {} messages to dispatch.", this.messageList.size()); } } + interface HandshakeConsumer + { + void accept(HandshakeHandler handler, MSG msg, Supplier context); + } + /** * Transforms a two-argument instance method reference into a {@link BiConsumer} based on the {@link #getHandshake(Supplier)} function. * @@ -139,13 +144,13 @@ public class FMLHandshakeHandler { * @param message type * @return A {@link BiConsumer} for use in message handling */ - public static BiConsumer> biConsumerFor(ThreeConsumer> consumer) + public static BiConsumer> biConsumerFor(HandshakeConsumer consumer) { - return (m, c) -> ThreeConsumer.bindArgs(consumer, m, c).accept(getHandshake(c)); + return (m, c) -> consumer.accept(getHandshake(c), m, c); } /** - * Transforms a two-argument instance method reference into a {@link BiConsumer} {@link #biConsumerFor(ThreeConsumer)}, first calling the {@link #handleIndexedMessage(IntSupplier, Supplier)} + * Transforms a two-argument instance method reference into a {@link BiConsumer} {@link #biConsumerFor(HandshakeConsumer)}, first calling the {@link #handleIndexedMessage(IntSupplier, Supplier)} * method to handle index tracking. Used for client to server replies. * * This should only be used for login messages. @@ -154,9 +159,9 @@ public class FMLHandshakeHandler { * @param message type * @return A {@link BiConsumer} for use in message handling */ - public static BiConsumer> indexFirst(ThreeConsumer> next) + public static BiConsumer> indexFirst(HandshakeConsumer next) { - final BiConsumer> loginIndexedMessageSupplierBiConsumer = biConsumerFor(FMLHandshakeHandler::handleIndexedMessage); + final BiConsumer> loginIndexedMessageSupplierBiConsumer = biConsumerFor(HandshakeHandler::handleIndexedMessage); return loginIndexedMessageSupplierBiConsumer.andThen(biConsumerFor(next)); } @@ -166,11 +171,11 @@ public class FMLHandshakeHandler { * @param contextSupplier the {@link NetworkEvent.Context} * @return The handshake handler for the connection */ - private static FMLHandshakeHandler getHandshake(Supplier contextSupplier) { - return contextSupplier.get().attr(FMLNetworkConstants.FML_HANDSHAKE_HANDLER).get(); + private static HandshakeHandler getHandshake(Supplier contextSupplier) { + return contextSupplier.get().attr(NetworkConstants.FML_HANDSHAKE_HANDLER).get(); } - void handleServerModListOnClient(FMLHandshakeMessages.S2CModList serverModList, Supplier c) + void handleServerModListOnClient(HandshakeMessages.S2CModList serverModList, Supplier c) { LOGGER.debug(FMLHSMARKER, "Logging into server with mod list [{}]", String.join(", ", serverModList.getModList())); boolean accepted = NetworkRegistry.validateClientChannels(serverModList.getChannels()); @@ -180,13 +185,13 @@ public class FMLHandshakeHandler { c.get().getNetworkManager().disconnect(new TextComponent("Connection closed - mismatched mod channel list")); return; } - FMLNetworkConstants.handshakeChannel.reply(new FMLHandshakeMessages.C2SModListReply(), c.get()); + NetworkConstants.handshakeChannel.reply(new HandshakeMessages.C2SModListReply(), c.get()); LOGGER.debug(FMLHSMARKER, "Accepted server connection"); // Set the modded marker on the channel so we know we got packets - c.get().getNetworkManager().channel().attr(FMLNetworkConstants.FML_NETVERSION).set(FMLNetworkConstants.NETVERSION); - c.get().getNetworkManager().channel().attr(FMLNetworkConstants.FML_CONNECTION_DATA) - .set(new FMLConnectionData(serverModList.getModList(), serverModList.getChannels())); + c.get().getNetworkManager().channel().attr(NetworkConstants.FML_NETVERSION).set(NetworkConstants.NETVERSION); + c.get().getNetworkManager().channel().attr(NetworkConstants.FML_CONNECTION_DATA) + .set(new ConnectionData(serverModList.getModList(), serverModList.getChannels())); this.registriesToReceive = new HashSet<>(serverModList.getRegistries()); this.registrySnapshots = Maps.newHashMap(); @@ -202,12 +207,12 @@ public class FMLHandshakeHandler { } } - void handleClientModListOnServer(FMLHandshakeMessages.C2SModListReply clientModList, Supplier c) + void handleClientModListOnServer(HandshakeMessages.C2SModListReply clientModList, Supplier c) { LOGGER.debug(FMLHSMARKER, "Received client connection with modlist [{}]", String.join(", ", clientModList.getModList())); boolean accepted = NetworkRegistry.validateServerChannels(clientModList.getChannels()); - c.get().getNetworkManager().channel().attr(FMLNetworkConstants.FML_CONNECTION_DATA) - .set(new FMLConnectionData(clientModList.getModList(), clientModList.getChannels())); + c.get().getNetworkManager().channel().attr(NetworkConstants.FML_CONNECTION_DATA) + .set(new ConnectionData(clientModList.getModList(), clientModList.getChannels())); c.get().setPacketHandled(true); if (!accepted) { LOGGER.error(FMLHSMARKER, "Terminating connection with client, mismatched mod list"); @@ -217,7 +222,7 @@ public class FMLHandshakeHandler { LOGGER.debug(FMLHSMARKER, "Accepted client connection mod list"); } - void handleRegistryMessage(final FMLHandshakeMessages.S2CRegistry registryPacket, final Supplier contextSupplier){ + void handleRegistryMessage(final HandshakeMessages.S2CRegistry registryPacket, final Supplier contextSupplier){ LOGGER.debug(FMLHSMARKER,"Received registry packet for {}", registryPacket.getRegistryName()); this.registriesToReceive.remove(registryPacket.getRegistryName()); this.registrySnapshots.put(registryPacket.getRegistryName(), registryPacket.getSnapshot()); @@ -231,12 +236,12 @@ public class FMLHandshakeHandler { if (!continueHandshake) { LOGGER.error(FMLHSMARKER, "Connection closed, not continuing handshake"); } else { - FMLNetworkConstants.handshakeChannel.reply(new FMLHandshakeMessages.C2SAcknowledge(), contextSupplier.get()); + NetworkConstants.handshakeChannel.reply(new HandshakeMessages.C2SAcknowledge(), contextSupplier.get()); } } private boolean handleRegistryLoading(final Supplier contextSupplier) { - // We use a countdown latch to suspend the network thread pending the client thread processing the registry data + // We use a countdown latch to suspend the impl thread pending the client thread processing the registry data AtomicBoolean successfulConnection = new AtomicBoolean(false); CountDownLatch block = new CountDownLatch(1); contextSupplier.get().enqueueWork(() -> { @@ -244,7 +249,7 @@ public class FMLHandshakeHandler { final Multimap missingData = GameData.injectSnapshot(registrySnapshots, false, false); LOGGER.debug(FMLHSMARKER, "Snapshot injected."); if (!missingData.isEmpty()) { - LOGGER.error(FMLHSMARKER, "Missing registry data for network connection:\n{}", LogMessageAdapter.adapt(sb-> + LOGGER.error(FMLHSMARKER, "Missing registry data for impl connection:\n{}", LogMessageAdapter.adapt(sb-> missingData.forEach((reg, entry)-> sb.append("\t").append(reg).append(": ").append(entry).append('\n')))); } successfulConnection.set(missingData.isEmpty()); @@ -265,16 +270,16 @@ public class FMLHandshakeHandler { return successfulConnection.get(); } - void handleClientAck(final FMLHandshakeMessages.C2SAcknowledge msg, final Supplier contextSupplier) { + void handleClientAck(final HandshakeMessages.C2SAcknowledge msg, final Supplier contextSupplier) { LOGGER.debug(FMLHSMARKER, "Received acknowledgement from client"); contextSupplier.get().setPacketHandled(true); } - void handleConfigSync(final FMLHandshakeMessages.S2CConfigData msg, final Supplier contextSupplier) { + void handleConfigSync(final HandshakeMessages.S2CConfigData msg, final Supplier contextSupplier) { LOGGER.debug(FMLHSMARKER, "Received config sync from server"); ConfigSync.INSTANCE.receiveSyncedConfig(msg, contextSupplier); contextSupplier.get().setPacketHandled(true); - FMLNetworkConstants.handshakeChannel.reply(new FMLHandshakeMessages.C2SAcknowledge(), contextSupplier.get()); + NetworkConstants.handshakeChannel.reply(new HandshakeMessages.C2SAcknowledge(), contextSupplier.get()); } /** * FML will send packets, from Server to Client, from the messages queue until the queue is drained. Each message @@ -301,7 +306,7 @@ public class FMLHandshakeHandler { // we're done when sentMessages is empty if (sentMessages.isEmpty() && packetPosition >= messageList.size()-1) { // clear ourselves - we're done! - this.manager.channel().attr(FMLNetworkConstants.FML_HANDSHAKE_HANDLER).set(null); + this.manager.channel().attr(NetworkConstants.FML_HANDSHAKE_HANDLER).set(null); LOGGER.debug(FMLHSMARKER, "Handshake complete!"); return true; } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeMessages.java b/src/main/java/net/minecraftforge/network/HandshakeMessages.java similarity index 98% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeMessages.java rename to src/main/java/net/minecraftforge/network/HandshakeMessages.java index 71446cbb7d..dfffbdeea4 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLHandshakeMessages.java +++ b/src/main/java/net/minecraftforge/network/HandshakeMessages.java @@ -17,12 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; import net.minecraftforge.forgespi.language.IModInfo; +import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.RegistryManager; @@ -37,7 +38,7 @@ import javax.annotation.Nullable; import com.google.common.collect.Maps; -public class FMLHandshakeMessages +public class HandshakeMessages { static class LoginIndexedMessage implements IntSupplier { diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/IContainerFactory.java b/src/main/java/net/minecraftforge/network/IContainerFactory.java similarity index 96% rename from src/main/java/net/minecraftforge/fmllegacy/network/IContainerFactory.java rename to src/main/java/net/minecraftforge/network/IContainerFactory.java index 1a777dd552..9bc0b7e5d5 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/IContainerFactory.java +++ b/src/main/java/net/minecraftforge/network/IContainerFactory.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/ICustomPacket.java b/src/main/java/net/minecraftforge/network/ICustomPacket.java similarity index 97% rename from src/main/java/net/minecraftforge/fmllegacy/network/ICustomPacket.java rename to src/main/java/net/minecraftforge/network/ICustomPacket.java index 4513e05ee3..6eda34070e 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/ICustomPacket.java +++ b/src/main/java/net/minecraftforge/network/ICustomPacket.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import it.unimi.dsi.fastutil.objects.Reference2ReferenceArrayMap; import net.minecraft.network.protocol.Packet; @@ -78,7 +78,7 @@ public interface ICustomPacket> { } default ResourceLocation getName() { - return Fields.lookup.get(this.getClass()).channel.map(f->UnsafeHacks.getField(f, this)).orElse(FMLLoginWrapper.WRAPPER); + return Fields.lookup.get(this.getClass()).channel.map(f->UnsafeHacks.getField(f, this)).orElse(LoginWrapper.WRAPPER); } default int getIndex() { diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLLoginWrapper.java b/src/main/java/net/minecraftforge/network/LoginWrapper.java similarity index 81% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLLoginWrapper.java rename to src/main/java/net/minecraftforge/network/LoginWrapper.java index fc022896b9..6e8a1357ed 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLLoginWrapper.java +++ b/src/main/java/net/minecraftforge/network/LoginWrapper.java @@ -17,13 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import io.netty.buffer.Unpooled; import net.minecraft.network.Connection; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; +import net.minecraftforge.network.event.EventNetworkChannel; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -32,16 +32,17 @@ import org.apache.logging.log4j.Logger; * Wrapper for custom login packets. Transforms unnamed login channel messages into channels dispatched the same * as regular custom packets. */ -public class FMLLoginWrapper { +public class LoginWrapper +{ private static final Logger LOGGER = LogManager.getLogger(); static final ResourceLocation WRAPPER = new ResourceLocation("fml:loginwrapper"); private EventNetworkChannel wrapperChannel; - FMLLoginWrapper() { - wrapperChannel = NetworkRegistry.ChannelBuilder.named(FMLLoginWrapper.WRAPPER). + LoginWrapper() { + wrapperChannel = NetworkRegistry.ChannelBuilder.named(LoginWrapper.WRAPPER). clientAcceptedVersions(a->true). serverAcceptedVersions(a->true). - networkProtocolVersion(()-> FMLNetworkConstants.NETVERSION) + networkProtocolVersion(()-> NetworkConstants.NETVERSION) .eventNetworkChannel(); wrapperChannel.addListener(this::wrapperReceived); } @@ -51,7 +52,7 @@ public class FMLLoginWrapper { if (packet instanceof NetworkEvent.ChannelRegistrationChangeEvent) return; final NetworkEvent.Context wrappedContext = packet.getSource().get(); final FriendlyByteBuf payload = packet.getPayload(); - ResourceLocation targetNetworkReceiver = FMLNetworkConstants.FML_HANDSHAKE_RESOURCE; + ResourceLocation targetNetworkReceiver = NetworkConstants.FML_HANDSHAKE_RESOURCE; FriendlyByteBuf data = null; if (payload != null) { targetNetworkReceiver = payload.readResourceLocation(); @@ -59,11 +60,11 @@ public class FMLLoginWrapper { data = new FriendlyByteBuf(payload.readBytes(payloadLength)); } final int loginSequence = packet.getLoginIndex(); - LOGGER.debug(FMLHandshakeHandler.FMLHSMARKER, "Recieved login wrapper packet event for channel {} with index {}", targetNetworkReceiver, loginSequence); - final NetworkEvent.Context context = new NetworkEvent.Context(wrappedContext.getNetworkManager(), wrappedContext.getDirection(), new PacketDispatcher((rl, buf) -> { - LOGGER.debug(FMLHandshakeHandler.FMLHSMARKER, "Dispatching wrapped packet reply for channel {} with index {}", rl, loginSequence); + LOGGER.debug(HandshakeHandler.FMLHSMARKER, "Recieved login wrapper packet event for channel {} with index {}", targetNetworkReceiver, loginSequence); + final NetworkEvent.Context context = new NetworkEvent.Context(wrappedContext.getNetworkManager(), wrappedContext.getDirection(), (rl, buf) -> { + LOGGER.debug(HandshakeHandler.FMLHSMARKER, "Dispatching wrapped packet reply for channel {} with index {}", rl, loginSequence); wrappedContext.getPacketDispatcher().sendPacket(WRAPPER, this.wrapPacket(rl, buf)); - })); + }); final NetworkEvent.LoginPayloadEvent loginPayloadEvent = new NetworkEvent.LoginPayloadEvent(data, () -> context, loginSequence); NetworkRegistry.findTarget(targetNetworkReceiver).ifPresent(ni -> { ni.dispatchLoginPacket(loginPayloadEvent); diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler.java b/src/main/java/net/minecraftforge/network/MCRegisterPacketHandler.java similarity index 91% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler.java rename to src/main/java/net/minecraftforge/network/MCRegisterPacketHandler.java index 7ff8f8e75f..57b3f8e2ce 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLMCRegisterPacketHandler.java +++ b/src/main/java/net/minecraftforge/network/MCRegisterPacketHandler.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import io.netty.buffer.Unpooled; import io.netty.util.Attribute; @@ -36,8 +36,9 @@ import java.util.Optional; import java.util.Set; import java.util.function.Supplier; -public class FMLMCRegisterPacketHandler { - public static final FMLMCRegisterPacketHandler INSTANCE = new FMLMCRegisterPacketHandler(); +public class MCRegisterPacketHandler +{ + public static final MCRegisterPacketHandler INSTANCE = new MCRegisterPacketHandler(); public static class ChannelList { private Set locations = new HashSet<>(); @@ -100,11 +101,11 @@ public class FMLMCRegisterPacketHandler { } private static ChannelList getFrom(Connection manager) { - return fromAttr(manager.channel().attr(FMLNetworkConstants.FML_MC_REGISTRY)); + return fromAttr(manager.channel().attr(NetworkConstants.FML_MC_REGISTRY)); } private static ChannelList getFrom(NetworkEvent event) { - return fromAttr(event.getSource().get().attr(FMLNetworkConstants.FML_MC_REGISTRY)); + return fromAttr(event.getSource().get().attr(NetworkConstants.FML_MC_REGISTRY)); } private static ChannelList fromAttr(Attribute attr) { @@ -115,7 +116,7 @@ public class FMLMCRegisterPacketHandler { public void sendRegistry(Connection manager, final NetworkDirection dir) { FriendlyByteBuf pb = new FriendlyByteBuf(Unpooled.buffer()); pb.writeBytes(getFrom(manager).toByteArray()); - final ICustomPacket> iPacketICustomPacket = dir.buildPacket(Pair.of(pb, 0), FMLNetworkConstants.MC_REGISTER_RESOURCE); + final ICustomPacket> iPacketICustomPacket = dir.buildPacket(Pair.of(pb, 0), NetworkConstants.MC_REGISTER_RESOURCE); manager.send(iPacketICustomPacket.getThis()); } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java b/src/main/java/net/minecraftforge/network/NetworkConstants.java similarity index 80% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java rename to src/main/java/net/minecraftforge/network/NetworkConstants.java index 26d0f70749..1cfaba037f 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLNetworkConstants.java +++ b/src/main/java/net/minecraftforge/network/NetworkConstants.java @@ -17,13 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import io.netty.util.AttributeKey; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.IExtensionPoint.DisplayTest; -import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; +import net.minecraftforge.network.event.EventNetworkChannel; +import net.minecraftforge.network.simple.SimpleChannel; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.MarkerManager; @@ -31,7 +31,7 @@ import java.util.List; /** * Constants related to networking */ -public class FMLNetworkConstants +public class NetworkConstants { public static final String FMLNETMARKER = "FML"; public static final int FMLNETVERSION = 2; @@ -40,9 +40,9 @@ public class FMLNetworkConstants static final Marker NETWORK = MarkerManager.getMarker("FMLNETWORK"); static final AttributeKey FML_NETVERSION = AttributeKey.valueOf("fml:netversion"); - static final AttributeKey FML_HANDSHAKE_HANDLER = AttributeKey.valueOf("fml:handshake"); - static final AttributeKey FML_MC_REGISTRY = AttributeKey.valueOf("minecraft:netregistry"); - static final AttributeKey FML_CONNECTION_DATA = AttributeKey.valueOf("fml:conndata"); + static final AttributeKey FML_HANDSHAKE_HANDLER = AttributeKey.valueOf("fml:handshake"); + static final AttributeKey FML_MC_REGISTRY = AttributeKey.valueOf("minecraft:netregistry"); + static final AttributeKey FML_CONNECTION_DATA = AttributeKey.valueOf("fml:conndata"); static final ResourceLocation FML_HANDSHAKE_RESOURCE = new ResourceLocation("fml:handshake"); static final ResourceLocation FML_PLAY_RESOURCE = new ResourceLocation("fml:play"); static final ResourceLocation MC_REGISTER_RESOURCE = new ResourceLocation("minecraft:register"); @@ -56,6 +56,6 @@ public class FMLNetworkConstants public static final String IGNORESERVERONLY = "OHNOES\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31\uD83D\uDE31"; public static String init() { - return FMLNetworkConstants.NETVERSION; + return NetworkConstants.NETVERSION; } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkDirection.java b/src/main/java/net/minecraftforge/network/NetworkDirection.java similarity index 98% rename from src/main/java/net/minecraftforge/fmllegacy/network/NetworkDirection.java rename to src/main/java/net/minecraftforge/network/NetworkDirection.java index 5dcddae09f..c4e7bd5ca0 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkDirection.java +++ b/src/main/java/net/minecraftforge/network/NetworkDirection.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import it.unimi.dsi.fastutil.objects.Reference2ReferenceArrayMap; import net.minecraft.network.protocol.Packet; diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkEvent.java b/src/main/java/net/minecraftforge/network/NetworkEvent.java similarity index 79% rename from src/main/java/net/minecraftforge/fmllegacy/network/NetworkEvent.java rename to src/main/java/net/minecraftforge/network/NetworkEvent.java index af94ab328e..4e60a15478 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkEvent.java +++ b/src/main/java/net/minecraftforge/network/NetworkEvent.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import javax.annotation.Nullable; @@ -32,10 +32,13 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.thread.BlockableEventLoop; import net.minecraftforge.eventbus.api.Event; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.common.util.LogicalSidedProvider; +import org.apache.commons.lang3.tuple.Pair; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; import java.util.function.Supplier; public class NetworkEvent extends Event @@ -178,6 +181,10 @@ public class NetworkEvent extends Event this(netHandler, networkDirection, new PacketDispatcher.NetworkManagerDispatcher(netHandler, index, networkDirection.reply()::buildPacket)); } + Context(Connection networkManager, NetworkDirection networkDirection, final BiConsumer packetSink) { + this(networkManager, networkDirection, new PacketDispatcher(packetSink)); + } + Context(Connection networkManager, NetworkDirection networkDirection, PacketDispatcher dispatcher) { this.networkManager = networkManager; this.networkDirection = networkDirection; @@ -236,4 +243,44 @@ public class NetworkEvent extends Event return networkManager; } } + + /** + * Dispatcher for sending packets in response to a received packet. Abstracts out the difference between wrapped packets + * and unwrapped packets. + */ + public static class PacketDispatcher { + BiConsumer packetSink; + + PacketDispatcher(final BiConsumer packetSink) { + this.packetSink = packetSink; + } + + private PacketDispatcher() { + + } + + public void sendPacket(ResourceLocation resourceLocation, FriendlyByteBuf buffer) { + packetSink.accept(resourceLocation, buffer); + } + + static class NetworkManagerDispatcher extends PacketDispatcher + { + private final Connection manager; + private final int packetIndex; + private final BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier; + + NetworkManagerDispatcher(Connection manager, int packetIndex, BiFunction, ResourceLocation, ICustomPacket> customPacketSupplier) { + super(); + this.packetSink = this::dispatchPacket; + this.manager = manager; + this.packetIndex = packetIndex; + this.customPacketSupplier = customPacketSupplier; + } + + private void dispatchPacket(final ResourceLocation resourceLocation, final FriendlyByteBuf buffer) { + final ICustomPacket packet = this.customPacketSupplier.apply(Pair.of(buffer, packetIndex), resourceLocation); + this.manager.send(packet.getThis()); + } + } + } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkHooks.java b/src/main/java/net/minecraftforge/network/NetworkHooks.java similarity index 84% rename from src/main/java/net/minecraftforge/fmllegacy/network/NetworkHooks.java rename to src/main/java/net/minecraftforge/network/NetworkHooks.java index f75d4f9045..2d0f2c877e 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkHooks.java +++ b/src/main/java/net/minecraftforge/network/NetworkHooks.java @@ -17,9 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; -import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -29,11 +28,10 @@ import java.util.stream.Collectors; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; -import net.minecraft.tags.TagCollection; -import net.minecraft.tags.TagContainer; import net.minecraft.network.chat.TextComponent; import net.minecraftforge.fml.util.thread.EffectiveSide; -import net.minecraftforge.fmlclient.ConfigGuiHandler.ConfigGuiFactory; +import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory; +import net.minecraftforge.network.filters.NetworkFilters; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -53,7 +51,6 @@ import net.minecraft.core.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerContainerEvent; import net.minecraftforge.fml.config.ConfigTracker; -import net.minecraftforge.network.NetworkFilters; import javax.annotation.Nullable; @@ -63,7 +60,7 @@ public class NetworkHooks public static String getFMLVersion(final String ip) { - return ip.contains("\0") ? Objects.equals(ip.split("\0")[1], FMLNetworkConstants.NETVERSION) ? FMLNetworkConstants.NETVERSION : ip.split("\0")[1] : FMLNetworkConstants.NOVERSION; + return ip.contains("\0") ? Objects.equals(ip.split("\0")[1], NetworkConstants.NETVERSION) ? NetworkConstants.NETVERSION : ip.split("\0")[1] : NetworkConstants.NOVERSION; } public static ConnectionType getConnectionType(final Supplier connection) @@ -78,12 +75,12 @@ public class NetworkHooks private static ConnectionType getConnectionType(Channel channel) { - return ConnectionType.forVersionFlag(channel.attr(FMLNetworkConstants.FML_NETVERSION).get()); + return ConnectionType.forVersionFlag(channel.attr(NetworkConstants.FML_NETVERSION).get()); } public static Packet getEntitySpawningPacket(Entity entity) { - return FMLNetworkConstants.playChannel.toVanillaPacket(new FMLPlayMessages.SpawnEntity(entity), NetworkDirection.PLAY_TO_CLIENT); + return NetworkConstants.playChannel.toVanillaPacket(new PlayMessages.SpawnEntity(entity), NetworkDirection.PLAY_TO_CLIENT); } public static boolean onCustomPayload(final ICustomPacket packet, final Connection manager) { @@ -108,14 +105,14 @@ public class NetworkHooks } public static void registerServerLoginChannel(Connection manager, ClientIntentionPacket packet) { - manager.channel().attr(FMLNetworkConstants.FML_NETVERSION).set(packet.getFMLVersion()); - FMLHandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_CLIENT); + manager.channel().attr(NetworkConstants.FML_NETVERSION).set(packet.getFMLVersion()); + HandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_CLIENT); } public synchronized static void registerClientLoginChannel(Connection manager) { - manager.channel().attr(FMLNetworkConstants.FML_NETVERSION).set(FMLNetworkConstants.NOVERSION); - FMLHandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_SERVER); + manager.channel().attr(NetworkConstants.FML_NETVERSION).set(NetworkConstants.NOVERSION); + HandshakeHandler.registerHandshake(manager, NetworkDirection.LOGIN_TO_SERVER); } public synchronized static void sendMCRegistryPackets(Connection manager, String direction) { @@ -123,8 +120,8 @@ public class NetworkHooks final Set resourceLocations = NetworkRegistry.buildChannelVersions().keySet().stream(). filter(rl -> !Objects.equals(rl.getNamespace(), "minecraft")). collect(Collectors.toSet()); - FMLMCRegisterPacketHandler.INSTANCE.addChannels(resourceLocations, manager); - FMLMCRegisterPacketHandler.INSTANCE.sendRegistry(manager, NetworkDirection.valueOf(direction)); + MCRegisterPacketHandler.INSTANCE.addChannels(resourceLocations, manager); + MCRegisterPacketHandler.INSTANCE.sendRegistry(manager, NetworkDirection.valueOf(direction)); } //TODO Dimensions.. @@ -153,7 +150,7 @@ public class NetworkHooks public static boolean tickNegotiation(ServerLoginPacketListenerImpl netHandlerLoginServer, Connection networkManager, ServerPlayer player) { - return FMLHandshakeHandler.tickLogin(networkManager); + return HandshakeHandler.tickLogin(networkManager); } /** @@ -215,8 +212,8 @@ public class NetworkHooks } AbstractContainerMenu c = containerSupplier.createMenu(openContainerId, player.getInventory(), player); MenuType type = c.getType(); - FMLPlayMessages.OpenContainer msg = new FMLPlayMessages.OpenContainer(type, openContainerId, containerSupplier.getDisplayName(), output); - FMLNetworkConstants.playChannel.sendTo(msg, player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT); + PlayMessages.OpenContainer msg = new PlayMessages.OpenContainer(type, openContainerId, containerSupplier.getDisplayName(), output); + NetworkConstants.playChannel.sendTo(msg, player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT); player.containerMenu = c; player.initMenu(player.containerMenu); @@ -224,8 +221,8 @@ public class NetworkHooks } @Nullable - public static FMLConnectionData getConnectionData(Connection mgr) + public static ConnectionData getConnectionData(Connection mgr) { - return mgr.channel().attr(FMLNetworkConstants.FML_CONNECTION_DATA).get(); + return mgr.channel().attr(NetworkConstants.FML_CONNECTION_DATA).get(); } } diff --git a/src/main/java/net/minecraftforge/network/NetworkInitialization.java b/src/main/java/net/minecraftforge/network/NetworkInitialization.java new file mode 100644 index 0000000000..57d516c63a --- /dev/null +++ b/src/main/java/net/minecraftforge/network/NetworkInitialization.java @@ -0,0 +1,120 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.network; + +import net.minecraftforge.network.event.EventNetworkChannel; +import net.minecraftforge.network.simple.SimpleChannel; +import net.minecraftforge.registries.RegistryManager; + +import java.util.Arrays; +import java.util.List; + +class NetworkInitialization { + + public static SimpleChannel getHandshakeChannel() { + SimpleChannel handshakeChannel = NetworkRegistry.ChannelBuilder. + named(NetworkConstants.FML_HANDSHAKE_RESOURCE). + clientAcceptedVersions(a -> true). + serverAcceptedVersions(a -> true). + networkProtocolVersion(() -> NetworkConstants.NETVERSION). + simpleChannel(); + + handshakeChannel.messageBuilder(HandshakeMessages.C2SAcknowledge.class, 99, NetworkDirection.LOGIN_TO_SERVER). + loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex). + decoder(HandshakeMessages.C2SAcknowledge::decode). + encoder(HandshakeMessages.C2SAcknowledge::encode). + consumer(HandshakeHandler.indexFirst(HandshakeHandler::handleClientAck)). + add(); + + handshakeChannel.messageBuilder(HandshakeMessages.S2CModList.class, 1, NetworkDirection.LOGIN_TO_CLIENT). + loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex). + decoder(HandshakeMessages.S2CModList::decode). + encoder(HandshakeMessages.S2CModList::encode). + markAsLoginPacket(). + consumer(HandshakeHandler.biConsumerFor(HandshakeHandler::handleServerModListOnClient)). + add(); + + handshakeChannel.messageBuilder(HandshakeMessages.C2SModListReply.class, 2, NetworkDirection.LOGIN_TO_SERVER). + loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex). + decoder(HandshakeMessages.C2SModListReply::decode). + encoder(HandshakeMessages.C2SModListReply::encode). + consumer(HandshakeHandler.indexFirst(HandshakeHandler::handleClientModListOnServer)). + add(); + + handshakeChannel.messageBuilder(HandshakeMessages.S2CRegistry.class, 3, NetworkDirection.LOGIN_TO_CLIENT). + loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex). + decoder(HandshakeMessages.S2CRegistry::decode). + encoder(HandshakeMessages.S2CRegistry::encode). + buildLoginPacketList(RegistryManager::generateRegistryPackets). //TODO: Make this non-static, and store a cache on the client. + consumer(HandshakeHandler.biConsumerFor(HandshakeHandler::handleRegistryMessage)). + add(); + + handshakeChannel.messageBuilder(HandshakeMessages.S2CConfigData.class, 4, NetworkDirection.LOGIN_TO_CLIENT). + loginIndex(HandshakeMessages.LoginIndexedMessage::getLoginIndex, HandshakeMessages.LoginIndexedMessage::setLoginIndex). + decoder(HandshakeMessages.S2CConfigData::decode). + encoder(HandshakeMessages.S2CConfigData::encode). + buildLoginPacketList(ConfigSync.INSTANCE::syncConfigs). + consumer(HandshakeHandler.biConsumerFor(HandshakeHandler::handleConfigSync)). + add(); + + return handshakeChannel; + } + + public static SimpleChannel getPlayChannel() { + SimpleChannel playChannel = NetworkRegistry.ChannelBuilder. + named(NetworkConstants.FML_PLAY_RESOURCE). + clientAcceptedVersions(a -> true). + serverAcceptedVersions(a -> true). + networkProtocolVersion(() -> NetworkConstants.NETVERSION). + simpleChannel(); + + playChannel.messageBuilder(PlayMessages.SpawnEntity.class, 0). + decoder(PlayMessages.SpawnEntity::decode). + encoder(PlayMessages.SpawnEntity::encode). + consumer(PlayMessages.SpawnEntity::handle). + add(); + + playChannel.messageBuilder(PlayMessages.OpenContainer.class,1). + decoder(PlayMessages.OpenContainer::decode). + encoder(PlayMessages.OpenContainer::encode). + consumer(PlayMessages.OpenContainer::handle). + add(); + + return playChannel; + } + + public static List buildMCRegistrationChannels() { + final EventNetworkChannel mcRegChannel = NetworkRegistry.ChannelBuilder. + named(NetworkConstants.MC_REGISTER_RESOURCE). + clientAcceptedVersions(a -> true). + serverAcceptedVersions(a -> true). + networkProtocolVersion(() -> NetworkConstants.NETVERSION). + eventNetworkChannel(); + mcRegChannel.addListener(MCRegisterPacketHandler.INSTANCE::registerListener); + final EventNetworkChannel mcUnregChannel = NetworkRegistry.ChannelBuilder. + named(NetworkConstants.MC_UNREGISTER_RESOURCE). + clientAcceptedVersions(a -> true). + serverAcceptedVersions(a -> true). + networkProtocolVersion(() -> NetworkConstants.NETVERSION). + eventNetworkChannel(); + mcUnregChannel.addListener(MCRegisterPacketHandler.INSTANCE::unregisterListener); + return Arrays.asList(mcRegChannel, mcUnregChannel); + } +} diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInstance.java b/src/main/java/net/minecraftforge/network/NetworkInstance.java similarity index 96% rename from src/main/java/net/minecraftforge/fmllegacy/network/NetworkInstance.java rename to src/main/java/net/minecraftforge/network/NetworkInstance.java index 4c4722828a..b82576addf 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkInstance.java +++ b/src/main/java/net/minecraftforge/network/NetworkInstance.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import net.minecraft.network.Connection; import net.minecraft.resources.ResourceLocation; @@ -108,7 +108,7 @@ public class NetworkInstance } public boolean isRemotePresent(Connection manager) { - FMLConnectionData connectionData = NetworkHooks.getConnectionData(manager); + ConnectionData connectionData = NetworkHooks.getConnectionData(manager); return connectionData != null && connectionData.getChannels().containsKey(channelName); } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkRegistry.java b/src/main/java/net/minecraftforge/network/NetworkRegistry.java similarity index 93% rename from src/main/java/net/minecraftforge/fmllegacy/network/NetworkRegistry.java rename to src/main/java/net/minecraftforge/network/NetworkRegistry.java index a46caf84a0..100e0cc479 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/NetworkRegistry.java +++ b/src/main/java/net/minecraftforge/network/NetworkRegistry.java @@ -17,13 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import net.minecraft.network.Connection; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; +import net.minecraftforge.network.event.EventNetworkChannel; +import net.minecraftforge.network.simple.SimpleChannel; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -44,7 +44,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; /** - * The network registry. Tracks channels on behalf of mods. + * The impl registry. Tracks channels on behalf of mods. */ public class NetworkRegistry { @@ -106,7 +106,7 @@ public class NetworkRegistry * Create a new {@link SimpleChannel}. * * @param name The registry name for this channel. Must be unique - * @param networkProtocolVersion The network protocol version string that will be offered to the remote side {@link ChannelBuilder#networkProtocolVersion(Supplier)} + * @param networkProtocolVersion The impl protocol version string that will be offered to the remote side {@link ChannelBuilder#networkProtocolVersion(Supplier)} * @param clientAcceptedVersions Called on the client with the networkProtocolVersion string from the server {@link ChannelBuilder#clientAcceptedVersions(Predicate)} * @param serverAcceptedVersions Called on the server with the networkProtocolVersion string from the client {@link ChannelBuilder#serverAcceptedVersions(Predicate)} * @return A new {@link SimpleChannel} @@ -121,7 +121,7 @@ public class NetworkRegistry * Create a new {@link EventNetworkChannel}. * * @param name The registry name for this channel. Must be unique - * @param networkProtocolVersion The network protocol version string that will be offered to the remote side {@link ChannelBuilder#networkProtocolVersion(Supplier)} + * @param networkProtocolVersion The impl protocol version string that will be offered to the remote side {@link ChannelBuilder#networkProtocolVersion(Supplier)} * @param clientAcceptedVersions Called on the client with the networkProtocolVersion string from the server {@link ChannelBuilder#clientAcceptedVersions(Predicate)} * @param serverAcceptedVersions Called on the server with the networkProtocolVersion string from the client {@link ChannelBuilder#serverAcceptedVersions(Predicate)} @@ -146,7 +146,7 @@ public class NetworkRegistry { if(lock) { LOGGER.error(NETREGISTRY, "Attempted to register channel {} even though registry phase is over", name); - throw new IllegalArgumentException("Registration of network channels is locked"); + throw new IllegalArgumentException("Registration of impl channels is locked"); } if (instances.containsKey(name)) { LOGGER.error(NETREGISTRY, "NetworkDirection channel {} already registered.", name); @@ -160,7 +160,7 @@ public class NetworkRegistry /** * Find the {@link NetworkInstance}, if possible * - * @param resourceLocation The network instance to lookup + * @param resourceLocation The impl instance to lookup * @return The {@link Optional} {@link NetworkInstance} */ static Optional findTarget(ResourceLocation resourceLocation) @@ -171,8 +171,8 @@ public class NetworkRegistry /** * Construct the Map representation of the channel list, for use during login handshaking * - * @see FMLHandshakeMessages.S2CModList - * @see FMLHandshakeMessages.C2SModListReply + * @see HandshakeMessages.S2CModList + * @see HandshakeMessages.C2SModListReply */ static Map buildChannelVersions() { return instances.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getNetworkProtocolVersion())); @@ -181,8 +181,8 @@ public class NetworkRegistry /** * Construct the Map representation of the channel list, for the client to check against during list ping * - * @see FMLHandshakeMessages.S2CModList - * @see FMLHandshakeMessages.C2SModListReply + * @see HandshakeMessages.S2CModList + * @see HandshakeMessages.C2SModListReply */ static Map> buildChannelVersionsForListPing() { return instances.entrySet().stream(). @@ -210,7 +210,7 @@ public class NetworkRegistry } /** * Validate the channels from the server on the client. Tests the client predicates against the server - * supplied network protocol version. + * supplied impl protocol version. * * @param channels An @{@link Map} of name->version pairs for testing * @return true if all channels accept themselves @@ -221,7 +221,7 @@ public class NetworkRegistry /** * Validate the channels from the client on the server. Tests the server predicates against the client - * supplied network protocol version. + * supplied impl protocol version. * @param channels An @{@link Map} of name->version pairs for testing * @return true if all channels accept themselves */ @@ -257,11 +257,11 @@ public class NetworkRegistry } /** - * Retrieve the {@link LoginPayload} list for dispatch during {@link FMLHandshakeHandler#tickLogin(Connection)} handling. + * Retrieve the {@link LoginPayload} list for dispatch during {@link HandshakeHandler#tickLogin(Connection)} handling. * Dispatches {@link NetworkEvent.GatherLoginPayloadsEvent} to each {@link NetworkInstance}. * * @return The {@link LoginPayload} list - * @param direction the network direction for the request - only gathers for LOGIN_TO_CLIENT + * @param direction the impl direction for the request - only gathers for LOGIN_TO_CLIENT */ static List gatherLoginPayloads(final NetworkDirection direction, boolean isLocal) { if (direction!=NetworkDirection.LOGIN_TO_CLIENT) return Collections.emptyList(); @@ -321,7 +321,7 @@ public class NetworkRegistry */ private final FriendlyByteBuf data; /** - * A channel which will receive a {@link NetworkEvent.LoginPayloadEvent} from the {@link FMLLoginWrapper} + * A channel which will receive a {@link NetworkEvent.LoginPayloadEvent} from the {@link LoginWrapper} */ private final ResourceLocation channelName; @@ -350,7 +350,7 @@ public class NetworkRegistry } /** - * Builder for constructing network channels using a builder style API. + * Builder for constructing impl channels using a builder style API. */ public static class ChannelBuilder { private ResourceLocation channelName; @@ -371,12 +371,12 @@ public class NetworkRegistry } /** - * The network protocol string for this channel. This will be gathered during login and sent to + * The impl protocol string for this channel. This will be gathered during login and sent to * the remote partner, where it will be tested with against the relevant predicate. * * @see #serverAcceptedVersions(Predicate) * @see #clientAcceptedVersions(Predicate) - * @param networkProtocolVersion A supplier of strings for network protocol version testing + * @param networkProtocolVersion A supplier of strings for impl protocol version testing * @return the channel builder */ public ChannelBuilder networkProtocolVersion(Supplier networkProtocolVersion) @@ -412,7 +412,7 @@ public class NetworkRegistry } /** - * Create the network instance + * Create the impl instance * @return the {@link NetworkInstance} */ private NetworkInstance createNetworkInstance() { diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/PacketDistributor.java b/src/main/java/net/minecraftforge/network/PacketDistributor.java similarity index 97% rename from src/main/java/net/minecraftforge/fmllegacy/network/PacketDistributor.java rename to src/main/java/net/minecraftforge/network/PacketDistributor.java index 7e161b3884..66f6555dd2 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/PacketDistributor.java +++ b/src/main/java/net/minecraftforge/network/PacketDistributor.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import net.minecraft.client.Minecraft; import net.minecraft.world.entity.Entity; @@ -29,9 +29,8 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.server.level.ServerChunkCache; -import net.minecraftforge.fml.LogicalSide; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; -import net.minecraftforge.fmllegacy.network.simple.SimpleChannel; +import net.minecraftforge.network.simple.SimpleChannel; +import net.minecraftforge.server.ServerLifecycleHooks; import java.util.List; import java.util.function.BiFunction; @@ -262,6 +261,6 @@ public class PacketDistributor { } private MinecraftServer getServer() { - return LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); + return ServerLifecycleHooks.getCurrentServer(); } } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLPlayMessages.java b/src/main/java/net/minecraftforge/network/PlayMessages.java similarity index 97% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLPlayMessages.java rename to src/main/java/net/minecraftforge/network/PlayMessages.java index fae848da92..41df322cb0 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLPlayMessages.java +++ b/src/main/java/net/minecraftforge/network/PlayMessages.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; @@ -35,15 +35,17 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; import net.minecraft.world.level.Level; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraft.core.Registry; import net.minecraft.network.chat.Component; -import net.minecraftforge.fmllegacy.common.registry.IEntityAdditionalSpawnData; +import net.minecraftforge.entity.IEntityAdditionalSpawnData; +import net.minecraftforge.network.NetworkEvent; + import java.util.Optional; import java.util.UUID; import java.util.function.Supplier; -public class FMLPlayMessages +public class PlayMessages { /** * Used to spawn a custom entity without the same restrictions as diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/FMLStatusPing.java b/src/main/java/net/minecraftforge/network/ServerStatusPing.java similarity index 87% rename from src/main/java/net/minecraftforge/fmllegacy/network/FMLStatusPing.java rename to src/main/java/net/minecraftforge/network/ServerStatusPing.java index 6b1f053e26..0a358406bd 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/FMLStatusPing.java +++ b/src/main/java/net/minecraftforge/network/ServerStatusPing.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network; +package net.minecraftforge.network; import com.google.common.collect.ImmutableMap; import com.google.gson.JsonArray; @@ -60,7 +60,8 @@ import java.util.stream.StreamSupport; * } * */ -public class FMLStatusPing { +public class ServerStatusPing +{ private static final Logger LOGGER = LogManager.getLogger(); private static final int CHANNEL_TRUNCATE_LIMIT = 150; private static final int MOD_TRUNCATE_LIMIT = 150; @@ -71,19 +72,19 @@ public class FMLStatusPing { private transient int fmlNetworkVer; private transient boolean truncated; - public FMLStatusPing() { + public ServerStatusPing() { this.channels = NetworkRegistry.buildChannelVersionsForListPing(); this.mods = new HashMap<>(); ModList.get().forEachModContainer((modid, mc) -> mods.put(modid, mc.getCustomExtension(IExtensionPoint.DisplayTest.class) .map(IExtensionPoint.DisplayTest::suppliedVersion) .map(Supplier::get) - .orElse(FMLNetworkConstants.IGNORESERVERONLY))); - this.fmlNetworkVer = FMLNetworkConstants.FMLNETVERSION; + .orElse(NetworkConstants.IGNORESERVERONLY))); + this.fmlNetworkVer = NetworkConstants.FMLNETVERSION; this.truncated = false; } - private FMLStatusPing(Map> deserialized, Map modMarkers, int fmlNetVer, boolean truncated) { + private ServerStatusPing(Map> deserialized, Map modMarkers, int fmlNetVer, boolean truncated) { this.channels = ImmutableMap.copyOf(deserialized); this.mods = modMarkers; this.fmlNetworkVer = fmlNetVer; @@ -91,7 +92,7 @@ public class FMLStatusPing { } public static class Serializer { - public static FMLStatusPing deserialize(JsonObject forgeData, JsonDeserializationContext ctx) { + public static ServerStatusPing deserialize(JsonObject forgeData, JsonDeserializationContext ctx) { try { final Map> channels = StreamSupport.stream(GsonHelper.getAsJsonArray(forgeData, "channels").spliterator(), false). map(JsonElement::getAsJsonObject). @@ -105,21 +106,21 @@ public class FMLStatusPing { final int remoteFMLVersion = GsonHelper.getAsInt(forgeData, "fmlNetworkVersion"); final boolean truncated = GsonHelper.getAsBoolean(forgeData, "truncated", false); - return new FMLStatusPing(channels, mods, remoteFMLVersion, truncated); + return new ServerStatusPing(channels, mods, remoteFMLVersion, truncated); } catch (JsonSyntaxException e) { - LOGGER.debug(FMLNetworkConstants.NETWORK, "Encountered an error parsing status ping data", e); + LOGGER.debug(NetworkConstants.NETWORK, "Encountered an error parsing status ping data", e); return null; } } - public static JsonObject serialize(FMLStatusPing forgeData, JsonSerializationContext ctx) { + public static JsonObject serialize(ServerStatusPing forgeData, JsonSerializationContext ctx) { JsonObject obj = new JsonObject(); JsonArray channels = new JsonArray(); boolean truncated = forgeData.channels.size() > CHANNEL_TRUNCATE_LIMIT || forgeData.mods.size() > MOD_TRUNCATE_LIMIT; if (truncated && !warnedAboutTruncation) { warnedAboutTruncation = true; - LOGGER.warn("Heuristically truncating mod and/or network channel list in server status ping packet. Compatibility report " + + LOGGER.warn("Heuristically truncating mod and/or impl channel list in server status ping packet. Compatibility report " + "in the multiplayer screen may be inaccurate."); } diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/event/EventNetworkChannel.java b/src/main/java/net/minecraftforge/network/event/EventNetworkChannel.java similarity index 89% rename from src/main/java/net/minecraftforge/fmllegacy/network/event/EventNetworkChannel.java rename to src/main/java/net/minecraftforge/network/event/EventNetworkChannel.java index a177e287e2..734d10c488 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/event/EventNetworkChannel.java +++ b/src/main/java/net/minecraftforge/network/event/EventNetworkChannel.java @@ -17,11 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network.event; +package net.minecraftforge.network.event; import net.minecraft.network.Connection; -import net.minecraftforge.fmllegacy.network.NetworkEvent; -import net.minecraftforge.fmllegacy.network.NetworkInstance; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.network.NetworkInstance; import java.util.function.Consumer; diff --git a/src/main/java/net/minecraftforge/network/CommandTreeCleaner.java b/src/main/java/net/minecraftforge/network/filters/CommandTreeCleaner.java similarity index 98% rename from src/main/java/net/minecraftforge/network/CommandTreeCleaner.java rename to src/main/java/net/minecraftforge/network/filters/CommandTreeCleaner.java index 9861621714..ab12d8c586 100644 --- a/src/main/java/net/minecraftforge/network/CommandTreeCleaner.java +++ b/src/main/java/net/minecraftforge/network/filters/CommandTreeCleaner.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.network; +package net.minecraftforge.network.filters; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java similarity index 96% rename from src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java rename to src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java index f30eeadee6..c4fb6b9c78 100644 --- a/src/main/java/net/minecraftforge/network/ForgeConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/ForgeConnectionNetworkFilter.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.network; +package net.minecraftforge.network.filters; import java.util.List; import java.util.Map; @@ -42,13 +42,6 @@ import com.google.common.collect.ImmutableMap; @ChannelHandler.Sharable public class ForgeConnectionNetworkFilter extends VanillaPacketFilter { - - @Deprecated - public ForgeConnectionNetworkFilter() - { - this(null); - } - public ForgeConnectionNetworkFilter(@Nullable Connection manager) { super(buildHandlers(manager)); diff --git a/src/main/java/net/minecraftforge/network/NetworkFilters.java b/src/main/java/net/minecraftforge/network/filters/NetworkFilters.java similarity index 97% rename from src/main/java/net/minecraftforge/network/NetworkFilters.java rename to src/main/java/net/minecraftforge/network/filters/NetworkFilters.java index fb9b9b4a29..4f20dcfc23 100644 --- a/src/main/java/net/minecraftforge/network/NetworkFilters.java +++ b/src/main/java/net/minecraftforge/network/filters/NetworkFilters.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.network; +package net.minecraftforge.network.filters; import java.util.Map; import java.util.function.Function; diff --git a/src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java similarity index 96% rename from src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java rename to src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java index 4c9dab6164..5341a6c7ce 100644 --- a/src/main/java/net/minecraftforge/network/VanillaConnectionNetworkFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaConnectionNetworkFilter.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.network; +package net.minecraftforge.network.filters; import java.util.Collections; import java.util.List; @@ -40,7 +40,7 @@ import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagCollection; import net.minecraftforge.common.ForgeTagHandler; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; @@ -50,7 +50,7 @@ import com.google.common.collect.ImmutableMap; import com.mojang.brigadier.tree.RootCommandNode; /** - * A filter for network packets, used to filter/modify parts of vanilla network messages that + * A filter for impl packets, used to filter/modify parts of vanilla impl messages that * will cause errors or warnings on vanilla clients, for example entity attributes that are added by Forge or mods. */ @ChannelHandler.Sharable diff --git a/src/main/java/net/minecraftforge/network/VanillaPacketFilter.java b/src/main/java/net/minecraftforge/network/filters/VanillaPacketFilter.java similarity index 97% rename from src/main/java/net/minecraftforge/network/VanillaPacketFilter.java rename to src/main/java/net/minecraftforge/network/filters/VanillaPacketFilter.java index e5526c150d..6d47c1a304 100644 --- a/src/main/java/net/minecraftforge/network/VanillaPacketFilter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaPacketFilter.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.network; +package net.minecraftforge.network.filters; import java.util.AbstractMap; import java.util.List; @@ -33,7 +33,7 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.Connection; /** - * A filter for vanilla network packets. + * A filter for vanilla impl packets. */ public abstract class VanillaPacketFilter extends MessageToMessageEncoder> { diff --git a/src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java b/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java similarity index 93% rename from src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java rename to src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java index 5b623163de..4e6668e69d 100644 --- a/src/main/java/net/minecraftforge/network/VanillaPacketSplitter.java +++ b/src/main/java/net/minecraftforge/network/filters/VanillaPacketSplitter.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.network; +package net.minecraftforge.network.filters; import java.util.ArrayList; import java.util.List; @@ -32,12 +32,8 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fmllegacy.network.FMLConnectionData; -import net.minecraftforge.fmllegacy.network.NetworkDirection; -import net.minecraftforge.fmllegacy.network.NetworkEvent; -import net.minecraftforge.fmllegacy.network.NetworkHooks; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; -import net.minecraftforge.fmllegacy.network.event.EventNetworkChannel; +import net.minecraftforge.network.*; +import net.minecraftforge.network.event.EventNetworkChannel; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -183,7 +179,7 @@ public class VanillaPacketSplitter public static RemoteCompatibility getRemoteCompatibility(Connection manager) { - FMLConnectionData connectionData = NetworkHooks.getConnectionData(manager); + ConnectionData connectionData = NetworkHooks.getConnectionData(manager); if (connectionData != null && connectionData.getChannels().containsKey(CHANNEL)) { return RemoteCompatibility.PRESENT; diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/simple/IndexedMessageCodec.java b/src/main/java/net/minecraftforge/network/simple/IndexedMessageCodec.java similarity index 96% rename from src/main/java/net/minecraftforge/fmllegacy/network/simple/IndexedMessageCodec.java rename to src/main/java/net/minecraftforge/network/simple/IndexedMessageCodec.java index f460a7f29a..da1b056c64 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/simple/IndexedMessageCodec.java +++ b/src/main/java/net/minecraftforge/network/simple/IndexedMessageCodec.java @@ -17,15 +17,15 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network.simple; +package net.minecraftforge.network.simple; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.fmllegacy.network.NetworkDirection; -import net.minecraftforge.fmllegacy.network.NetworkEvent; -import net.minecraftforge.fmllegacy.network.NetworkHooks; -import net.minecraftforge.fmllegacy.network.NetworkInstance; +import net.minecraftforge.network.NetworkDirection; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.network.NetworkHooks; +import net.minecraftforge.network.NetworkInstance; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; diff --git a/src/main/java/net/minecraftforge/fmllegacy/network/simple/SimpleChannel.java b/src/main/java/net/minecraftforge/network/simple/SimpleChannel.java similarity index 96% rename from src/main/java/net/minecraftforge/fmllegacy/network/simple/SimpleChannel.java rename to src/main/java/net/minecraftforge/network/simple/SimpleChannel.java index 2754e0c42d..3e86dc1561 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/network/simple/SimpleChannel.java +++ b/src/main/java/net/minecraftforge/network/simple/SimpleChannel.java @@ -17,17 +17,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.network.simple; +package net.minecraftforge.network.simple; import io.netty.buffer.Unpooled; import net.minecraft.client.Minecraft; import net.minecraft.network.Connection; import net.minecraft.network.protocol.Packet; import net.minecraft.network.FriendlyByteBuf; -import net.minecraftforge.fmllegacy.network.NetworkDirection; -import net.minecraftforge.fmllegacy.network.NetworkEvent; -import net.minecraftforge.fmllegacy.network.NetworkInstance; -import net.minecraftforge.fmllegacy.network.PacketDistributor; +import net.minecraftforge.network.NetworkDirection; +import net.minecraftforge.network.NetworkEvent; +import net.minecraftforge.network.NetworkInstance; +import net.minecraftforge.network.PacketDistributor; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; @@ -160,7 +160,7 @@ public class SimpleChannel * packet. * @param type Type of message * @param id id in the indexed codec - * @param direction a network direction which will be asserted before any processing of this message occurs. Use to + * @param direction a impl direction which will be asserted before any processing of this message occurs. Use to * enforce strict sided handling to prevent spoofing. * @param Type of type * @return a MessageBuilder diff --git a/src/main/java/net/minecraftforge/registries/DeferredRegister.java b/src/main/java/net/minecraftforge/registries/DeferredRegister.java index f27727c4c8..f2defe8b2b 100644 --- a/src/main/java/net/minecraftforge/registries/DeferredRegister.java +++ b/src/main/java/net/minecraftforge/registries/DeferredRegister.java @@ -23,7 +23,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmllegacy.RegistryObject; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java index e46ce5649a..3cf5186375 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistries.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistries.java @@ -46,19 +46,15 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.chunk.ChunkStatus; -import net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType; import net.minecraft.world.level.levelgen.carver.WorldCarver; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; -import net.minecraft.world.level.levelgen.placement.FeatureDecorator; -import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraftforge.common.Tags; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; -import net.minecraftforge.common.world.ForgeWorldType; -import net.minecraftforge.fmllegacy.common.registry.GameRegistry; +import net.minecraftforge.common.world.ForgeWorldPreset; /** * A class that exposes static references to all vanilla and Forge registries. @@ -96,13 +92,10 @@ public class ForgeRegistries // Worldgen public static final IForgeRegistry> WORLD_CARVERS = RegistryManager.ACTIVE.getRegistry(WorldCarver.class); - public static final IForgeRegistry> SURFACE_BUILDERS = RegistryManager.ACTIVE.getRegistry(SurfaceBuilder.class); public static final IForgeRegistry> FEATURES = RegistryManager.ACTIVE.getRegistry(Feature.class); - public static final IForgeRegistry> DECORATORS = RegistryManager.ACTIVE.getRegistry(FeatureDecorator.class); public static final IForgeRegistry CHUNK_STATUS = RegistryManager.ACTIVE.getRegistry(ChunkStatus.class); public static final IForgeRegistry> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(StructureFeature.class); public static final IForgeRegistry> BLOCK_STATE_PROVIDER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockStateProviderType.class); - public static final IForgeRegistry> BLOCK_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockPlacerType.class); public static final IForgeRegistry> FOLIAGE_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(FoliagePlacerType.class); public static final IForgeRegistry> TREE_DECORATOR_TYPES = RegistryManager.ACTIVE.getRegistry(TreeDecoratorType.class); @@ -112,7 +105,7 @@ public class ForgeRegistries // Custom forge registries public static final IForgeRegistry DATA_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class); public static final IForgeRegistry> LOOT_MODIFIER_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(GlobalLootModifierSerializer.class); - public static final IForgeRegistry WORLD_TYPES = RegistryManager.ACTIVE.getRegistry(ForgeWorldType.class); + public static final IForgeRegistry WORLD_TYPES = RegistryManager.ACTIVE.getRegistry(ForgeWorldPreset.class); public static final class Keys { //Vanilla @@ -138,13 +131,10 @@ public class ForgeRegistries public static final ResourceKey> SCHEDULES = key("schedule"); public static final ResourceKey> ACTIVITIES = key("activity"); public static final ResourceKey>> WORLD_CARVERS = key("worldgen/carver"); - public static final ResourceKey>> SURFACE_BUILDERS = key("worldgen/surface_builder"); public static final ResourceKey>> FEATURES = key("worldgen/feature"); - public static final ResourceKey>> DECORATORS = key("worldgen/decorator"); public static final ResourceKey> CHUNK_STATUS = key("chunk_status"); public static final ResourceKey>> STRUCTURE_FEATURES = key("worldgen/structure_feature"); public static final ResourceKey>> BLOCK_STATE_PROVIDER_TYPES = key("worldgen/block_state_provider_type"); - public static final ResourceKey>> BLOCK_PLACER_TYPES = key("worldgen/block_placer_type"); public static final ResourceKey>> FOLIAGE_PLACER_TYPES = key("worldgen/foliage_placer_type"); public static final ResourceKey>> TREE_DECORATOR_TYPES = key("worldgen/tree_decorator_type"); @@ -154,7 +144,7 @@ public class ForgeRegistries //Forge public static final ResourceKey> DATA_SERIALIZERS = key("data_serializers"); public static final ResourceKey>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers"); - public static final ResourceKey> WORLD_TYPES = key("forge:world_types"); + public static final ResourceKey> WORLD_TYPES = key("forge:world_types"); private static ResourceKey> key(String name) { diff --git a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java index 844b6fe904..565aae9cb1 100644 --- a/src/main/java/net/minecraftforge/registries/ForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ForgeRegistry.java @@ -19,13 +19,7 @@ package net.minecraftforge.registries; -import java.util.BitSet; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import javax.annotation.Nonnull; @@ -36,8 +30,6 @@ import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import org.apache.commons.lang3.Validate; -import java.util.Set; - import com.google.common.base.Preconditions; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.BiMap; @@ -76,6 +68,7 @@ public class ForgeRegistry> implements IForgeRe private final Map aliases = Maps.newHashMap(); final Map slaves = Maps.newHashMap(); private final ResourceLocation defaultKey; + private final ResourceKey defaultResourceKey; private final CreateCallback create; private final AddCallback add; private final ClearCallback clear; @@ -111,6 +104,7 @@ public class ForgeRegistry> implements IForgeRe this.stage = stage; this.superType = builder.getType(); this.defaultKey = builder.getDefault(); + this.defaultResourceKey = ResourceKey.create(key, defaultKey); this.min = builder.getMinId(); this.max = builder.getMaxId(); this.availabilityMap = new BitSet(Math.min(max + 1, 0x0FFF)); @@ -237,6 +231,12 @@ public class ForgeRegistry> implements IForgeRe return ret == null ? this.defaultKey : ret; } + @Override + public Optional> getResourceKey(V value) + { + return Optional.ofNullable(this.keys.inverse().get(value)); + } + @Override public Set getKeys() { diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index f0040e66f8..16ef0d0c9f 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -58,20 +58,17 @@ import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.levelgen.DebugLevelSource; -import net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType; import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType; import net.minecraft.world.level.levelgen.carver.WorldCarver; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.StructureFeature; import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType; -import net.minecraft.world.level.levelgen.placement.FeatureDecorator; -import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder; import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType; import net.minecraftforge.common.ForgeTagHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.util.LogMessageAdapter; -import net.minecraftforge.common.world.ForgeWorldType; +import net.minecraftforge.common.world.ForgeWorldPreset; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.RegistryEvent.MissingMappings; import net.minecraftforge.fml.ModLoadingContext; @@ -79,7 +76,6 @@ import net.minecraftforge.fml.IModStateTransition; import net.minecraftforge.fml.StartupMessageManager; import net.minecraftforge.fml.util.EnhancedRuntimeException; import net.minecraftforge.fml.util.thread.EffectiveSide; -import net.minecraftforge.fmllegacy.event.lifecycle.FMLModIdMappingEvent; import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; @@ -165,13 +161,10 @@ public class GameData // Worldgen makeRegistry(WORLD_CARVERS, c(WorldCarver.class)).disableSaving().disableSync().create(); - makeRegistry(SURFACE_BUILDERS, c(SurfaceBuilder.class)).disableSaving().disableSync().create(); makeRegistry(FEATURES, c(Feature.class)).addCallback(FeatureCallbacks.INSTANCE).disableSaving().disableSync().create(); - makeRegistry(DECORATORS, c(FeatureDecorator.class)).disableSaving().disableSync().create(); makeRegistry(CHUNK_STATUS, ChunkStatus.class, "empty").disableSaving().disableSync().create(); makeRegistry(STRUCTURE_FEATURES, c(StructureFeature.class)).disableSaving().disableSync().create(); makeRegistry(BLOCK_STATE_PROVIDER_TYPES, c(BlockStateProviderType.class)).disableSaving().disableSync().create(); - makeRegistry(BLOCK_PLACER_TYPES, c(BlockPlacerType.class)).disableSaving().disableSync().create(); makeRegistry(FOLIAGE_PLACER_TYPES, c(FoliagePlacerType.class)).disableSaving().disableSync().create(); makeRegistry(TREE_DECORATOR_TYPES, c(TreeDecoratorType.class)).disableSaving().disableSync().create(); @@ -181,7 +174,7 @@ public class GameData // Custom forge registries makeRegistry(DATA_SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create(); makeRegistry(LOOT_MODIFIER_SERIALIZERS, c(GlobalLootModifierSerializer.class)).disableSaving().disableSync().create(); - makeRegistry(WORLD_TYPES, ForgeWorldType.class).disableSaving().disableSync().create(); + makeRegistry(WORLD_TYPES, ForgeWorldPreset.class).disableSaving().disableSync().create(); } @SuppressWarnings("unchecked") //Ugly hack to let us pass in a typed Class object. Remove when we remove type specific references. private static Class c(Class cls) { return (Class)cls; } @@ -883,7 +876,7 @@ public class GameData private static void fireRemapEvent(final Map> remaps, final boolean isFreezing) { StartupMessageManager.modLoaderConsumer().ifPresent(s->s.accept("Remapping mod data")); - MinecraftForge.EVENT_BUS.post(new FMLModIdMappingEvent(remaps, isFreezing)); + MinecraftForge.EVENT_BUS.post(new RegistryEvent.IdMappingEvent(remaps, isFreezing)); StartupMessageManager.modLoaderConsumer().ifPresent(s->s.accept("Remap complete")); } diff --git a/src/main/java/net/minecraftforge/registries/IForgeRegistry.java b/src/main/java/net/minecraftforge/registries/IForgeRegistry.java index f2a896c539..7bc53ded7b 100644 --- a/src/main/java/net/minecraftforge/registries/IForgeRegistry.java +++ b/src/main/java/net/minecraftforge/registries/IForgeRegistry.java @@ -21,6 +21,7 @@ package net.minecraftforge.registries; import java.util.Collection; import java.util.Map.Entry; +import java.util.Optional; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -49,6 +50,7 @@ public interface IForgeRegistry> extends Iterab @Nullable V getValue(ResourceLocation key); @Nullable ResourceLocation getKey(V value); @Nullable ResourceLocation getDefaultKey(); + @Nullable Optional> getResourceKey(V value); @Nonnull Set getKeys(); @Nonnull Collection getValues(); diff --git a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java index 17d61cb8e1..53ab82387a 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedDefaultedWrapper.java @@ -110,6 +110,12 @@ class NamespacedDefaultedWrapper> extends Defau return this.delegate.getKey(value); } + @Override + public Optional> getResourceKey(T p_122755_) + { + return this.delegate.getResourceKey(p_122755_); + } + @Override public boolean containsKey(ResourceLocation key) { @@ -129,6 +135,11 @@ class NamespacedDefaultedWrapper> extends Defau return this.delegate.getValue(id); } + @Override + public Lifecycle lifecycle(T p_122764_) { + return Lifecycle.stable(); + } + @Override public Iterator iterator() { diff --git a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java index 74ddc1eee8..efd7944c44 100644 --- a/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java +++ b/src/main/java/net/minecraftforge/registries/NamespacedWrapper.java @@ -108,6 +108,12 @@ class NamespacedWrapper> extends MappedRegistry return this.delegate.getKey(value); } + @Override + public Optional> getResourceKey(T p_122755_) + { + return this.delegate.getResourceKey(p_122755_); + } + @Override public boolean containsKey(ResourceLocation key) { @@ -127,6 +133,11 @@ class NamespacedWrapper> extends MappedRegistry return this.delegate.getValue(id); } + @Override + public Lifecycle lifecycle(T p_122764_) { + return Lifecycle.stable(); + } + @Override public Iterator iterator() { diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java index 1d9bfe0a6c..22ce797c73 100644 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java +++ b/src/main/java/net/minecraftforge/registries/ObjectHolderRef.java @@ -36,7 +36,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @SuppressWarnings("rawtypes") -public class ObjectHolderRef implements Consumer> +class ObjectHolderRef implements Consumer> { private static final Logger LOGGER = LogManager.getLogger(); private Field field; diff --git a/src/main/java/net/minecraftforge/registries/RegistryManager.java b/src/main/java/net/minecraftforge/registries/RegistryManager.java index 27e3a13869..977ea5c791 100644 --- a/src/main/java/net/minecraftforge/registries/RegistryManager.java +++ b/src/main/java/net/minecraftforge/registries/RegistryManager.java @@ -35,7 +35,7 @@ import com.google.common.collect.Sets.SetView; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.core.Registry; -import net.minecraftforge.fmllegacy.network.FMLHandshakeMessages; +import net.minecraftforge.network.HandshakeMessages; import net.minecraftforge.registries.ForgeRegistry.Snapshot; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.LogManager; @@ -190,10 +190,10 @@ public class RegistryManager this.superTypes.clear(); } - public static List> generateRegistryPackets(boolean isLocal) + public static List> generateRegistryPackets(boolean isLocal) { return !isLocal ? ACTIVE.takeSnapshot(false).entrySet().stream(). - map(e->Pair.of("Registry " + e.getKey(), new FMLHandshakeMessages.S2CRegistry(e.getKey(), e.getValue()))). + map(e->Pair.of("Registry " + e.getKey(), new HandshakeMessages.S2CRegistry(e.getKey(), e.getValue()))). collect(Collectors.toList()) : Collections.emptyList(); } diff --git a/src/main/java/net/minecraftforge/fmllegacy/RegistryObject.java b/src/main/java/net/minecraftforge/registries/RegistryObject.java similarity index 97% rename from src/main/java/net/minecraftforge/fmllegacy/RegistryObject.java rename to src/main/java/net/minecraftforge/registries/RegistryObject.java index 5e05e66363..fb5b3d6452 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/RegistryObject.java +++ b/src/main/java/net/minecraftforge/registries/RegistryObject.java @@ -17,13 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy; +package net.minecraftforge.registries; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -import net.minecraftforge.registries.ObjectHolderRegistry; -import net.minecraftforge.registries.RegistryManager; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/net/minecraftforge/fmllegacy/packs/DelegatingResourcePack.java b/src/main/java/net/minecraftforge/resource/DelegatingResourcePack.java similarity index 99% rename from src/main/java/net/minecraftforge/fmllegacy/packs/DelegatingResourcePack.java rename to src/main/java/net/minecraftforge/resource/DelegatingResourcePack.java index 2b87cc9a22..bce6f799c9 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/packs/DelegatingResourcePack.java +++ b/src/main/java/net/minecraftforge/resource/DelegatingResourcePack.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.packs; +package net.minecraftforge.resource; import java.io.File; import java.io.IOException; diff --git a/src/main/java/net/minecraftforge/resource/IResourceType.java b/src/main/java/net/minecraftforge/resource/IResourceType.java deleted file mode 100644 index 9646fd02d5..0000000000 --- a/src/main/java/net/minecraftforge/resource/IResourceType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.resource; - -/** - * Represents a generic type of reloadable resource. Used for resource reload filtering. - * @deprecated Selective reloading is no longer supported due to vanilla now reloading resources in parallel - */ -@Deprecated(since="1.17.1", forRemoval = true) -public interface IResourceType -{ -} diff --git a/src/main/java/net/minecraftforge/resource/ReloadRequirements.java b/src/main/java/net/minecraftforge/resource/ReloadRequirements.java deleted file mode 100644 index d062ff3244..0000000000 --- a/src/main/java/net/minecraftforge/resource/ReloadRequirements.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.resource; - -import java.util.Set; -import java.util.function.Predicate; - -import com.google.common.collect.Sets; - -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; - -/** - * Holds methods to create standard predicates to select {@link IResourceType}s that should be reloaded. - * @deprecated Selective reloading is no longer supported due to vanilla now reloading resources in parallel - */ -@OnlyIn(Dist.CLIENT) -@Deprecated(since="1.17.1", forRemoval = true) -public final class ReloadRequirements -{ - /** - * Creates a reload predicate accepting all resource types. - * - * @return a predicate accepting all types - */ - public static Predicate all() - { - return type -> true; - } - - /** - * Creates an inclusive reload predicate. Only given resource types will be loaded along with this. - * - * @param inclusion the set of resource types to be included in the reload - * @return an inclusion predicate based on the given types - */ - public static Predicate include(IResourceType... inclusion) - { - Set inclusionSet = Sets.newHashSet(inclusion); - return inclusionSet::contains; - } -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/packs/ResourcePackLoader.java b/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java similarity index 82% rename from src/main/java/net/minecraftforge/fmllegacy/packs/ResourcePackLoader.java rename to src/main/java/net/minecraftforge/resource/ResourcePackLoader.java index 642183f0b3..9a99d95646 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/packs/ResourcePackLoader.java +++ b/src/main/java/net/minecraftforge/resource/ResourcePackLoader.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.packs; +package net.minecraftforge.resource; import java.util.ArrayList; import java.util.Comparator; @@ -47,14 +47,6 @@ import net.minecraftforge.resource.PathResourcePack; public class ResourcePackLoader { private static Map modResourcePacks; - @Deprecated(since="1.18", forRemoval = true) - public static Optional getResourcePackFor(String modId) { - return Optional.ofNullable(ModList.get().getModFileById(modId)). - map(IModFileInfo::getFile).map(mf->modResourcePacks.get(mf)) - .filter(ModFileResourcePack.class::isInstance) - .map(ModFileResourcePack.class::cast); - } - public static Optional getPackFor(String modId) { return Optional.ofNullable(ModList.get().getModFileById(modId)). map(IModFileInfo::getFile).map(mf->modResourcePacks.get(mf)); @@ -68,7 +60,7 @@ public class ResourcePackLoader { public static void loadResourcePacks(PackRepository resourcePacks, Function, ? extends RepositorySource> packFinder) { modResourcePacks = ModList.get().getModFiles().stream() .filter(mf->mf.requiredLanguageLoaders().stream().noneMatch(ls->ls.languageName().equals("minecraft"))) - .map(mf -> Pair.of(mf, new ModFileResourcePack(mf.getFile()))) // TODO: change to PathResourcePack in 1.18 + .map(mf -> Pair.of(mf, new PathResourcePack(mf.getFile().getFileName(), mf.getFile().getFilePath()))) .collect(Collectors.toMap(p -> p.getFirst().getFile(), Pair::getSecond, (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); }, LinkedHashMap::new)); resourcePacks.addPackFinder(packFinder.apply(modResourcePacks)); } @@ -106,14 +98,4 @@ public class ResourcePackLoader { }; } - @Deprecated(since="1.18", forRemoval = true) - public interface IPackInfoFinder extends RepositorySource { - - @Override - default void loadPacks(Consumer consumer, PackConstructor factory) { - addPackInfos(consumer, factory); - } - - void addPackInfos(Consumer consumer, PackConstructor factory); - } } diff --git a/src/main/java/net/minecraftforge/resource/VanillaResourceType.java b/src/main/java/net/minecraftforge/resource/VanillaResourceType.java deleted file mode 100644 index 818109fc6d..0000000000 --- a/src/main/java/net/minecraftforge/resource/VanillaResourceType.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.resource; - -/** - * An enum of all {@link IResourceType}s used by the Vanilla game. These should be used if handling vanilla-related - * resources. - * @deprecated Selective reloading is no longer supported due to vanilla now reloading resources in parallel - */ -@Deprecated(since="1.17.1", forRemoval = true) -public enum VanillaResourceType implements IResourceType -{ - /** - * Used when block and item models are reloaded and rebaked. This also includes the texture-stitching from that - * phase. - */ - MODELS, - - /** - * Used when textures from the {@link net.minecraft.client.renderer.texture.TextureManager} are reloaded. Does not - * effect block or item textures on the texture atlas. - */ - TEXTURES, - - /** - * Used when all game sounds are reloaded. - */ - SOUNDS, - - /** - * Used when the current language is reloaded. - */ - LANGUAGES, - - /** - * Used when all shaders are reloaded. - */ - SHADERS, -} diff --git a/src/main/java/net/minecraftforge/fmllegacy/server/LanguageHook.java b/src/main/java/net/minecraftforge/server/LanguageHook.java similarity index 98% rename from src/main/java/net/minecraftforge/fmllegacy/server/LanguageHook.java rename to src/main/java/net/minecraftforge/server/LanguageHook.java index 7af0709a0c..ae81121b69 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/server/LanguageHook.java +++ b/src/main/java/net/minecraftforge/server/LanguageHook.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.server; +package net.minecraftforge.server; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -27,7 +27,7 @@ import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.MinecraftServer; import net.minecraft.util.GsonHelper; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.fmllegacy.ForgeI18n; +import net.minecraftforge.common.ForgeI18n; import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/minecraftforge/fmllegacy/server/ServerLifecycleHooks.java b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java similarity index 79% rename from src/main/java/net/minecraftforge/fmllegacy/server/ServerLifecycleHooks.java rename to src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java index a8f84d8694..f133e01fd4 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/server/ServerLifecycleHooks.java +++ b/src/main/java/net/minecraftforge/server/ServerLifecycleHooks.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.server; +package net.minecraftforge.server; import static net.minecraftforge.fml.Logging.CORE; @@ -27,23 +27,21 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.BiConsumer; import java.util.function.Consumer; import net.minecraft.server.packs.repository.PackSource; import net.minecraft.server.packs.repository.RepositorySource; import net.minecraft.world.level.storage.LevelResource; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.common.util.LogicalSidedProvider; import net.minecraftforge.fml.ModLoader; import net.minecraftforge.fml.ModLoadingStage; import net.minecraftforge.fml.ModLoadingWarning; -import net.minecraftforge.fmllegacy.network.ConnectionType; -import net.minecraftforge.fmllegacy.network.FMLNetworkConstants; -import net.minecraftforge.fmllegacy.network.FMLStatusPing; -import net.minecraftforge.fmllegacy.network.NetworkHooks; -import net.minecraftforge.fmllegacy.network.NetworkRegistry; -import net.minecraftforge.fmllegacy.packs.ResourcePackLoader; +import net.minecraftforge.network.ConnectionType; +import net.minecraftforge.network.NetworkConstants; +import net.minecraftforge.network.ServerStatusPing; +import net.minecraftforge.network.NetworkHooks; +import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.forgespi.locating.IModFile; import net.minecraftforge.resource.PathResourcePack; import org.apache.logging.log4j.LogManager; @@ -62,11 +60,11 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.config.ConfigTracker; import net.minecraftforge.fml.config.ModConfig; -import net.minecraftforge.fmlserverevents.FMLServerAboutToStartEvent; -import net.minecraftforge.fmlserverevents.FMLServerStartedEvent; -import net.minecraftforge.fmlserverevents.FMLServerStartingEvent; -import net.minecraftforge.fmlserverevents.FMLServerStoppedEvent; -import net.minecraftforge.fmlserverevents.FMLServerStoppingEvent; +import net.minecraftforge.event.server.ServerAboutToStartEvent; +import net.minecraftforge.event.server.ServerStartedEvent; +import net.minecraftforge.event.server.ServerStartingEvent; +import net.minecraftforge.event.server.ServerStoppedEvent; +import net.minecraftforge.event.server.ServerStoppingEvent; import net.minecraftforge.fml.loading.FileUtils; import net.minecraftforge.forgespi.language.IModInfo; import net.minecraftforge.registries.GameData; @@ -89,29 +87,29 @@ public class ServerLifecycleHooks public static boolean handleServerAboutToStart(final MinecraftServer server) { currentServer = server; - currentServer.getStatus().setForgeData(new FMLStatusPing()); //gathers NetworkRegistry data + currentServer.getStatus().setForgeData(new ServerStatusPing()); //gathers NetworkRegistry data // on the dedi server we need to force the stuff to setup properly LogicalSidedProvider.setServer(()->server); ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.SERVER, getServerConfigPath(server)); - return !MinecraftForge.EVENT_BUS.post(new FMLServerAboutToStartEvent(server)); + return !MinecraftForge.EVENT_BUS.post(new ServerAboutToStartEvent(server)); } public static boolean handleServerStarting(final MinecraftServer server) { DistExecutor.runWhenOn(Dist.DEDICATED_SERVER, ()->()->LanguageHook.loadLanguagesOnServer(server)); - return !MinecraftForge.EVENT_BUS.post(new FMLServerStartingEvent(server)); + return !MinecraftForge.EVENT_BUS.post(new ServerStartingEvent(server)); } public static void handleServerStarted(final MinecraftServer server) { - MinecraftForge.EVENT_BUS.post(new FMLServerStartedEvent(server)); + MinecraftForge.EVENT_BUS.post(new ServerStartedEvent(server)); allowLogins.set(true); } public static void handleServerStopping(final MinecraftServer server) { allowLogins.set(false); - MinecraftForge.EVENT_BUS.post(new FMLServerStoppingEvent(server)); + MinecraftForge.EVENT_BUS.post(new ServerStoppingEvent(server)); } public static void expectServerStopped() @@ -122,7 +120,7 @@ public class ServerLifecycleHooks public static void handleServerStopped(final MinecraftServer server) { if (!server.isDedicatedServer()) GameData.revertToFrozen(); - MinecraftForge.EVENT_BUS.post(new FMLServerStoppedEvent(server)); + MinecraftForge.EVENT_BUS.post(new ServerStoppedEvent(server)); currentServer = null; LogicalSidedProvider.setServer(null); CountDownLatch latch = exitLatch; @@ -155,8 +153,8 @@ public class ServerLifecycleHooks final ConnectionType connectionType = ConnectionType.forVersionFlag(packet.getFMLVersion()); final int versionNumber = connectionType.getFMLVersionNumber(packet.getFMLVersion()); - if (connectionType == ConnectionType.MODDED && versionNumber != FMLNetworkConstants.FMLNETVERSION) { - rejectConnection(manager, connectionType, "This modded server is not network compatible with your modded client. Please verify your Forge version closely matches the server. Got net version "+ versionNumber + " this server is net version "+FMLNetworkConstants.FMLNETVERSION); + if (connectionType == ConnectionType.MODDED && versionNumber != NetworkConstants.FMLNETVERSION) { + rejectConnection(manager, connectionType, "This modded server is not impl compatible with your modded client. Please verify your Forge version closely matches the server. Got net version "+ versionNumber + " this server is net version "+ NetworkConstants.FMLNETVERSION); return false; } @@ -187,15 +185,7 @@ public class ServerLifecycleHooks } //INTERNAL MODDERS DO NOT USE - @Deprecated(since="1.18", forRemoval = true) - public static RepositorySource buildPackFinder(Map modResourcePacks, BiConsumer packSetter) { - return (packList, factory) -> serverPackFinder(modResourcePacks, packList, factory); - } - - //INTERNAL MODDERS DO NOT USE - // TODO: Rename in 1.18 (if this doesn't get - @Deprecated - public static RepositorySource buildPackFinderNew(Map modResourcePacks) { + public static RepositorySource buildPackFinder(Map modResourcePacks) { return (packList, factory) -> serverPackFinder(modResourcePacks, packList, factory); } diff --git a/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java b/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java deleted file mode 100644 index e36d4335f2..0000000000 --- a/src/main/java/net/minecraftforge/server/command/CommandSetDimension.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Minecraft Forge - * Copyright (c) 2016-2021. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation version 2.1 - * of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -package net.minecraftforge.server.command; - -import net.minecraft.commands.CommandSourceStack; -import net.minecraft.commands.Commands; -import net.minecraft.commands.arguments.coordinates.BlockPosArgument; -import net.minecraft.commands.arguments.DimensionArgument; -import net.minecraft.commands.arguments.EntityArgument; -import net.minecraft.world.entity.Entity; -import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.Component; -import net.minecraft.ChatFormatting; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.network.chat.ClickEvent; -import net.minecraft.server.level.ServerLevel; - -import com.mojang.brigadier.builder.ArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.context.ParsedCommandNode; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; -import com.mojang.brigadier.tree.ArgumentCommandNode; - -import java.util.Collection; - -/** @deprecated For removal in 1.18, superseded by {@code /execute in run tp } */ -@Deprecated(forRemoval = true, since = "1.17.1") -public class CommandSetDimension -{ - private static final SimpleCommandExceptionType NO_ENTITIES = new SimpleCommandExceptionType(new TranslatableComponent("commands.forge.setdim.invalid.entity")); - static ArgumentBuilder register() - { - return Commands.literal("setdimension") - .requires(cs->cs.hasPermission(2)) //permission - .then(Commands.argument("targets", EntityArgument.entities()) - .then(Commands.argument("dim", DimensionArgument.dimension()) - .then(Commands.argument("pos", BlockPosArgument.blockPos()) - .executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), BlockPosArgument.getSpawnablePos(ctx, "pos"))) - ) - .executes(ctx -> execute(ctx, EntityArgument.getOptionalEntities(ctx, "targets"), DimensionArgument.getDimension(ctx, "dim"), new BlockPos(ctx.getSource().getPosition()))) - ) - ); - } - - private static int execute(CommandContext ctx, Collection entities, ServerLevel dim, BlockPos pos) throws CommandSyntaxException - { - entities.removeIf(e -> !canEntityTeleport(e)); - if (entities.isEmpty()) - throw NO_ENTITIES.create(); - - String cmdTarget = "@s"; - String posTarget = "~ ~ ~"; - for (ParsedCommandNode parsed : ctx.getNodes()) - { - if (parsed.getNode() instanceof ArgumentCommandNode) - { - if ("targets".equals(parsed.getNode().getName())) - { - cmdTarget = parsed.getRange().get(ctx.getInput()); - } - else if ("pos".equals(parsed.getNode().getName())) - { - posTarget = parsed.getRange().get(ctx.getInput()); - } - } - } - final String dimName = dim.dimension().location().toString(); - final String finalCmdTarget = cmdTarget; - final String finalPosTarget = posTarget; - Component suggestion = new TranslatableComponent("/execute in %s run tp %s %s", dimName, cmdTarget, finalPosTarget) - .withStyle((style) -> style.withColor(ChatFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/execute in " + dimName + " run tp " + finalCmdTarget + " " + finalPosTarget))); - ctx.getSource().sendSuccess(new TranslatableComponent("commands.forge.setdim.deprecated", suggestion), true); - - return 0; - } - - private static boolean canEntityTeleport(Entity entity) - { - // use vanilla portal logic from BlockPortal#onEntityCollision - return !entity.isPassenger() && !entity.isVehicle() && entity.canChangeDimensions(); - } -} diff --git a/src/main/java/net/minecraftforge/server/command/CommandDimensions.java b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java similarity index 98% rename from src/main/java/net/minecraftforge/server/command/CommandDimensions.java rename to src/main/java/net/minecraftforge/server/command/DimensionsCommand.java index 80ca3d001f..ea355f18e4 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandDimensions.java +++ b/src/main/java/net/minecraftforge/server/command/DimensionsCommand.java @@ -36,7 +36,7 @@ import java.util.stream.Collectors; import com.mojang.brigadier.builder.ArgumentBuilder; -public class CommandDimensions +class DimensionsCommand { static ArgumentBuilder register() { diff --git a/src/main/java/net/minecraftforge/server/command/CommandEntity.java b/src/main/java/net/minecraftforge/server/command/EntityCommand.java similarity index 99% rename from src/main/java/net/minecraftforge/server/command/CommandEntity.java rename to src/main/java/net/minecraftforge/server/command/EntityCommand.java index e2868d6261..aa9abcfc06 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandEntity.java +++ b/src/main/java/net/minecraftforge/server/command/EntityCommand.java @@ -49,7 +49,7 @@ import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; -class CommandEntity +class EntityCommand { static ArgumentBuilder register() { diff --git a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java index 7916e564a0..8ad479922d 100644 --- a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java @@ -29,13 +29,12 @@ public class ForgeCommand { dispatcher.register( LiteralArgumentBuilder.literal("forge") - .then(CommandTps.register()) - .then(CommandTrack.register()) - .then(CommandEntity.register()) - .then(CommandGenerate.register()) - .then(CommandDimensions.register()) - .then(CommandSetDimension.register()) - .then(CommandModList.register()) + .then(TPSCommand.register()) + .then(TrackCommand.register()) + .then(EntityCommand.register()) + .then(GenerateCommand.register()) + .then(DimensionsCommand.register()) + .then(ModListCommand.register()) ); } } diff --git a/src/main/java/net/minecraftforge/server/command/CommandGenerate.java b/src/main/java/net/minecraftforge/server/command/GenerateCommand.java similarity index 99% rename from src/main/java/net/minecraftforge/server/command/CommandGenerate.java rename to src/main/java/net/minecraftforge/server/command/GenerateCommand.java index 0d4122331b..b611ceef26 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandGenerate.java +++ b/src/main/java/net/minecraftforge/server/command/GenerateCommand.java @@ -32,7 +32,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.WorldWorkerManager; -class CommandGenerate +class GenerateCommand { static ArgumentBuilder register() { diff --git a/src/main/java/net/minecraftforge/server/command/CommandModList.java b/src/main/java/net/minecraftforge/server/command/ModListCommand.java similarity index 98% rename from src/main/java/net/minecraftforge/server/command/CommandModList.java rename to src/main/java/net/minecraftforge/server/command/ModListCommand.java index 64577a87d8..8b86068a12 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandModList.java +++ b/src/main/java/net/minecraftforge/server/command/ModListCommand.java @@ -26,7 +26,7 @@ import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.fml.ModList; import java.util.stream.Collectors; -public class CommandModList { +class ModListCommand { static ArgumentBuilder register() { return Commands.literal("mods") diff --git a/src/main/java/net/minecraftforge/server/command/CommandTps.java b/src/main/java/net/minecraftforge/server/command/TPSCommand.java similarity index 99% rename from src/main/java/net/minecraftforge/server/command/CommandTps.java rename to src/main/java/net/minecraftforge/server/command/TPSCommand.java index c572f52a87..db10db1eca 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandTps.java +++ b/src/main/java/net/minecraftforge/server/command/TPSCommand.java @@ -30,7 +30,7 @@ import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.server.level.ServerLevel; -class CommandTps +class TPSCommand { private static final DecimalFormat TIME_FORMATTER = new DecimalFormat("########0.000"); private static final long[] UNLOADED = new long[] {0}; diff --git a/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java b/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java index 612084328d..e5d5cb3ad4 100644 --- a/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java +++ b/src/main/java/net/minecraftforge/server/command/TextComponentHelper.java @@ -26,8 +26,8 @@ import net.minecraft.locale.Language; import net.minecraft.network.chat.BaseComponent; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; -import net.minecraftforge.fmllegacy.network.ConnectionType; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.ConnectionType; +import net.minecraftforge.network.NetworkHooks; public class TextComponentHelper { diff --git a/src/main/java/net/minecraftforge/server/command/CommandTrack.java b/src/main/java/net/minecraftforge/server/command/TrackCommand.java similarity index 99% rename from src/main/java/net/minecraftforge/server/command/CommandTrack.java rename to src/main/java/net/minecraftforge/server/command/TrackCommand.java index fc58f026d6..193d5d2e8f 100644 --- a/src/main/java/net/minecraftforge/server/command/CommandTrack.java +++ b/src/main/java/net/minecraftforge/server/command/TrackCommand.java @@ -39,7 +39,7 @@ import net.minecraft.network.chat.TranslatableComponent; import net.minecraftforge.server.timings.ForgeTimings; import net.minecraftforge.server.timings.TimeTracker; -class CommandTrack +class TrackCommand { private static final DecimalFormat TIME_FORMAT = new DecimalFormat("#####0.00"); diff --git a/src/main/java/net/minecraftforge/fmllegacy/server/ServerModLoader.java b/src/main/java/net/minecraftforge/server/loading/ServerModLoader.java similarity index 92% rename from src/main/java/net/minecraftforge/fmllegacy/server/ServerModLoader.java rename to src/main/java/net/minecraftforge/server/loading/ServerModLoader.java index 0f2c7d0e68..402c528ab5 100644 --- a/src/main/java/net/minecraftforge/fmllegacy/server/ServerModLoader.java +++ b/src/main/java/net/minecraftforge/server/loading/ServerModLoader.java @@ -17,12 +17,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -package net.minecraftforge.fmllegacy.server; +package net.minecraftforge.server.loading; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.*; -import net.minecraftforge.fmllegacy.CrashReportExtender; -import net.minecraftforge.fmllegacy.LogicalSidedProvider; +import net.minecraftforge.logging.CrashReportExtender; +import net.minecraftforge.common.util.LogicalSidedProvider; +import net.minecraftforge.server.LanguageHook; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java b/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java index 5e1a95e47b..c1332ff315 100644 --- a/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java +++ b/src/main/java/net/minecraftforge/server/permission/DefaultPermissionHandler.java @@ -21,7 +21,7 @@ package net.minecraftforge.server.permission; import com.mojang.authlib.GameProfile; import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fmllegacy.server.ServerLifecycleHooks; +import net.minecraftforge.server.ServerLifecycleHooks; import net.minecraftforge.server.permission.context.IContext; import javax.annotation.Nullable; diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index dd800f4702..cbb524a262 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -16,6 +16,10 @@ protected net.minecraft.client.gui.Gui f_168671_ # SPACER protected net.minecraft.client.gui.Gui f_168672_ # PORTAL_OVERLAY_ALPHA_MIN protected net.minecraft.client.gui.Gui f_168673_ # HEART_SIZE protected net.minecraft.client.gui.Gui f_168674_ # HEART_SEPARATION +protected net.minecraft.client.gui.Gui f_193828_ # autosaveIndicatorValue +protected net.minecraft.client.gui.Gui f_193829_ # lastAutosaveIndicatorValue +protected net.minecraft.client.gui.Gui f_193830_ # SAVING_TEXT +protected net.minecraft.client.gui.Gui f_193831_ # AUTOSAVE_FADE_SPEED_FACTOR protected net.minecraft.client.gui.Gui f_92970_ # titleFadeInTime protected net.minecraft.client.gui.Gui f_92971_ # titleStayTime protected net.minecraft.client.gui.Gui f_92972_ # titleFadeOutTime @@ -188,12 +192,10 @@ protected net.minecraft.data.recipes.RecipeProvider m_176531_(Ljava/util/functio public net.minecraft.data.recipes.ShapedRecipeBuilder$Result protected net.minecraft.data.tags.TagsProvider f_126543_ # builders public net.minecraft.data.tags.TagsProvider$TagAppender f_126569_ # registry -public net.minecraft.data.worldgen.Features$Decorators public net.minecraft.network.protocol.status.ClientboundStatusResponsePacket f_134885_ # GSON public net.minecraft.resources.RegistryReadOps f_179860_ # registryAccess protected net.minecraft.server.MinecraftServer f_129726_ # nextTickTime public net.minecraft.server.dedicated.DedicatedServer f_139600_ # consoleInput -public net.minecraft.server.level.ServerChunkCache f_8328_ # generator public net.minecraft.server.level.ServerChunkCache f_8329_ # level public net.minecraft.server.level.ServerLevel m_142646_()Lnet/minecraft/world/level/entity/LevelEntityGetter; # getEntities public net.minecraft.server.level.ServerPlayer f_8940_ # containerCounter @@ -210,7 +212,6 @@ protected net.minecraft.tags.StaticTagHelper$Wrapper f_13251_ # tag public net.minecraft.tags.Tag$BuilderEntry (Lnet/minecraft/tags/Tag$Entry;Ljava/lang/String;)V # constructor public net.minecraft.tags.TagContainer (Ljava/util/Map;)V # constructor public net.minecraft.tags.TagContainer f_144433_ # collections -public net.minecraft.util.WeighedRandom$WeighedRandomItem f_14482_ # weight public net.minecraft.util.thread.BlockableEventLoop m_18689_(Ljava/lang/Runnable;)Ljava/util/concurrent/CompletableFuture; # submitAsync #group public net.minecraft.world.damagesource.DamageSource *() #All methods public, most are already public net.minecraft.world.damagesource.DamageSource (Ljava/lang/String;)V # constructor @@ -276,15 +277,12 @@ public net.minecraft.world.level.biome.Biome$ClimateSettings f_47680_ # precipit public net.minecraft.world.level.biome.Biome$ClimateSettings f_47681_ # temperature public net.minecraft.world.level.biome.Biome$ClimateSettings f_47682_ # temperatureModifier public net.minecraft.world.level.biome.Biome$ClimateSettings f_47683_ # downfall -protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47826_ # surfaceBuilder protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47827_ # carvers protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47828_ # features -protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder f_47829_ # structureStarts protected net.minecraft.world.level.biome.BiomeGenerationSettings$Builder m_47832_(I)V # addFeatureStepsUpTo protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48362_ # spawners protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48363_ # mobSpawnCosts protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48364_ # creatureGenerationProbability -protected net.minecraft.world.level.biome.MobSpawnSettings$Builder f_48365_ # playerCanSpawn #group public net.minecraft.world.level.block.Block public net.minecraft.world.level.block.AirBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor public net.minecraft.world.level.block.AttachedStemBlock (Lnet/minecraft/world/level/block/StemGrownBlock;Ljava/util/function/Supplier;Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V # constructor @@ -392,100 +390,52 @@ public net.minecraft.world.level.block.entity.HopperBlockEntity m_59395_(I)V # s public net.minecraft.world.level.block.entity.HopperBlockEntity m_59409_()Z # isOnCustomCooldown public net.minecraft.world.level.block.state.properties.WoodType m_61844_(Lnet/minecraft/world/level/block/state/properties/WoodType;)Lnet/minecraft/world/level/block/state/properties/WoodType; # register public net.minecraft.world.level.chunk.ChunkStatus (Ljava/lang/String;Lnet/minecraft/world/level/chunk/ChunkStatus;ILjava/util/EnumSet;Lnet/minecraft/world/level/chunk/ChunkStatus$ChunkType;Lnet/minecraft/world/level/chunk/ChunkStatus$GenerationTask;Lnet/minecraft/world/level/chunk/ChunkStatus$LoadingTask;)V # constructor -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer (Lnet/minecraft/world/level/ChunkPos;Lnet/minecraft/world/level/levelgen/synth/NormalNoise;Lnet/minecraft/world/level/levelgen/synth/NormalNoise;Lnet/minecraft/world/level/levelgen/synth/NormalNoise;Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings;Lnet/minecraft/world/level/levelgen/NoiseSampler;II)V # constructor protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157994_ # barrierNoise -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157995_ # waterLevelNoise protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157996_ # lavaNoise -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157997_ # noiseGeneratorSettings protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157998_ # aquiferCache protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_157999_ # aquiferLocationCache protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158000_ # shouldScheduleFluidUpdate -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158001_ # sampler protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158002_ # minGridX protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158003_ # minGridY protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158004_ # minGridZ protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158005_ # gridSizeX protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer f_158006_ # gridSizeZ -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158017_(I)Z # isLavaLevel -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158019_(IDLnet/minecraft/world/level/levelgen/Aquifer$NoiseBasedAquifer$AquiferStatus;Lnet/minecraft/world/level/levelgen/Aquifer$NoiseBasedAquifer$AquiferStatus;)D # calculatePressure protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158024_(II)D # similarity protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158027_(III)I # getIndex -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158031_(J)Lnet/minecraft/world/level/levelgen/Aquifer$NoiseBasedAquifer$AquiferStatus; # getAquiferStatus protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158039_(I)I # gridX -protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158041_(III)Lnet/minecraft/world/level/levelgen/Aquifer$NoiseBasedAquifer$AquiferStatus; # computeAquifer protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158045_(I)I # gridY protected net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer m_158047_(I)I # gridZ -public net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer$AquiferStatus -public net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer$AquiferStatus f_158049_ # fluidLevel -public net.minecraft.world.level.levelgen.Aquifer$NoiseBasedAquifer$AquiferStatus f_158050_ # fluidType -protected net.minecraft.world.level.levelgen.Beardifier ()V # constructor protected net.minecraft.world.level.levelgen.Beardifier f_158063_ # rigids protected net.minecraft.world.level.levelgen.Beardifier f_158064_ # junctions protected net.minecraft.world.level.levelgen.Beardifier f_158065_ # pieceIterator protected net.minecraft.world.level.levelgen.Beardifier f_158066_ # junctionIterator -public net.minecraft.world.level.levelgen.Beardifier m_158072_(III)D # beardifyOrBury protected net.minecraft.world.level.levelgen.Beardifier m_158083_(III)D # getBuryContribution protected net.minecraft.world.level.levelgen.Beardifier m_158087_(III)D # getBeardContribution private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64114_ # ALL_BLOCKS private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64115_ # GRID_WIDTH private-f net.minecraft.world.level.levelgen.DebugLevelSource f_64116_ # GRID_HEIGHT public-f net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158374_ # cellHeight -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158375_ # cellWidth -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158376_ # cellCountX -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158377_ # cellCountY -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158378_ # cellCountZ -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158379_ # barrierNoise -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158380_ # waterLevelNoise -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158381_ # lavaNoise protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158382_ # sampler -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158383_ # baseStoneSource -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158384_ # oreVeinifier -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_158385_ # noodleCavifier -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_64330_ # surfaceNoise protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_64333_ # seed -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator f_64334_ # height -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_158396_(IILnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/world/level/levelgen/Aquifer; # getAquifer protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_158413_(II[Lnet/minecraft/world/level/block/state/BlockState;Ljava/util/function/Predicate;II)Ljava/util/OptionalInt; # iterateNoiseColumn -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_158420_(ILnet/minecraft/world/level/ChunkPos;Ljava/util/function/Consumer;)Ljava/util/function/DoubleFunction; # createCaveNoiseModifier -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_158427_(Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess; # doFill -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_158466_([DIIII)V # fillNoiseColumn -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_158477_(ILnet/minecraft/world/level/ChunkPos;Ljava/util/function/Consumer;)Ljava/util/function/DoubleFunction; # createBaseStoneSource -protected net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator m_64399_(Lnet/minecraft/world/level/chunk/ChunkAccess;Ljava/util/Random;)V # setBedrock -public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator$NoodleCaveNoiseModifier -public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator$OreVeinNoiseSource #group public net.minecraft.world.level.levelgen.NoiseGeneratorSettings *() -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings (Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/levelgen/NoiseSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;IIIIZZZZZZ)V # constructor -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158553_(Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # netherLikePreset -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158557_(Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;ZZ)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # endLikePreset -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158563_(Lnet/minecraft/world/level/levelgen/StructureSettings;Z)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # overworld -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158567_()Z # isAquifersEnabled -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158568_()Z # isNoiseCavesEnabled -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158569_()Z # isDeepslateEnabled -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158570_()Z # isOreVeinsEnabled -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_158571_()Z # isNoodleCavesEnabled +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings (Lnet/minecraft/world/level/levelgen/StructureSettings;Lnet/minecraft/world/level/levelgen/NoiseSettings;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/levelgen/SurfaceRules$RuleSource;IZZZZZZ)V # constructor +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198262_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings;)V # register +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198265_(ZZ)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # overworld +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198268_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # end +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198269_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # nether +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198270_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # caves +public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_198271_()Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # floatingIslands public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64474_(Lcom/mojang/serialization/codecs/RecordCodecBuilder$Instance;)Lcom/mojang/datafixers/kinds/App; # lambda$static$0 -public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64478_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings;)Lnet/minecraft/world/level/levelgen/NoiseGeneratorSettings; # register public net.minecraft.world.level.levelgen.NoiseGeneratorSettings m_64487_()Z # disableMobGeneration #endgroup -protected net.minecraft.world.level.levelgen.NoiseSampler f_158638_ # BIOME_WEIGHTS -protected net.minecraft.world.level.levelgen.NoiseSampler f_158639_ # biomeSource -protected net.minecraft.world.level.levelgen.NoiseSampler f_158640_ # cellWidth -protected net.minecraft.world.level.levelgen.NoiseSampler f_158641_ # cellHeight -protected net.minecraft.world.level.levelgen.NoiseSampler f_158642_ # cellCountY protected net.minecraft.world.level.levelgen.NoiseSampler f_158643_ # noiseSettings public net.minecraft.world.level.levelgen.NoiseSampler f_158644_ # blendedNoise public net.minecraft.world.level.levelgen.NoiseSampler f_158645_ # islandNoise -public net.minecraft.world.level.levelgen.NoiseSampler f_158646_ # depthNoise -public net.minecraft.world.level.levelgen.NoiseSampler f_158655_ # caveNoiseModifier protected net.minecraft.world.level.levelgen.NoiseSampler m_158667_(DI)D # applySlide -protected net.minecraft.world.level.levelgen.NoiseSampler m_158670_(IDDD)D # computeInitialDensity -protected net.minecraft.world.level.levelgen.NoiseSampler m_158675_(II)D # getRandomDensity -public net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType (Lcom/mojang/serialization/Codec;)V # constructor public net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType (Lcom/mojang/serialization/Codec;)V # constructor public net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType (Lcom/mojang/serialization/Codec;)V # constructor public net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType (Lcom/mojang/serialization/Codec;)V # constructor -public net.minecraft.world.level.newbiome.layer.Layers m_76729_(JLnet/minecraft/world/level/newbiome/layer/traits/AreaTransformer1;Lnet/minecraft/world/level/newbiome/area/AreaFactory;ILjava/util/function/LongFunction;)Lnet/minecraft/world/level/newbiome/area/AreaFactory; # zoom protected net.minecraft.world.level.portal.PortalForcer f_77648_ # level public net.minecraft.world.level.storage.LevelResource (Ljava/lang/String;)V # constructor private-f net.minecraft.world.level.storage.loot.LootPool f_79028_ # rolls diff --git a/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider b/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider index 9c9e602fc7..debb6f9735 100644 --- a/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider +++ b/src/main/resources/META-INF/services/net.minecraftforge.fml.IBindingsProvider @@ -1 +1 @@ -net.minecraftforge.fmllegacy.ForgeBindings \ No newline at end of file +net.minecraftforge.internal.ForgeBindings \ No newline at end of file diff --git a/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider b/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider index 106ec46513..64aab6f00d 100644 --- a/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider +++ b/src/main/resources/META-INF/services/net.minecraftforge.fml.IModStateProvider @@ -1,2 +1,2 @@ net.minecraftforge.fml.core.ModStateProvider -net.minecraftforge.fmllegacy.ForgeStatesProvider \ No newline at end of file +net.minecraftforge.common.ForgeStatesProvider \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 0f2303f560..0bb8888406 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 7, + "pack_format": 8, "description": "Forge resource pack" } } diff --git a/src/test/java/net/minecraftforge/debug/CodecsTest.java b/src/test/java/net/minecraftforge/debug/CodecsTest.java index 300a8732af..4548eb6be3 100644 --- a/src/test/java/net/minecraftforge/debug/CodecsTest.java +++ b/src/test/java/net/minecraftforge/debug/CodecsTest.java @@ -33,11 +33,15 @@ import org.apache.logging.log4j.Logger; @Mod("forge_codecs_test") public class CodecsTest { + public static final boolean ENABLE = true; private static final Logger LOGGER = LogManager.getLogger(); public CodecsTest() { - testFluidStackCodec(); + if (ENABLE) + { + testFluidStackCodec(); + } } /** diff --git a/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java b/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java index a114724041..293b4841e7 100644 --- a/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/CustomSoundTypeTest.java @@ -30,7 +30,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraftforge.common.util.ForgeSoundType; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java b/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java index 82add731f5..932b66b910 100644 --- a/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java +++ b/src/test/java/net/minecraftforge/debug/DeferredRegistryTest.java @@ -33,7 +33,7 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java b/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java index a71dcea324..45a8b05e02 100644 --- a/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java +++ b/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java @@ -35,7 +35,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import org.apache.logging.log4j.LogManager; diff --git a/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java b/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java index a8a18d0a57..4f13c55ddd 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomRespawnTest.java @@ -39,7 +39,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java b/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java index aca2896d08..e97662e746 100644 --- a/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java +++ b/src/test/java/net/minecraftforge/debug/block/CustomSignsTest.java @@ -32,7 +32,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; diff --git a/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java b/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java index cfaf2f38e9..784ad9480f 100644 --- a/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java +++ b/src/test/java/net/minecraftforge/debug/block/FlowerPotTest.java @@ -27,7 +27,7 @@ import net.minecraft.world.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java b/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java index 0cc5a34c67..35f1197d4b 100644 --- a/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java +++ b/src/test/java/net/minecraftforge/debug/block/FullPotsAccessorDemo.java @@ -56,13 +56,12 @@ import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.*; import net.minecraftforge.client.model.data.*; import net.minecraftforge.client.model.geometry.IModelGeometry; -import net.minecraftforge.common.util.Constants; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -194,7 +193,7 @@ public class FullPotsAccessorDemo { this.plant = plant; //noinspection ConstantConditions - level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), Constants.BlockFlags.DEFAULT); + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), Block.UPDATE_ALL); setChanged(); } @@ -220,7 +219,7 @@ public class FullPotsAccessorDemo @Override public ClientboundBlockEntityDataPacket getUpdatePacket() { - return new ClientboundBlockEntityDataPacket(getBlockPos(), -1, getUpdateTag()); + return ClientboundBlockEntityDataPacket.create(this, be -> be.getUpdateTag()); } @Override @@ -228,7 +227,7 @@ public class FullPotsAccessorDemo { handleUpdateTag(pkt.getTag()); //noinspection ConstantConditions - level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), Constants.BlockFlags.DEFAULT); + level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), Block.UPDATE_ALL); } @Override diff --git a/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java b/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java index 027c3d8460..409cf4eeb3 100644 --- a/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java +++ b/src/test/java/net/minecraftforge/debug/block/PistonEventTest.java @@ -46,7 +46,7 @@ import net.minecraftforge.event.world.PistonEvent.PistonMoveType; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java b/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java index 3349c8fdd7..cef91ad469 100644 --- a/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java +++ b/src/test/java/net/minecraftforge/debug/block/RedstoneSidedConnectivityTest.java @@ -33,7 +33,7 @@ import net.minecraft.world.level.material.Material; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java b/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java index bfe02ec9b8..2d1db45f24 100644 --- a/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java +++ b/src/test/java/net/minecraftforge/debug/block/ScaffoldingTest.java @@ -37,7 +37,7 @@ import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.Tags.IOptionalNamedTag; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java index a4df3b878c..4dbc160e92 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTASTest.java @@ -37,7 +37,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLLoader; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java index cb9fe03768..064c4be4ef 100644 --- a/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java +++ b/src/test/java/net/minecraftforge/debug/client/CustomTooltipTest.java @@ -55,7 +55,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; @@ -110,7 +110,7 @@ public class CustomTooltipTest } @Override - public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer_, int zIndex, TextureManager textureManager) + public void renderImage(Font font, int x, int y, PoseStack poseStack, ItemRenderer itemRenderer_, int zIndex) { GuiComponent.fill(poseStack, x, y, x + 10, y+ 10, tooltip.color); } @@ -174,11 +174,11 @@ public class CustomTooltipTest @SubscribeEvent public static void gatherTooltips(RenderTooltipEvent.GatherComponents event) { - if (event.getStack().getItem() == Items.STICK) + if (event.getItemStack().getItem() == Items.STICK) { event.getTooltipElements().add(Either.right(new CustomTooltip(0xFF0000FF))); } - if (event.getStack().getItem() == Items.CLOCK) + if (event.getItemStack().getItem() == Items.CLOCK) { event.setMaxWidth(30); } @@ -187,7 +187,7 @@ public class CustomTooltipTest @SubscribeEvent public static void preTooltip(RenderTooltipEvent.Color event) { - if (event.getStack().getItem() == Items.APPLE) + if (event.getItemStack().getItem() == Items.APPLE) { event.setBackgroundStart(0xFF0000FF); event.setBackgroundEnd(0xFFFFFF00); @@ -335,13 +335,13 @@ public class CustomTooltipTest @SuppressWarnings("removal") private void test13(Button button, PoseStack poseStack, int mouseX, int mouseY) { - renderToolTip(poseStack, List.of(new TextComponent("test").getVisualOrderText()), mouseX, mouseY, this.testFont); + renderTooltip(poseStack, List.of(new TextComponent("test").getVisualOrderText()), mouseX, mouseY, this.testFont); } @SuppressWarnings("removal") private void test14(Button button, PoseStack poseStack, int mouseX, int mouseY) { - renderComponentToolTip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY, this.testFont); + renderComponentTooltip(poseStack, List.of(new TextComponent("test")), mouseX, mouseY, this.testFont, ItemStack.EMPTY); } } diff --git a/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java b/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java index 3804883eaa..99c763e25e 100644 --- a/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java +++ b/src/test/java/net/minecraftforge/debug/client/GuiLayeringTest.java @@ -27,7 +27,7 @@ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -43,14 +43,14 @@ public class GuiLayeringTest public static class ClientEvents { @SubscribeEvent - public static void guiOpen(GuiScreenEvent.InitGuiEvent event) + public static void guiOpen(ScreenEvent.InitScreenEvent event) { - if (event.getGui() instanceof AbstractContainerScreen) + if (event.getScreen() instanceof AbstractContainerScreen) { - event.addWidget(new Button(2, 2, 150, 20, new TextComponent("Test Gui Layering"), btn -> { + event.addListener(new Button(2, 2, 150, 20, new TextComponent("Test Gui Layering"), btn -> { Minecraft.getInstance().pushGuiLayer(new TestLayer(new TextComponent("LayerScreen"))); })); - event.addWidget(new Button(2, 25, 150, 20, new TextComponent("Test Gui Normal"), btn -> { + event.addListener(new Button(2, 25, 150, 20, new TextComponent("Test Gui Normal"), btn -> { Minecraft.getInstance().setScreen(new TestLayer(new TextComponent("LayerScreen"))); })); } diff --git a/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java index 1a968923f3..b18065734d 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/CompositeModelTest.java @@ -37,7 +37,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.level.BlockGetter; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java index 009640398e..d61cb39751 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/DynBucketModelTest.java @@ -22,7 +22,7 @@ package net.minecraftforge.debug.client.model; import net.minecraft.world.item.Item; import net.minecraft.world.item.CreativeModeTab; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java b/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java index 90351e7dfa..03137670d5 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/NewModelLoaderTest.java @@ -57,7 +57,7 @@ import net.minecraftforge.client.model.geometry.ISimpleModelGeometry; import net.minecraftforge.client.model.pipeline.BakedQuadBuilder; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java b/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java index ad9728dcee..f25e755313 100644 --- a/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java +++ b/src/test/java/net/minecraftforge/debug/client/model/TRSRTransformerTest.java @@ -50,7 +50,7 @@ import net.minecraftforge.client.model.pipeline.TRSRTransformer; import net.minecraftforge.common.model.TransformationHelper; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java index fe50cd97eb..a66c8142a5 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/LinearTextTextureFilteringTest.java @@ -21,7 +21,7 @@ package net.minecraftforge.debug.client.rendering; import net.minecraft.client.gui.screens.TitleScreen; import net.minecraftforge.client.ForgeRenderTypes; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.ScreenEvent.DrawScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.api.distmarker.Dist; @@ -36,7 +36,7 @@ public class LinearTextTextureFilteringTest @SubscribeEvent public static void onGuiRenderPre(DrawScreenEvent.Pre event) { - if (ENABLED && event.getGui() instanceof TitleScreen) + if (ENABLED && event.getScreen() instanceof TitleScreen) { ForgeRenderTypes.enableTextTextureLinearFiltering = true; } @@ -45,7 +45,7 @@ public class LinearTextTextureFilteringTest @SubscribeEvent public static void onGuiRenderPost(DrawScreenEvent.Post event) { - if (ENABLED && event.getGui() instanceof TitleScreen) + if (ENABLED && event.getScreen() instanceof TitleScreen) { ForgeRenderTypes.enableTextTextureLinearFiltering = false; } diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java index 2b8f6c4b7b..3b314a747d 100644 --- a/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java +++ b/src/test/java/net/minecraftforge/debug/client/rendering/ShaderFixTest.java @@ -23,7 +23,7 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmlclient.registry.ClientRegistry; +import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; diff --git a/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java index c3c7100f99..1bb86b6fac 100644 --- a/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/AddEntityAttributeTest.java @@ -23,7 +23,7 @@ import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.RangedAttribute; import net.minecraftforge.event.entity.EntityAttributeModificationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java b/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java index d374b7c8e3..127a1b1425 100644 --- a/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/PartEntityTest.java @@ -39,7 +39,7 @@ import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java index c5cd303aae..85f96b011a 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerAttackKnockbackTest.java @@ -33,7 +33,7 @@ import net.minecraft.world.item.Tiers; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java index dba5fb9d8b..c2388c6af8 100644 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java +++ b/src/test/java/net/minecraftforge/debug/entity/player/PlayerGameModeEventTest.java @@ -21,7 +21,7 @@ package net.minecraftforge.debug.entity.player; import net.minecraft.world.level.GameType; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.ClientPlayerChangeGameModeEvent; +import net.minecraftforge.client.event.ClientPlayerChangeGameTypeEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -49,10 +49,10 @@ public class PlayerGameModeEventTest public static class PlayerGameModeEventTestClientForgeEvents { @SubscribeEvent - public static void onClientPlayerChangeGameModeEvent(ClientPlayerChangeGameModeEvent event) + public static void onClientPlayerChangeGameModeEvent(ClientPlayerChangeGameTypeEvent event) { if (!ENABLE) return; - LOGGER.info("Client notified of changed game mode from '{}'. Current GameType: {}. New Game Type: {}", event.getInfo().getProfile(), event.getCurrentGameMode(), event.getNewGameMode()); + LOGGER.info("Client notified of changed game mode from '{}'. Current GameType: {}. New Game Type: {}", event.getInfo().getProfile(), event.getCurrentGameType(), event.getNewGameType()); } } } diff --git a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java index 13de4dbde6..33d369fbea 100644 --- a/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java +++ b/src/test/java/net/minecraftforge/debug/fluid/NewFluidTest.java @@ -37,7 +37,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.ForgeFlowingFluid; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -154,7 +154,7 @@ public class NewFluidTest if (canPlaceLiquid(worldIn, pos, state, fluidStateIn.getType())) { if (!worldIn.isClientSide()) { worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, true), 3); - worldIn.getLiquidTicks().scheduleTick(pos, fluidStateIn.getType(), fluidStateIn.getType().getTickDelay(worldIn)); + worldIn.scheduleTick(pos, fluidStateIn.getType(), fluidStateIn.getType().getTickDelay(worldIn)); } return true; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java index 58e18bffcd..fa2b2e8e8f 100644 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java +++ b/src/test/java/net/minecraftforge/debug/gameplay/loot/GlobalLootModifiersTest.java @@ -52,7 +52,7 @@ import net.minecraftforge.common.loot.GlobalLootModifierSerializer; import net.minecraftforge.common.loot.LootModifier; import net.minecraftforge.common.loot.LootTableIdCondition; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; diff --git a/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java b/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java index f706a4690d..ca6f88d810 100644 --- a/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CustomElytraTest.java @@ -33,7 +33,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java b/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java index bcfc9a8f39..3611148e7b 100644 --- a/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java +++ b/src/test/java/net/minecraftforge/debug/item/CustomShieldTest.java @@ -31,7 +31,7 @@ import net.minecraftforge.common.ToolAction; import net.minecraftforge.common.ToolActions; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; @Mod("custom_shield_test") diff --git a/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java b/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java index 3f21cfdef0..a3a8449a02 100644 --- a/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java +++ b/src/test/java/net/minecraftforge/debug/item/EnderMaskTest.java @@ -23,7 +23,7 @@ import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.EquipmentSlot; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java b/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java index 514332b384..46c4224cd0 100644 --- a/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java +++ b/src/test/java/net/minecraftforge/debug/item/ForgeSpawnEggItemTest.java @@ -32,7 +32,7 @@ import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java b/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java index 3dddba07da..ae762f116b 100644 --- a/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java +++ b/src/test/java/net/minecraftforge/debug/item/MusicDiscTest.java @@ -25,7 +25,7 @@ import net.minecraft.world.item.Rarity; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; diff --git a/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java b/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java index 3ec8604e1c..96503da291 100644 --- a/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java +++ b/src/test/java/net/minecraftforge/debug/item/RangedMobsUseModdedWeaponsTest.java @@ -30,7 +30,7 @@ import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; diff --git a/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java b/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java index 7f6fbf7609..7a2356d49e 100644 --- a/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/ContainerTypeTest.java @@ -38,13 +38,13 @@ import net.minecraft.world.InteractionHand; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.extensions.IForgeContainerType; +import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fmllegacy.network.NetworkHooks; +import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.registries.ObjectHolder; @Mod("containertypetest") @@ -101,7 +101,7 @@ public class ContainerTypeTest private void registerContainers(final RegistryEvent.Register> event) { - event.getRegistry().register(IForgeContainerType.create(TestContainer::new).setRegistryName("container")); + event.getRegistry().register(IForgeMenuType.create(TestContainer::new).setRegistryName("container")); } private void setup(FMLClientSetupEvent event) diff --git a/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java b/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java index c4cb01e9a9..75b19c1608 100644 --- a/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java +++ b/src/test/java/net/minecraftforge/debug/misc/CustomTagTypesTest.java @@ -48,7 +48,7 @@ import net.minecraftforge.common.data.ForgeRegistryTagsProvider; import net.minecraftforge.common.util.ReverseTagWrapper; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java b/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java index 9589bf9592..08380d7581 100644 --- a/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java +++ b/src/test/java/net/minecraftforge/debug/world/DimensionSettingsTest.java @@ -112,16 +112,14 @@ public class DimensionSettingsTest { overworld.noiseSettings(), overworld.getDefaultBlock(), overworld.getDefaultFluid(), - overworld.getBedrockRoofPosition(), - overworld.getBedrockFloorPosition(), + overworld.surfaceRule(), overworld.seaLevel(), - overworld.getMinSurfaceLevel(), overworld.disableMobGeneration(), overworld.isAquifersEnabled(), overworld.isNoiseCavesEnabled(), - overworld.isDeepslateEnabled(), overworld.isOreVeinsEnabled(), - overworld.isNoodleCavesEnabled() + overworld.isNoodleCavesEnabled(), + overworld.useLegacyRandomSource() ); } } diff --git a/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java b/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java index d3c47838fe..b8230967c6 100644 --- a/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ForgeChunkManagerTest.java @@ -36,7 +36,7 @@ import net.minecraft.world.level.Level; import net.minecraft.server.level.ServerLevel; import net.minecraftforge.common.world.ForgeChunkManager; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; diff --git a/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java b/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java index 87f7a9a0ab..2593179f62 100644 --- a/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java +++ b/src/test/java/net/minecraftforge/debug/world/ForgeWorldTypeTest.java @@ -23,14 +23,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.chat.TextComponent; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.ForgeWorldTypeScreens; -import net.minecraftforge.common.world.ForgeWorldType; +import net.minecraftforge.client.ForgeWorldPresetScreens; +import net.minecraftforge.common.world.ForgeWorldPreset; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -43,26 +44,26 @@ import net.minecraftforge.registries.ObjectHolder; public class ForgeWorldTypeTest { @ObjectHolder("forge_world_type_test:test_world_type") - public static ForgeWorldType testWorldType; + public static ForgeWorldPreset testWorldType; public ForgeWorldTypeTest() { - FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ForgeWorldType.class, this::registerWorldTypes); + FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ForgeWorldPreset.class, this::registerWorldTypes); } - private void registerWorldTypes(RegistryEvent.Register event) + private void registerWorldTypes(RegistryEvent.Register event) { event.getRegistry().registerAll( - new ForgeWorldType(WorldGenSettings::makeDefaultOverworld).setRegistryName("test_world_type") + new ForgeWorldPreset(WorldGenSettings::makeDefaultOverworld).setRegistryName("test_world_type") ); event.getRegistry().registerAll( - new ForgeWorldType(this::createChunkGenerator).setRegistryName("test_world_type2") + new ForgeWorldPreset(this::createChunkGenerator).setRegistryName("test_world_type2") ); } - private ChunkGenerator createChunkGenerator(Registry biomes, Registry dimensionSettings, long seed, String settings) + private ChunkGenerator createChunkGenerator(RegistryAccess registry, long seed, String settings) { - return WorldGenSettings.makeDefaultOverworld(biomes, dimensionSettings, seed); + return WorldGenSettings.makeDefaultOverworld(registry, seed); } @Mod.EventBusSubscriber(modid="forge_world_type_test", value=Dist.CLIENT, bus=Bus.MOD) @@ -71,7 +72,7 @@ public class ForgeWorldTypeTest @SubscribeEvent public static void registerWorldTypeScreenFactories(FMLClientSetupEvent event) { - ForgeWorldTypeScreens.registerFactory(testWorldType, (returnTo, dimensionGeneratorSettings) -> new Screen(testWorldType.getDisplayName()) + ForgeWorldPresetScreens.registerPresetEditor(testWorldType, (returnTo, dimensionGeneratorSettings) -> new Screen(testWorldType.getDisplayName()) { @Override protected void init() diff --git a/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java b/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java index faf03c6ddf..b2d4e5af4f 100644 --- a/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java +++ b/src/test/java/net/minecraftforge/debug/world/WorldgenRegistryDesyncTest.java @@ -20,12 +20,12 @@ package net.minecraftforge.debug.world; import net.minecraft.world.level.biome.Biome; -import net.minecraft.data.worldgen.biome.VanillaBiomes; +//import net.minecraft.data.worldgen.biome.VanillaBiomes; import net.minecraft.world.level.levelgen.feature.MonsterRoomFeature; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fmllegacy.RegistryObject; +import net.minecraftforge.registries.RegistryObject; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.registries.DeferredRegister; @@ -38,7 +38,7 @@ public class WorldgenRegistryDesyncTest { public static final DeferredRegister> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, "worldgen_registry_desync_test"); public static final RegistryObject> dungeon = FEATURES.register("dungeon", () -> new MonsterRoomFeature(NoneFeatureConfiguration.CODEC)); public static final DeferredRegister BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, "worldgen_registry_desync_test"); - public static final RegistryObject biome = BIOMES.register("biome", VanillaBiomes::theVoidBiome); + //TODO: public static final RegistryObject biome = BIOMES.register("biome", VanillaBiomes::theVoidBiome); public WorldgenRegistryDesyncTest() { diff --git a/src/test/resources/pack.mcmeta b/src/test/resources/pack.mcmeta index 3f41e9bf86..d7d0769ba3 100644 --- a/src/test/resources/pack.mcmeta +++ b/src/test/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 7, + "pack_format": 8, "description": "Forge tests resource pack" } } diff --git a/src/test/resources/test_nested_resource_pack/pack.mcmeta b/src/test/resources/test_nested_resource_pack/pack.mcmeta index 0510da06c2..c4ce141db9 100644 --- a/src/test/resources/test_nested_resource_pack/pack.mcmeta +++ b/src/test/resources/test_nested_resource_pack/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { - "pack_format": 7, + "pack_format": 8, "description": "Nested resource pack" } }