mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 01:04:24 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e00bddd6d8 | ||
|
|
f0ef4fe307 | ||
|
|
71f626be39 | ||
|
|
1554afd613 | ||
|
|
631b756d5b | ||
|
|
bc6408ee24 | ||
|
|
998999412f | ||
|
|
02bbab1f90 | ||
|
|
1cde9f70a9 | ||
|
|
2dd93eea1d | ||
|
|
592ca2897c | ||
|
|
27fb189b0d | ||
|
|
3cd49ed58d | ||
|
|
f31519b6bb | ||
|
|
f715248a1e | ||
|
|
e1bc30a04b | ||
|
|
85ab903cd1 | ||
|
|
530c7c4eb5 | ||
|
|
3c740e488d | ||
|
|
03d07a9621 | ||
|
|
90dc29b1ef | ||
|
|
eae9d72dd8 | ||
|
|
7ac8903a3b | ||
|
|
bd96ff8777 | ||
|
|
ebfd92e0e1 | ||
|
|
43288f79e3 | ||
|
|
dbd7da6885 | ||
|
|
bb98165ee8 | ||
|
|
6a1f1acc42 | ||
|
|
a982445295 | ||
|
|
89919519ac | ||
|
|
4d592ba5ac | ||
|
|
5657e6542b | ||
|
|
c1c327ce11 | ||
|
|
142f07cbad | ||
|
|
c4f18dfa4b | ||
|
|
9f5a6d716e | ||
|
|
984cedda5c | ||
|
|
cc4a431711 | ||
|
|
ee07bcac57 | ||
|
|
b1cc694453 | ||
|
|
838ab9e1a5 | ||
|
|
99a7fcd8bd | ||
|
|
3535dcdbb3 | ||
|
|
d7ccecefe0 | ||
|
|
d3e9cfaaba | ||
|
|
7134b93427 | ||
|
|
61694447b2 | ||
|
|
561f3ee534 | ||
|
|
d0fea9cf76 | ||
|
|
dd866ed53e | ||
|
|
54f5e1213a | ||
|
|
9d4f283e6b | ||
|
|
28d4205a97 | ||
|
|
d0d1f1d782 | ||
|
|
397ceac0b6 | ||
|
|
1b7665cdaa | ||
|
|
70f96ef64e | ||
|
|
0cf4446352 | ||
|
|
b8270cd9ff |
No files matched your search
@@ -0,0 +1,28 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ '1.20.4' ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
|
||||
with:
|
||||
java: 17
|
||||
gradle_setup: './gradlew setup'
|
||||
gradle_tasks: 'build publish'
|
||||
artifact_name: 'forge'
|
||||
secrets:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}
|
||||
PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }}
|
||||
PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }}
|
||||
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
||||
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
||||
SIGN_KEY_ALIAS: ${{ secrets.SIGN_KEY_ALIAS }}
|
||||
SIGN_KEY_PASSWORD: ${{ secrets.SIGN_KEY_PASSWORD }}
|
||||
SIGN_KEYSTORE_PASSWORD: ${{ secrets.SIGN_KEYSTORE_PASSWORD }}
|
||||
SIGN_KEYSTORE_DATA: ${{ secrets.SIGN_KEYSTORE_DATA }}
|
||||
Vendored
-104
@@ -1,104 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>MinecraftForge_Forge Config DSL Script</name>
|
||||
<groupId>MinecraftForge_Forge</groupId>
|
||||
<artifactId>MinecraftForge_Forge_dsl</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>configs-dsl-kotlin-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jetbrains-all</id>
|
||||
<url>https://download.jetbrains.com/teamcity-repository</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>teamcity-server</id>
|
||||
<url>https://teamcity.minecraftforge.net/app/dsl-plugins-repository</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>JetBrains</id>
|
||||
<url>https://download.jetbrains.com/teamcity-repository</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${basedir}</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<configuration/>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>process-test-sources</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>teamcity-configs-maven-plugin</artifactId>
|
||||
<version>${teamcity.dsl.version}</version>
|
||||
<configuration>
|
||||
<format>kotlin</format>
|
||||
<dstDir>target/generated-configs</dstDir>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>configs-dsl-kotlin</artifactId>
|
||||
<version>${teamcity.dsl.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.teamcity</groupId>
|
||||
<artifactId>configs-dsl-kotlin-plugins</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-script-runtime</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
Vendored
-193
@@ -1,193 +0,0 @@
|
||||
import jetbrains.buildServer.configs.kotlin.v2019_2.*
|
||||
import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues
|
||||
import jetbrains.buildServer.configs.kotlin.*
|
||||
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.gradle
|
||||
|
||||
/*
|
||||
The settings script is an entry point for defining a TeamCity
|
||||
project hierarchy. The script should contain a single call to the
|
||||
project() function with a Project instance or an init function as
|
||||
an argument.
|
||||
|
||||
VcsRoots, BuildTypes, Templates, and subprojects can be
|
||||
registered inside the project using the vcsRoot(), buildType(),
|
||||
template(), and subProject() methods respectively.
|
||||
|
||||
To debug settings scripts in command-line, run the
|
||||
|
||||
mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate
|
||||
|
||||
command and attach your debugger to the port 8000.
|
||||
|
||||
To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
|
||||
-> Tool Windows -> Maven Projects), find the generate task node
|
||||
(Plugins -> teamcity-configs -> teamcity-configs:generate), the
|
||||
'Debug' option is available in the context menu for the task.
|
||||
*/
|
||||
|
||||
version = "2021.2"
|
||||
|
||||
project {
|
||||
|
||||
buildType(Build)
|
||||
buildType(BuildSecondaryBranches)
|
||||
buildType(PullRequests)
|
||||
buildType(PullRequestChecks)
|
||||
buildType(PullRequestCompatibility)
|
||||
|
||||
params {
|
||||
text("docker_jdk_version", "17", label = "Gradle version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("docker_gradle_version", "7.5.1", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("git_main_branch", "1.20.x", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("git_branch_spec", """
|
||||
+:refs/heads/(main*)
|
||||
+:refs/heads/(master*)
|
||||
+:refs/heads/(develop|release|staging|main|master)
|
||||
+:refs/heads/(1.*)
|
||||
""".trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
|
||||
text("github_repository_name", "MinecraftForge", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `MinecraftForge` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false)
|
||||
text("env.PUBLISHED_JAVA_ARTIFACT_ID", "forge", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false)
|
||||
text("env.PUBLISHED_JAVA_GROUP", "net.minecraftforge", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false)
|
||||
//These are references and not actually keys
|
||||
password("env.CROWDIN_KEY", "credentialsJSON:a3102dbe-805d-4177-9f54-3d2c2eb08fd5", display = ParameterDisplay.HIDDEN)
|
||||
password("env.KEYSTORE_URL", "credentialsJSON:a7ae1c82-8058-4061-8d12-7f6bc2618d2e", display = ParameterDisplay.HIDDEN)
|
||||
password("env.KEYSTORE_PASSWORD", "credentialsJSON:d7b964e3-a1fd-47a8-b892-6f601fe47479", display = ParameterDisplay.HIDDEN)
|
||||
text("additional_publishing_gradle_parameters", "-PcrowdinKey=%env.CROWDIN_KEY% -PkeystoreKeyPass=%env.KEYSTORE_PASSWORD% -PkeystoreStorePass=%env.KEYSTORE_PASSWORD% -Pkeystore=%env.KEYSTORE_URL%", label = "Additional gradle parameters for publish", description = "Contains the additional gradle parameters used during publishing.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
|
||||
|
||||
checkbox("should_execute_build", "false", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
|
||||
checked = "true", unchecked = "false")
|
||||
checkbox("should_execute_test", "false", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
|
||||
checked = "true", unchecked = "false")
|
||||
}
|
||||
|
||||
features {
|
||||
githubIssues {
|
||||
id = "MinecraftForge_MinecraftForge__IssueTracker"
|
||||
displayName = "MinecraftForge/MinecraftForge"
|
||||
repositoryURL = "https://github.com/MinecraftForge/MinecraftForge"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object Build : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"), AbsoluteId("MinecraftForge_PublishProjectUsingGradle"), AbsoluteId("MinecraftForge_TriggersStaticFilesWebpageGenerator"))
|
||||
id("MinecraftForge_MinecraftForge__Build")
|
||||
name = "Build"
|
||||
description = "Builds and Publishes the main branches of the project."
|
||||
})
|
||||
|
||||
object BuildSecondaryBranches : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_ExcludesBuildingDefaultBranch"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__BuildSecondaryBranches")
|
||||
name = "Build - Secondary Branches"
|
||||
description = "Builds and Publishes the secondary branches of the project."
|
||||
params {
|
||||
text("git_branch_spec", """
|
||||
+:refs/heads/(*)
|
||||
-:refs/heads/noci*
|
||||
""".trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true)
|
||||
}
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
|
||||
object PullRequests : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"), AbsoluteId("MinecraftForge_BuildUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__PullRequests")
|
||||
name = "Pull Requests"
|
||||
description = "Builds pull requests for the project"
|
||||
|
||||
params {
|
||||
checkbox("should_execute_build", "true", label = "Should build", description = "Indicates if the build task should be executed.", display = ParameterDisplay.HIDDEN,
|
||||
checked = "true", unchecked = "false")
|
||||
text(
|
||||
"gradle_build_task",
|
||||
"assemble",
|
||||
label = "Gradle build task to execute during build",
|
||||
description = "Determines the build task that is executed to build the project.",
|
||||
display = ParameterDisplay.HIDDEN,
|
||||
allowEmpty = false
|
||||
)
|
||||
}
|
||||
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
|
||||
object PullRequestChecks : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__PullRequestChecks")
|
||||
name = "Pull Requests (Checks)"
|
||||
description = "Checks pull requests for the project"
|
||||
|
||||
steps {
|
||||
gradle {
|
||||
name = "Check"
|
||||
id = "RUNNER_10_Check"
|
||||
|
||||
tasks = "checkAll"
|
||||
gradleParams = "--continue %gradle_custom_args%"
|
||||
enableStacktrace = true
|
||||
dockerImage = "%docker_gradle_image%"
|
||||
dockerRunParameters = """
|
||||
-v "/opt/cache/agent/gradle:/home/gradle/.gradle"
|
||||
-v "/opt/cache/shared/gradle:/home/gradle/rocache:ro"
|
||||
--network=host
|
||||
-u 1000:1000
|
||||
%docker_additional_args%
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
|
||||
object PullRequestCompatibility : BuildType({
|
||||
templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_SetupProjectUsingGradle"))
|
||||
id("MinecraftForge_MinecraftForge__PullRequestCompatibility")
|
||||
name = "Pull Requests (Compatibility)"
|
||||
description = "Validates binary compatibility for pull requests made to the project"
|
||||
|
||||
steps {
|
||||
gradle {
|
||||
name = "Validate"
|
||||
id = "RUNNER_10_Compatibility"
|
||||
|
||||
tasks = "checkJarCompatibility"
|
||||
gradleParams = "--continue %gradle_custom_args%"
|
||||
enableStacktrace = true
|
||||
dockerImage = "%docker_gradle_image%"
|
||||
dockerRunParameters = """
|
||||
-v "/opt/cache/agent/gradle:/home/gradle/.gradle"
|
||||
-v "/opt/cache/shared/gradle:/home/gradle/rocache:ro"
|
||||
--network=host
|
||||
-u 1000:1000
|
||||
%docker_additional_args%
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
|
||||
vcs {
|
||||
branchFilter = """
|
||||
+:*
|
||||
-:1.*
|
||||
-:<default>
|
||||
""".trimIndent()
|
||||
}
|
||||
})
|
||||
@@ -4,9 +4,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.ow2.asm:asm:9.6'
|
||||
implementation 'org.ow2.asm:asm-tree:9.6'
|
||||
implementation 'net.minecraftforge:srgutils:0.5.+'
|
||||
implementation 'org.ow2.asm:asm:9.9.1'
|
||||
implementation 'org.ow2.asm:asm-tree:9.9.1'
|
||||
implementation 'net.minecraftforge:srgutils:0.6.2'
|
||||
implementation 'commons-io:commons-io:2.13.0'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r'
|
||||
|
||||
@@ -19,6 +19,8 @@ abstract class BundleList extends DefaultTask {
|
||||
configure {
|
||||
dependsOn(project.tasks.universalJar)
|
||||
inputs.file(project.tasks.universalJar.archiveFile)
|
||||
dependsOn(project.tasks.applyServerBinPatches)
|
||||
inputs.file(project.tasks.applyServerBinPatches.output)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ abstract class BytecodePredicateFinder extends BytecodeFinder {
|
||||
@Internal
|
||||
@Override
|
||||
protected Object getData() {
|
||||
return matches.toSorted(Comparator.naturalOrder()) ?: {throw new RuntimeException('Failed to find any targets, please ensure that method names and descriptors are correct.')}()
|
||||
return matches.toSorted(Comparator.<String>naturalOrder()) ?: {throw new RuntimeException('Failed to find any targets, please ensure that method names and descriptors are correct.')}()
|
||||
}
|
||||
}
|
||||
@@ -74,3 +74,11 @@ eclipse {
|
||||
// Run when importing the project
|
||||
synchronizationTasks generateResources, copyEclipseSettings, eclipseClasspath, eclipseProject
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
// IntelliJ IDEA does not do this by itself anymore...
|
||||
downloadJavadoc = true
|
||||
downloadSources = true
|
||||
}
|
||||
}
|
||||
+25
-6
@@ -2,16 +2,15 @@
|
||||
|
||||
MinecraftForge
|
||||
=============
|
||||
[][Download]
|
||||
[][Download]
|
||||
[][Download] [][Discord] [][Patreon]
|
||||
|
||||
Forge is a free, open-source modding API all of your favourite mods use!
|
||||
|
||||
| Version | Support |
|
||||
|---------| ------------- |
|
||||
| 1.20.x | Active |
|
||||
| 1.19.x | Legacy |
|
||||
| Version | Support |
|
||||
|--------------|-----------------------------|
|
||||
| All versions | [Supported][Support-Policy] |
|
||||
|
||||
* [Download]
|
||||
* [Forum]
|
||||
@@ -31,6 +30,19 @@ You can download the installer for the *Recommended Build* or the
|
||||
|
||||
For support and questions, visit [the Support Forum][Support-Forum] or [the Forge Discord server][Discord].
|
||||
|
||||
## Required Java Versions
|
||||
|
||||
We require the version of Java that Minecraft requires, which is currently:
|
||||
|
||||
| Minecraft | Java |
|
||||
|---------------|-------------------|
|
||||
| 1.20.6+ | [21][Adoptium-21] |
|
||||
| 1.18 - 1.20.4 | [17][Adoptium-17] |
|
||||
| 1.17.1 | [16][Adoptium-16] |
|
||||
| 1.16.5- | [8][Adoptium-8] |
|
||||
|
||||
**If you are on Windows and have difficulty using Java to launch JAR files, consider using [Jarfix by Johann Löfflmann][Jarfix].**
|
||||
|
||||
# Creating Mods
|
||||
|
||||
[See the "Getting Started" section in the Forge Documentation][Getting-Started].
|
||||
@@ -63,8 +75,15 @@ Please ensure you have a valid email address associated with your GitHub account
|
||||
|
||||
[Download]: https://files.minecraftforge.net/
|
||||
|
||||
[Adoptium-21]: https://adoptium.net/temurin/releases/?version=21
|
||||
[Adoptium-17]: https://adoptium.net/temurin/releases/?version=17
|
||||
[Adoptium-16]: https://adoptium.net/temurin/releases/?version=16
|
||||
[Adoptium-8]: https://adoptium.net/temurin/releases/?version=8
|
||||
[Jarfix]: https://johann.loefflmann.net/en/software/jarfix/index.html
|
||||
|
||||
[Forum]: https://forums.minecraftforge.net/
|
||||
[Support-Forum]: https://forums.minecraftforge.net/forum/18-support-bug-reports/
|
||||
[Support-Policy]: https://forums.minecraftforge.net/topic/144690-new-tiered-support-policy
|
||||
|
||||
[Discord]: https://discord.minecraftforge.net/
|
||||
|
||||
|
||||
@@ -9,41 +9,35 @@ import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.config.IConfigEvent;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Used to allow access to certain things from the game layer
|
||||
*/
|
||||
public class Bindings {
|
||||
private static final Bindings INSTANCE = new Bindings();
|
||||
private Bindings() {}
|
||||
|
||||
private final IBindingsProvider provider;
|
||||
|
||||
private Bindings() {
|
||||
var providers = new ArrayList<IBindingsProvider>(1);
|
||||
for (var itr = ServiceLoader.load(FMLLoader.getGameLayer(), IBindingsProvider.class).iterator(); itr.hasNext(); ) {
|
||||
try {
|
||||
providers.add(itr.next());
|
||||
} catch (ServiceConfigurationError sce) {
|
||||
sce.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (providers.size() != 1)
|
||||
throw new IllegalStateException("Could not find bindings provider: " + providers);
|
||||
|
||||
this.provider = providers.get(0);
|
||||
}
|
||||
/**
|
||||
* The provider of the bindings
|
||||
* @implNote May also throw a {@link ServiceConfigurationError}
|
||||
*/
|
||||
private static final IBindingsProvider PROVIDER = ServiceLoader.load(FMLLoader.getGameLayer(), IBindingsProvider.class)
|
||||
.findFirst().orElseThrow(() -> new IllegalStateException("Could not find bindings provider"));
|
||||
|
||||
/**
|
||||
* @return A supplier of net.minecraftforge.common.MinecraftForge#EVENT_BUS
|
||||
*/
|
||||
public static Supplier<IEventBus> getForgeBus() {
|
||||
return INSTANCE.provider.getForgeBusSupplier();
|
||||
return PROVIDER.getForgeBusSupplier();
|
||||
}
|
||||
|
||||
public static Supplier<I18NParser> getMessageParser() {
|
||||
return INSTANCE.provider.getMessageParser();
|
||||
return PROVIDER.getMessageParser();
|
||||
}
|
||||
|
||||
public static Supplier<IConfigEvent.ConfigConfig> getConfigConfiguration() {
|
||||
return INSTANCE.provider.getConfigConfiguration();
|
||||
return PROVIDER.getConfigConfiguration();
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,7 @@ package net.minecraftforge.fml;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.fml.config.IConfigSpec;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Supplier;
|
||||
@@ -19,28 +17,45 @@ public class ModLoadingContext
|
||||
{
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final ThreadLocal<ModLoadingContext> context = ThreadLocal.withInitial(ModLoadingContext::new);
|
||||
private ModContainer activeContainer;
|
||||
private Object languageExtension;
|
||||
private ModLoadingStage stage;
|
||||
|
||||
/**
|
||||
* @deprecated Use the context provided by your language loader in your mod's constructor.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public static ModLoadingContext get() {
|
||||
return context.get();
|
||||
}
|
||||
|
||||
private ModContainer activeContainer;
|
||||
|
||||
/**
|
||||
* @deprecated Going to be moved to ForgeHooks for internal use.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public void setActiveContainer(final ModContainer container) {
|
||||
this.activeContainer = container;
|
||||
this.languageExtension = container == null ? null : container.contextExtension.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Going to be moved to ForgeHooks for internal use.
|
||||
* @deprecated Override/Use {@link ModLoadingContext#getContainer()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public ModContainer getActiveContainer() {
|
||||
return activeContainer == null ? ModList.get().getModContainerById("minecraft").orElseThrow(()->new RuntimeException("Where is minecraft???!")) : activeContainer;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public String getActiveNamespace() {
|
||||
return activeContainer == null ? "minecraft" : activeContainer.getNamespace();
|
||||
}
|
||||
|
||||
public ModContainer getContainer() {
|
||||
return getActiveContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an {@link IExtensionPoint} with the mod container.
|
||||
* @param point The extension point to register
|
||||
@@ -48,7 +63,7 @@ public class ModLoadingContext
|
||||
* @param <T> The type signature of the extension operator
|
||||
*/
|
||||
public <T extends Record & IExtensionPoint<T>> void registerExtensionPoint(Class<? extends IExtensionPoint<T>> point, Supplier<T> extension) {
|
||||
getActiveContainer().registerExtensionPoint(point, extension);
|
||||
getContainer().registerExtensionPoint(point, extension);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +72,7 @@ public class ModLoadingContext
|
||||
* @param displayTest The {@link IExtensionPoint.DisplayTest} to register
|
||||
*/
|
||||
public void registerDisplayTest(IExtensionPoint.DisplayTest displayTest) {
|
||||
getActiveContainer().registerDisplayTest(() -> displayTest);
|
||||
getContainer().registerDisplayTest(() -> displayTest);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +81,7 @@ public class ModLoadingContext
|
||||
* @param displayTest The {@link Supplier<IExtensionPoint.DisplayTest>} to register
|
||||
*/
|
||||
public void registerDisplayTest(Supplier<IExtensionPoint.DisplayTest> displayTest) {
|
||||
getActiveContainer().registerDisplayTest(displayTest);
|
||||
getContainer().registerDisplayTest(displayTest);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +91,7 @@ public class ModLoadingContext
|
||||
* @see IExtensionPoint.DisplayTest#DisplayTest(String, BiPredicate)
|
||||
*/
|
||||
public void registerDisplayTest(String version, BiPredicate<String, Boolean> remoteVersionTest) {
|
||||
getActiveContainer().registerDisplayTest(new IExtensionPoint.DisplayTest(version, remoteVersionTest));
|
||||
getContainer().registerDisplayTest(new IExtensionPoint.DisplayTest(version, remoteVersionTest));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,29 +101,29 @@ public class ModLoadingContext
|
||||
* @see IExtensionPoint.DisplayTest#DisplayTest(Supplier, BiPredicate)
|
||||
*/
|
||||
public void registerDisplayTest(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) {
|
||||
getActiveContainer().registerDisplayTest(new IExtensionPoint.DisplayTest(suppliedVersion, remoteVersionTest));
|
||||
getContainer().registerDisplayTest(new IExtensionPoint.DisplayTest(suppliedVersion, remoteVersionTest));
|
||||
}
|
||||
|
||||
public void registerConfig(ModConfig.Type type, IConfigSpec<?> spec) {
|
||||
if (spec.isEmpty())
|
||||
{
|
||||
// This handles the case where a mod tries to register a config, without any options configured inside it.
|
||||
LOGGER.debug("Attempted to register an empty config for type {} on mod {}", type, getActiveContainer().getModId());
|
||||
LOGGER.debug("Attempted to register an empty config for type {} on mod {}", type, getContainer().getModId());
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer()));
|
||||
getContainer().addConfig(new ModConfig(type, spec, getContainer()));
|
||||
}
|
||||
|
||||
public void registerConfig(ModConfig.Type type, IConfigSpec<?> spec, String fileName) {
|
||||
if (spec.isEmpty())
|
||||
{
|
||||
// This handles the case where a mod tries to register a config, without any options configured inside it.
|
||||
LOGGER.debug("Attempted to register an empty config for type {} on mod {} using file name {}", type, getActiveContainer().getModId(), fileName);
|
||||
LOGGER.debug("Attempted to register an empty config for type {} on mod {} using file name {}", type, getContainer().getModId(), fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer(), fileName));
|
||||
getContainer().addConfig(new ModConfig(type, spec, getContainer(), fileName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ public class VersionChecker {
|
||||
BETA(),
|
||||
BETA_OUTDATED(6, true, true);
|
||||
|
||||
final int sheetOffset;
|
||||
final boolean draw, animated;
|
||||
private final int sheetOffset;
|
||||
private final boolean draw, animated;
|
||||
|
||||
Status() {
|
||||
this(0, false, false);
|
||||
@@ -72,6 +72,10 @@ public class VersionChecker {
|
||||
public boolean isAnimated() {
|
||||
return animated;
|
||||
}
|
||||
|
||||
public boolean isOutdated() {
|
||||
return this == OUTDATED || this == BETA_OUTDATED;
|
||||
}
|
||||
}
|
||||
|
||||
public record CheckResult(VersionChecker.Status status, ComparableVersion target, Map<ComparableVersion, String> changes, String url) {}
|
||||
@@ -211,7 +215,7 @@ public class VersionChecker {
|
||||
LOGGER.warn("Failed to process update information", e);
|
||||
status = FAILED;
|
||||
}
|
||||
results.put(mod, new CheckResult(status, target, changes, display_url));
|
||||
RESULTS.put(mod, new CheckResult(status, target, changes, display_url));
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@@ -226,10 +230,10 @@ public class VersionChecker {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static Map<IModInfo, CheckResult> results = new ConcurrentHashMap<>();
|
||||
private static final Map<IModInfo, CheckResult> RESULTS = new ConcurrentHashMap<>();
|
||||
private static final CheckResult PENDING_CHECK = new CheckResult(PENDING, null, null, null);
|
||||
|
||||
public static CheckResult getResult(IModInfo mod) {
|
||||
return results.getOrDefault(mod, PENDING_CHECK);
|
||||
return RESULTS.getOrDefault(mod, PENDING_CHECK);
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -13,10 +13,10 @@ import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
|
||||
public class PerformanceInfo {
|
||||
private static final MemoryMXBean MEMORY_BEAN = ManagementFactory.getMemoryMXBean();
|
||||
|
||||
private final boolean showCPUUsage;
|
||||
private final OperatingSystemMXBean osBean;
|
||||
private final MemoryMXBean memoryBean;
|
||||
|
||||
private float memory;
|
||||
private String text;
|
||||
@@ -24,15 +24,14 @@ public class PerformanceInfo {
|
||||
PerformanceInfo() {
|
||||
showCPUUsage = FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_SHOW_CPU);
|
||||
osBean = showCPUUsage ? ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class) : null;
|
||||
memoryBean = ManagementFactory.getMemoryMXBean();
|
||||
}
|
||||
|
||||
void update() {
|
||||
final MemoryUsage heapusage = memoryBean.getHeapMemoryUsage();
|
||||
final MemoryUsage heapusage = MEMORY_BEAN.getHeapMemoryUsage();
|
||||
memory = (float) heapusage.getUsed() / heapusage.getMax();
|
||||
|
||||
if (!showCPUUsage) {
|
||||
text = "Heap: %d/%d MB (%.1f%%) OffHeap: %d MB".formatted(heapusage.getUsed() >> 20, heapusage.getMax() >> 20, memory * 100.0, memoryBean.getNonHeapMemoryUsage().getUsed() >> 20);
|
||||
text = "Memory: %d/%dMB (%.1f%%)".formatted(heapusage.getUsed() >>> 20, heapusage.getMax() >>> 20, memory * 100f);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,7 +43,7 @@ public class PerformanceInfo {
|
||||
cpuText = "CPU: %.1f%%".formatted(cpuLoad * 100f);
|
||||
}
|
||||
|
||||
text = "Heap: %d/%d MB (%.1f%%) OffHeap: %d MB %s".formatted(heapusage.getUsed() >> 20, heapusage.getMax() >> 20, memory * 100.0, memoryBean.getNonHeapMemoryUsage().getUsed() >> 20, cpuText);
|
||||
text = "Memory: %d/%dMB (%.1f%%) %s".formatted(heapusage.getUsed() >>> 20, heapusage.getMax() >>> 20, memory * 100f, cpuText);
|
||||
}
|
||||
|
||||
String text() {
|
||||
|
||||
+13
-6
@@ -36,9 +36,9 @@ import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||
*/
|
||||
public class CapabilityTokenSubclass implements ILaunchPluginService {
|
||||
|
||||
private final String FUNC_NAME = "getType";
|
||||
private final String FUNC_DESC = "()Ljava/lang/String;";
|
||||
private final String CAP_INJECT = "net/minecraftforge/common/capabilities/CapabilityToken"; //Don't directly reference this to prevent class loading.
|
||||
private static final String FUNC_NAME = "getType";
|
||||
private static final String FUNC_DESC = "()Ljava/lang/String;";
|
||||
private static final String CAP_INJECT = "net/minecraftforge/common/capabilities/CapabilityToken"; //Don't directly reference this to prevent class loading.
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -51,7 +51,14 @@ public class CapabilityTokenSubclass implements ILaunchPluginService {
|
||||
@Override
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||
{
|
||||
return isEmpty ? NAY : YAY;
|
||||
if (isEmpty)
|
||||
return NAY;
|
||||
|
||||
String internalName = classType.getInternalName();
|
||||
if (internalName.startsWith("net/minecraft/") || internalName.startsWith("com/mojang/"))
|
||||
return NAY;
|
||||
|
||||
return YAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +82,7 @@ public class CapabilityTokenSubclass implements ILaunchPluginService {
|
||||
SignatureReader reader = new SignatureReader(classNode.signature); // Having a node version of this would probably be useful.
|
||||
reader.accept(new SignatureVisitor(Opcodes.ASM9)
|
||||
{
|
||||
Deque<String> stack = new ArrayDeque<>();
|
||||
final Deque<String> stack = new ArrayDeque<>();
|
||||
|
||||
@Override
|
||||
public void visitClassType(final String name)
|
||||
@@ -113,7 +120,7 @@ public class CapabilityTokenSubclass implements ILaunchPluginService {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Holder {
|
||||
private static final class Holder {
|
||||
String value;
|
||||
}
|
||||
|
||||
|
||||
+29
-9
@@ -8,6 +8,7 @@ package net.minecraftforge.fml.common.asm;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -35,7 +36,11 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
||||
new VanillaObjectHolderData("net.minecraft.core.particles.ParticleTypes", "particle_type", "net.minecraft.core.particles.ParticleType"),
|
||||
new VanillaObjectHolderData("net.minecraft.sounds.SoundEvents", "sound_event", "net.minecraft.sounds.SoundEvent")
|
||||
).collect(Collectors.toMap(VanillaObjectHolderData::holderClass, Function.identity()));
|
||||
private final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
|
||||
private static final Set<String> VANILLA_OBJECT_HOLDER_CLASSES = VANILLA_OBJECT_HOLDERS.keySet().stream()
|
||||
.map(it -> it.replace('.', '/'))
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
private static final String OBJECT_HOLDER = "Lnet/minecraftforge/registries/ObjectHolder;"; //Don't directly reference this to prevent class loading.
|
||||
private static final int PUBLIC_STATIC_FINAL_FLAGS = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -46,13 +51,29 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
||||
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||
|
||||
@Override
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||
{
|
||||
return isEmpty ? NAY : YAY;
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
|
||||
if (isEmpty)
|
||||
return NAY;
|
||||
|
||||
// Let's skip processing classes that definitely don't have object holders
|
||||
String internalName = classType.getInternalName();
|
||||
|
||||
// Forge classes that aren't in the debug package (that package is used for tests)
|
||||
if (internalName.startsWith("net/minecraftforge/") && !internalName.substring(18).contains("debug"))
|
||||
return NAY;
|
||||
|
||||
// Vanilla classes that don't have object holders
|
||||
if (internalName.startsWith("com/mojang/"))
|
||||
return NAY;
|
||||
|
||||
// ...except specific ones we added to the VANILLA_OBJECT_HOLDERS map
|
||||
if (internalName.startsWith("net/minecraft/") && !VANILLA_OBJECT_HOLDER_CLASSES.contains(internalName))
|
||||
return NAY;
|
||||
|
||||
return YAY;
|
||||
}
|
||||
|
||||
private boolean hasHolder(List<AnnotationNode> lst)
|
||||
{
|
||||
private boolean hasHolder(List<AnnotationNode> lst) {
|
||||
return lst != null && lst.stream().anyMatch(n -> n.desc.equals(OBJECT_HOLDER));
|
||||
}
|
||||
|
||||
@@ -76,10 +97,9 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
||||
{
|
||||
final AtomicBoolean changes = new AtomicBoolean();
|
||||
//Must be public static finals, and non-array objects
|
||||
final int flags = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
|
||||
|
||||
//Fix Annotated Fields before injecting from class level
|
||||
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L") && hasHolder(f.visibleAnnotations)).forEach(f ->
|
||||
classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L") && hasHolder(f.visibleAnnotations)).forEach(f ->
|
||||
{
|
||||
int prev = f.access;
|
||||
f.access &= ~Opcodes.ACC_FINAL; //Strip final
|
||||
@@ -89,7 +109,7 @@ public class ObjectHolderDefinalize implements ILaunchPluginService {
|
||||
|
||||
if (VANILLA_OBJECT_HOLDERS.containsKey(classType.getClassName())) //Class level, de-finalize all fields and add @ObjectHolder to them!
|
||||
{
|
||||
classNode.fields.stream().filter(f -> ((f.access & flags) == flags) && f.desc.startsWith("L")).forEach(f ->
|
||||
classNode.fields.stream().filter(f -> ((f.access & PUBLIC_STATIC_FINAL_FLAGS) == PUBLIC_STATIC_FINAL_FLAGS) && f.desc.startsWith("L")).forEach(f ->
|
||||
{
|
||||
int prev = f.access;
|
||||
f.access &= ~Opcodes.ACC_FINAL;
|
||||
|
||||
+29
-24
@@ -28,15 +28,16 @@ import org.slf4j.Logger;
|
||||
public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private final Type STRING = Type.getType(String.class);
|
||||
private final Type ENUM = Type.getType(Enum.class);
|
||||
private final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;");
|
||||
private final Type ARRAY_UTILS = Type.getType("Lorg/apache/commons/lang3/ArrayUtils;"); //Don't directly reference this to prevent class loading.
|
||||
private final String ADD_DESC = Type.getMethodDescriptor(Type.getType(Object[].class), Type.getType(Object[].class), Type.getType(Object.class));
|
||||
private final Type UNSAFE_HACKS = Type.getType("Lnet/minecraftforge/fml/unsafe/UnsafeHacks;"); //Again, not direct reference to prevent class loading.
|
||||
private final String CLEAN_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Class.class));
|
||||
private final String NAME_DESC = Type.getMethodDescriptor(STRING);
|
||||
private final String EQUALS_DESC = Type.getMethodDescriptor(Type.BOOLEAN_TYPE, STRING);
|
||||
private static final Type STRING = Type.getType(String.class);
|
||||
private static final Type ENUM = Type.getType(Enum.class);
|
||||
private static final Type MARKER_IFACE = Type.getType("Lnet/minecraftforge/common/IExtensibleEnum;");
|
||||
private static final Type ARRAY_UTILS = Type.getType("Lorg/apache/commons/lang3/ArrayUtils;"); //Don't directly reference this to prevent class loading.
|
||||
private static final String ADD_DESC = Type.getMethodDescriptor(Type.getType(Object[].class), Type.getType(Object[].class), Type.getType(Object.class));
|
||||
private static final Type UNSAFE_HACKS = Type.getType("Lnet/minecraftforge/fml/unsafe/UnsafeHacks;"); //Again, not direct reference to prevent class loading.
|
||||
private static final String CLEAN_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Class.class));
|
||||
private static final String NAME_DESC = Type.getMethodDescriptor(STRING);
|
||||
private static final String EQUALS_DESC = Type.getMethodDescriptor(Type.BOOLEAN_TYPE, STRING);
|
||||
private static final int FLAGS = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
@@ -47,9 +48,15 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||
|
||||
@Override
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||
{
|
||||
return isEmpty ? NAY : YAY;
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
|
||||
if (isEmpty)
|
||||
return NAY;
|
||||
|
||||
String internalName = classType.getInternalName();
|
||||
if (internalName.startsWith("net/minecraftforge/") || internalName.startsWith("com/mojang/"))
|
||||
return NAY;
|
||||
|
||||
return YAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,25 +65,24 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
if ((classNode.access & Opcodes.ACC_ENUM) == 0)
|
||||
return ComputeFlags.NO_REWRITE;
|
||||
|
||||
Type array = Type.getType("[" + classType.getDescriptor());
|
||||
final int flags = Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL | Opcodes.ACC_SYNTHETIC;
|
||||
|
||||
FieldNode values = classNode.fields.stream().filter(f -> f.desc.contentEquals(array.getDescriptor()) && ((f.access & flags) == flags)).findFirst().orElse(null);
|
||||
|
||||
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) {
|
||||
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName()))
|
||||
return ComputeFlags.NO_REWRITE;
|
||||
}
|
||||
|
||||
Type array = Type.getType("[" + classType.getDescriptor());
|
||||
String arrayDesc = array.getDescriptor();
|
||||
|
||||
FieldNode values = classNode.fields.stream().filter(f -> f.desc.equals(arrayDesc) && ((f.access & FLAGS) == FLAGS)).findFirst().orElse(null);
|
||||
|
||||
//Static methods named "create" with first argument as a string
|
||||
List<MethodNode> candidates = classNode.methods.stream()
|
||||
.filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create"))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
if (candidates.isEmpty()) {
|
||||
throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName());
|
||||
}
|
||||
|
||||
candidates.forEach(mtd ->
|
||||
for (var mtd : candidates)
|
||||
{
|
||||
Type[] args = Type.getArgumentTypes(mtd.desc);
|
||||
if (args.length == 0 || !args[0].equals(STRING)) {
|
||||
@@ -108,8 +114,7 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
Type[] ctrArgs = new Type[args.length + 1];
|
||||
ctrArgs[0] = STRING;
|
||||
ctrArgs[1] = Type.INT_TYPE;
|
||||
for (int x = 1; x < args.length; x++)
|
||||
ctrArgs[1 + x] = args[x];
|
||||
System.arraycopy(args, 1, ctrArgs, 2, args.length - 1);
|
||||
|
||||
String desc = Type.getMethodDescriptor(Type.VOID_TYPE, ctrArgs);
|
||||
|
||||
@@ -231,7 +236,7 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
ins.load(vars, classType);
|
||||
ins.areturn(classType);
|
||||
}
|
||||
});
|
||||
}
|
||||
return ComputeFlags.COMPUTE_FRAMES;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class FMLConfig
|
||||
EARLY_WINDOW_SQUIR("earlyWindowSquir", Boolean.FALSE, "Squir?"),
|
||||
EARLY_WINDOW_SHOW_CPU("earlyWindowShowCPU", Boolean.FALSE, "Whether to show CPU usage stats in early window"),
|
||||
EARLY_WINDOW_LOG_HELP_MSG("earlyWindowLogHelpMessage", Boolean.TRUE, "Whether to log a help message on first attempt, to aid troubleshooting. This setting should automatically disable itself after a successful launch"),
|
||||
DETECT_NON_FORGE_MODS_TOML("detectNonForgeModsToml", Boolean.TRUE, "Attempt to detect non-Forge mods from their mods.toml to show a friendlier error message. This is a best-effort feature - disable if it causes issues."),
|
||||
;
|
||||
|
||||
private final String entry;
|
||||
|
||||
@@ -57,6 +57,9 @@ public class FMLLoader {
|
||||
LOGGER.debug(CORE, "Detected version data : {}", versionInfo);
|
||||
LOGGER.debug(CORE, "FML {} loading", LauncherVersion.getVersion());
|
||||
|
||||
// Allows us to communicate properties with other services through ModLauncher
|
||||
setupBlackboardKeys();
|
||||
|
||||
checkPackage(ITransformationService.class, "4.0", "ModLauncher");
|
||||
accessTransformer = getPlugin(env, "accesstransformer", "1.0", "AccessTransformer");
|
||||
/*eventBus =*/ getPlugin(env, "eventbus", "1.0", "EventBus");
|
||||
@@ -120,6 +123,12 @@ public class FMLLoader {
|
||||
return providers.get(0);
|
||||
}
|
||||
|
||||
private static void setupBlackboardKeys() {
|
||||
LOGGER.debug(CORE, "Requesting CoreMods to not apply the fix for ASMAPI.findFirstInstructionBefore by default");
|
||||
var blackboardKey = TypesafeMap.Key.getOrCreate(Launcher.INSTANCE.blackboard(), "coremods.use_old_findFirstInstructionBefore", Boolean.class);
|
||||
Launcher.INSTANCE.blackboard().<Boolean>computeIfAbsent(blackboardKey, k -> true);
|
||||
}
|
||||
|
||||
static void setupLaunchHandler(final IEnvironment environment, final Map<String, Object> arguments) {
|
||||
final String launchTarget = environment.getProperty(IEnvironment.Keys.LAUNCHTARGET.get()).orElse("MISSING");
|
||||
arguments.put("launchTarget", launchTarget);
|
||||
@@ -181,7 +190,7 @@ public class FMLLoader {
|
||||
}
|
||||
|
||||
public static void addAccessTransformer(Path atPath, ModFile modName) {
|
||||
LOGGER.debug(SCAN, "Adding Access Transformer in {}", modName.getFilePath());
|
||||
LOGGER.debug(SCAN, "Adding Access Transformer in {} in {}", atPath, modName.getFilePath());
|
||||
accessTransformer.offerResource(atPath, modName.getFileName());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
|
||||
package net.minecraftforge.fml.loading;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.BackgroundScanHandler;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
@@ -30,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class LoadingModList
|
||||
{
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static LoadingModList INSTANCE;
|
||||
private final List<ModFileInfo> modFiles;
|
||||
private final List<ModInfo> sortedList;
|
||||
@@ -78,9 +81,22 @@ public class LoadingModList
|
||||
|
||||
public void addAccessTransformers()
|
||||
{
|
||||
modFiles.stream()
|
||||
.map(ModFileInfo::getFile)
|
||||
.forEach(mod -> mod.getAccessTransformer().ifPresent(path -> FMLLoader.addAccessTransformer(path, mod)));
|
||||
var errors = new ArrayList<EarlyLoadingException.ExceptionData>();
|
||||
for (ModFileInfo modFile : modFiles) {
|
||||
ModFile mod = modFile.getFile();
|
||||
for (Path at : mod.getAccessTransformers()) {
|
||||
if (!Files.exists(at)) {
|
||||
var message = "Invalid mod file: " + modFile.getFile().getFileName() + ". Missing Access Transformer: " + at;
|
||||
errors.add(new EarlyLoadingException.ExceptionData(message));
|
||||
LOGGER.error(message);
|
||||
} else {
|
||||
FMLLoader.addAccessTransformer(at, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!errors.isEmpty()) {
|
||||
preLoadErrors.add(new EarlyLoadingException("Invalid Access Transformers", null, errors));
|
||||
}
|
||||
}
|
||||
|
||||
public void addForScanning(BackgroundScanHandler backgroundScanHandler)
|
||||
|
||||
+14
@@ -10,6 +10,8 @@ import cpw.mods.jarhandling.SecureJar;
|
||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||
import cpw.mods.modlauncher.api.NamedPath;
|
||||
import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -20,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final Set<String> SERVICES = Set.of(
|
||||
@@ -76,4 +79,15 @@ public class ModDirTransformerDiscoverer implements ITransformerDiscoveryService
|
||||
.filter(SERVICES::contains)
|
||||
.forEach(s -> found.add(new NamedPath(s, path)));
|
||||
}
|
||||
|
||||
public static boolean isServiceProvider(Path path) {
|
||||
var jar = SecureJar.from(path);
|
||||
|
||||
for (var providers : jar.moduleDataProvider().descriptor().provides()) {
|
||||
if (SERVICES.contains(providers.service()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
|
||||
public class RuntimeDistCleaner implements ILaunchPluginService
|
||||
{
|
||||
public final class RuntimeDistCleaner implements ILaunchPluginService {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final Marker DISTXFORM = MarkerFactory.getMarker("DISTXFORM");
|
||||
private static String DIST;
|
||||
@@ -147,7 +146,7 @@ public class RuntimeDistCleaner implements ILaunchPluginService
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean remove(final List<AnnotationNode> anns, final String side)
|
||||
private static boolean remove(final List<AnnotationNode> anns, final String side)
|
||||
{
|
||||
return unpack(anns).stream().
|
||||
filter(ann->Objects.equals(ann.desc, ONLYIN)).
|
||||
@@ -169,9 +168,19 @@ public class RuntimeDistCleaner implements ILaunchPluginService
|
||||
private static final EnumSet<Phase> NAY = EnumSet.noneOf(Phase.class);
|
||||
|
||||
@Override
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty)
|
||||
{
|
||||
return isEmpty ? NAY : YAY;
|
||||
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
|
||||
if (isEmpty)
|
||||
return NAY;
|
||||
|
||||
String internalName = classType.getInternalName();
|
||||
if (internalName.startsWith("net/minecraftforge/"))
|
||||
return NAY;
|
||||
|
||||
// No Vanilla classes use @OnlyIn(Dist.SERVER), so we can skip them entirely when we're running on a client
|
||||
if (FMLEnvironment.dist.isClient() && (internalName.startsWith("net/minecraft/") || internalName.startsWith("com/mojang/")))
|
||||
return NAY;
|
||||
|
||||
return YAY;
|
||||
}
|
||||
|
||||
private static class LambdaGatherer extends MethodVisitor {
|
||||
|
||||
+6
-3
@@ -8,7 +8,6 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import cpw.mods.jarhandling.JarMetadata;
|
||||
import cpw.mods.jarhandling.SecureJar;
|
||||
import net.minecraftforge.fml.loading.EarlyLoadingException;
|
||||
import net.minecraftforge.fml.loading.LogMarkers;
|
||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
@@ -37,6 +36,10 @@ public abstract class AbstractModProvider implements IModProvider {
|
||||
protected static final String MODS_TOML = "META-INF/mods.toml";
|
||||
|
||||
protected IModLocator.ModFileOrException createMod(Path path) {
|
||||
return this.createMod(path, getDefaultJarModType());
|
||||
}
|
||||
|
||||
protected IModLocator.ModFileOrException createMod(Path path, String defaultType) {
|
||||
var mjm = new ModJarMetadata();
|
||||
var sj = SecureJar.from(
|
||||
jar -> jar.moduleDataProvider().findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path),
|
||||
@@ -46,12 +49,12 @@ public abstract class AbstractModProvider implements IModProvider {
|
||||
IModFile mod;
|
||||
var type = sj.moduleDataProvider().getManifest().getMainAttributes().getValue(ModFile.TYPE);
|
||||
if (type == null)
|
||||
type = getDefaultJarModType();
|
||||
type = defaultType;
|
||||
|
||||
if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) {
|
||||
LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path);
|
||||
mod = new ModFile(sj, this, ModFileParser::modsTomlParser);
|
||||
if (mod.getModFileInfo().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||
if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && mod.getModFileInfo().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||
LOGGER.error(LogMarkers.SCAN, "Unable to load file \"{}\" because its mods.toml is requesting an invalid javafml loaderVersion (use \"*\" if you want to allow all versions) and is missing a forge modId dependency declaration (see the sample mods.toml in the MDK).", path);
|
||||
return new IModLocator.ModFileOrException(null, new ModFileLoadingException("File \"%s\" is not a Forge mod and cannot be loaded. Look for a Forge version of this mod or consider alternative mods.".formatted(mod.getFileName())));
|
||||
}
|
||||
|
||||
+6
-2
@@ -8,6 +8,7 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import net.minecraftforge.fml.loading.LogMarkers;
|
||||
import net.minecraftforge.fml.loading.ModDirTransformerDiscoverer;
|
||||
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -71,8 +72,11 @@ public class ClasspathLocator extends AbstractModProvider implements IModLocator
|
||||
}
|
||||
|
||||
var ret = new ArrayList<ModFileOrException>();
|
||||
for (var path : claimed)
|
||||
ret.add(createMod(path));
|
||||
for (var path : claimed) {
|
||||
// Filter out anything found by the ServiceLoader
|
||||
if (!ModDirTransformerDiscoverer.isServiceProvider(path))
|
||||
ret.add(createMod(path));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -83,7 +83,14 @@ public class JarInJarDependencyLocator extends AbstractModProvider implements ID
|
||||
final Map<String, ?> outerFsArgs = ImmutableMap.of("packagePath", pathInModFile);
|
||||
final FileSystem zipFS = FileSystems.newFileSystem(filePathUri, outerFsArgs);
|
||||
final Path pathInFS = zipFS.getPath("/");
|
||||
return Optional.of(createMod(pathInFS).file());
|
||||
final IModFile.Type parentType = file.getType();
|
||||
final String modType;
|
||||
if (parentType == IModFile.Type.LIBRARY || parentType == IModFile.Type.LANGPROVIDER) {
|
||||
modType = IModFile.Type.LIBRARY.name();
|
||||
} else {
|
||||
modType = IModFile.Type.GAMELIBRARY.name();
|
||||
}
|
||||
return Optional.of(createMod(pathInFS, modType).file());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to load mod file {} from {}", path, file.getFileName());
|
||||
final RuntimeException exception = new ModFileLoadingException("Failed to load mod file " + file.getFileName());
|
||||
|
||||
@@ -52,6 +52,7 @@ public class ModFile implements IModFile {
|
||||
private CompletableFuture<ModFileScanData> futureScanResult;
|
||||
private List<CoreModFile> coreMods;
|
||||
private Path accessTransformer;
|
||||
private List<Path> accessTransformers = Collections.emptyList();
|
||||
|
||||
static final Attributes.Name TYPE = new Attributes.Name("FMLModType");
|
||||
private SecureJar.Status securityStatus;
|
||||
@@ -96,7 +97,11 @@ public class ModFile implements IModFile {
|
||||
}
|
||||
|
||||
public Optional<Path> getAccessTransformer() {
|
||||
return Optional.ofNullable(Files.exists(accessTransformer) ? accessTransformer : null);
|
||||
return Optional.ofNullable(accessTransformer);
|
||||
}
|
||||
|
||||
public List<Path> getAccessTransformers() {
|
||||
return accessTransformers;
|
||||
}
|
||||
|
||||
public boolean identifyMods() {
|
||||
@@ -105,7 +110,28 @@ public class ModFile implements IModFile {
|
||||
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(LogMarkers.LOADING,"Found coremod {}", mi.getPath()));
|
||||
this.accessTransformer = findResource("META-INF", "accesstransformer.cfg");
|
||||
List<String> cfg;
|
||||
// Note: Some mods may have invalid tomls copied from other projects.
|
||||
// Unfortunately we must protect against those landmines.
|
||||
try {
|
||||
cfg = this.modFileInfo.getConfig().<List<String>>getConfigElement("accessTransformers").orElse(null);
|
||||
} catch (Exception e) {
|
||||
cfg = null;
|
||||
LOGGER.warn("{} contains an invalid 'accessTransformers' TOML entry. Should be e.g. accessTransformers = [\"META-INF/accesstransformer.cfg\", \"META-INF/extra_at.cfg\"] or accessTransformers = [] for no ATs. Falling back to default.", this.getFileName());
|
||||
}
|
||||
if (cfg == null) {
|
||||
var path = findResource("META-INF", "accesstransformer.cfg");
|
||||
if (Files.exists(path)) {
|
||||
this.accessTransformer = path;
|
||||
this.accessTransformers = List.of(path);
|
||||
}
|
||||
} else if (!cfg.isEmpty()) {
|
||||
var paths = new ArrayList<Path>(cfg.size());
|
||||
for (var path : cfg) {
|
||||
paths.add(getSecureJar().getPath(path.replace("\\","/")));
|
||||
}
|
||||
this.accessTransformers = List.copyOf(paths);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -8,6 +8,7 @@ package net.minecraftforge.fml.loading.moddiscovery;
|
||||
import com.google.common.base.Strings;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.LogMarkers;
|
||||
import net.minecraftforge.fml.loading.StringUtils;
|
||||
import net.minecraftforge.forgespi.language.IConfigurable;
|
||||
@@ -48,6 +49,9 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
|
||||
@ApiStatus.Internal
|
||||
public static final String NOT_A_FORGE_MOD_PROP = "__FORGE__not_a_forge_mod";
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static final boolean DETECT_NON_FORGE_MODS_TOML = FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.DETECT_NON_FORGE_MODS_TOML);
|
||||
|
||||
private final IConfigurable config;
|
||||
private final ModFile modFile;
|
||||
private final URL issueURL;
|
||||
@@ -75,7 +79,8 @@ public class ModFileInfo implements IModFileInfo, IConfigurable
|
||||
this.languageSpecs = new ArrayList<>(List.of(new LanguageSpec(modLoader, modLoaderVersion)));
|
||||
|
||||
// if true, this might not be a Forge mod
|
||||
boolean maybeNotAForgeMod = modLoader.equals(JAVAFML)
|
||||
boolean maybeNotAForgeMod = DETECT_NON_FORGE_MODS_TOML
|
||||
&& modLoader.equals(JAVAFML)
|
||||
&& modLoaderVersion.hasRestrictions() // if loaderVersion is not "*"
|
||||
&& modLoaderVerStr.equals(MAYBE_NOT_JAVAFML_VER); // if loaderVersion is exactly "[2,)"
|
||||
|
||||
|
||||
+12
-4
@@ -6,6 +6,7 @@
|
||||
package net.minecraftforge.fml.loading.moddiscovery;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.FileConfig;
|
||||
import com.electronwill.nightconfig.core.io.ParsingException;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mojang.logging.LogUtils;
|
||||
@@ -13,6 +14,7 @@ import net.minecraftforge.fml.loading.LogMarkers;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.forgespi.locating.ModFileFactory;
|
||||
import net.minecraftforge.forgespi.locating.ModFileLoadingException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -31,6 +33,7 @@ public class ModFileParser {
|
||||
return parser.build(modFile);
|
||||
}
|
||||
|
||||
// Note: Although @Nullable, several other places in FML assume ModFileInfo is not null. Keep this in mind
|
||||
public static @Nullable IModFileInfo modsTomlParser(final IModFile imodFile) {
|
||||
ModFile modFile = (ModFile) imodFile;
|
||||
LOGGER.debug(LogMarkers.LOADING,"Considering mod file candidate {}", modFile.getFilePath());
|
||||
@@ -41,10 +44,15 @@ public class ModFileParser {
|
||||
}
|
||||
|
||||
final FileConfig fileConfig = FileConfig.builder(modsjson).build();
|
||||
fileConfig.load();
|
||||
fileConfig.close();
|
||||
final NightConfigWrapper configWrapper = new NightConfigWrapper(fileConfig);
|
||||
return new ModFileInfo(modFile, configWrapper, configWrapper::setFile);
|
||||
try {
|
||||
fileConfig.load();
|
||||
fileConfig.close();
|
||||
final NightConfigWrapper configWrapper = new NightConfigWrapper(fileConfig);
|
||||
return new ModFileInfo(modFile, configWrapper, configWrapper::setFile);
|
||||
} catch (ParsingException e) {
|
||||
LOGGER.error("Mod candidate {} contains a corrupt or misconfigured toml.", modFile.getFileName());
|
||||
throw new ModFileLoadingException("Mod candidate " + modFile.getFileName() + " contains a corrupt or misconfigured toml.");
|
||||
}
|
||||
}
|
||||
|
||||
protected static List<CoreModFile> getCoreMods(final ModFile modFile) {
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ModInfo implements IModInfo, IConfigurable {
|
||||
this.owner = owner;
|
||||
this.modId = config.<String>getConfigElement("modId")
|
||||
.orElseThrow(()->new InvalidModFileException("Missing required field modid in dependency", getOwningFile()));
|
||||
if (this.modId.equals("forge")) {
|
||||
if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && this.modId.equals("forge")) {
|
||||
var fileProps = owner.getOwningFile().getFileProperties();
|
||||
// Checking containsKey to avoid a possible exception if the property is not present (due to Collections.emptyMap())
|
||||
if (!fileProps.isEmpty() && fileProps.containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||
@@ -226,7 +226,7 @@ public class ModInfo implements IModInfo, IConfigurable {
|
||||
var mandatory = config.<Boolean>getConfigElement("mandatory");
|
||||
if (mandatory.isPresent()) {
|
||||
this.mandatory = mandatory.get();
|
||||
} else if (owner.getOwningFile().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||
} else if (ModFileInfo.DETECT_NON_FORGE_MODS_TOML && owner.getOwningFile().getFileProperties().containsKey(ModFileInfo.NOT_A_FORGE_MOD_PROP)) {
|
||||
this.mandatory = true;
|
||||
} else {
|
||||
throw new InvalidModFileException("Missing required field mandatory in dependency", getOwningFile());
|
||||
|
||||
@@ -48,7 +48,7 @@ class Scanner {
|
||||
try (InputStream in = Files.newInputStream(path)){
|
||||
ModClassVisitor mcv = new ModClassVisitor();
|
||||
ClassReader cr = new ClassReader(in);
|
||||
cr.accept(mcv, 0);
|
||||
cr.accept(mcv, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
mcv.buildData(result.getClasses(), result.getAnnotations());
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
// mark path bad
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+2
-1
@@ -1,6 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -83,7 +83,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -130,10 +131,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -198,11 +202,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Automatic eventbus subscriber - reads {@link EventBusSubscriber}
|
||||
* annotations and passes the class instances to the {@link nBus}
|
||||
* annotations and passes the class instances to the {@link Bus}
|
||||
* defined by the annotation. Defaults to {@code MinecraftForge#EVENT_BUS}
|
||||
*/
|
||||
public class AutomaticEventSubscriber {
|
||||
|
||||
+8
-1
@@ -8,7 +8,7 @@ package net.minecraftforge.fml.javafmlmod;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
|
||||
public class FMLJavaModLoadingContext
|
||||
public class FMLJavaModLoadingContext extends ModLoadingContext
|
||||
{
|
||||
private final FMLModContainer container;
|
||||
|
||||
@@ -24,11 +24,18 @@ public class FMLJavaModLoadingContext
|
||||
return container.getEventBus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FMLModContainer getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to get the right instance from the {@link ModLoadingContext} correctly.
|
||||
* @return The FMLJavaMod language specific extension from the ModLoadingContext
|
||||
*
|
||||
* @deprecated use {@link FMLJavaModLoadingContext} in your mod constructor
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public static FMLJavaModLoadingContext get() {
|
||||
return ModLoadingContext.get().extension();
|
||||
}
|
||||
|
||||
+10
-4
@@ -21,6 +21,7 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -32,6 +33,7 @@ public class FMLModContainer extends ModContainer {
|
||||
private final IEventBus eventBus;
|
||||
private Object modInstance;
|
||||
private final Class<?> modClass;
|
||||
private final FMLJavaModLoadingContext context = new FMLJavaModLoadingContext(this);
|
||||
|
||||
public FMLModContainer(IModInfo info, String className, ModFileScanData modFileScanResults, ModuleLayer gameLayer) {
|
||||
super(info);
|
||||
@@ -40,9 +42,7 @@ public class FMLModContainer extends ModContainer {
|
||||
activityMap.put(ModLoadingStage.CONSTRUCT, this::constructMod);
|
||||
this.eventBus = BusBuilder.builder().setExceptionHandler(this::onEventFailed).setTrackPhases(false).markerType(IModBusEvent.class).useModLauncher().build();
|
||||
this.configHandler = Optional.of(ce->this.eventBus.post(ce.self()));
|
||||
final FMLJavaModLoadingContext contextExtension = new FMLJavaModLoadingContext(this);
|
||||
this.contextExtension = () -> contextExtension;
|
||||
|
||||
this.contextExtension = () -> context;
|
||||
|
||||
try {
|
||||
var moduleName = info.getOwningFile().moduleName();
|
||||
@@ -63,7 +63,13 @@ public class FMLModContainer extends ModContainer {
|
||||
private void constructMod() {
|
||||
try {
|
||||
LOGGER.trace(LOADING, "Loading mod instance {} of type {}", getModId(), modClass.getName());
|
||||
this.modInstance = modClass.getDeclaredConstructor().newInstance();
|
||||
Constructor<?> constructor;
|
||||
try {
|
||||
constructor = modClass.getDeclaredConstructor(context.getClass());
|
||||
} catch (NoSuchMethodException | SecurityException exception) {
|
||||
constructor = modClass.getDeclaredConstructor();
|
||||
}
|
||||
this.modInstance = constructor.getParameterCount() == 0 ? constructor.newInstance() : constructor.newInstance(context);
|
||||
LOGGER.trace(LOADING, "Loaded mod instance {} of type {}", getModId(), modClass.getName());
|
||||
} catch (Throwable e) {
|
||||
// When a mod constructor throws an exception, it's wrapped in an InvocationTargetException which hides the
|
||||
|
||||
@@ -199,6 +199,10 @@ tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
// IntelliJ no longer downloads javadocs and sources by default.
|
||||
// This tells Gradle to force IDEA to do it.
|
||||
idea.module { downloadJavadoc = downloadSources = true }
|
||||
|
||||
eclipse {
|
||||
// Run everytime eclipse builds the code
|
||||
//autoBuildTasks genEclipseRuns
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -61,9 +60,9 @@ public class ExampleMod
|
||||
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
|
||||
}).build());
|
||||
|
||||
public ExampleMod()
|
||||
public ExampleMod(FMLJavaModLoadingContext context)
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
IEventBus modEventBus = context.getModEventBus();
|
||||
|
||||
// Register the commonSetup method for modloading
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
@@ -82,7 +81,7 @@ public class ExampleMod
|
||||
modEventBus.addListener(this::addCreative);
|
||||
|
||||
// Register our mod's ForgeConfigSpec so that Forge can create and load the config file for us
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||
context.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||
}
|
||||
|
||||
private void commonSetup(final FMLCommonSetupEvent event)
|
||||
|
||||
@@ -41,6 +41,13 @@ authors="${mod_authors}" #optional
|
||||
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||
#displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional)
|
||||
|
||||
|
||||
# Access Transformers
|
||||
# Optional, if not specified Forge will attempt to find the default META-INF/accesstransformer.cfg and silently continue if not found. May default to an empty list in a future MC.
|
||||
# If you specify AT path strings in this list, Forge will attempt to load each of them and throw errors for any that aren't found.
|
||||
# Specifying an empty list when your mod has no ATs is recommended to opt-out of the default for slightly better loading performance.
|
||||
#accessTransformers = []
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''${mod_description}'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
this.renderTooltipInternal(p_283128_, list, p_283678_, p_281696_, DefaultTooltipPositioner.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -582,7 +_,15 @@
|
||||
@@ -582,7 +_,22 @@
|
||||
}
|
||||
|
||||
public void renderComponentTooltip(Font p_282739_, List<Component> p_281832_, int p_282191_, int p_282446_) {
|
||||
@@ -85,6 +85,13 @@
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponents(stack, tooltips, mouseX, guiWidth(), guiHeight(), font);
|
||||
+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
+ }
|
||||
+
|
||||
+ public void renderComponentTooltipFromElements(Font font, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> elements, int mouseX, int mouseY, ItemStack stack) {
|
||||
+ this.tooltipStack = stack;
|
||||
+ List<ClientTooltipComponent> components = net.minecraftforge.client.ForgeHooksClient.gatherTooltipComponentsFromElements(stack, elements, mouseX, guiWidth(), guiHeight(), font);
|
||||
+ this.renderTooltipInternal(font, components, mouseX, mouseY, DefaultTooltipPositioner.INSTANCE);
|
||||
+ this.tooltipStack = ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,12 +88,14 @@
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -263,7 +_,7 @@
|
||||
@@ -263,7 +_,9 @@
|
||||
|
||||
private boolean sameDestroyTarget(BlockPos p_105282_) {
|
||||
ItemStack itemstack = this.minecraft.player.getMainHandItem();
|
||||
- return p_105282_.equals(this.destroyBlockPos) && ItemStack.isSameItemSameTags(itemstack, this.destroyingItem);
|
||||
+ return p_105282_.equals(this.destroyBlockPos) && ItemStack.isSameItemSameTags(itemstack, this.destroyingItem) && !destroyingItem.shouldCauseBlockBreakReset(itemstack);
|
||||
+ if (Boolean.FALSE)
|
||||
+ ItemStack.isSameItemSameTags(itemstack, this.destroyingItem);
|
||||
+ return p_105282_.equals(this.destroyBlockPos) && !destroyingItem.shouldCauseBlockBreakReset(itemstack);
|
||||
}
|
||||
|
||||
private void ensureHasSentCarriedItem() {
|
||||
|
||||
@@ -52,16 +52,23 @@
|
||||
public static RenderType getRenderType(ItemStack p_109280_, boolean p_109281_) {
|
||||
Item item = p_109280_.getItem();
|
||||
if (item instanceof BlockItem) {
|
||||
@@ -389,8 +_,73 @@
|
||||
@@ -389,11 +_,79 @@
|
||||
}
|
||||
|
||||
public static RenderType getRenderLayer(FluidState p_109288_) {
|
||||
- RenderType rendertype = TYPE_BY_FLUID.get(p_109288_.getType());
|
||||
+ RenderType rendertype = FLUID_RENDER_TYPES.get(net.minecraftforge.registries.ForgeRegistries.FLUIDS.getDelegateOrThrow(p_109288_.getType()));
|
||||
return rendertype != null ? rendertype : RenderType.solid();
|
||||
}
|
||||
|
||||
public static void setFancy(boolean p_109292_) {
|
||||
renderCutout = p_109292_;
|
||||
+ }
|
||||
+
|
||||
+ // FORGE START
|
||||
+ /** Forge: Check if we are running in {@linkplain net.minecraft.client.Minecraft#useFancyGraphics() fancy graphics} to account for fast graphics render types */
|
||||
+ public static boolean isFancy() {
|
||||
+ return renderCutout;
|
||||
+ }
|
||||
+
|
||||
+ private static final net.minecraftforge.client.ChunkRenderTypeSet CUTOUT_MIPPED = net.minecraftforge.client.ChunkRenderTypeSet.of(RenderType.cutoutMipped());
|
||||
+ private static final net.minecraftforge.client.ChunkRenderTypeSet SOLID = net.minecraftforge.client.ChunkRenderTypeSet.of(RenderType.solid());
|
||||
@@ -79,7 +86,7 @@
|
||||
+ });
|
||||
+
|
||||
+ /** @deprecated Use {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)}. */
|
||||
+ @Deprecated(since = "1.19")
|
||||
+ @Deprecated(since = "1.21.4", forRemoval = true)
|
||||
+ public static net.minecraftforge.client.ChunkRenderTypeSet getRenderLayers(BlockState state) {
|
||||
+ Block block = state.getBlock();
|
||||
+ if (block instanceof LeavesBlock) {
|
||||
@@ -90,20 +97,20 @@
|
||||
+ }
|
||||
+
|
||||
+ /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */
|
||||
+ @Deprecated(since = "1.19")
|
||||
+ @Deprecated(since = "1.21.4", forRemoval = true)
|
||||
+ public static void setRenderLayer(Block block, RenderType type) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(type.getChunkLayerId() >= 0, "The argument must be a valid chunk render type returned by RenderType#chunkBufferLayers().");
|
||||
+ setRenderLayer(block, net.minecraftforge.client.ChunkRenderTypeSet.of(type));
|
||||
+ }
|
||||
+
|
||||
+ /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */
|
||||
+ @Deprecated(since = "1.19")
|
||||
+ @Deprecated(since = "1.21.4", forRemoval = true)
|
||||
+ public static synchronized void setRenderLayer(Block block, java.util.function.Predicate<RenderType> predicate) {
|
||||
+ setRenderLayer(block, createSetFromPredicate(predicate));
|
||||
+ }
|
||||
+
|
||||
+ /** @deprecated Set your render type in your block model's JSON (eg. {@code "render_type": "cutout"}) or override {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)} */
|
||||
+ @Deprecated(since = "1.19")
|
||||
+ @Deprecated(since = "1.21.4", forRemoval = true)
|
||||
+ public static synchronized void setRenderLayer(Block block, net.minecraftforge.client.ChunkRenderTypeSet layers) {
|
||||
+ checkClientLoading();
|
||||
+ BLOCK_RENDER_TYPES.put(net.minecraftforge.registries.ForgeRegistries.BLOCKS.getDelegateOrThrow(block), layers);
|
||||
@@ -125,5 +132,4 @@
|
||||
+ private static net.minecraftforge.client.ChunkRenderTypeSet createSetFromPredicate(java.util.function.Predicate<RenderType> predicate) {
|
||||
+ return net.minecraftforge.client.ChunkRenderTypeSet.of(RenderType.chunkBufferLayers().stream().filter(predicate).toArray(RenderType[]::new));
|
||||
}
|
||||
|
||||
public static void setFancy(boolean p_109292_) {
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
- this.renderNameTag(p_114485_, p_114485_.getDisplayName(), p_114488_, p_114489_, p_114490_);
|
||||
+ var renderNameTagEvent = new net.minecraftforge.client.event.RenderNameTagEvent(p_114485_, p_114485_.getDisplayName(), this, p_114488_, p_114489_, p_114490_, p_114487_);
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(renderNameTagEvent);
|
||||
+ if (renderNameTagEvent.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY && (renderNameTagEvent.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || this.shouldShowName(p_114485_))) {
|
||||
+ if (!renderNameTagEvent.getResult().isDenied() && (renderNameTagEvent.getResult().isAllowed() || this.shouldShowName(p_114485_))) {
|
||||
+ this.renderNameTag(p_114485_, renderNameTagEvent.getContent(), p_114488_, p_114489_, p_114490_);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,13 +1,15 @@
|
||||
--- a/net/minecraft/client/renderer/entity/FallingBlockRenderer.java
|
||||
+++ b/net/minecraft/client/renderer/entity/FallingBlockRenderer.java
|
||||
@@ -34,7 +_,9 @@
|
||||
@@ -34,7 +_,11 @@
|
||||
p_114637_.pushPose();
|
||||
BlockPos blockpos = BlockPos.containing(p_114634_.getX(), p_114634_.getBoundingBox().maxY, p_114634_.getZ());
|
||||
p_114637_.translate(-0.5D, 0.0D, -0.5D);
|
||||
- this.dispatcher.getModelRenderer().tesselateBlock(level, this.dispatcher.getBlockModel(blockstate), blockstate, blockpos, p_114637_, p_114638_.getBuffer(ItemBlockRenderTypes.getMovingBlockRenderType(blockstate)), false, RandomSource.create(), blockstate.getSeed(p_114634_.getStartPos()), OverlayTexture.NO_OVERLAY);
|
||||
+ var model = this.dispatcher.getBlockModel(blockstate);
|
||||
+ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_114634_.getStartPos())), net.minecraftforge.client.model.data.ModelData.EMPTY))
|
||||
+ for (var renderType : model.getRenderTypes(blockstate, RandomSource.create(blockstate.getSeed(p_114634_.getStartPos())), net.minecraftforge.client.model.data.ModelData.EMPTY)) {
|
||||
+ renderType = net.minecraftforge.client.RenderTypeHelper.getMovingBlockRenderType(renderType);
|
||||
+ this.dispatcher.getModelRenderer().tesselateBlock(level, model, blockstate, blockpos, p_114637_, p_114638_.getBuffer(renderType), false, RandomSource.create(), blockstate.getSeed(p_114634_.getStartPos()), OverlayTexture.NO_OVERLAY, net.minecraftforge.client.model.data.ModelData.EMPTY, renderType);
|
||||
+ }
|
||||
p_114637_.popPose();
|
||||
super.render(p_114634_, p_114635_, p_114636_, p_114637_, p_114638_, p_114639_);
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
int k1 = Mth.log2(j1);
|
||||
int l1;
|
||||
- if (k1 < p_261919_) {
|
||||
+ if (false) { // Forge: Do not lower the mipmap level
|
||||
+ if (k1 < p_261919_ && net.minecraftforge.common.ForgeConfig.CLIENT.allowMipmapLowering()) { // Forge: Do not lower the mipmap level
|
||||
LOGGER.warn("{}: dropping miplevel from {} to {}, because of minimum power of two: {}", this.location, p_261919_, k1, j1);
|
||||
l1 = k1;
|
||||
} else {
|
||||
|
||||
+88
-12
@@ -1,39 +1,81 @@
|
||||
--- a/net/minecraft/client/resources/model/SimpleBakedModel.java
|
||||
+++ b/net/minecraft/client/resources/model/SimpleBakedModel.java
|
||||
@@ -26,8 +_,17 @@
|
||||
@@ -26,8 +_,44 @@
|
||||
protected final TextureAtlasSprite particleIcon;
|
||||
protected final ItemTransforms transforms;
|
||||
protected final ItemOverrides overrides;
|
||||
+ /** Forge: Block render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} */
|
||||
+ protected final net.minecraftforge.client.ChunkRenderTypeSet blockRenderTypes;
|
||||
+ /** Forge: Block render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} */
|
||||
+ protected final net.minecraftforge.client.ChunkRenderTypeSet blockRenderTypesFast;
|
||||
+ /** Forge: Item render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} */
|
||||
+ protected final List<net.minecraft.client.renderer.RenderType> itemRenderTypes;
|
||||
+ /** Forge: Item render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} */
|
||||
+ protected final List<net.minecraft.client.renderer.RenderType> itemRenderTypesFast;
|
||||
+ /** Forge: Item render types to be used with {@linkplain net.minecraft.client.GraphicsStatus#FABULOUS fabulous graphics} */
|
||||
+ protected final List<net.minecraft.client.renderer.RenderType> fabulousItemRenderTypes;
|
||||
+ /** Forge: If this model's {@linkplain #blockRenderTypes block render types} are rendering cutout, to account for older leaves model JSONs */
|
||||
+ protected final boolean isRenderingCutout;
|
||||
|
||||
+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, ItemOverrides, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/
|
||||
+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, ItemOverrides, net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/
|
||||
+ @Deprecated
|
||||
public SimpleBakedModel(List<BakedQuad> p_119489_, Map<Direction, List<BakedQuad>> p_119490_, boolean p_119491_, boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, ItemTransforms p_119495_, ItemOverrides p_119496_) {
|
||||
+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, p_119496_, net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, ItemOverrides, net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup for fast graphics} **/
|
||||
+ @Deprecated(forRemoval = true, since = "1.21.4")
|
||||
+ public SimpleBakedModel(List<BakedQuad> p_119489_, Map<Direction, List<BakedQuad>> p_119490_, boolean p_119491_, boolean p_119492_, boolean p_119493_, TextureAtlasSprite p_119494_, ItemTransforms p_119495_, ItemOverrides p_119496_, net.minecraftforge.client.RenderTypeGroup renderTypes) {
|
||||
+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, p_119496_, renderTypes, net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ /** Constructor with {@link net.minecraftforge.client.RenderTypeGroup RenderTypeGroup} for fancy and fast graphics. Preferred over {@link net.minecraft.client.renderer.ItemBlockRenderTypes#setRenderLayer(net.minecraft.world.level.block.Block, net.minecraft.client.renderer.RenderType) ItemBlockRenderTypes.setRenderLayer(Block, RenderType)}. */
|
||||
+ public SimpleBakedModel(
|
||||
+ List<BakedQuad> p_119489_,
|
||||
+ Map<Direction, List<BakedQuad>> p_119490_,
|
||||
+ boolean p_119491_,
|
||||
+ boolean p_119492_,
|
||||
+ boolean p_119493_,
|
||||
+ TextureAtlasSprite p_119494_,
|
||||
+ ItemTransforms p_119495_,
|
||||
+ ItemOverrides p_119496_,
|
||||
+ net.minecraftforge.client.RenderTypeGroup renderTypes,
|
||||
+ net.minecraftforge.client.RenderTypeGroup renderTypesFast
|
||||
+ ) {
|
||||
this.unculledFaces = p_119489_;
|
||||
this.culledFaces = p_119490_;
|
||||
this.hasAmbientOcclusion = p_119491_;
|
||||
@@ -36,6 +_,9 @@
|
||||
@@ -36,6 +_,15 @@
|
||||
this.particleIcon = p_119494_;
|
||||
this.transforms = p_119495_;
|
||||
this.overrides = p_119496_;
|
||||
+ this.blockRenderTypes = !renderTypes.isEmpty() ? net.minecraftforge.client.ChunkRenderTypeSet.of(renderTypes.block()) : null;
|
||||
+ this.itemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entity()) : null;
|
||||
+ this.fabulousItemRenderTypes = !renderTypes.isEmpty() ? List.of(renderTypes.entityFabulous()) : null;
|
||||
+
|
||||
+ boolean hasRenderTypes = renderTypes != null && !renderTypes.isEmpty();
|
||||
+ boolean hasRenderTypesFast = renderTypesFast != null && !renderTypesFast.isEmpty();
|
||||
+ this.blockRenderTypes = hasRenderTypes ? net.minecraftforge.client.ChunkRenderTypeSet.of(renderTypes.block()) : null;
|
||||
+ this.blockRenderTypesFast = hasRenderTypesFast ? net.minecraftforge.client.ChunkRenderTypeSet.of(renderTypesFast.block()) : null;
|
||||
+ this.itemRenderTypes = hasRenderTypes ? List.of(renderTypes.entity()) : null;
|
||||
+ this.itemRenderTypesFast = hasRenderTypesFast ? List.of(renderTypesFast.entity()) : null;
|
||||
+ this.fabulousItemRenderTypes = hasRenderTypes ? List.of(renderTypes.entityFabulous()) : null;
|
||||
+ this.isRenderingCutout = hasRenderTypes && (renderTypes.block() == net.minecraft.client.renderer.RenderType.cutout() || renderTypes.block() == net.minecraft.client.renderer.RenderType.cutoutMipped());
|
||||
}
|
||||
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState p_235054_, @Nullable Direction p_235055_, RandomSource p_235056_) {
|
||||
@@ -70,6 +_,25 @@
|
||||
@@ -70,6 +_,40 @@
|
||||
return this.overrides;
|
||||
}
|
||||
|
||||
+ private static final net.minecraftforge.client.ChunkRenderTypeSet SOLID_BLOCK = net.minecraftforge.client.ChunkRenderTypeSet.of(net.minecraft.client.renderer.RenderType.solid());
|
||||
+ private static final List<net.minecraft.client.renderer.RenderType> SOLID_BLOCK_ITEM = List.of(net.minecraft.client.renderer.RenderType.solid());
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraftforge.client.ChunkRenderTypeSet getRenderTypes(@org.jetbrains.annotations.NotNull BlockState state, @org.jetbrains.annotations.NotNull RandomSource rand, @org.jetbrains.annotations.NotNull net.minecraftforge.client.model.data.ModelData data) {
|
||||
+ if (!net.minecraft.client.renderer.ItemBlockRenderTypes.isFancy()) {
|
||||
+ if (blockRenderTypesFast != null)
|
||||
+ return blockRenderTypesFast;
|
||||
+ if (isRenderingCutout && state.getBlock() instanceof net.minecraft.world.level.block.LeavesBlock)
|
||||
+ return SOLID_BLOCK;
|
||||
+ }
|
||||
+ if (blockRenderTypes != null)
|
||||
+ return blockRenderTypes;
|
||||
+ return BakedModel.super.getRenderTypes(state, rand, data);
|
||||
@@ -42,11 +84,17 @@
|
||||
+ @Override
|
||||
+ public List<net.minecraft.client.renderer.RenderType> getRenderTypes(net.minecraft.world.item.ItemStack itemStack, boolean fabulous) {
|
||||
+ if (!fabulous) {
|
||||
+ if (!net.minecraft.client.renderer.ItemBlockRenderTypes.isFancy()) {
|
||||
+ if (itemRenderTypesFast != null)
|
||||
+ return itemRenderTypesFast;
|
||||
+ if (isRenderingCutout && itemStack.getItem() instanceof net.minecraft.world.item.BlockItem blockItem && blockItem.getBlock() instanceof net.minecraft.world.level.block.LeavesBlock)
|
||||
+ return SOLID_BLOCK_ITEM;
|
||||
+ }
|
||||
+ if (itemRenderTypes != null)
|
||||
+ return itemRenderTypes;
|
||||
+ return itemRenderTypes;
|
||||
+ } else {
|
||||
+ if (fabulousItemRenderTypes != null)
|
||||
+ return fabulousItemRenderTypes;
|
||||
+ return fabulousItemRenderTypes;
|
||||
+ }
|
||||
+ return BakedModel.super.getRenderTypes(itemStack, fabulous);
|
||||
+ }
|
||||
@@ -54,22 +102,50 @@
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Builder {
|
||||
private final List<BakedQuad> unculledFaces = Lists.newArrayList();
|
||||
@@ -116,11 +_,17 @@
|
||||
@@ -116,11 +_,45 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Use {@linkplain #build(net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/
|
||||
+ @Deprecated
|
||||
public BakedModel build() {
|
||||
+ return build(net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ return build(net.minecraftforge.client.RenderTypeGroup.EMPTY, net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Builds with the render type to be used for this model, which will be used for any graphics setting.
|
||||
+ * <p>
|
||||
+ * If you need to set a specific render type for
|
||||
+ * {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}, consider using
|
||||
+ * {@link #build(net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup)
|
||||
+ * renderTypes(RenderTypeGroup, RenderTypeGroup)} instead which allows choosing render types for both fancy and
|
||||
+ * fast graphics.
|
||||
+ *
|
||||
+ * @apiNote If this model is for {@linkplain net.minecraft.world.level.block.LeavesBlock leaves} and if the
|
||||
+ * given render type is either {@linkplain net.minecraft.client.renderer.RenderType#cutout() cutout} or
|
||||
+ * {@linkplain net.minecraft.client.renderer.RenderType#cutoutMipped() cutout mipped}, it will be overridden
|
||||
+ * with {@linkplain net.minecraft.client.renderer.RenderType#solid() solid} when fast graphics is enabled.
|
||||
+ * @see #build(net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup)
|
||||
+ * renderTypes(RenderTypeGroup, RenderTypeGroup)
|
||||
+ */
|
||||
+ public BakedModel build(net.minecraftforge.client.RenderTypeGroup renderTypes) {
|
||||
+ return this.build(renderTypes, net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Builds with the render types to be used for this model: one for
|
||||
+ * {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics} and one for
|
||||
+ * {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}.
|
||||
+ *
|
||||
+ * @see #build(net.minecraftforge.client.RenderTypeGroup)
|
||||
+ */
|
||||
+ public BakedModel build(net.minecraftforge.client.RenderTypeGroup renderTypes, net.minecraftforge.client.RenderTypeGroup renderTypesFast) {
|
||||
if (this.particleIcon == null) {
|
||||
throw new RuntimeException("Missing particle!");
|
||||
} else {
|
||||
- return new SimpleBakedModel(this.unculledFaces, this.culledFaces, this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.overrides);
|
||||
+ return new SimpleBakedModel(this.unculledFaces, this.culledFaces, this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.overrides, renderTypes);
|
||||
+ // Forge: Account for render types in model JSONs
|
||||
+ return new SimpleBakedModel(this.unculledFaces, this.culledFaces, this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.overrides, renderTypes, renderTypesFast);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,3 +9,28 @@
|
||||
private final GameTestInfo testInfo;
|
||||
private boolean finalCheckAdded;
|
||||
|
||||
@@ -882,5 +_,24 @@
|
||||
this.fail("Failed to set biome for test");
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Adds a cleanup handler that will be called when the test is done, pass or fail.
|
||||
+ */
|
||||
+ public void addCleanup(Consumer<Boolean> handler) {
|
||||
+ this.testInfo.addListener(new GameTestListener() {
|
||||
+ @Override
|
||||
+ public void testPassed(GameTestInfo info) {
|
||||
+ handler.accept(true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void testFailed(GameTestInfo info) {
|
||||
+ handler.accept(false);
|
||||
+ }
|
||||
+
|
||||
+ @Override public void testStructureLoaded(GameTestInfo info) { }
|
||||
+ });
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,29 @@
|
||||
--- a/net/minecraft/resources/ResourceLocation.java
|
||||
+++ b/net/minecraft/resources/ResourceLocation.java
|
||||
@@ -34,6 +_,8 @@
|
||||
this.path = p_249394_;
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Consider using {@link #fromNamespaceAndPath(String, String)} instead, as Mojang made this constructor private in 1.21 */
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.6")
|
||||
public ResourceLocation(String p_135811_, String p_135812_) {
|
||||
this(assertValidNamespace(p_135811_, p_135812_), assertValidPath(p_135811_, p_135812_), (ResourceLocation.Dummy)null);
|
||||
}
|
||||
@@ -42,10 +_,14 @@
|
||||
this(p_135814_[0], p_135814_[1]);
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Consider using {@link #parse(String)} instead, as Mojang made this constructor private in 1.21 */
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.6")
|
||||
public ResourceLocation(String p_135809_) {
|
||||
this(decompose(p_135809_, ':'));
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Consider using {@link #bySeparator(String, char)} instead, as Mojang removed this method in 1.21 */
|
||||
+ @Deprecated(forRemoval = true, since = "1.20.6")
|
||||
public static ResourceLocation of(String p_135823_, char p_135824_) {
|
||||
return new ResourceLocation(decompose(p_135823_, p_135824_));
|
||||
}
|
||||
@@ -143,6 +_,12 @@
|
||||
return i;
|
||||
}
|
||||
@@ -13,3 +37,55 @@
|
||||
public String toDebugFileName() {
|
||||
return this.toString().replace('/', '_').replace(':', '_');
|
||||
}
|
||||
@@ -243,6 +_,51 @@
|
||||
|
||||
public JsonElement serialize(ResourceLocation p_135855_, Type p_135856_, JsonSerializationContext p_135857_) {
|
||||
return new JsonPrimitive(p_135855_.toString());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /** Forge: This is a backported method from 1.21, and is the replacement for {@link #ResourceLocation(String, String)}. */
|
||||
+ public static ResourceLocation fromNamespaceAndPath(String namespace, String path) {
|
||||
+ return new ResourceLocation(namespace, path);
|
||||
+ }
|
||||
+
|
||||
+ /** Forge: This is a backported method from 1.21, and is the replacement for {@link #ResourceLocation(String)}. */
|
||||
+ public static ResourceLocation parse(String location) {
|
||||
+ return new ResourceLocation(location);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Forge: This is a backported method from 1.21, and acts as an alternative to using {@link #parse(String)}. If you
|
||||
+ * know for sure you are going to be using the {@linkplain #DEFAULT_NAMESPACE default namespace}
|
||||
+ * ({@code "minecraft"}), use this.
|
||||
+ */
|
||||
+ public static ResourceLocation withDefaultNamespace(String path) {
|
||||
+ return new ResourceLocation(DEFAULT_NAMESPACE, assertValidPath(DEFAULT_NAMESPACE, path), null);
|
||||
+ }
|
||||
+
|
||||
+ /** Forge: This is a backported method from 1.21, and is the replacement for {@link #of(String, char)}. */
|
||||
+ public static ResourceLocation bySeparator(String location, char separator) {
|
||||
+ return of(location, separator);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Forge: This is a backported method from 1.21, and is the same as {@link #bySeparator(String, char)} but returns
|
||||
+ * {@code null} if a resource location cannot be created.
|
||||
+ */
|
||||
+ public static @Nullable ResourceLocation tryBySeparator(String location, char separator) {
|
||||
+ int i = location.indexOf(separator);
|
||||
+ if (i >= 0) {
|
||||
+ String s = location.substring(i + 1);
|
||||
+ if (!isValidPath(s)) {
|
||||
+ return null;
|
||||
+ } else if (i != 0) {
|
||||
+ String s1 = location.substring(0, i);
|
||||
+ return isValidNamespace(s1) ? new ResourceLocation(s1, s, null) : null;
|
||||
+ } else {
|
||||
+ return new ResourceLocation(DEFAULT_NAMESPACE, s, null);
|
||||
+ }
|
||||
+ } else {
|
||||
+ return isValidPath(location) ? new ResourceLocation(DEFAULT_NAMESPACE, location, null) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,14 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -699,6 +_,7 @@
|
||||
return BuiltInRegistries.ENTITY_TYPE.getKey(p_8648_.getType()).toString();
|
||||
});
|
||||
profilerfiller.incrementCounter("tickNonPassenger");
|
||||
+ if (p_8648_.canUpdate())
|
||||
p_8648_.tick();
|
||||
this.getProfiler().pop();
|
||||
|
||||
@@ -718,6 +_,7 @@
|
||||
return BuiltInRegistries.ENTITY_TYPE.getKey(p_8664_.getType()).toString();
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
float f = 1.0F;
|
||||
BlockState blockstate = this.level.getBlockState(p_215120_);
|
||||
if (!blockstate.isAir()) {
|
||||
+ if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY)
|
||||
+ if (!event.getUseBlock().isDenied())
|
||||
blockstate.attack(this.level, p_215120_, this.player);
|
||||
f = blockstate.getDestroyProgress(this.player, this.player.level(), p_215120_);
|
||||
}
|
||||
@@ -103,12 +103,12 @@
|
||||
MenuProvider menuprovider = blockstate.getMenuProvider(p_9267_, blockpos);
|
||||
if (menuprovider != null) {
|
||||
p_9266_.openMenu(menuprovider);
|
||||
@@ -308,10 +_,15 @@
|
||||
@@ -308,10 +_,16 @@
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
} else {
|
||||
+ UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_);
|
||||
+ if (event.getUseItem() != net.minecraftforge.eventbus.api.Event.Result.DENY) {
|
||||
+ if (!event.getUseItem().isDenied()) {
|
||||
+ InteractionResult result = p_9268_.onItemUseFirst(useoncontext);
|
||||
+ if (result != InteractionResult.PASS) return result;
|
||||
+ }
|
||||
@@ -117,7 +117,8 @@
|
||||
+ boolean flag1 = (p_9266_.isSecondaryUseActive() && flag) && !(p_9266_.getMainHandItem().doesSneakBypassUse(p_9267_, blockpos, p_9266_) && p_9266_.getOffhandItem().doesSneakBypassUse(p_9267_, blockpos, p_9266_));
|
||||
ItemStack itemstack = p_9268_.copy();
|
||||
- if (!flag1) {
|
||||
+ if (event.getUseBlock() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && !flag1)) {
|
||||
+ var useBlockResult = event.getUseBlock();
|
||||
+ if (useBlockResult.isAllowed() || (!flag1 && !useBlockResult.isDenied())) {
|
||||
InteractionResult interactionresult = blockstate.use(p_9267_, p_9266_, p_9269_, p_9270_);
|
||||
if (interactionresult.consumesAction()) {
|
||||
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger(p_9266_, blockpos, itemstack);
|
||||
@@ -127,8 +128,8 @@
|
||||
|
||||
- if (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem())) {
|
||||
- UseOnContext useoncontext = new UseOnContext(p_9266_, p_9269_, p_9270_);
|
||||
+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem()))) {
|
||||
+ if (event.getUseItem() == net.minecraftforge.eventbus.api.Event.Result.DENY) return InteractionResult.PASS;
|
||||
+ if (event.getUseItem().isAllowed() || (!p_9268_.isEmpty() && !p_9266_.getCooldowns().isOnCooldown(p_9268_.getItem()))) {
|
||||
+ if (event.getUseItem().isDenied()) return InteractionResult.PASS;
|
||||
InteractionResult interactionresult1;
|
||||
if (this.isCreative()) {
|
||||
int i = p_9268_.getCount();
|
||||
-12
@@ -13,18 +13,6 @@
|
||||
public static final double MAX_INTERACTION_DISTANCE = Mth.square(6.0D);
|
||||
private static final int NO_BLOCK_UPDATES_TO_ACK = -1;
|
||||
private static final int TRACKED_MESSAGE_DISCONNECT_THRESHOLD = 4096;
|
||||
@@ -414,9 +_,11 @@
|
||||
}
|
||||
|
||||
entity.absMoveTo(d3, d4, d5, f, f1);
|
||||
+ this.player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // Forge - Resync player position on vehicle moving
|
||||
boolean flag3 = serverlevel.noCollision(entity, entity.getBoundingBox().deflate(0.0625D));
|
||||
if (flag && (flag2 || !flag3)) {
|
||||
entity.absMoveTo(d0, d1, d2, f, f1);
|
||||
+ this.player.absMoveTo(d3, d4, d5, this.player.getYRot(), this.player.getXRot()); // Forge - Resync player position on vehicle moving
|
||||
this.send(new ClientboundMoveVehiclePacket(entity));
|
||||
return;
|
||||
}
|
||||
@@ -981,8 +_,10 @@
|
||||
case SWAP_ITEM_WITH_OFFHAND:
|
||||
if (!this.player.isSpectator()) {
|
||||
|
||||
@@ -131,13 +131,12 @@
|
||||
if (mobeffectinstance == null) {
|
||||
this.activeEffects.put(p_147208_.getEffect(), p_147208_);
|
||||
this.onEffectAdded(p_147208_, p_147209_);
|
||||
@@ -928,6 +_,9 @@
|
||||
@@ -928,6 +_,8 @@
|
||||
}
|
||||
|
||||
public boolean canBeAffected(MobEffectInstance p_21197_) {
|
||||
+ var event = new net.minecraftforge.event.entity.living.MobEffectEvent.Applicable(this, p_21197_);
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
|
||||
+ if (event.getResult() != net.minecraftforge.eventbus.api.Event.Result.DEFAULT) return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW;
|
||||
+ var eventResult = net.minecraftforge.event.ForgeEventFactory.onLivingEffectCanApply(this, p_21197_).getResult();
|
||||
+ if (!eventResult.isDefault()) return eventResult.isAllowed();
|
||||
if (this.getMobType() == MobType.UNDEAD) {
|
||||
MobEffect mobeffect = p_21197_.getEffect();
|
||||
if (mobeffect == MobEffects.REGENERATION || mobeffect == MobEffects.POISON) {
|
||||
@@ -575,7 +574,7 @@
|
||||
ItemStack itemstack = this.getItemInHand(p_21159_);
|
||||
if (!itemstack.isEmpty() && !this.isUsingItem()) {
|
||||
+ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.getUseDuration());
|
||||
+ if (duration <= 0) return;
|
||||
+ if (duration < net.minecraftforge.common.ForgeConfig.SERVER.getUseItemDuration()) return;
|
||||
this.useItem = itemstack;
|
||||
- this.useItemRemaining = itemstack.getUseDuration();
|
||||
+ this.useItemRemaining = duration;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
--- a/net/minecraft/world/entity/monster/Spider.java
|
||||
+++ b/net/minecraft/world/entity/monster/Spider.java
|
||||
@@ -121,7 +_,12 @@
|
||||
@@ -121,7 +_,10 @@
|
||||
}
|
||||
|
||||
public boolean canBeAffected(MobEffectInstance p_33809_) {
|
||||
- return p_33809_.getEffect() == MobEffects.POISON ? false : super.canBeAffected(p_33809_);
|
||||
+ if (p_33809_.getEffect() == MobEffects.POISON) {
|
||||
+ net.minecraftforge.event.entity.living.MobEffectEvent.Applicable event = new net.minecraftforge.event.entity.living.MobEffectEvent.Applicable(this, p_33809_);
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
|
||||
+ return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW;
|
||||
+ return net.minecraftforge.event.ForgeEventFactory.onLivingEffectCanApply(this, p_33809_).getResult().isAllowed();
|
||||
+ }
|
||||
+ return super.canBeAffected(p_33809_);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -275,11 +_,15 @@
|
||||
@@ -275,11 +_,16 @@
|
||||
livingentity = (LivingEntity)p_34288_.getEntity();
|
||||
}
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
int j = Mth.floor(this.getY());
|
||||
int k = Mth.floor(this.getZ());
|
||||
- Zombie zombie = new Zombie(this.level());
|
||||
+ net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, level(), i, j, k, livingentity, this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).getValue());
|
||||
+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return true;
|
||||
+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW ||
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, level(), i, j, k, livingentity, this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).getValue());
|
||||
+ var eventResult = event.getResult();
|
||||
+ if (eventResult.isDenied()) return true;
|
||||
+ if (eventResult.isAllowed() ||
|
||||
+ livingentity != null && this.level().getDifficulty() == Difficulty.HARD && (double)this.random.nextFloat() < this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE).getValue() && this.level()
|
||||
+ .getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
|
||||
+ Zombie zombie = event.getCustomSummonedAid() != null && event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW ? event.getCustomSummonedAid() : EntityType.ZOMBIE.create(this.level());
|
||||
+ Zombie zombie = event.getCustomSummonedAid() != null && eventResult.isAllowed() ? event.getCustomSummonedAid() : EntityType.ZOMBIE.create(this.level());
|
||||
|
||||
for(int l = 0; l < 50; ++l) {
|
||||
int i1 = i + Mth.nextInt(this.random, 7, 40) * Mth.nextInt(this.random, -1, 1);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
+++ b/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
@@ -191,6 +_,7 @@
|
||||
private final int villagerXp;
|
||||
|
||||
public EmeraldsForVillagerTypeItem(int p_35669_, int p_35670_, int p_35671_, Map<VillagerType, Item> p_35672_) {
|
||||
+ if (false) // FORGE: Modders can add custom villager types, so remove this validation
|
||||
BuiltInRegistries.VILLAGER_TYPE.stream().filter((p_35680_) -> {
|
||||
return !p_35672_.containsKey(p_35680_);
|
||||
}).findAny().ifPresent((p_258962_) -> {
|
||||
@@ -205,7 +_,9 @@
|
||||
@Nullable
|
||||
public MerchantOffer getOffer(Entity p_219685_, RandomSource p_219686_) {
|
||||
if (p_219685_ instanceof VillagerDataHolder villagerdataholder) {
|
||||
- ItemStack itemstack = new ItemStack(this.trades.get(villagerdataholder.getVillagerData().getType()), this.cost);
|
||||
+ Item item = this.trades.get(villagerdataholder.getVillagerData().getType());
|
||||
+ if (item == null) return null; // FORGE: Account for modded villager types by returning null if there is no trade
|
||||
+ ItemStack itemstack = new ItemStack(item, this.cost);
|
||||
return new MerchantOffer(itemstack, new ItemStack(Items.EMERALD), this.maxUses, this.villagerXp, 0.05F);
|
||||
} else {
|
||||
return null;
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/world/entity/npc/VillagerType.java
|
||||
+++ b/net/minecraft/world/entity/npc/VillagerType.java
|
||||
@@ -67,4 +_,9 @@
|
||||
public static VillagerType byBiome(Holder<Biome> p_204074_) {
|
||||
return p_204074_.unwrapKey().map(BY_BIOME::get).orElse(PLAINS);
|
||||
}
|
||||
+
|
||||
+ /** FORGE: Registers the VillagerType that will spawn in the given biome. This method should be called during FMLCommonSetupEvent using event.enqueueWork() */
|
||||
+ public static void registerBiomeType(ResourceKey<Biome> biomeKey, VillagerType villagerType) {
|
||||
+ BY_BIOME.put(biomeKey, villagerType);
|
||||
+ }
|
||||
}
|
||||
@@ -135,15 +135,23 @@
|
||||
if (!this.level().isClientSide) {
|
||||
this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem()));
|
||||
}
|
||||
@@ -864,6 +_,8 @@
|
||||
@@ -862,10 +_,15 @@
|
||||
if (p_36383_ >= 3.0F) {
|
||||
int i = 1 + Mth.floor(p_36383_);
|
||||
InteractionHand interactionhand = this.getUsedItemHand();
|
||||
+ // FORGE: cache this.useItem -- if this.stopUsingItem() is called, it will be set to ItemStack.EMPTY
|
||||
+ ItemStack currentItem = this.useItem;
|
||||
this.useItem.hurtAndBreak(i, this, (p_219739_) -> {
|
||||
p_219739_.broadcastBreakEvent(interactionhand);
|
||||
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.useItem, interactionhand);
|
||||
+ stopUsingItem(); // Forge: fix MC-168573
|
||||
+ if (this.useItem == currentItem) stopUsingItem(); // Forge: fix MC-168573
|
||||
});
|
||||
if (this.useItem.isEmpty()) {
|
||||
- if (this.useItem.isEmpty()) {
|
||||
+ // FORGE: use cached item since this.useItem could be ItemStack.EMPTY
|
||||
+ if (currentItem.isEmpty()) {
|
||||
if (interactionhand == InteractionHand.MAIN_HAND) {
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
|
||||
} else {
|
||||
@@ -882,10 +_,13 @@
|
||||
|
||||
protected void actuallyHurt(DamageSource p_36312_, float p_36313_) {
|
||||
|
||||
@@ -63,20 +63,3 @@
|
||||
}
|
||||
|
||||
protected int getMaxPassengers() {
|
||||
@@ -817,6 +_,16 @@
|
||||
|
||||
public boolean isUnderWater() {
|
||||
return this.status == Boat.Status.UNDER_WATER || this.status == Boat.Status.UNDER_FLOWING_WATER;
|
||||
+ }
|
||||
+
|
||||
+ // Forge: Fix MC-119811 by instantly completing lerp on board
|
||||
+ @Override
|
||||
+ protected void addPassenger(Entity passenger) {
|
||||
+ super.addPassenger(passenger);
|
||||
+ if (this.isControlledByLocalInstance() && this.lerpSteps > 0) {
|
||||
+ this.lerpSteps = 0;
|
||||
+ this.absMoveTo(this.lerpX, this.lerpY, this.lerpZ, (float)this.lerpYRot, (float)this.lerpXRot);
|
||||
+ }
|
||||
}
|
||||
|
||||
public ItemStack getPickResult() {
|
||||
@@ -10,7 +10,7 @@
|
||||
if (optional.isEmpty()) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
@@ -79,9 +_,20 @@
|
||||
@@ -79,9 +_,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,5 +29,10 @@
|
||||
+ @Override
|
||||
+ public boolean canPerformAction(ItemStack stack, net.minecraftforge.common.ToolAction toolAction) {
|
||||
+ return net.minecraftforge.common.ToolActions.DEFAULT_AXE_ACTIONS.contains(toolAction);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canDisableShield(ItemStack stack, ItemStack shield, net.minecraft.world.entity.LivingEntity entity, net.minecraft.world.entity.LivingEntity attacker) {
|
||||
+ return true;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
public LevelSettings withDataConfiguration(WorldDataConfiguration p_250867_) {
|
||||
- return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_250867_);
|
||||
+ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, dataConfiguration, this.lifecycle);
|
||||
+ return new LevelSettings(this.levelName, this.gameType, this.hardcore, this.difficulty, this.allowCommands, this.gameRules, p_250867_, this.lifecycle);
|
||||
}
|
||||
|
||||
public LevelSettings copy() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/ChorusFlowerBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java
|
||||
@@ -61,7 +_,7 @@
|
||||
@@ -61,11 +_,11 @@
|
||||
BlockPos blockpos = p_220982_.above();
|
||||
if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() < p_220981_.getMaxBuildHeight()) {
|
||||
int i = p_220980_.getValue(AGE);
|
||||
@@ -9,6 +9,20 @@
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
BlockState blockstate = p_220981_.getBlockState(p_220982_.below());
|
||||
- if (blockstate.is(Blocks.END_STONE)) {
|
||||
+ if (blockstate.is(Blocks.END_STONE) || blockstate.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)) {
|
||||
flag = true;
|
||||
} else if (blockstate.is(this.plant)) {
|
||||
int j = 1;
|
||||
@@ -73,7 +_,7 @@
|
||||
for(int k = 0; k < 4; ++k) {
|
||||
BlockState blockstate1 = p_220981_.getBlockState(p_220982_.below(j + 1));
|
||||
if (!blockstate1.is(this.plant)) {
|
||||
- if (blockstate1.is(Blocks.END_STONE)) {
|
||||
+ if (blockstate1.is(Blocks.END_STONE) || blockstate1.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)) {
|
||||
flag1 = true;
|
||||
}
|
||||
break;
|
||||
@@ -117,7 +_,7 @@
|
||||
} else {
|
||||
this.placeDeadFlower(p_220981_, p_220982_);
|
||||
@@ -18,3 +32,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,7 +_,7 @@
|
||||
|
||||
public boolean canSurvive(BlockState p_51683_, LevelReader p_51684_, BlockPos p_51685_) {
|
||||
BlockState blockstate = p_51684_.getBlockState(p_51685_.below());
|
||||
- if (!blockstate.is(this.plant) && !blockstate.is(Blocks.END_STONE)) {
|
||||
+ if (!blockstate.is(this.plant) && !blockstate.is(Blocks.END_STONE) && !blockstate.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)) {
|
||||
if (!blockstate.isAir()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/world/level/block/ChorusPlantBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ChorusPlantBlock.java
|
||||
@@ -38,7 +_,7 @@
|
||||
BlockState blockstate4 = p_51711_.getBlockState(p_51712_.south());
|
||||
BlockState blockstate5 = p_51711_.getBlockState(p_51712_.west());
|
||||
Block block = p_312378_.getBlock();
|
||||
- return p_312378_.trySetValue(DOWN, Boolean.valueOf(blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE))).trySetValue(UP, Boolean.valueOf(blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER))).trySetValue(NORTH, Boolean.valueOf(blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER))).trySetValue(EAST, Boolean.valueOf(blockstate3.is(block) || blockstate3.is(Blocks.CHORUS_FLOWER))).trySetValue(SOUTH, Boolean.valueOf(blockstate4.is(block) || blockstate4.is(Blocks.CHORUS_FLOWER))).trySetValue(WEST, Boolean.valueOf(blockstate5.is(block) || blockstate5.is(Blocks.CHORUS_FLOWER)));
|
||||
+ return p_312378_.trySetValue(DOWN, Boolean.valueOf(blockstate.is(block) || blockstate.is(Blocks.CHORUS_FLOWER) || blockstate.is(Blocks.END_STONE) || blockstate.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON))).trySetValue(UP, Boolean.valueOf(blockstate1.is(block) || blockstate1.is(Blocks.CHORUS_FLOWER))).trySetValue(NORTH, Boolean.valueOf(blockstate2.is(block) || blockstate2.is(Blocks.CHORUS_FLOWER))).trySetValue(EAST, Boolean.valueOf(blockstate3.is(block) || blockstate3.is(Blocks.CHORUS_FLOWER))).trySetValue(SOUTH, Boolean.valueOf(blockstate4.is(block) || blockstate4.is(Blocks.CHORUS_FLOWER))).trySetValue(WEST, Boolean.valueOf(blockstate5.is(block) || blockstate5.is(Blocks.CHORUS_FLOWER)));
|
||||
}
|
||||
|
||||
public BlockState updateShape(BlockState p_51728_, Direction p_51729_, BlockState p_51730_, LevelAccessor p_51731_, BlockPos p_51732_, BlockPos p_51733_) {
|
||||
@@ -46,7 +_,7 @@
|
||||
p_51731_.scheduleTick(p_51732_, this, 1);
|
||||
return super.updateShape(p_51728_, p_51729_, p_51730_, p_51731_, p_51732_, p_51733_);
|
||||
} else {
|
||||
- boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && p_51730_.is(Blocks.END_STONE);
|
||||
+ boolean flag = p_51730_.is(this) || p_51730_.is(Blocks.CHORUS_FLOWER) || p_51729_ == Direction.DOWN && (p_51730_.is(Blocks.END_STONE) || p_51730_.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON));
|
||||
return p_51728_.setValue(PROPERTY_BY_DIRECTION.get(p_51729_), Boolean.valueOf(flag));
|
||||
}
|
||||
}
|
||||
@@ -71,13 +_,13 @@
|
||||
}
|
||||
|
||||
BlockState blockstate2 = p_51725_.getBlockState(blockpos.below());
|
||||
- if (blockstate2.is(this) || blockstate2.is(Blocks.END_STONE)) {
|
||||
+ if (blockstate2.is(this) || blockstate2.is(Blocks.END_STONE) || blockstate2.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- return blockstate.is(this) || blockstate.is(Blocks.END_STONE);
|
||||
+ return blockstate.is(this) || blockstate.is(Blocks.END_STONE) || blockstate.is(net.minecraftforge.common.Tags.Blocks.CHORUS_ADDITIONALLY_GROWS_ON);
|
||||
}
|
||||
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_51735_) {
|
||||
@@ -16,11 +16,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,14 +_,14 @@
|
||||
p_221161_.scheduleTick(p_221162_, this, getFireTickDelay(p_221161_.random));
|
||||
if (p_221161_.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
|
||||
if (!p_221160_.canSurvive(p_221161_, p_221162_)) {
|
||||
- p_221161_.removeBlock(p_221162_, false);
|
||||
@@ -139,7 +_,7 @@
|
||||
}
|
||||
|
||||
BlockState blockstate = p_221161_.getBlockState(p_221162_.below());
|
||||
@@ -29,10 +25,6 @@
|
||||
int i = p_221160_.getValue(AGE);
|
||||
if (!flag && p_221161_.isRaining() && this.isNearRain(p_221161_, p_221162_) && p_221163_.nextFloat() < 0.2F + (float)i * 0.03F) {
|
||||
p_221161_.removeBlock(p_221162_, false);
|
||||
+ p_221161_.removeBlock(p_221162_, false);
|
||||
} else {
|
||||
int j = Math.min(15, i + p_221163_.nextInt(3) / 2);
|
||||
if (i != j) {
|
||||
@@ -160,7 +_,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
this.getFeature(p_221243_).ifPresent((p_256352_) -> {
|
||||
- p_256352_.value().place(p_221243_, p_221243_.getChunkSource().getGenerator(), p_221244_, p_221245_);
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_221243_, p_221244_, p_221245_, p_256352_);
|
||||
+ if (event.getResult().equals(net.minecraftforge.eventbus.api.Event.Result.DENY)) return;
|
||||
+ if (event.getResult().isDenied()) return;
|
||||
+ event.getFeature().value().place(p_221243_, p_221243_.getChunkSource().getGenerator(), p_221244_, p_221245_);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ @Deprecated //Forge: Prefer using IForgeBlock#catchFire
|
||||
+ @Deprecated //Forge: Prefer using IForgeBlock#onCaughtFire
|
||||
public static void explode(Level p_57434_, BlockPos p_57435_) {
|
||||
explode(p_57434_, p_57435_, (LivingEntity)null);
|
||||
}
|
||||
|
||||
+ @Deprecated //Forge: Prefer using IForgeBlock#catchFire
|
||||
+ @Deprecated //Forge: Prefer using IForgeBlock#onCaughtFire
|
||||
private static void explode(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_) {
|
||||
if (!p_57437_.isClientSide) {
|
||||
PrimedTnt primedtnt = new PrimedTnt(p_57437_, (double)p_57438_.getX() + 0.5D, (double)p_57438_.getY(), (double)p_57438_.getZ() + 0.5D, p_57439_);
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
--- a/net/minecraft/world/level/block/entity/HangingSignBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/HangingSignBlockEntity.java
|
||||
@@ -13,6 +_,10 @@
|
||||
super(BlockEntityType.HANGING_SIGN, p_250603_, p_251674_);
|
||||
}
|
||||
|
||||
+ public HangingSignBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
+ super(type, pos, state);
|
||||
+ }
|
||||
+
|
||||
public int getTextLineHeight() {
|
||||
return 9;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
Holder<ConfiguredFeature<?, ?>> holder = p_309830_.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(resourcekey).orElse((Holder.Reference<ConfiguredFeature<?, ?>>)null);
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.blockGrowFeature(p_309830_, p_309951_, p_310327_, holder);
|
||||
+ holder = event.getFeature();
|
||||
+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) return false;
|
||||
+ if (event.getResult().isDenied()) return false;
|
||||
if (holder != null) {
|
||||
for(int i = 0; i >= -1; --i) {
|
||||
for(int j = 0; j >= -1; --j) {
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
+++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
||||
@@ -42,19 +_,22 @@
|
||||
@@ -42,19 +_,23 @@
|
||||
for(ServerPlayer serverplayer : p_64576_.players()) {
|
||||
if (!serverplayer.isSpectator()) {
|
||||
BlockPos blockpos = serverplayer.blockPosition();
|
||||
@@ -9,14 +9,15 @@
|
||||
+ DifficultyInstance difficultyinstance = p_64576_.getCurrentDifficultyAt(blockpos);
|
||||
+ var event = new net.minecraftforge.event.entity.player.PlayerSpawnPhantomsEvent(serverplayer, 1 + randomsource.nextInt(difficultyinstance.getDifficulty().getId() + 1));
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
|
||||
+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.DENY) continue;
|
||||
+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || !p_64576_.dimensionType().hasSkyLight() || blockpos.getY() >= p_64576_.getSeaLevel() && p_64576_.canSeeSky(blockpos)) {
|
||||
+ var eventResult = event.getResult();
|
||||
+ if (eventResult.isDenied()) continue;
|
||||
+ if (eventResult.isAllowed() || !p_64576_.dimensionType().hasSkyLight() || blockpos.getY() >= p_64576_.getSeaLevel() && p_64576_.canSeeSky(blockpos)) {
|
||||
if (difficultyinstance.isHarderThan(randomsource.nextFloat() * 3.0F)) {
|
||||
ServerStatsCounter serverstatscounter = serverplayer.getStats();
|
||||
int j = Mth.clamp(serverstatscounter.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE);
|
||||
int k = 24000;
|
||||
- if (randomsource.nextInt(j) >= 72000) {
|
||||
+ if (event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || randomsource.nextInt(j) >= 72000) {
|
||||
+ if (eventResult.isAllowed() || randomsource.nextInt(j) >= 72000) {
|
||||
BlockPos blockpos1 = blockpos.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21));
|
||||
BlockState blockstate = p_64576_.getBlockState(blockpos1);
|
||||
FluidState fluidstate = p_64576_.getFluidState(blockpos1);
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
--- a/net/minecraft/world/level/storage/LevelSummary.java
|
||||
+++ b/net/minecraft/world/level/storage/LevelSummary.java
|
||||
@@ -257,6 +_,10 @@
|
||||
}
|
||||
}
|
||||
@@ -13,7 +_,7 @@
|
||||
import net.minecraft.world.level.LevelSettings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
+ public boolean isLifecycleExperimental() {
|
||||
+ return this.settings.getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental());
|
||||
-public class LevelSummary implements Comparable<LevelSummary> {
|
||||
+public class LevelSummary implements Comparable<LevelSummary>, net.minecraftforge.common.extensions.IForgeLevelSummary {
|
||||
public static final Component PLAY_WORLD = Component.translatable("selectWorld.select");
|
||||
private final LevelSettings settings;
|
||||
private final LevelVersion levelVersion;
|
||||
@@ -255,6 +_,12 @@
|
||||
public boolean canRecreate() {
|
||||
return false;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ // TODO Forge: Remove in 1.22. It is kept here for binary compatibility, but already exists in IForgeLevelSummary
|
||||
+ @Deprecated(forRemoval = true, since = "1.21.4")
|
||||
+ public boolean isLifecycleExperimental() {
|
||||
+ return net.minecraftforge.common.extensions.IForgeLevelSummary.super.isLifecycleExperimental();
|
||||
}
|
||||
|
||||
public static class SymlinkLevelSummary extends LevelSummary {
|
||||
private static final Component MORE_INFO_BUTTON = Component.translatable("symlink_warning.more_info");
|
||||
private static final Component INFO = Component.translatable("symlink_warning.title").withColor(-65536);
|
||||
@@ -9,7 +9,7 @@ if %ERRORLEVEL% NEQ 0 (
|
||||
)
|
||||
|
||||
REM Add custom program arguments (such as nogui) to the next line before the %* or pass them to this script directly
|
||||
java @libraries/@MAVEN_PATH@/win_args.txt %*
|
||||
java @user_jvm_args.txt @libraries/@MAVEN_PATH@/win_args.txt %*
|
||||
|
||||
:exit
|
||||
pause
|
||||
+8
-10
@@ -1,5 +1,3 @@
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
@@ -27,33 +25,33 @@ dependencyResolutionManagement {
|
||||
libs {
|
||||
library('forgespi', 'net.minecraftforge:forgespi:7.1.3') // Needs modlauncher
|
||||
library('modlauncher', 'net.minecraftforge:modlauncher:10.1.2') // Needs securemodules
|
||||
library('securemodules', 'net.minecraftforge:securemodules:2.2.10') // Needs unsafe
|
||||
library('securemodules', 'net.minecraftforge:securemodules:2.2.21') // Needs unsafe
|
||||
library('unsafe', 'net.minecraftforge:unsafe:0.9.2')
|
||||
library('accesstransformers', 'net.minecraftforge:accesstransformers:8.1.1')
|
||||
library('antlr-runtime', 'org.antlr:antlr4-runtime:4.9.1') // Needed by Access Transformer because parsing a simple text file was too complicated
|
||||
library('coremods', 'net.minecraftforge:coremods:5.1.0')
|
||||
library('nashorn', 'org.openjdk.nashorn:nashorn-core:15.3') // Needed by coremods, because the JRE no longer ships JS
|
||||
library('eventbus', 'net.minecraftforge:eventbus:6.2.0')
|
||||
library('coremods', 'net.minecraftforge:coremods:5.2.6')
|
||||
library('nashorn', 'org.openjdk.nashorn:nashorn-core:15.4') // Needed by coremods, because the JRE no longer ships JS
|
||||
library('eventbus', 'net.minecraftforge:eventbus:6.2.33')
|
||||
library('typetools', 'net.jodah:typetools:0.6.3') // Needed by EventBus because of lambdas
|
||||
library('mergetool-api', 'net.minecraftforge:mergetool-api:1.0')
|
||||
|
||||
library('mixin', 'org.spongepowered:mixin:0.8.5')
|
||||
library('nulls', 'org.jetbrains:annotations:23.0.0') // Got to have our null annotations!
|
||||
library('slf4j-api', 'org.slf4j:slf4j-api:2.0.7')
|
||||
library('maven-artifact', 'org.apache.maven:maven-artifact:3.8.5')
|
||||
library('maven-artifact', 'org.apache.maven:maven-artifact:3.8.8')
|
||||
|
||||
// Google's InMemory File System. Used by ForgeDev Tests for now, but could be useful for a lot of things.
|
||||
library('jimfs', 'com.google.jimfs:jimfs:1.3.0')
|
||||
bundle('jimfs', ['guava', 'failureaccess'])
|
||||
|
||||
version('bootstrap', '2.1.0')
|
||||
version('bootstrap', '2.1.8')
|
||||
library('bootstrap', 'net.minecraftforge', 'bootstrap' ).versionRef('bootstrap') // Needs modlauncher
|
||||
library('bootstrap-api', 'net.minecraftforge', 'bootstrap-api' ).versionRef('bootstrap')
|
||||
library('bootstrap-dev', 'net.minecraftforge', 'bootstrap-dev' ).versionRef('bootstrap')
|
||||
library('bootstrap-shim', 'net.minecraftforge', 'bootstrap-shim').versionRef('bootstrap')
|
||||
|
||||
// ASM it's used for so many of our hacks
|
||||
version('asm', '9.6')
|
||||
version('asm', '9.9.1')
|
||||
library('asm', 'org.ow2.asm', 'asm' ).versionRef('asm')
|
||||
library('asm-tree', 'org.ow2.asm', 'asm-tree' ).versionRef('asm')
|
||||
library('asm-util', 'org.ow2.asm', 'asm-util' ).versionRef('asm')
|
||||
@@ -63,7 +61,7 @@ dependencyResolutionManagement {
|
||||
|
||||
// Terminal Console Appender.. essentually make pretty colors in the console, but it's been a PITA
|
||||
library('terminalconsoleappender', 'net.minecrell:terminalconsoleappender:1.2.0')
|
||||
version('jline', '3.12.1')
|
||||
version('jline', '3.25.1')
|
||||
library('jline-reader', 'org.jline', 'jline-reader' ).versionRef('jline')
|
||||
library('jline-terminal', 'org.jline', 'jline-terminal' ).versionRef('jline')
|
||||
library('jline-terminal-jna', 'org.jline', 'jline-terminal-jna').versionRef('jline') // Colors and tab completeion
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"#forge:end_stones"
|
||||
]
|
||||
}
|
||||
@@ -872,11 +872,15 @@ public class ForgeHooksClient {
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, Optional<TooltipComponent> itemComponent, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) {
|
||||
Font font = getTooltipFont(stack, fallbackFont);
|
||||
List<Either<FormattedText, TooltipComponent>> elements = textElements.stream()
|
||||
.map((Function<FormattedText, Either<FormattedText, TooltipComponent>>) Either::left)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
itemComponent.ifPresent(c -> elements.add(1, Either.right(c)));
|
||||
return gatherTooltipComponentsFromElements(stack, elements, mouseX, screenWidth, screenHeight, fallbackFont);
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponentsFromElements(ItemStack stack, List<Either<FormattedText, TooltipComponent>> elements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) {
|
||||
Font font = getTooltipFont(stack, fallbackFont);
|
||||
|
||||
var event = new RenderTooltipEvent.GatherComponents(stack, screenWidth, screenHeight, elements, -1);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
@@ -10,8 +10,6 @@ import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
@@ -38,7 +36,6 @@ import java.util.function.Consumer;
|
||||
* @see MouseInput
|
||||
* @see KeyInput
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class ScreenEvent extends Event {
|
||||
private final Screen screen;
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraftforge.client.ConfigScreenHandler;
|
||||
import net.minecraftforge.client.gui.widget.ModListWidget;
|
||||
import net.minecraftforge.client.gui.widget.ScrollPanel;
|
||||
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.maven.artifact.versioning.ComparableVersion;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
@@ -56,10 +55,11 @@ import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraft.locale.Language;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class ModListScreen extends Screen {
|
||||
private static String stripControlCodes(String value) { return net.minecraft.util.StringUtil.stripColor(value); }
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
private enum SortType implements Comparator<IModInfo> {
|
||||
NORMAL,
|
||||
A_TO_Z{ @Override protected int compare(String name1, String name2){ return name1.compareTo(name2); }},
|
||||
@@ -229,7 +229,7 @@ public class ModListScreen extends Screen {
|
||||
listWidth = Math.max(listWidth,getFontRenderer().width(mod.getDisplayName()) + 10);
|
||||
listWidth = Math.max(listWidth,getFontRenderer().width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
|
||||
}
|
||||
listWidth = Math.max(Math.min(listWidth, width/3), 100);
|
||||
listWidth = Math.max(Math.min(listWidth, width / 3), 100);
|
||||
listWidth += listWidth % NUM_BUTTONS != 0 ? (NUM_BUTTONS - listWidth % NUM_BUTTONS) : 0;
|
||||
|
||||
int modInfoWidth = this.width - this.listWidth - (PADDING * 3);
|
||||
@@ -237,14 +237,23 @@ public class ModListScreen extends Screen {
|
||||
int y = this.height - 20 - PADDING;
|
||||
int fullButtonHeight = PADDING + 20 + PADDING;
|
||||
|
||||
doneButton = Button.builder(Component.translatable("gui.done"), b -> ModListScreen.this.onClose()).bounds(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20).build();
|
||||
openModsFolderButton = Button.builder(Component.translatable("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())).bounds(6, y, this.listWidth, 20).build();
|
||||
doneButton = Button.builder(Component.translatable("gui.done"), b -> ModListScreen.this.onClose())
|
||||
.bounds(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20)
|
||||
.build();
|
||||
|
||||
openModsFolderButton = Button.builder(Component.translatable("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()))
|
||||
.bounds(6, y, this.listWidth, 20)
|
||||
.build();
|
||||
|
||||
y -= 20 + PADDING;
|
||||
configButton = Button.builder(Component.translatable("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()).bounds(6, y, this.listWidth, 20).build();
|
||||
configButton = Button.builder(Component.translatable("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig())
|
||||
.bounds(6, y, this.listWidth, 20)
|
||||
.build();
|
||||
|
||||
y -= 14 + PADDING;
|
||||
search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, Component.translatable("fml.menu.mods.search"));
|
||||
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.getY() - getFontRenderer().lineHeight*4 - PADDING);
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.getY() - getFontRenderer().lineHeight * 4 - PADDING);
|
||||
this.modList.setX(6);
|
||||
this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
|
||||
|
||||
@@ -261,11 +270,20 @@ public class ModListScreen extends Screen {
|
||||
|
||||
final int width = listWidth / NUM_BUTTONS;
|
||||
int x = PADDING;
|
||||
addRenderableWidget(SortType.NORMAL.button = Button.builder(SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL)).bounds(x, PADDING, width - BUTTON_MARGIN, 20).build());
|
||||
addRenderableWidget(SortType.NORMAL.button = Button.builder(SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL))
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, 20)
|
||||
.build());
|
||||
|
||||
x += width + BUTTON_MARGIN;
|
||||
addRenderableWidget(SortType.A_TO_Z.button = Button.builder(SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z)).bounds(x, PADDING, width - BUTTON_MARGIN, 20).build());
|
||||
addRenderableWidget(SortType.A_TO_Z.button = Button.builder(SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z))
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, 20)
|
||||
.build());
|
||||
|
||||
x += width + BUTTON_MARGIN;
|
||||
addRenderableWidget(SortType.Z_TO_A.button = Button.builder(SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A)).bounds(x, PADDING, width - BUTTON_MARGIN, 20).build());
|
||||
addRenderableWidget(SortType.Z_TO_A.button = Button.builder(SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A))
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, 20)
|
||||
.build());
|
||||
|
||||
resortMods(SortType.NORMAL);
|
||||
updateCache();
|
||||
}
|
||||
@@ -275,7 +293,9 @@ public class ModListScreen extends Screen {
|
||||
return;
|
||||
|
||||
try {
|
||||
ConfigScreenHandler.getScreenFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.setScreen(newScreen));
|
||||
ConfigScreenHandler.getScreenFactoryFor(selected.getInfo())
|
||||
.map(f -> f.apply(this.minecraft, this))
|
||||
.ifPresent(newScreen -> this.minecraft.setScreen(newScreen));
|
||||
} catch (final Exception e) {
|
||||
LOGGER.error("There was a critical issue trying to build the config GUI for {}", selected.getInfo().getModId(), e);
|
||||
}
|
||||
@@ -295,7 +315,10 @@ public class ModListScreen extends Screen {
|
||||
mods.sort(sortType);
|
||||
modList.refreshList();
|
||||
if (selected != null) {
|
||||
selected = modList.children().stream().filter(e -> e.getInfo() == selected.getInfo()).findFirst().orElse(null);
|
||||
selected = modList.children().stream()
|
||||
.filter(e -> e.getInfo() == selected.getInfo())
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
updateCache();
|
||||
}
|
||||
sorted = true;
|
||||
@@ -303,7 +326,9 @@ public class ModListScreen extends Screen {
|
||||
}
|
||||
|
||||
public <T extends ObjectSelectionList.Entry<T>> void buildModList(Consumer<T> modListViewConsumer, Function<IModInfo, T> newEntry) {
|
||||
mods.forEach(mod->modListViewConsumer.accept(newEntry.apply(mod)));
|
||||
for (IModInfo mod : mods) {
|
||||
modListViewConsumer.accept(newEntry.apply(mod));
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadMods() {
|
||||
@@ -405,12 +430,12 @@ public class ModListScreen extends Screen {
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.authors", authors)));
|
||||
selectedMod.getConfig().getConfigElement("displayURL").ifPresent(displayURL ->
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.displayurl", displayURL)));
|
||||
if (selectedMod.getOwningFile() == null || selectedMod.getOwningFile().getMods().size()==1)
|
||||
if (selectedMod.getOwningFile() == null || selectedMod.getOwningFile().getMods().size() == 1)
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.nochildmods"));
|
||||
else
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.childmods", selectedMod.getOwningFile().getMods().stream().map(IModInfo::getDisplayName).collect(Collectors.joining(","))));
|
||||
|
||||
if (vercheck.status() == VersionChecker.Status.OUTDATED || vercheck.status() == VersionChecker.Status.BETA_OUTDATED)
|
||||
if (vercheck.status().isOutdated())
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.updateavailable", vercheck.url() == null ? "" : vercheck.url()));
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.license", ((ModFileInfo) selectedMod.getOwningFile()).getLicense()));
|
||||
lines.add(null);
|
||||
@@ -426,7 +451,7 @@ public class ModListScreen extends Screen {
|
||||
}
|
||||
*/
|
||||
|
||||
if ((vercheck.status() == VersionChecker.Status.OUTDATED || vercheck.status() == VersionChecker.Status.BETA_OUTDATED) && !vercheck.changes().isEmpty()) {
|
||||
if (vercheck.status().isOutdated() && !vercheck.changes().isEmpty()) {
|
||||
lines.add(null);
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.changelogheader"));
|
||||
for (Entry<ComparableVersion, String> entry : vercheck.changes().entrySet()) {
|
||||
|
||||
@@ -11,14 +11,11 @@ import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
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.client.loading.ClientModLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TitleScreenModUpdateIndicator extends Screen
|
||||
{
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry>
|
||||
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
|
||||
private final int listWidth;
|
||||
|
||||
private ModListScreen parent;
|
||||
private final ModListScreen parent;
|
||||
|
||||
public ModListWidget(ModListScreen parent, int listWidth, int top, int bottom)
|
||||
{
|
||||
|
||||
@@ -25,15 +25,12 @@ import org.apache.logging.log4j.Logger;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.ForgeConfig;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.client.gui.LoadingErrorScreen;
|
||||
import net.minecraftforge.resource.ResourcePackLoader;
|
||||
import net.minecraftforge.server.LanguageHook;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ClientModLoader {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static boolean loading;
|
||||
@@ -91,8 +88,8 @@ public class ClientModLoader {
|
||||
public static VersionChecker.Status checkForUpdates() {
|
||||
boolean anyOutdated = ModList.get().getMods().stream()
|
||||
.map(VersionChecker::getResult)
|
||||
.map(result -> result.status())
|
||||
.anyMatch(status -> status == VersionChecker.Status.OUTDATED || status == VersionChecker.Status.BETA_OUTDATED);
|
||||
.map(VersionChecker.CheckResult::status)
|
||||
.anyMatch(VersionChecker.Status::isOutdated);
|
||||
return anyOutdated ? VersionChecker.Status.OUTDATED : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,7 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
private final ItemTransforms transforms;
|
||||
private TextureAtlasSprite particle;
|
||||
private RenderTypeGroup lastRenderTypes = RenderTypeGroup.EMPTY;
|
||||
private RenderTypeGroup lastRenderTypesFast = RenderTypeGroup.EMPTY;
|
||||
|
||||
private Builder(boolean isAmbientOcclusion, boolean isGui3d, boolean isSideLit, TextureAtlasSprite particle, ItemOverrides overrides, ItemTransforms transforms)
|
||||
{
|
||||
@@ -256,27 +257,38 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
|
||||
public void addLayer(BakedModel model)
|
||||
{
|
||||
flushQuads(null);
|
||||
flushQuads(RenderTypeGroup.EMPTY, RenderTypeGroup.EMPTY);
|
||||
children.add(model);
|
||||
}
|
||||
|
||||
private void addLayer(RenderTypeGroup renderTypes, List<BakedQuad> quads)
|
||||
{
|
||||
var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, overrides, particle, renderTypes);
|
||||
this.addLayer(renderTypes, RenderTypeGroup.EMPTY, quads);
|
||||
}
|
||||
|
||||
private void addLayer(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast, List<BakedQuad> quads)
|
||||
{
|
||||
var modelBuilder = IModelBuilder.of(isAmbientOcclusion, isSideLit, isGui3d, transforms, overrides, particle, renderTypes, renderTypesFast);
|
||||
quads.forEach(modelBuilder::addUnculledFace);
|
||||
children.add(modelBuilder.build());
|
||||
}
|
||||
|
||||
private void flushQuads(RenderTypeGroup renderTypes)
|
||||
{
|
||||
this.flushQuads(renderTypes, RenderTypeGroup.EMPTY);
|
||||
}
|
||||
|
||||
private void flushQuads(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast)
|
||||
{
|
||||
if (!Objects.equals(renderTypes, lastRenderTypes))
|
||||
{
|
||||
if (quads.size() > 0)
|
||||
{
|
||||
addLayer(lastRenderTypes, quads);
|
||||
addLayer(lastRenderTypes, lastRenderTypesFast, quads);
|
||||
quads.clear();
|
||||
}
|
||||
lastRenderTypes = renderTypes;
|
||||
lastRenderTypesFast = renderTypesFast;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,14 +300,24 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
|
||||
public Builder addQuads(RenderTypeGroup renderTypes, BakedQuad... quadsToAdd)
|
||||
{
|
||||
flushQuads(renderTypes);
|
||||
return this.addQuads(renderTypes, RenderTypeGroup.EMPTY, quadsToAdd);
|
||||
}
|
||||
|
||||
public Builder addQuads(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast, BakedQuad... quadsToAdd)
|
||||
{
|
||||
flushQuads(renderTypes, renderTypesFast);
|
||||
Collections.addAll(quads, quadsToAdd);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addQuads(RenderTypeGroup renderTypes, Collection<BakedQuad> quadsToAdd)
|
||||
{
|
||||
flushQuads(renderTypes);
|
||||
return this.addQuads(renderTypes, RenderTypeGroup.EMPTY, quadsToAdd);
|
||||
}
|
||||
|
||||
public Builder addQuads(RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast, Collection<BakedQuad> quadsToAdd)
|
||||
{
|
||||
flushQuads(renderTypes, renderTypesFast);
|
||||
quads.addAll(quadsToAdd);
|
||||
return this;
|
||||
}
|
||||
@@ -304,7 +326,7 @@ public class CompositeModel implements IUnbakedGeometry<CompositeModel>
|
||||
{
|
||||
if (quads.size() > 0)
|
||||
{
|
||||
addLayer(lastRenderTypes, quads);
|
||||
addLayer(lastRenderTypes, lastRenderTypesFast, quads);
|
||||
}
|
||||
var childrenBuilder = ImmutableMap.<String, BakedModel>builder();
|
||||
var itemPassesBuilder = ImmutableList.<BakedModel>builder();
|
||||
|
||||
@@ -63,7 +63,7 @@ public class EmptyModel extends SimpleUnbakedGeometry<EmptyModel>
|
||||
|
||||
public Baked()
|
||||
{
|
||||
super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, ItemOverrides.EMPTY, RenderTypeGroup.EMPTY);
|
||||
super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, ItemOverrides.EMPTY, RenderTypeGroup.EMPTY, RenderTypeGroup.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,6 +73,12 @@ public class ExtendedBlockModelDeserializer extends BlockModel.Deserializer
|
||||
model.customData.setRenderTypeHint(new ResourceLocation(renderTypeHintName));
|
||||
}
|
||||
|
||||
if (jsonobject.has("render_type_fast"))
|
||||
{
|
||||
var renderTypeHintName = GsonHelper.getAsString(jsonobject, "render_type_fast");
|
||||
model.customData.setRenderTypeFastHint(ResourceLocation.parse(renderTypeHintName));
|
||||
}
|
||||
|
||||
if (jsonobject.has("visibility"))
|
||||
{
|
||||
JsonObject visibility = GsonHelper.getAsJsonObject(jsonobject, "visibility");
|
||||
|
||||
@@ -34,6 +34,19 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides, particle, renderTypes);
|
||||
}
|
||||
|
||||
static IModelBuilder<?> of(
|
||||
boolean hasAmbientOcclusion,
|
||||
boolean usesBlockLight,
|
||||
boolean isGui3d,
|
||||
ItemTransforms transforms,
|
||||
ItemOverrides overrides,
|
||||
TextureAtlasSprite particle,
|
||||
RenderTypeGroup renderTypes,
|
||||
RenderTypeGroup renderTypesFast
|
||||
){
|
||||
return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides, particle, renderTypes, renderTypesFast);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new model builder that collects quads to the provided list, returning
|
||||
* {@linkplain EmptyModel#BAKED an empty model} if you call {@link #build()}.
|
||||
@@ -53,13 +66,22 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
{
|
||||
private final SimpleBakedModel.Builder builder;
|
||||
private final RenderTypeGroup renderTypes;
|
||||
private final RenderTypeGroup renderTypesFast;
|
||||
|
||||
private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d,
|
||||
ItemTransforms transforms, ItemOverrides overrides, TextureAtlasSprite particle,
|
||||
RenderTypeGroup renderTypes)
|
||||
{
|
||||
this(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides, particle, renderTypes, RenderTypeGroup.EMPTY);
|
||||
}
|
||||
|
||||
private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d,
|
||||
ItemTransforms transforms, ItemOverrides overrides, TextureAtlasSprite particle,
|
||||
RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast)
|
||||
{
|
||||
this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, overrides).particle(particle);
|
||||
this.renderTypes = renderTypes;
|
||||
this.renderTypesFast = renderTypesFast;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +102,7 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
|
||||
@Override
|
||||
public BakedModel build()
|
||||
{
|
||||
return builder.build(renderTypes);
|
||||
return builder.build(renderTypes, renderTypesFast);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,19 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel>
|
||||
private ImmutableList<Material> textures;
|
||||
private final Int2ObjectMap<ForgeFaceData> layerData;
|
||||
private final Int2ObjectMap<ResourceLocation> renderTypeNames;
|
||||
private final Int2ObjectMap<ResourceLocation> renderTypeFastNames;
|
||||
|
||||
private ItemLayerModel(@Nullable ImmutableList<Material> textures, Int2ObjectMap<ForgeFaceData> layerData, Int2ObjectMap<ResourceLocation> renderTypeNames)
|
||||
{
|
||||
this(textures, layerData, renderTypeNames, new Int2ObjectOpenHashMap<>());
|
||||
}
|
||||
|
||||
private ItemLayerModel(@Nullable ImmutableList<Material> textures, Int2ObjectMap<ForgeFaceData> layerData, Int2ObjectMap<ResourceLocation> renderTypeNames, Int2ObjectMap<ResourceLocation> renderTypeFastNames)
|
||||
{
|
||||
this.textures = textures;
|
||||
this.layerData = layerData;
|
||||
this.renderTypeNames = renderTypeNames;
|
||||
this.renderTypeFastNames = renderTypeFastNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,7 +89,9 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel>
|
||||
var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, modelState, modelLocation);
|
||||
var renderTypeName = renderTypeNames.get(i);
|
||||
var renderTypes = renderTypeName != null ? context.getRenderType(renderTypeName) : null;
|
||||
builder.addQuads(renderTypes != null ? renderTypes : normalRenderTypes, quads);
|
||||
var renderTypeFastName = renderTypeFastNames.get(i);
|
||||
var renderTypesFast = renderTypeFastName != null ? context.getRenderType(renderTypeFastName) : null;
|
||||
builder.addQuads(renderTypes != null ? renderTypes : normalRenderTypes, renderTypesFast != null ? renderTypesFast : RenderTypeGroup.EMPTY, quads);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
@@ -108,6 +117,19 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel>
|
||||
}
|
||||
}
|
||||
|
||||
var renderTypeFastNames = new Int2ObjectOpenHashMap<ResourceLocation>();
|
||||
if (jsonObject.has("render_types_fast"))
|
||||
{
|
||||
var renderTypes = jsonObject.getAsJsonObject("render_types_fast");
|
||||
for (Map.Entry<String, JsonElement> entry : renderTypes.entrySet())
|
||||
{
|
||||
var renderType = new ResourceLocation(entry.getKey());
|
||||
for (var layer : entry.getValue().getAsJsonArray())
|
||||
if (renderTypeFastNames.put(layer.getAsInt(), renderType) != null)
|
||||
throw new JsonParseException("Registered duplicate fast graphics render type for layer " + layer);
|
||||
}
|
||||
}
|
||||
|
||||
var emissiveLayers = new Int2ObjectArrayMap<ForgeFaceData>();
|
||||
if(jsonObject.has("forge_data"))
|
||||
{
|
||||
@@ -118,6 +140,12 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel>
|
||||
}
|
||||
|
||||
protected void readLayerData(JsonObject jsonObject, String name, Int2ObjectOpenHashMap<ResourceLocation> renderTypeNames, Int2ObjectMap<ForgeFaceData> layerData, boolean logWarning)
|
||||
{
|
||||
this.readLayerData(jsonObject, name, renderTypeNames, new Int2ObjectOpenHashMap<>(), layerData, logWarning);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
protected void readLayerData(JsonObject jsonObject, String name, Int2ObjectOpenHashMap<ResourceLocation> renderTypeNames, Int2ObjectOpenHashMap<ResourceLocation> renderTypeFastNames, Int2ObjectMap<ForgeFaceData> layerData, boolean logWarning)
|
||||
{
|
||||
if (!jsonObject.has(name))
|
||||
{
|
||||
|
||||
@@ -251,6 +251,42 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType));
|
||||
}
|
||||
|
||||
public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, String renderType, String renderTypeFast) {
|
||||
axisBlockWithRenderTypeAndFast(block, blockTexture(block), renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void logBlockWithRenderTypeAndFast(RotatedPillarBlock block, String renderType, String renderTypeFast) {
|
||||
axisBlockWithRenderTypeAndFast(block, blockTexture(block), extend(blockTexture(block), "_top"), renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation baseName, String renderType, String renderTypeFast) {
|
||||
axisBlockWithRenderTypeAndFast(block, extend(baseName, "_side"), extend(baseName, "_end"), renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end, String renderType, String renderTypeFast) {
|
||||
axisBlock(block,
|
||||
models().cubeColumn(name(block), side, end).renderType(renderType, renderTypeFast),
|
||||
models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
axisBlockWithRenderTypeAndFast(block, blockTexture(block), renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void logBlockWithRenderType(RotatedPillarBlock block, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
axisBlockWithRenderTypeAndFast(block, blockTexture(block), extend(blockTexture(block), "_top"), renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation baseName, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
axisBlockWithRenderTypeAndFast(block, extend(baseName, "_side"), extend(baseName, "_end"), renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void axisBlockWithRenderTypeAndFast(RotatedPillarBlock block, ResourceLocation side, ResourceLocation end, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
axisBlock(block,
|
||||
models().cubeColumn(name(block), side, end).renderType(renderType, renderTypeFast),
|
||||
models().cubeColumnHorizontal(name(block) + "_horizontal", side, end).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public void axisBlock(RotatedPillarBlock block, ModelFile vertical, ModelFile horizontal) {
|
||||
getVariantBuilder(block)
|
||||
.partialState().with(RotatedPillarBlock.AXIS, Axis.Y)
|
||||
@@ -382,6 +418,38 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
stairsBlockInternalWithRenderType(block, name + "_stairs", side, bottom, top, renderType);
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
stairsBlockWithRenderTypeAndFast(block, texture, texture, texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
stairsBlockWithRenderTypeAndFast(block, name, texture, texture, texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) {
|
||||
stairsBlockInternalWithRenderTypeAndFast(block, key(block).toString(), side, bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) {
|
||||
stairsBlockInternalWithRenderTypeAndFast(block, name + "_stairs", side, bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
stairsBlockWithRenderTypeAndFast(block, texture, texture, texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
stairsBlockWithRenderTypeAndFast(block, name, texture, texture, texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
stairsBlockInternalWithRenderTypeAndFast(block, key(block).toString(), side, bottom, top, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void stairsBlockWithRenderTypeAndFast(StairBlock block, String name, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
stairsBlockInternalWithRenderTypeAndFast(block, name + "_stairs", side, bottom, top, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
private void stairsBlockInternal(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top) {
|
||||
ModelFile stairs = models().stairs(baseName, side, bottom, top);
|
||||
ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top);
|
||||
@@ -396,6 +464,13 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
stairsBlock(block, stairs, stairsInner, stairsOuter);
|
||||
}
|
||||
|
||||
private void stairsBlockInternalWithRenderTypeAndFast(StairBlock block, String baseName, ResourceLocation side, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
ModelFile stairs = models().stairs(baseName, side, bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile stairsInner = models().stairsInner(baseName + "_inner", side, bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile stairsOuter = models().stairsOuter(baseName + "_outer", side, bottom, top).renderType(renderType, renderTypeFast);
|
||||
stairsBlock(block, stairs, stairsInner, stairsOuter);
|
||||
}
|
||||
|
||||
public void stairsBlock(StairBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
|
||||
getVariantBuilder(block)
|
||||
.forAllStatesExcept(state -> {
|
||||
@@ -533,6 +608,32 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
models().fenceSide(name + "_fence_side", texture).renderType(renderType));
|
||||
}
|
||||
|
||||
public void fenceBlockWithRenderTypeAndFast(FenceBlock block, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
String baseName = key(block).toString();
|
||||
fourWayBlock(block,
|
||||
models().fencePost(baseName + "_post", texture).renderType(renderType, renderTypeFast),
|
||||
models().fenceSide(baseName + "_side", texture).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public void fenceBlockWithRenderTypeAndFast(FenceBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
fourWayBlock(block,
|
||||
models().fencePost(name + "_fence_post", texture).renderType(renderType, renderTypeFast),
|
||||
models().fenceSide(name + "_fence_side", texture).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public void fenceBlockWithRenderTypeAndFast(FenceBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
String baseName = key(block).toString();
|
||||
fourWayBlock(block,
|
||||
models().fencePost(baseName + "_post", texture).renderType(renderType, renderTypeFast),
|
||||
models().fenceSide(baseName + "_side", texture).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public void fenceBlockWithRenderTypeAndFast(FenceBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
fourWayBlock(block,
|
||||
models().fencePost(name + "_fence_post", texture).renderType(renderType, renderTypeFast),
|
||||
models().fenceSide(name + "_fence_side", texture).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public void fenceGateBlock(FenceGateBlock block, ResourceLocation texture) {
|
||||
fenceGateBlockInternal(block, key(block).toString(), texture);
|
||||
}
|
||||
@@ -557,6 +658,22 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
fenceGateBlockInternalWithRenderType(block, name + "_fence_gate", texture, renderType);
|
||||
}
|
||||
|
||||
public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
fenceGateBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
fenceGateBlockInternalWithRenderTypeAndFast(block, name + "_fence_gate", texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
fenceGateBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void fenceGateBlockWithRenderTypeAndFast(FenceGateBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
fenceGateBlockInternalWithRenderTypeAndFast(block, name + "_fence_gate", texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
private void fenceGateBlockInternal(FenceGateBlock block, String baseName, ResourceLocation texture) {
|
||||
ModelFile gate = models().fenceGate(baseName, texture);
|
||||
ModelFile gateOpen = models().fenceGateOpen(baseName + "_open", texture);
|
||||
@@ -573,6 +690,14 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
fenceGateBlock(block, gate, gateOpen, gateWall, gateWallOpen);
|
||||
}
|
||||
|
||||
private void fenceGateBlockInternalWithRenderTypeAndFast(FenceGateBlock block, String baseName, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
ModelFile gate = models().fenceGate(baseName, texture).renderType(renderType, renderTypeFast);
|
||||
ModelFile gateOpen = models().fenceGateOpen(baseName + "_open", texture).renderType(renderType, renderTypeFast);
|
||||
ModelFile gateWall = models().fenceGateWall(baseName + "_wall", texture).renderType(renderType, renderTypeFast);
|
||||
ModelFile gateWallOpen = models().fenceGateWallOpen(baseName + "_wall_open", texture).renderType(renderType, renderTypeFast);
|
||||
fenceGateBlock(block, gate, gateOpen, gateWall, gateWallOpen);
|
||||
}
|
||||
|
||||
public void fenceGateBlock(FenceGateBlock block, ModelFile gate, ModelFile gateOpen, ModelFile gateWall, ModelFile gateWallOpen) {
|
||||
getVariantBuilder(block).forAllStatesExcept(state -> {
|
||||
ModelFile model = gate;
|
||||
@@ -614,6 +739,22 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
wallBlockInternalWithRenderType(block, name + "_wall", texture, renderType);
|
||||
}
|
||||
|
||||
public void wallBlockWithRenderTypeAndFast(WallBlock block, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
wallBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void wallBlockWithRenderTypeAndFast(WallBlock block, String name, ResourceLocation texture, String renderType, String renderTypeFast) {
|
||||
wallBlockInternalWithRenderTypeAndFast(block, name + "_wall", texture, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void wallBlockWithRenderTypeAndFast(WallBlock block, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
wallBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void wallBlockWithRenderTypeAndFast(WallBlock block, String name, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
wallBlockInternalWithRenderTypeAndFast(block, name + "_wall", texture, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
private void wallBlockInternal(WallBlock block, String baseName, ResourceLocation texture) {
|
||||
wallBlock(block, models().wallPost(baseName + "_post", texture),
|
||||
models().wallSide(baseName + "_side", texture),
|
||||
@@ -626,6 +767,12 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
models().wallSideTall(baseName + "_side_tall", texture).renderType(renderType));
|
||||
}
|
||||
|
||||
private void wallBlockInternalWithRenderTypeAndFast(WallBlock block, String baseName, ResourceLocation texture, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
wallBlock(block, models().wallPost(baseName + "_post", texture).renderType(renderType, renderTypeFast),
|
||||
models().wallSide(baseName + "_side", texture).renderType(renderType, renderTypeFast),
|
||||
models().wallSideTall(baseName + "_side_tall", texture).renderType(renderType, renderTypeFast));
|
||||
}
|
||||
|
||||
public static final ImmutableMap<Direction, Property<WallSide>> WALL_PROPS = ImmutableMap.<Direction, Property<WallSide>>builder()
|
||||
.put(Direction.EAST, BlockStateProperties.EAST_WALL)
|
||||
.put(Direction.NORTH, BlockStateProperties.NORTH_WALL)
|
||||
@@ -678,6 +825,22 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
paneBlockInternalWithRenderType(block, name + "_pane", pane, edge, renderType);
|
||||
}
|
||||
|
||||
public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge, String renderType, String renderTypeFast) {
|
||||
paneBlockInternalWithRenderTypeAndFast(block, key(block).toString(), pane, edge, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge, String renderType, String renderTypeFast) {
|
||||
paneBlockInternalWithRenderTypeAndFast(block, name + "_pane", pane, edge, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
paneBlockInternalWithRenderTypeAndFast(block, key(block).toString(), pane, edge, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void paneBlockWithRenderTypeAndFast(IronBarsBlock block, String name, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
paneBlockInternalWithRenderTypeAndFast(block, name + "_pane", pane, edge, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
private void paneBlockInternal(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge) {
|
||||
ModelFile post = models().panePost(baseName + "_post", pane, edge);
|
||||
ModelFile side = models().paneSide(baseName + "_side", pane, edge);
|
||||
@@ -696,6 +859,15 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
paneBlock(block, post, side, sideAlt, noSide, noSideAlt);
|
||||
}
|
||||
|
||||
private void paneBlockInternalWithRenderTypeAndFast(IronBarsBlock block, String baseName, ResourceLocation pane, ResourceLocation edge, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
ModelFile post = models().panePost(baseName + "_post", pane, edge).renderType(renderType, renderTypeFast);
|
||||
ModelFile side = models().paneSide(baseName + "_side", pane, edge).renderType(renderType, renderTypeFast);
|
||||
ModelFile sideAlt = models().paneSideAlt(baseName + "_side_alt", pane, edge).renderType(renderType, renderTypeFast);
|
||||
ModelFile noSide = models().paneNoSide(baseName + "_noside", pane).renderType(renderType, renderTypeFast);
|
||||
ModelFile noSideAlt = models().paneNoSideAlt(baseName + "_noside_alt", pane).renderType(renderType, renderTypeFast);
|
||||
paneBlock(block, post, side, sideAlt, noSide, noSideAlt);
|
||||
}
|
||||
|
||||
public void paneBlock(IronBarsBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) {
|
||||
MultiPartBlockStateBuilder builder = getMultipartBuilder(block)
|
||||
.part().modelFile(post).addModel().end();
|
||||
@@ -735,6 +907,22 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
doorBlockInternalWithRenderType(block, name + "_door", bottom, top, renderType);
|
||||
}
|
||||
|
||||
public void doorBlockWithRenderTypeAndFast(DoorBlock block, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) {
|
||||
doorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void doorBlockWithRenderTypeAndFast(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top, String renderType, String renderTypeFast) {
|
||||
doorBlockInternalWithRenderTypeAndFast(block, name + "_door", bottom, top, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void doorBlockWithRenderTypeAndFast(DoorBlock block, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
doorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), bottom, top, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void doorBlockWithRenderTypeAndFast(DoorBlock block, String name, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
doorBlockInternalWithRenderTypeAndFast(block, name + "_door", bottom, top, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
private void doorBlockInternal(DoorBlock block, String baseName, ResourceLocation bottom, ResourceLocation top) {
|
||||
ModelFile bottomLeft = models().doorBottomLeft(baseName + "_bottom_left", bottom, top);
|
||||
ModelFile bottomLeftOpen = models().doorBottomLeftOpen(baseName + "_bottom_left_open", bottom, top);
|
||||
@@ -759,6 +947,18 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
doorBlock(block, bottomLeft, bottomLeftOpen, bottomRight, bottomRightOpen, topLeft, topLeftOpen, topRight, topRightOpen);
|
||||
}
|
||||
|
||||
private void doorBlockInternalWithRenderTypeAndFast(DoorBlock block, String baseName, ResourceLocation bottom, ResourceLocation top, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
ModelFile bottomLeft = models().doorBottomLeft(baseName + "_bottom_left", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile bottomLeftOpen = models().doorBottomLeftOpen(baseName + "_bottom_left_open", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile bottomRight = models().doorBottomRight(baseName + "_bottom_right", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile bottomRightOpen = models().doorBottomRightOpen(baseName + "_bottom_right_open", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile topLeft = models().doorTopLeft(baseName + "_top_left", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile topLeftOpen = models().doorTopLeftOpen(baseName + "_top_left_open", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile topRight = models().doorTopRight(baseName + "_top_right", bottom, top).renderType(renderType, renderTypeFast);
|
||||
ModelFile topRightOpen = models().doorTopRightOpen(baseName + "_top_right_open", bottom, top).renderType(renderType, renderTypeFast);
|
||||
doorBlock(block, bottomLeft, bottomLeftOpen, bottomRight, bottomRightOpen, topLeft, topLeftOpen, topRight, topRightOpen);
|
||||
}
|
||||
|
||||
public void doorBlock(DoorBlock block, ModelFile bottomLeft, ModelFile bottomLeftOpen, ModelFile bottomRight, ModelFile bottomRightOpen, ModelFile topLeft, ModelFile topLeftOpen, ModelFile topRight, ModelFile topRightOpen) {
|
||||
getVariantBuilder(block).forAllStatesExcept(state -> {
|
||||
int yRot = ((int) state.getValue(DoorBlock.FACING).toYRot()) + 90;
|
||||
@@ -825,6 +1025,22 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
trapdoorBlockInternalWithRenderType(block, name + "_trapdoor", texture, orientable, renderType);
|
||||
}
|
||||
|
||||
public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, ResourceLocation texture, boolean orientable, String renderType, String renderTypeFast) {
|
||||
trapdoorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, orientable, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable, String renderType, String renderTypeFast) {
|
||||
trapdoorBlockInternalWithRenderTypeAndFast(block, name + "_trapdoor", texture, orientable, ResourceLocation.tryParse(renderType), ResourceLocation.tryParse(renderTypeFast));
|
||||
}
|
||||
|
||||
public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, ResourceLocation texture, boolean orientable, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
trapdoorBlockInternalWithRenderTypeAndFast(block, key(block).toString(), texture, orientable, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
public void trapdoorBlockWithRenderTypeAndFast(TrapDoorBlock block, String name, ResourceLocation texture, boolean orientable, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
trapdoorBlockInternalWithRenderTypeAndFast(block, name + "_trapdoor", texture, orientable, renderType, renderTypeFast);
|
||||
}
|
||||
|
||||
private void trapdoorBlockInternal(TrapDoorBlock block, String baseName, ResourceLocation texture, boolean orientable) {
|
||||
ModelFile bottom = orientable ? models().trapdoorOrientableBottom(baseName + "_bottom", texture) : models().trapdoorBottom(baseName + "_bottom", texture);
|
||||
ModelFile top = orientable ? models().trapdoorOrientableTop(baseName + "_top", texture) : models().trapdoorTop(baseName + "_top", texture);
|
||||
@@ -839,6 +1055,13 @@ public abstract class BlockStateProvider implements DataProvider {
|
||||
trapdoorBlock(block, bottom, top, open, orientable);
|
||||
}
|
||||
|
||||
private void trapdoorBlockInternalWithRenderTypeAndFast(TrapDoorBlock block, String baseName, ResourceLocation texture, boolean orientable, ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
ModelFile bottom = orientable ? models().trapdoorOrientableBottom(baseName + "_bottom", texture).renderType(renderType, renderTypeFast) : models().trapdoorBottom(baseName + "_bottom", texture).renderType(renderType, renderTypeFast);
|
||||
ModelFile top = orientable ? models().trapdoorOrientableTop(baseName + "_top", texture).renderType(renderType, renderTypeFast) : models().trapdoorTop(baseName + "_top", texture).renderType(renderType, renderTypeFast);
|
||||
ModelFile open = orientable ? models().trapdoorOrientableOpen(baseName + "_open", texture).renderType(renderType, renderTypeFast) : models().trapdoorOpen(baseName + "_open", texture).renderType(renderType, renderTypeFast);
|
||||
trapdoorBlock(block, bottom, top, open, orientable);
|
||||
}
|
||||
|
||||
public void trapdoorBlock(TrapDoorBlock block, ModelFile bottom, ModelFile top, ModelFile open, boolean orientable) {
|
||||
getVariantBuilder(block).forAllStatesExcept(state -> {
|
||||
int xRot = 0;
|
||||
|
||||
@@ -60,6 +60,7 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
protected final ExistingFileHelper existingFileHelper;
|
||||
|
||||
protected String renderType = null;
|
||||
protected String renderTypeFast = null;
|
||||
protected boolean ambientOcclusion = true;
|
||||
protected GuiLight guiLight = null;
|
||||
|
||||
@@ -149,12 +150,17 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the render type for this model.
|
||||
* Set the render type for this model. Any render types to be used must be registered via
|
||||
* {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}.
|
||||
* <p>
|
||||
* Consider using {@linkplain #renderType(String, String)} if you need to set a render type for
|
||||
* {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}.
|
||||
*
|
||||
* @param renderType the render type. Must be registered via
|
||||
* {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent}
|
||||
* @param renderType the render type
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code renderType} is {@code null}
|
||||
*
|
||||
* @throws NullPointerException if {@code renderType} is {@code null}
|
||||
* @see #renderType(String, String)
|
||||
*/
|
||||
public T renderType(String renderType) {
|
||||
Preconditions.checkNotNull(renderType, "Render type must not be null");
|
||||
@@ -162,16 +168,55 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the render type for this model.
|
||||
* Set the render types for this model. Any render types to be used must be registered via
|
||||
* {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}.
|
||||
*
|
||||
* @param renderType the render type. Must be registered via
|
||||
* {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent}
|
||||
* @param renderType the render type for {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics}
|
||||
* @param renderTypeFast the render type for {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}
|
||||
* @return this builder
|
||||
* @throws NullPointerException if {@code renderType} is {@code null}
|
||||
*
|
||||
* @throws NullPointerException if {@code renderType} is {@code null}
|
||||
*/
|
||||
public T renderType(String renderType, String renderTypeFast) {
|
||||
Preconditions.checkNotNull(renderType, "Render type must not be null");
|
||||
return renderType(ResourceLocation.parse(renderType), ResourceLocation.parse(renderTypeFast));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the render type for this model. Any render types to be used must be registered via
|
||||
* {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}.
|
||||
* <p>
|
||||
* Consider using {@linkplain #renderType(ResourceLocation, ResourceLocation)} if you need to set a render type for
|
||||
* {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}.
|
||||
*
|
||||
* @param renderType the render type
|
||||
* @return this builder
|
||||
*
|
||||
* @throws NullPointerException if {@code renderType} is {@code null}
|
||||
* @see #renderType(ResourceLocation, ResourceLocation)
|
||||
*/
|
||||
public T renderType(ResourceLocation renderType) {
|
||||
Preconditions.checkNotNull(renderType, "Render type must not be null");
|
||||
this.renderType = renderType.toString();
|
||||
this.renderTypeFast = null;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the render types for this model. Any render types to be used must be registered via
|
||||
* {@link net.minecraftforge.client.event.RegisterNamedRenderTypesEvent RegisterNamedRenderTypesEvent}.
|
||||
*
|
||||
* @param renderType the render type for {@linkplain net.minecraft.client.GraphicsStatus#FANCY fancy graphics}
|
||||
* @param renderTypeFast the render type for {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics}
|
||||
* @return this builder
|
||||
*
|
||||
* @throws NullPointerException if {@code renderType} is {@code null}
|
||||
*/
|
||||
public T renderType(ResourceLocation renderType, ResourceLocation renderTypeFast) {
|
||||
Preconditions.checkNotNull(renderType, "Render type must not be null");
|
||||
Preconditions.checkNotNull(renderTypeFast, "Fast graphics render type must not be null");
|
||||
this.renderType = renderType.toString();
|
||||
this.renderTypeFast = renderType.toString();
|
||||
return self();
|
||||
}
|
||||
|
||||
|
||||
@@ -369,7 +369,8 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements DataPr
|
||||
}
|
||||
|
||||
public T leaves(String name, ResourceLocation texture) {
|
||||
return singleTexture(name, BLOCK_FOLDER + "/leaves", "all", texture);
|
||||
return singleTexture(name, BLOCK_FOLDER + "/leaves", "all", texture)
|
||||
.renderType("cutout_mipped", "solid");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+45
@@ -33,6 +33,7 @@ public class ItemLayerModelBuilder<T extends ModelBuilder<T>> extends CustomLoad
|
||||
|
||||
private final Int2ObjectMap<ForgeFaceData> faceData = new Int2ObjectOpenHashMap<>();
|
||||
private final Map<ResourceLocation, IntSet> renderTypes = new LinkedHashMap<>();
|
||||
private final Map<ResourceLocation, IntSet> renderTypesFast = new LinkedHashMap<>();
|
||||
private final IntSet layersWithRenderTypes = new IntOpenHashSet();
|
||||
|
||||
protected ItemLayerModelBuilder(T parent, ExistingFileHelper existingFileHelper)
|
||||
@@ -115,6 +116,23 @@ public class ItemLayerModelBuilder<T extends ModelBuilder<T>> extends CustomLoad
|
||||
return renderType(asLoc, layers);
|
||||
}
|
||||
|
||||
public ItemLayerModelBuilder<T> renderType(String renderType, String renderTypeFast, int... layers)
|
||||
{
|
||||
Preconditions.checkNotNull(renderType, "Render type must not be null");
|
||||
Preconditions.checkNotNull(renderTypeFast, "Fast graphics render type must not be null");
|
||||
ResourceLocation asLoc;
|
||||
if (renderType.contains(":"))
|
||||
asLoc = ResourceLocation.parse(renderType);
|
||||
else
|
||||
asLoc = parent.getLocation().withPath(renderType);
|
||||
ResourceLocation asLocFast;
|
||||
if (renderTypeFast.contains(":"))
|
||||
asLocFast = ResourceLocation.parse(renderTypeFast);
|
||||
else
|
||||
asLocFast = parent.getLocation().withPath(renderTypeFast);
|
||||
return renderType(asLoc, asLocFast, layers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the render type for a set of layers.
|
||||
*
|
||||
@@ -144,6 +162,25 @@ public class ItemLayerModelBuilder<T extends ModelBuilder<T>> extends CustomLoad
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemLayerModelBuilder<T> renderType(ResourceLocation renderType, ResourceLocation renderTypeFast, int... layers)
|
||||
{
|
||||
Preconditions.checkNotNull(renderType, "Render type must not be null");
|
||||
Preconditions.checkNotNull(renderTypeFast, "Fast graphics render type must not be null");
|
||||
Preconditions.checkNotNull(layers, "Layers must not be null");
|
||||
Preconditions.checkArgument(layers.length > 0, "At least one layer must be specified");
|
||||
Preconditions.checkArgument(Arrays.stream(layers).allMatch(i -> i >= 0), "All layers must be >= 0");
|
||||
var alreadyAssigned = Arrays.stream(layers).filter(layersWithRenderTypes::contains).toArray();
|
||||
Preconditions.checkArgument(alreadyAssigned.length == 0, "Attempted to re-assign layer render types: " + Arrays.toString(alreadyAssigned));
|
||||
var renderTypeLayers = renderTypes.computeIfAbsent(renderType, $ -> new IntOpenHashSet());
|
||||
var renderTypeFastLayers = renderTypesFast.computeIfAbsent(renderType, $ -> new IntOpenHashSet());
|
||||
Arrays.stream(layers).forEach(layer -> {
|
||||
renderTypeLayers.add(layer);
|
||||
renderTypeFastLayers.add(layer);
|
||||
layersWithRenderTypes.add(layer);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject toJson(JsonObject json)
|
||||
{
|
||||
@@ -168,6 +205,14 @@ public class ItemLayerModelBuilder<T extends ModelBuilder<T>> extends CustomLoad
|
||||
});
|
||||
json.add("render_types", renderTypes);
|
||||
|
||||
JsonObject renderTypesFast = new JsonObject();
|
||||
this.renderTypesFast.forEach((renderTypeFast, layers) -> {
|
||||
JsonArray array = new JsonArray();
|
||||
layers.intStream().sorted().forEach(array::add);
|
||||
renderTypesFast.add(renderTypeFast.toString(), array);
|
||||
});
|
||||
json.add("render_types_fast", renderTypesFast);
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
+17
@@ -41,6 +41,8 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext
|
||||
private Transformation rootTransform;
|
||||
@Nullable
|
||||
private ResourceLocation renderTypeHint;
|
||||
@Nullable
|
||||
private ResourceLocation renderTypeFastHint;
|
||||
private boolean gui3d = true;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -137,11 +139,25 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext
|
||||
return owner.parent != null ? owner.parent.customData.getRenderTypeHint() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getRenderTypeFastHint()
|
||||
{
|
||||
if (renderTypeFastHint != null)
|
||||
return renderTypeFastHint;
|
||||
return owner.parent != null ? owner.parent.customData.getRenderTypeFastHint() : null;
|
||||
}
|
||||
|
||||
public void setRenderTypeHint(ResourceLocation renderTypeHint)
|
||||
{
|
||||
this.renderTypeHint = renderTypeHint;
|
||||
}
|
||||
|
||||
public void setRenderTypeFastHint(ResourceLocation renderTypeFastHint)
|
||||
{
|
||||
this.renderTypeFastHint = renderTypeFastHint;
|
||||
}
|
||||
|
||||
public void setGui3d(boolean gui3d)
|
||||
{
|
||||
this.gui3d = gui3d;
|
||||
@@ -153,6 +169,7 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext
|
||||
this.rootTransform = other.rootTransform;
|
||||
this.visibilityData.copyFrom(other.visibilityData);
|
||||
this.renderTypeHint = other.renderTypeHint;
|
||||
this.renderTypeFastHint = other.renderTypeFastHint;
|
||||
this.gui3d = other.gui3d;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,13 @@ public interface IGeometryBakingContext
|
||||
@Nullable
|
||||
ResourceLocation getRenderTypeHint();
|
||||
|
||||
/**
|
||||
* @return a hint of the {@linkplain net.minecraft.client.GraphicsStatus#FAST fast graphics} render type this model
|
||||
* should use. Custom loaders may ignore this.
|
||||
*/
|
||||
@Nullable
|
||||
default ResourceLocation getRenderTypeFastHint() { return null; }
|
||||
|
||||
/**
|
||||
* Queries the visibility of a component of this model.
|
||||
*
|
||||
@@ -91,4 +98,20 @@ public interface IGeometryBakingContext
|
||||
{
|
||||
return NamedRenderTypeManager.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a {@link RenderTypeGroup} from the {@link #getRenderTypeHint()}, or the empty group if not found.}
|
||||
*/
|
||||
default RenderTypeGroup getRenderType() {
|
||||
var hint = getRenderTypeHint();
|
||||
return hint == null ? RenderTypeGroup.EMPTY : getRenderType(hint);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return a {@link RenderTypeGroup} from the {@link #getRenderTypeHint()}, or the empty group if not found.}
|
||||
*/
|
||||
default RenderTypeGroup getRenderTypeFast() {
|
||||
var hint = getRenderTypeFastHint();
|
||||
return hint == null ? RenderTypeGroup.EMPTY : getRenderType(hint);
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,8 @@ public abstract class SimpleUnbakedGeometry<T extends SimpleUnbakedGeometry<T>>
|
||||
{
|
||||
TextureAtlasSprite particle = spriteGetter.apply(context.getMaterial("particle"));
|
||||
|
||||
var renderTypeHint = context.getRenderTypeHint();
|
||||
var renderTypes = renderTypeHint != null ? context.getRenderType(renderTypeHint) : RenderTypeGroup.EMPTY;
|
||||
IModelBuilder<?> builder = IModelBuilder.of(context.useAmbientOcclusion(), context.useBlockLight(), context.isGui3d(),
|
||||
context.getTransforms(), overrides, particle, renderTypes);
|
||||
context.getTransforms(), overrides, particle, context.getRenderType(), context.getRenderTypeFast());
|
||||
|
||||
addQuads(context, builder, baker, spriteGetter, modelState, modelLocation);
|
||||
|
||||
|
||||
+33
-1
@@ -54,6 +54,8 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
private final Transformation rootTransform;
|
||||
@Nullable
|
||||
private final ResourceLocation renderTypeHint;
|
||||
@Nullable
|
||||
private final ResourceLocation renderTypeFastHint;
|
||||
private final BiPredicate<String, Boolean> visibilityTest;
|
||||
|
||||
private StandaloneGeometryBakingContext(ResourceLocation modelName, Predicate<String> materialCheck,
|
||||
@@ -62,6 +64,18 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
ItemTransforms transforms, Transformation rootTransform,
|
||||
@Nullable ResourceLocation renderTypeHint,
|
||||
BiPredicate<String, Boolean> visibilityTest)
|
||||
{
|
||||
this(modelName, materialCheck, materialLookup, isGui3d, useBlockLight, useAmbientOcclusion,
|
||||
transforms, rootTransform, renderTypeHint, null, visibilityTest);
|
||||
}
|
||||
|
||||
private StandaloneGeometryBakingContext(ResourceLocation modelName, Predicate<String> materialCheck,
|
||||
Function<String, Material> materialLookup, boolean isGui3d,
|
||||
boolean useBlockLight, boolean useAmbientOcclusion,
|
||||
ItemTransforms transforms, Transformation rootTransform,
|
||||
@Nullable ResourceLocation renderTypeHint,
|
||||
@Nullable ResourceLocation renderTypeFastHint,
|
||||
BiPredicate<String, Boolean> visibilityTest)
|
||||
{
|
||||
this.modelName = modelName;
|
||||
this.materialCheck = materialCheck;
|
||||
@@ -72,6 +86,7 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
this.transforms = transforms;
|
||||
this.rootTransform = rootTransform;
|
||||
this.renderTypeHint = renderTypeHint;
|
||||
this.renderTypeFastHint = renderTypeFastHint;
|
||||
this.visibilityTest = visibilityTest;
|
||||
}
|
||||
|
||||
@@ -130,6 +145,12 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
return renderTypeHint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getRenderTypeFastHint() {
|
||||
return renderTypeFastHint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComponentVisible(String component, boolean fallback)
|
||||
{
|
||||
@@ -158,6 +179,8 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
private Transformation rootTransform = Transformation.identity();
|
||||
@Nullable
|
||||
private ResourceLocation renderTypeHint;
|
||||
@Nullable
|
||||
private ResourceLocation renderTypeFastHint;
|
||||
private BiPredicate<String, Boolean> visibilityTest = (c, def) -> def;
|
||||
|
||||
private Builder()
|
||||
@@ -174,6 +197,7 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
this.transforms = parent.getTransforms();
|
||||
this.rootTransform = parent.getRootTransform();
|
||||
this.renderTypeHint = parent.getRenderTypeHint();
|
||||
this.renderTypeFastHint = parent.getRenderTypeFastHint();
|
||||
this.visibilityTest = parent::isComponentVisible;
|
||||
}
|
||||
|
||||
@@ -229,6 +253,14 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
public Builder withRenderTypeHint(ResourceLocation renderTypeHint)
|
||||
{
|
||||
this.renderTypeHint = renderTypeHint;
|
||||
this.renderTypeFastHint = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withRenderTypeHint(ResourceLocation renderTypeHint, ResourceLocation renderTypeFastHint)
|
||||
{
|
||||
this.renderTypeHint = renderTypeHint;
|
||||
this.renderTypeFastHint = renderTypeFastHint;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -240,7 +272,7 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext
|
||||
|
||||
public StandaloneGeometryBakingContext build(ResourceLocation modelName)
|
||||
{
|
||||
return new StandaloneGeometryBakingContext(modelName, materialCheck, materialLookup, isGui3d, useBlockLight, useAmbientOcclusion, transforms, rootTransform, renderTypeHint, visibilityTest);
|
||||
return new StandaloneGeometryBakingContext(modelName, materialCheck, materialLookup, isGui3d, useBlockLight, useAmbientOcclusion, transforms, rootTransform, renderTypeHint, renderTypeFastHint, visibilityTest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ public class ForgeConfig {
|
||||
|
||||
public final BooleanValue advertiseDedicatedServerToLan;
|
||||
|
||||
public final BooleanValue useItemWithDurationZero;
|
||||
|
||||
Server(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Server configuration settings")
|
||||
.push("server");
|
||||
@@ -74,19 +76,40 @@ public class ForgeConfig {
|
||||
.translation("forge.configgui.advertiseDedicatedServerToLan")
|
||||
.define("advertiseDedicatedServerToLan", true);
|
||||
|
||||
useItemWithDurationZero = builder
|
||||
.comment("Set this to true to enable living entities to use items with durations of 0. Fixes being able to use Eyes of Ender repeatedly by holding down the use button. Disabled by default as it could change interactions with items of existing mods.")
|
||||
.translation("forge.configgui.useItemWithDurationZero")
|
||||
.define("useItemWithDurationZero", false);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
public final int getUseItemDuration() {
|
||||
return useItemWithDurationZero.get() ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* General configuration that doesn't need to be synchronized but needs to be available before server startup
|
||||
*/
|
||||
public static class Common {
|
||||
public final ForgeConfigSpec.LongValue channelListLimit;
|
||||
|
||||
Common(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("[DEPRECATED / NO EFFECT]: General configuration settings")
|
||||
builder.comment("General configuration settings")
|
||||
.push("general");
|
||||
|
||||
channelListLimit = builder
|
||||
.comment(
|
||||
"Maximum size to use to store the channel list for a network connection.",
|
||||
"The other end of the connection may send as many channels as it wishes.",
|
||||
"Some malicious actors may use this to use up all your memory causing OutOfMemoryException",
|
||||
"A sane default is 1KB (1024), but may need to be expanded for larger modpacks.",
|
||||
"Forge will auto-adjust this if mods register their channels using our channel manager."
|
||||
)
|
||||
.translation("forge.configui.channellistlimit")
|
||||
.defineInRange("channelListLimit", 1024, 1, Long.MAX_VALUE);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
}
|
||||
@@ -110,6 +133,8 @@ public class ForgeConfig {
|
||||
|
||||
public final BooleanValue stabilizeDirectionGetNearest;
|
||||
|
||||
public final BooleanValue allowMipmapLowering;
|
||||
|
||||
|
||||
Client(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Client only settings, mostly things related to rendering")
|
||||
@@ -156,6 +181,11 @@ public class ForgeConfig {
|
||||
.translation("forge.configgui.stabilizeDirectionGetNearest")
|
||||
.define("stabilizeDirectionGetNearest", true);
|
||||
|
||||
allowMipmapLowering = builder
|
||||
.comment("When enabled, Forge will allow mipmaps to be lowered in real-time. This is the default behavior in vanilla. Use this if you experience issues with resource packs that use textures lower than 8x8.")
|
||||
.translation("forge.configgui.allowMipmapLowering")
|
||||
.define("allowMipmapLowering", false);
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
@@ -168,6 +198,10 @@ public class ForgeConfig {
|
||||
public final boolean showLoadWarnings() {
|
||||
return clientSpec.isLoaded() ? showLoadWarnings.get() : showLoadWarnings.getDefault();
|
||||
}
|
||||
|
||||
public final boolean allowMipmapLowering() {
|
||||
return clientSpec.isLoaded() ? allowMipmapLowering.get() : allowMipmapLowering.getDefault();
|
||||
}
|
||||
}
|
||||
|
||||
static final ForgeConfigSpec clientSpec;
|
||||
|
||||
@@ -757,9 +757,8 @@ public class ForgeHooks {
|
||||
}
|
||||
|
||||
public static boolean onCropsGrowPre(Level level, BlockPos pos, BlockState state, boolean def) {
|
||||
BlockEvent ev = new BlockEvent.CropGrowEvent.Pre(level,pos,state);
|
||||
MinecraftForge.EVENT_BUS.post(ev);
|
||||
return (ev.getResult() == Event.Result.ALLOW || (ev.getResult() == Event.Result.DEFAULT && def));
|
||||
var result = MinecraftForge.EVENT_BUS.fire(new BlockEvent.CropGrowEvent.Pre(level,pos,state)).getResult();
|
||||
return (result.isAllowed() || (def && result.isDefault()));
|
||||
}
|
||||
|
||||
public static void onCropsGrowPost(Level level, BlockPos pos, BlockState state) {
|
||||
@@ -768,9 +767,8 @@ public class ForgeHooks {
|
||||
|
||||
@Nullable
|
||||
public static CriticalHitEvent getCriticalHit(Player player, Entity target, boolean vanillaCritical, float damageModifier) {
|
||||
CriticalHitEvent hitResult = new CriticalHitEvent(player, target, damageModifier, vanillaCritical);
|
||||
MinecraftForge.EVENT_BUS.post(hitResult);
|
||||
if (hitResult.getResult() == Event.Result.ALLOW || (vanillaCritical && hitResult.getResult() == Event.Result.DEFAULT))
|
||||
CriticalHitEvent hitResult = MinecraftForge.EVENT_BUS.fire(new CriticalHitEvent(player, target, damageModifier, vanillaCritical));
|
||||
if (hitResult.getResult().isAllowed() || (vanillaCritical && hitResult.getResult().isDefault()))
|
||||
return hitResult;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,13 @@ public class ForgeInternalHandler {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(ServerTickEvent event) {
|
||||
WorldWorkerManager.tick(event.phase == TickEvent.Phase.START);
|
||||
public void onServerTick(ServerTickEvent.Pre event) {
|
||||
WorldWorkerManager.tick(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerTick(ServerTickEvent.Post event) {
|
||||
WorldWorkerManager.tick(false);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -389,7 +389,7 @@ public class ForgeMod {
|
||||
enableMilkFluid = true;
|
||||
}
|
||||
|
||||
public ForgeMod() {
|
||||
public ForgeMod(FMLJavaModLoadingContext context) {
|
||||
LOGGER.info(FORGEMOD,"Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion());
|
||||
INSTANCE = this;
|
||||
MinecraftForge.initialize();
|
||||
@@ -406,7 +406,7 @@ public class ForgeMod {
|
||||
CrashReportCallables.registerCrashCallable("FML", ForgeVersion::getSpec);
|
||||
CrashReportCallables.registerCrashCallable("Forge", ()->ForgeVersion.getGroup()+":"+ForgeVersion.getVersion());
|
||||
|
||||
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
final IEventBus modEventBus = context.getModEventBus();
|
||||
// Forge-provided datapack registries
|
||||
modEventBus.addListener((DataPackRegistryEvent.NewRegistry event) -> {
|
||||
event.dataPackRegistry(ForgeRegistries.Keys.BIOME_MODIFIERS, BiomeModifier.DIRECT_CODEC);
|
||||
@@ -421,13 +421,13 @@ public class ForgeMod {
|
||||
registries.forEach(r -> r.register(modEventBus));
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(this::serverStopping);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec);
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec);
|
||||
context.registerConfig(ModConfig.Type.CLIENT, ForgeConfig.clientSpec);
|
||||
context.registerConfig(ModConfig.Type.SERVER, ForgeConfig.serverSpec);
|
||||
context.registerConfig(ModConfig.Type.COMMON, ForgeConfig.commonSpec);
|
||||
modEventBus.register(ForgeConfig.class);
|
||||
ForgeDeferredRegistriesSetup.setup(modEventBus);
|
||||
// Forge does not display problems when the remote is not matching.
|
||||
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, ()->new IExtensionPoint.DisplayTest(()->"ANY", (remote, isServer)-> true));
|
||||
context.registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION);
|
||||
StartupMessageManager.addModMessage("Forge version "+ForgeVersion.getVersion());
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener(VillagerTradingManager::loadTrades);
|
||||
|
||||
@@ -31,12 +31,10 @@ import java.util.function.Supplier;
|
||||
public class MinecraftForge
|
||||
{
|
||||
/**
|
||||
* The core Forge EventBusses, all events for Forge will be fired on these,
|
||||
* you should use this to register all your listeners.
|
||||
* This replaces every register*Handler() function in the old version of Forge.
|
||||
* TERRAIN_GEN_BUS for terrain gen events
|
||||
* ORE_GEN_BUS for ore gen events
|
||||
* EVENT_BUS for everything else
|
||||
* The EventBus for all the Forge Events.
|
||||
*
|
||||
* Events marked with {@link net.minecraftforge.fml.event.IModBusEvent}
|
||||
* belong on the ModBus and not this bus
|
||||
*/
|
||||
public static final IEventBus EVENT_BUS = BusBuilder.builder().startShutdown().useModLauncher().build();
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ public class Tags
|
||||
public static final TagKey<Block> CHESTS_ENDER = tag("chests/ender");
|
||||
public static final TagKey<Block> CHESTS_TRAPPED = tag("chests/trapped");
|
||||
public static final TagKey<Block> CHESTS_WOODEN = tag("chests/wooden");
|
||||
public static final TagKey<Block> CHORUS_ADDITIONALLY_GROWS_ON = tag("chorus_additionally_grows_on");
|
||||
public static final TagKey<Block> COBBLESTONE = tag("cobblestone");
|
||||
public static final TagKey<Block> COBBLESTONE_NORMAL = tag("cobblestone/normal");
|
||||
public static final TagKey<Block> COBBLESTONE_INFESTED = tag("cobblestone/infested");
|
||||
|
||||
@@ -42,6 +42,7 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider
|
||||
tag(CHESTS_ENDER).add(Blocks.ENDER_CHEST);
|
||||
tag(CHESTS_TRAPPED).add(Blocks.TRAPPED_CHEST);
|
||||
tag(CHESTS_WOODEN).add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
|
||||
tag(CHORUS_ADDITIONALLY_GROWS_ON).addTags(END_STONES);
|
||||
tag(COBBLESTONE).addTags(COBBLESTONE_NORMAL, COBBLESTONE_INFESTED, COBBLESTONE_MOSSY, COBBLESTONE_DEEPSLATE);
|
||||
tag(COBBLESTONE_NORMAL).add(Blocks.COBBLESTONE);
|
||||
tag(COBBLESTONE_INFESTED).add(Blocks.INFESTED_COBBLESTONE);
|
||||
|
||||
@@ -5,47 +5,128 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.gametest.framework.GameTestAssertException;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.ConnectionProtocol;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public interface IForgeGameTestHelper {
|
||||
private GameTestHelper self() {
|
||||
return (GameTestHelper)this;
|
||||
return (GameTestHelper) this;
|
||||
}
|
||||
|
||||
default void say(String message) {
|
||||
this.say(message, Style.EMPTY);
|
||||
}
|
||||
|
||||
default void say(String message, Style style) {
|
||||
var component = ForgeI18n.getPattern(message) != null ? Component.translatable(message) : Component.literal(message);
|
||||
this.say(component.withStyle(style));
|
||||
}
|
||||
|
||||
default void say(Component component) {
|
||||
this.self().getLevel().players().forEach(p -> p.sendSystemMessage(component));
|
||||
}
|
||||
|
||||
default void assertTrue(boolean value, Supplier<String> message) {
|
||||
if (!value)
|
||||
throw new GameTestAssertException(message.get());
|
||||
if (!value)
|
||||
throw new GameTestAssertException(message.get());
|
||||
}
|
||||
|
||||
default void assertFalse(boolean value, Supplier<String> message) {
|
||||
if (value)
|
||||
throw new GameTestAssertException(message.get());
|
||||
if (value)
|
||||
throw new GameTestAssertException(message.get());
|
||||
}
|
||||
|
||||
default <N> void assertValueEqual(N expected, N actual, String name, String message) {
|
||||
this.assertValueEqual(expected, actual, name, () -> message);
|
||||
}
|
||||
|
||||
default <N> void assertValueEqual(N expected, N actual, String name, Supplier<String> message) {
|
||||
if (!Objects.equals(expected, actual))
|
||||
throw new GameTestAssertException("%s -- Expected %s to be %s, but was %s".formatted(message.get(), name, expected, actual));
|
||||
}
|
||||
|
||||
default <N> void assertValueEqual(N[] expected, N[] actual, String name, String message) {
|
||||
this.assertValueEqual(expected, actual, name, () -> message);
|
||||
}
|
||||
|
||||
default <N> void assertValueEqual(N[] expected, N[] actual, String name, Supplier<String> message) {
|
||||
if (!Objects.deepEquals(expected, actual))
|
||||
throw new GameTestAssertException("%s -- Expected %s to be %s, but was %s".formatted(message.get(), name, Arrays.toString(expected), Arrays.toString(actual)));
|
||||
}
|
||||
|
||||
// Backported from 1.20.6
|
||||
default <N> void assertValueEqual(N expected, N actual, String name) {
|
||||
if (!Objects.equals(expected, actual)) {
|
||||
throw new GameTestAssertException("Expected " + name + " to be " + expected + ", but was " + actual);
|
||||
}
|
||||
}
|
||||
|
||||
// Backported from 1.20.6
|
||||
default Player makeMockPlayer(final GameType p_333981_) {
|
||||
return new Player(this.self().getLevel(), BlockPos.ZERO, 0.0F, new GameProfile(UUID.randomUUID(), "test-mock-player")) {
|
||||
@Override
|
||||
public boolean isSpectator() {
|
||||
return p_333981_ == GameType.SPECTATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreative() {
|
||||
return p_333981_.isCreative();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalPlayer() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default <E> HolderLookup.RegistryLookup<E> registryLookup(ResourceKey<? extends Registry<? extends E>> registryKey) {
|
||||
return this.self().getLevel().registryAccess().lookupOrThrow(registryKey);
|
||||
}
|
||||
|
||||
default ServerPlayer makeMockServerPlayer() {
|
||||
var level = self().getLevel();
|
||||
var cookie = CommonListenerCookie.createInitial(new GameProfile(UUID.randomUUID(), "test-mock-player"));
|
||||
var player = new ServerPlayer(level.getServer(), level, cookie.gameProfile(), cookie.clientInformation()) {
|
||||
public boolean isSpectator() {
|
||||
return false;
|
||||
}
|
||||
public boolean isSpectator() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isCreative() {
|
||||
return true;
|
||||
}
|
||||
public boolean isCreative() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var connection = new Connection(PacketFlow.SERVERBOUND);
|
||||
var channel = new EmbeddedChannel(connection);
|
||||
@@ -54,4 +135,218 @@ public interface IForgeGameTestHelper {
|
||||
new ServerGamePacketListenerImpl(level.getServer(), connection, player, cookie);
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event listener that will be unregistered when the test is finished running.
|
||||
*/
|
||||
default <E extends Event> void addEventListener(Consumer<E> consumer) {
|
||||
MinecraftForge.EVENT_BUS.addListener(consumer);
|
||||
self().addCleanup(success -> MinecraftForge.EVENT_BUS.unregister(consumer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an event listener that will be unregistered when the test is finished running.
|
||||
*/
|
||||
default void registerEventListener(Object handler) {
|
||||
MinecraftForge.EVENT_BUS.register(handler);
|
||||
self().addCleanup(success -> MinecraftForge.EVENT_BUS.unregister(handler));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a floor of stone blocks at the bottom of the test area.
|
||||
*/
|
||||
default void makeFloor() {
|
||||
makeFloor(Blocks.STONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a floor of the specified block under the test area.
|
||||
*/
|
||||
default void makeFloor(Block block) {
|
||||
makeFloor(block, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a floor of the specified block at the specified height.
|
||||
*/
|
||||
default void makeFloor(Block block, int height) {
|
||||
var bounds = self().getBounds();
|
||||
var pos = new BlockPos.MutableBlockPos();
|
||||
for (int x = 0; x < (int) bounds.getXsize(); x++) {
|
||||
for (int y = 0; y < (int) bounds.getZsize(); y++) {
|
||||
pos.set(x, height, y);
|
||||
if (self().getBlockState(pos).is(Blocks.AIR))
|
||||
self().setBlock(pos, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(int x, int y, int z, Block block) {
|
||||
return this.setAndAssertBlock(x, y, z, block.defaultBlockState());
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(int x, int y, int z, BlockState state) {
|
||||
return this.setAndAssertBlock(new BlockPos(x, y, z), state);
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(BlockPos pos, Block block) {
|
||||
return this.setAndAssertBlock(pos, block.defaultBlockState());
|
||||
}
|
||||
|
||||
default BlockState setAndAssertBlock(BlockPos pos, BlockState state) {
|
||||
this.assertTrue(
|
||||
this.self().getLevel().setBlock(this.self().absolutePos(pos), state, Block.UPDATE_ALL),
|
||||
() -> "Failed to set block at pos %s : %s".formatted(pos, state.getBlock())
|
||||
);
|
||||
return state;
|
||||
}
|
||||
|
||||
default <T> Flag<T> flag(String name) {
|
||||
return new Flag<>(name);
|
||||
}
|
||||
|
||||
default IntFlag intFlag(String name) {
|
||||
return new IntFlag(name);
|
||||
}
|
||||
|
||||
default BoolFlag boolFlag(String name) {
|
||||
return new BoolFlag(name);
|
||||
}
|
||||
|
||||
public static class Flag<T> {
|
||||
private final String name;
|
||||
@Nullable
|
||||
protected T value = null;
|
||||
|
||||
public Flag(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void set(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T get() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void assertUnset() {
|
||||
this.assertUnset((Supplier<String>) null);
|
||||
}
|
||||
|
||||
public void assertUnset(String message) {
|
||||
this.assertUnset(message != null ? () -> message : null);
|
||||
}
|
||||
|
||||
public void assertUnset(Supplier<String> message) {
|
||||
if (this.value != null) {
|
||||
String s = message != null ? message.get() + " -- " : "";
|
||||
throw new GameTestAssertException(s + "Expected " + name + " to be null, but was " + this.value);
|
||||
}
|
||||
}
|
||||
|
||||
public void assertSet() {
|
||||
this.assertSet((Supplier<String>) null);
|
||||
}
|
||||
|
||||
public void assertSet(String message) {
|
||||
this.assertSet(message != null ? () -> message : null);
|
||||
}
|
||||
|
||||
public void assertSet(Supplier<String> message) {
|
||||
if (this.value == null) {
|
||||
String s = message != null ? message.get() + " -- " : "";
|
||||
throw new GameTestAssertException(s + "Flag " + name + " was never set");
|
||||
}
|
||||
}
|
||||
|
||||
public void assertEquals(T expected) {
|
||||
this.assertEquals(expected, (Supplier<String>) null);
|
||||
}
|
||||
|
||||
public void assertEquals(T expected, String message) {
|
||||
this.assertEquals(expected, message != null ? () -> message : null);
|
||||
}
|
||||
|
||||
public void assertEquals(T expected, Supplier<String> message) {
|
||||
assertSet(message);
|
||||
if (expected != null && !expected.equals(this.value)) {
|
||||
String s = message != null ? message.get() + " -- " : "";
|
||||
throw new GameTestAssertException(s + "Expected " + name + " to be " + expected + ", but was " + this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class IntFlag extends Flag<Long> {
|
||||
public IntFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void set(long value) {
|
||||
super.set(value);
|
||||
}
|
||||
|
||||
public byte getByte() {
|
||||
return this.value == null ? -1 : this.value.byteValue();
|
||||
}
|
||||
|
||||
public int getInt() {
|
||||
return this.value == null ? -1 : this.value.intValue();
|
||||
}
|
||||
|
||||
public long getLong() {
|
||||
return this.value == null ? -1 : this.value.longValue();
|
||||
}
|
||||
|
||||
public void assertEquals(int expected) {
|
||||
super.assertEquals((long) expected);
|
||||
}
|
||||
|
||||
public void assertEquals(long expected) {
|
||||
super.assertEquals(expected);
|
||||
}
|
||||
|
||||
public void assertEquals(int expected, String message) {
|
||||
super.assertEquals((long) expected, message);
|
||||
}
|
||||
|
||||
public void assertEquals(long expected, String message) {
|
||||
super.assertEquals(expected, message);
|
||||
}
|
||||
|
||||
public void assertEquals(int expected, Supplier<String> message) {
|
||||
super.assertEquals((long) expected, message);
|
||||
}
|
||||
|
||||
public void assertEquals(long expected, Supplier<String> message) {
|
||||
super.assertEquals(expected, message);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BoolFlag extends Flag<Boolean> {
|
||||
public BoolFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public void set(boolean value) {
|
||||
super.set(value);
|
||||
}
|
||||
|
||||
public boolean getBool() {
|
||||
return this.value != null && this.value;
|
||||
}
|
||||
|
||||
public void assertEquals(boolean expected) {
|
||||
super.assertEquals(expected);
|
||||
}
|
||||
|
||||
public void assertEquals(boolean expected, String message) {
|
||||
super.assertEquals(expected, message);
|
||||
}
|
||||
|
||||
public void assertEquals(boolean expected, Supplier<String> message) {
|
||||
super.assertEquals(expected, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -644,7 +644,7 @@ public interface IForgeItem {
|
||||
* @return True if this ItemStack can disable the shield in question.
|
||||
*/
|
||||
default boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) {
|
||||
return this instanceof AxeItem;
|
||||
return attacker.canDisableShield();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.world.level.storage.LevelSummary;
|
||||
|
||||
public interface IForgeLevelSummary {
|
||||
private LevelSummary self() {
|
||||
return (LevelSummary) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the Forge lifecycle of this level is experimental. This is used to render the experimental warning
|
||||
* tooltip on the level select screen.
|
||||
*
|
||||
* @return {@code true} if the level is experimental
|
||||
*/
|
||||
default boolean isLifecycleExperimental() {
|
||||
// NOTE: Because CorruptedLevelSummary and SymlinkLevelSummary can have null settings, we need to check it
|
||||
var settings = this.self().getSettings();
|
||||
|
||||
return settings != null && settings.getLifecycle().equals(com.mojang.serialization.Lifecycle.experimental());
|
||||
}
|
||||
}
|
||||
@@ -114,13 +114,13 @@ public class ConcatenatedListView<T> implements List<T>
|
||||
@Override
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
return Iterables.unmodifiableIterable(Iterables.concat(lists)).iterator();
|
||||
return Iterables.unmodifiableIterable(Iterables.<T>concat(lists)).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spliterator<T> spliterator()
|
||||
{
|
||||
return Iterables.unmodifiableIterable(Iterables.concat(lists)).spliterator();
|
||||
return Iterables.unmodifiableIterable(Iterables.<T>concat(lists)).spliterator();
|
||||
}
|
||||
|
||||
// Delegate to a concatenated collection
|
||||
|
||||
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user