mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 17:14:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7878d97fbb | ||
|
|
8b2980400b | ||
|
|
58c92b1e76 | ||
|
|
01568f90fa | ||
|
|
fba9c66164 | ||
|
|
afaba58edc | ||
|
|
8bdf29553b | ||
|
|
f6867c2151 | ||
|
|
63fa38ba14 | ||
|
|
e6318f8793 | ||
|
|
0bee88f4c0 | ||
|
|
75650bde6b | ||
|
|
29f1a5c117 | ||
|
|
aee3baf4ce | ||
|
|
c73c954e46 | ||
|
|
371938199e | ||
|
|
c047cf136c | ||
|
|
f4287ecc81 | ||
|
|
364a1e737f | ||
|
|
45a977bb33 | ||
|
|
ab00c907e7 | ||
|
|
979abb2b93 | ||
|
|
056360b050 | ||
|
|
960fce505c | ||
|
|
ea597ff45a | ||
|
|
f35dce7eb3 | ||
|
|
ef224bd2b8 | ||
|
|
0749f49b6c | ||
|
|
5c508efaa9 | ||
|
|
dbafe039d8 | ||
|
|
b36ee22925 | ||
|
|
287ee7b0b5 | ||
|
|
5f67621477 | ||
|
|
f237e7a8c3 | ||
|
|
a54420de36 | ||
|
|
65dbdc8eb0 | ||
|
|
d42979f620 | ||
|
|
ac56afc99c | ||
|
|
81b7bfe4ea | ||
|
|
4cbcf64ce1 | ||
|
|
29b763a0c3 | ||
|
|
52f41a4448 | ||
|
|
597409e2f2 | ||
|
|
21fbd72585 | ||
|
|
83a09f7584 | ||
|
|
0e864fbe6e | ||
|
|
2fd8900c01 |
No files matched your search
@@ -0,0 +1,28 @@
|
||||
name: Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ '1.21.3' ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
|
||||
with:
|
||||
java: 21
|
||||
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 }}
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
name: Upload payload
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/upload-artifact@v3 # Payload artifact is consumed in Actionable
|
||||
- uses: actions/upload-artifact@v4 # Payload artifact is consumed in Actionable
|
||||
with:
|
||||
name: payload
|
||||
path: ${{ github.event_path }}
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
name: Upload payload
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/upload-artifact@v3 # Payload artifact is consumed in Actionable
|
||||
- uses: actions/upload-artifact@v4 # Payload artifact is consumed in Actionable
|
||||
with:
|
||||
name: payload
|
||||
path: ${{ github.event_path }}
|
||||
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", "21", 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", "8.7", 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.21.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()
|
||||
}
|
||||
})
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
Minecraft Forge: Credits/Thank You
|
||||
|
||||
Forge is a set of tools and modifications to the Minecraft base game code to assist
|
||||
mod developers in creating new and exciting content. It has been in development for
|
||||
several years now, but I would like to take this time thank a few people who have
|
||||
helped it along its way.
|
||||
|
||||
First, the people who originally created the Forge projects way back in Minecraft
|
||||
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
|
||||
of me taking over the project, who knows what Minecraft modding would be today.
|
||||
|
||||
Secondly, someone who has worked with me, and developed some of the core features
|
||||
that allow modding to be as functional, and as simple as it is, cpw. For developing
|
||||
FML, which stabilized the client and server modding ecosystem. As well as the base
|
||||
loading system that allows us to modify Minecraft's code as elegently as possible.
|
||||
|
||||
Mezz, who has stepped up as the issue and pull request manager. Helping to keep me
|
||||
sane as well as guiding the community into creating better additions to Forge.
|
||||
|
||||
Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
|
||||
I am a part}. For creating some of the core tools needed to make Minecraft modding
|
||||
both possible, and as stable as can be.
|
||||
On that note, here is some specific information of the MCP data we use:
|
||||
* Minecraft Coder Pack (MCP) *
|
||||
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
|
||||
download components of MCP and distribute MCP data files. This permission is not
|
||||
transitive and others wishing to redistribute the Minecraft Forge source independently
|
||||
should seek permission of MCP or remove the MCP data files and request their users
|
||||
to download MCP separately.
|
||||
|
||||
And lastly, the countless community members who have spent time submitting bug reports,
|
||||
pull requests, and just helping out the community in general. Thank you.
|
||||
|
||||
--LexManos
|
||||
|
||||
=========================================================================
|
||||
|
||||
This is Forge Mod Loader.
|
||||
|
||||
You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml
|
||||
|
||||
This minecraft mod is a clean open source implementation of a mod loader for minecraft servers
|
||||
and minecraft clients.
|
||||
|
||||
The code is authored by cpw.
|
||||
|
||||
It began by partially implementing an API defined by the client side ModLoader, authored by Risugami.
|
||||
https://www.minecraftforum.net/topic/75440-
|
||||
This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader.
|
||||
|
||||
It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge.
|
||||
https://minecraftforge.net/
|
||||
|
||||
Additionally, it contains an implementation of topological sort based on that
|
||||
published at http://keithschwarz.com/interesting/code/?dir=topological-sort
|
||||
|
||||
It also contains code from the Maven project for performing versioned dependency
|
||||
resolution. http://maven.apache.org/
|
||||
|
||||
It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/
|
||||
with credit to it's authors.
|
||||
|
||||
Forge Mod Loader downloads components from the Minecraft Coder Pack
|
||||
(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team.
|
||||
|
||||
@@ -4,9 +4,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.ow2.asm:asm:9.7'
|
||||
implementation 'org.ow2.asm:asm-tree:9.7'
|
||||
implementation 'net.minecraftforge:srgutils:0.5.10'
|
||||
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.7.0.202309050840-r'
|
||||
|
||||
@@ -21,6 +21,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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-3
@@ -3,6 +3,7 @@ package net.minecraftforge.forge.tasks
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.tree.ClassNode
|
||||
import org.objectweb.asm.tree.MethodNode
|
||||
|
||||
@@ -12,13 +13,19 @@ abstract class BytecodePredicateFinder extends BytecodeFinder {
|
||||
@Internal
|
||||
abstract Property<Closure<Boolean>> getPredicate()
|
||||
|
||||
private final Set<String> matches = new HashSet<>()
|
||||
private final Map<String, List<String>> matches = new TreeMap<>(Comparator.naturalOrder())
|
||||
|
||||
@Override
|
||||
protected process(ClassNode parent, MethodNode node) {
|
||||
for (final current : node.instructions) {
|
||||
if (predicate.get().call(parent, node, current)) {
|
||||
matches.add(parent.name)
|
||||
var methods = matches.compute(parent.name, { k, v -> v ?: new ArrayList<>() })
|
||||
|
||||
// only add non-synthetic methods
|
||||
if ((node.access & Opcodes.ACC_SYNTHETIC) == 0) {
|
||||
methods.add(node.name + node.desc)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -27,6 +34,15 @@ 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.')}()
|
||||
var array = new ArrayList<Object>()
|
||||
matches.forEach { c, m ->
|
||||
{
|
||||
array.add(
|
||||
'class': c,
|
||||
'methods': m
|
||||
)
|
||||
}
|
||||
}
|
||||
return array ?: { throw new RuntimeException('Failed to find any targets, please ensure that method names and descriptors are correct.') }()
|
||||
}
|
||||
}
|
||||
+16
-9
@@ -79,7 +79,6 @@ final String SPEC_VERSION = gradleutils.gitInfo.tag
|
||||
final def MCP_ARTIFACT = project(':mcp').mcp.config.get()
|
||||
|
||||
final List<File> EXTRA_TXTS = [
|
||||
rootProject.file('CREDITS.txt'),
|
||||
rootProject.file('LICENSE.txt'),
|
||||
rootProject.tasks.createChangelog.outputFile
|
||||
]
|
||||
@@ -118,7 +117,7 @@ dependencies {
|
||||
bootstrap(libs.unsafe) // Needed by securemodules
|
||||
bootstrap(libs.bundles.asm) // Needed by securemodules
|
||||
|
||||
implementation(libs.jopt.simple) { version { strictly '5.0.4' } }
|
||||
implementation(libs.jopt.simple)
|
||||
|
||||
installer(libs.bootstrap)
|
||||
installer(libs.bootstrap.api) // Needed by securemodules
|
||||
@@ -381,13 +380,13 @@ tasks.register('extractInheritance', ExtractInheritance) {
|
||||
}
|
||||
}
|
||||
tasks.register("findFinalizeSpawnTargets", BytecodePredicateFinder) {
|
||||
jar = createJoinedSRG.output
|
||||
jar = createClientOfficial.output
|
||||
output = rootProject.file('src/main/resources/coremods/finalize_spawn_targets.json')
|
||||
predicate = {
|
||||
parent, node, insn ->
|
||||
return 'net/minecraft/world/level/BaseSpawner' != parent.name // Ignore this class as we special case it.
|
||||
&& insn.getOpcode().equals(Opcodes.INVOKEVIRTUAL)
|
||||
&& insn.name == 'm_6518_'
|
||||
&& insn.name == 'finalizeSpawn'
|
||||
&& insn.desc == '(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/DifficultyInstance;Lnet/minecraft/world/entity/EntitySpawnReason;Lnet/minecraft/world/entity/SpawnGroupData;)Lnet/minecraft/world/entity/SpawnGroupData;';
|
||||
}
|
||||
}
|
||||
@@ -893,23 +892,31 @@ tasks.register('installerJar', InstallerJar) {
|
||||
jarSigner.sign(it)
|
||||
}
|
||||
|
||||
final mdkGradleWrapper = tasks.register('mdkGradleWrapper', Wrapper) {
|
||||
gradleVersion = '9.3.1'
|
||||
}
|
||||
|
||||
tasks.register('mdkZip', Zip) {
|
||||
dependsOn mdkGradleWrapper
|
||||
|
||||
archiveBaseName = project.name
|
||||
archiveClassifier = 'mdk'
|
||||
archiveVersion = project.version
|
||||
destinationDirectory = file('build/libs')
|
||||
|
||||
from rootProject.file('gradlew')
|
||||
from rootProject.file('gradlew.bat')
|
||||
from mdkGradleWrapper.map(Wrapper.&getScriptFile)
|
||||
from mdkGradleWrapper.map(Wrapper.&getBatchScript)
|
||||
from(EXTRA_TXTS)
|
||||
from(rootProject.file('gradle/')){
|
||||
into('gradle/')
|
||||
into('gradle/wrapper/') {
|
||||
from mdkGradleWrapper.map(Wrapper.&getJarFile)
|
||||
from mdkGradleWrapper.map(Wrapper.&getPropertiesFile)
|
||||
}
|
||||
from(rootProject.file('mdk/')){
|
||||
rootProject.file('mdk/gitignore.txt').eachLine{
|
||||
rootProject.file('mdk/gitignore.txt').eachLine {
|
||||
if (!it.trim().isEmpty() && !it.trim().startsWith('#'))
|
||||
exclude it
|
||||
}
|
||||
|
||||
filter(ReplaceTokens, tokens: [
|
||||
FORGE_VERSION: FORGE_VERSION,
|
||||
FORGE_GROUP: project.group,
|
||||
|
||||
+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/
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
for file in $(find repo | grep --invert-match -e md5 -e sha | grep -e .jar -e .zip); do
|
||||
file_path=$(realpath $file)
|
||||
file_name=$(basename $file)
|
||||
|
||||
echo "$file_name"
|
||||
files=$(unzip -l $file | awk '{print $4}')
|
||||
for f in $files; do
|
||||
out="_actual/$file_name/$f"
|
||||
parent=$(dirname "$out")
|
||||
echo $out
|
||||
|
||||
if [ ! -d "$parent" ]; then
|
||||
mkdir -p "$parent"
|
||||
fi
|
||||
|
||||
if [[ $f == *.class ]]; then
|
||||
javap -v -p jar:file://$file_path!/$f | tail -n +4 >$out.txt
|
||||
elif [[ $f != */ && $f != "Name" && $f != "----" ]]; then
|
||||
unzip -o -q $file $f -d _actual/$file_name
|
||||
fi
|
||||
done
|
||||
done
|
||||
@@ -14,6 +14,7 @@ import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -25,9 +26,66 @@ import static net.minecraftforge.fml.config.ConfigTracker.CONFIG;
|
||||
|
||||
public class ConfigFileTypeHandler {
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
static final ConfigFileTypeHandler TOML = new ConfigFileTypeHandler();
|
||||
private static final Path defaultConfigPath = FMLPaths.GAMEDIR.get().resolve(FMLConfig.getConfigValue(FMLConfig.ConfigValue.DEFAULT_CONFIG_PATH));
|
||||
|
||||
private static final ConfigFileTypeHandler CLIENT = new ConfigFileTypeHandler(ModConfig.Type.CLIENT);
|
||||
private static final ConfigFileTypeHandler COMMON = new ConfigFileTypeHandler(ModConfig.Type.COMMON);
|
||||
private static final ConfigFileTypeHandler SERVER = new ConfigFileTypeHandler(ModConfig.Type.SERVER);
|
||||
|
||||
private final @Nullable ModConfig.Type type;
|
||||
private @Nullable FileWatcher watcher;
|
||||
|
||||
// exists for bin compat
|
||||
public ConfigFileTypeHandler() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
private ConfigFileTypeHandler(@Nullable ModConfig.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler for the given {@link ModConfig.Type}.
|
||||
*
|
||||
* @param type The type to get the handler for
|
||||
* @return The handler
|
||||
*/
|
||||
static ConfigFileTypeHandler get(ModConfig.Type type) {
|
||||
return switch (type) {
|
||||
case CLIENT -> CLIENT;
|
||||
case COMMON -> COMMON;
|
||||
case SERVER -> SERVER;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link FileWatcher} for this handler, creating it if it doesn't exist and/or has been stopped.
|
||||
*
|
||||
* @return The watcher
|
||||
*
|
||||
* @apiNote This is package-private so modders can't just call {@link FileWatcher#stop()} and fuck up everything.
|
||||
*/
|
||||
FileWatcher getWatcher() {
|
||||
if (this.watcher == null) {
|
||||
LOGGER.debug(CONFIG, "Starting watcher for handler: {}", this);
|
||||
this.watcher = new FileWatcher();
|
||||
}
|
||||
|
||||
return this.watcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the {@link FileWatcher} for this handler, and sets it to null afterward. Use this instead of
|
||||
* {@link FileWatcher#stop()}.
|
||||
*/
|
||||
void stopWatcher() {
|
||||
if (this.watcher == null) return;
|
||||
|
||||
LOGGER.debug(CONFIG, "Stopping watcher for hander: {}", this);
|
||||
this.watcher.stop();
|
||||
this.watcher = null;
|
||||
}
|
||||
|
||||
public Function<ModConfig, CommentedFileConfig> reader(Path configBasePath) {
|
||||
return (c) -> {
|
||||
final Path configPath = configBasePath.resolve(c.getFileName());
|
||||
@@ -37,7 +95,7 @@ public class ConfigFileTypeHandler {
|
||||
onFileNotFound((newfile, configFormat)-> setupConfigFile(c, newfile, configFormat)).
|
||||
writingMode(WritingMode.REPLACE).
|
||||
build();
|
||||
LOGGER.debug(CONFIG, "Built TOML config for {}", configPath.toString());
|
||||
LOGGER.debug(CONFIG, "Built TOML config for {}", configPath);
|
||||
try
|
||||
{
|
||||
configData.load();
|
||||
@@ -46,9 +104,9 @@ public class ConfigFileTypeHandler {
|
||||
{
|
||||
throw new ConfigLoadingException(c, ex);
|
||||
}
|
||||
LOGGER.debug(CONFIG, "Loaded TOML config file {}", configPath.toString());
|
||||
FileWatcher.defaultInstance().addWatch(configPath, new ConfigWatcher(c, configData, Thread.currentThread().getContextClassLoader()));
|
||||
LOGGER.debug(CONFIG, "Watching TOML config file {} for changes", configPath.toString());
|
||||
LOGGER.debug(CONFIG, "Loaded TOML config file {}", configPath);
|
||||
this.getWatcher().addWatch(configPath, new ConfigWatcher(c, configData, Thread.currentThread().getContextClassLoader()));
|
||||
LOGGER.debug(CONFIG, "Watching TOML config file {} for changes", configPath);
|
||||
return configData;
|
||||
};
|
||||
}
|
||||
@@ -56,9 +114,9 @@ public class ConfigFileTypeHandler {
|
||||
public void unload(Path configBasePath, ModConfig config) {
|
||||
Path configPath = configBasePath.resolve(config.getFileName());
|
||||
try {
|
||||
FileWatcher.defaultInstance().removeWatch(configBasePath.resolve(config.getFileName()));
|
||||
this.getWatcher().removeWatch(configPath);
|
||||
} catch (RuntimeException e) {
|
||||
LOGGER.error("Failed to remove config {} from tracker!", configPath.toString(), e);
|
||||
LOGGER.error("Failed to remove config {} from tracker!", configPath, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +167,11 @@ public class ConfigFileTypeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigFileTypeHandler[" + (type != null ? type : "UNKNOWN") + "]";
|
||||
}
|
||||
|
||||
private record ConfigWatcher(
|
||||
ModConfig modConfig,
|
||||
CommentedFileConfig commentedFileConfig,
|
||||
|
||||
@@ -8,6 +8,9 @@ package net.minecraftforge.fml.config;
|
||||
import com.electronwill.nightconfig.core.CommentedConfig;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
@@ -52,11 +55,24 @@ public class ConfigTracker {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: [FML] This is only called for the server (outside of forceUnload)
|
||||
// rethink config implementation for eventual FML rewrite
|
||||
public void unloadConfigs(ModConfig.Type type, Path configBasePath) {
|
||||
LOGGER.debug(CONFIG, "Unloading configs type {}", type);
|
||||
for (ModConfig config : this.configSets.get(type)) {
|
||||
closeConfig(config, configBasePath);
|
||||
}
|
||||
ConfigFileTypeHandler.get(type).stopWatcher();
|
||||
}
|
||||
|
||||
// If there is a better way to do this, please tell me. Because this is FUCKED
|
||||
public void forceUnload() {
|
||||
// This is how ModStateProvider handles loading configs. So we're doing the same but with unloadConfigs instead
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> this.unloadConfigs(ModConfig.Type.CLIENT, FMLPaths.CONFIGDIR.get()));
|
||||
this.unloadConfigs(ModConfig.Type.COMMON, FMLPaths.CONFIGDIR.get());
|
||||
|
||||
// just in case server watcher is still alive somehow...
|
||||
ConfigFileTypeHandler.get(ModConfig.Type.SERVER).stopWatcher();
|
||||
}
|
||||
|
||||
private static void openConfig(final ModConfig config, final Path configBasePath) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ModConfig
|
||||
this.spec = spec;
|
||||
this.fileName = fileName;
|
||||
this.container = container;
|
||||
this.configHandler = ConfigFileTypeHandler.TOML;
|
||||
this.configHandler = ConfigFileTypeHandler.get(type);
|
||||
ConfigTracker.INSTANCE.trackConfig(this);
|
||||
}
|
||||
|
||||
|
||||
+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() {
|
||||
|
||||
+8
-1
@@ -50,7 +50,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
|
||||
|
||||
+24
-3
@@ -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,6 +36,9 @@ 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.toUnmodifiableMap(VanillaObjectHolderData::holderClass, Function.identity()));
|
||||
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;
|
||||
|
||||
@@ -47,9 +51,26 @@ 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 static boolean hasHolder(List<AnnotationNode> lst) {
|
||||
|
||||
@@ -48,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
|
||||
@@ -59,15 +65,14 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
|
||||
if ((classNode.access & Opcodes.ACC_ENUM) == 0)
|
||||
return ComputeFlags.NO_REWRITE;
|
||||
|
||||
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);
|
||||
|
||||
if (!classNode.interfaces.contains(MARKER_IFACE.getInternalName())) {
|
||||
return ComputeFlags.NO_REWRITE;
|
||||
}
|
||||
|
||||
//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"))
|
||||
|
||||
@@ -27,7 +27,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;
|
||||
@@ -203,7 +203,18 @@ public class RuntimeDistCleaner 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/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 {
|
||||
|
||||
+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) {
|
||||
|
||||
@@ -46,7 +46,7 @@ record Scanner(ModFile fileToScan, ModFileScanData result) {
|
||||
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.7-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" \
|
||||
|
||||
Vendored
+10
-10
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
+29
-182
@@ -1,215 +1,62 @@
|
||||
// This is a minimal setup of a Forge mod workspace.
|
||||
// For complex examples (including AccessTransformers, Jar-in-Jar, and Mixin), see our examples repository.
|
||||
// https://github.com/MinecraftForge/MDKExamples
|
||||
|
||||
plugins {
|
||||
id 'eclipse'
|
||||
id 'java'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
||||
id 'eclipse'
|
||||
id 'net.minecraftforge.gradle' version '[7.0.3,8)'
|
||||
}
|
||||
|
||||
version = mod_version
|
||||
group = mod_group_id
|
||||
|
||||
base {
|
||||
archivesName = mod_id
|
||||
}
|
||||
version = '1.0.0'
|
||||
group = 'com.example.examplemod'
|
||||
|
||||
// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
|
||||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||
// Include generated resources
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time and must be in the following format.
|
||||
// Channel: Version:
|
||||
// official MCVersion Official field/method names from Mojang mapping files
|
||||
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
|
||||
//
|
||||
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
//
|
||||
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
|
||||
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
|
||||
//
|
||||
// Use non-default mappings at your own risk. They may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: mapping_channel, version: mapping_version
|
||||
|
||||
// Tell FG to not automtically create the reobf tasks, as we now use Official mappings at runtime, If you don't use them at dev time then you'll have to fix your reobf yourself.
|
||||
reobf = false
|
||||
mappings channel: 'official', version: '@MC_VERSION@'
|
||||
|
||||
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
|
||||
// In most cases, it is not necessary to enable.
|
||||
// enableEclipsePrepareRuns = true
|
||||
// enableIdeaPrepareRuns = true
|
||||
|
||||
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
||||
// It is REQUIRED to be set to true for this template to function.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
copyIdeResources = true
|
||||
|
||||
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||
// The folder name can be set on a run configuration using the "folderName" property.
|
||||
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||
// generateRunFolders = true
|
||||
|
||||
// This property enables access transformers for use in development.
|
||||
// They will be applied to the Minecraft artifact.
|
||||
// The access transformer file can be anywhere in the project.
|
||||
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
|
||||
// This default location is a best practice to automatically put the file in the right place in the final jar.
|
||||
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
// applies to all the run configs below
|
||||
configureEach {
|
||||
workingDirectory project.file('run')
|
||||
workingDir = layout.projectDirectory.dir('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be added/remove as needed separated by commas.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
systemProperty 'forge.enabledGameTestNamespaces', 'examplemod'
|
||||
}
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
register('client')
|
||||
|
||||
server {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
register('server') {
|
||||
args '--nogui'
|
||||
}
|
||||
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// By default, the server will crash when no gametests are provided.
|
||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||
gameTestServer {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
register('gameTestServer')
|
||||
|
||||
data {
|
||||
// example of overriding the workingDirectory set in configureEach above
|
||||
workingDirectory project.file('run-data')
|
||||
register('data') {
|
||||
workingDir = layout.projectDirectory.dir('run-data')
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
args '--mod', 'examplemod', '--all', '--output', layout.projectDirectory.dir('src/generated/resources'), '--existing', layout.projectDirectory.dir('src/main/resources')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
repositories {
|
||||
// Put repositories for dependencies here
|
||||
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
|
||||
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
|
||||
// flatDir {
|
||||
// dir 'libs'
|
||||
// }
|
||||
minecraft.mavenizer(it) // In Kotlin, it = this
|
||||
maven fg.forgeMaven
|
||||
maven fg.minecraftLibsMaven
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use.
|
||||
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
|
||||
// The "userdev" classifier will be requested and setup by ForgeGradle.
|
||||
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
|
||||
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
// Example mod dependency with JEI
|
||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
|
||||
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
|
||||
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
|
||||
|
||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||
// The group id is ignored when searching -- in this case, it is "blank"
|
||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||
|
||||
// For more info:
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
// Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+
|
||||
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
||||
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
tasks.named('processResources', ProcessResources).configure {
|
||||
var replaceProperties = [
|
||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version: forge_version, forge_version_range: forge_version_range,
|
||||
loader_version_range: loader_version_range,
|
||||
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||
mod_authors: mod_authors, mod_description: mod_description,
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
'Specification-Title' : mod_id,
|
||||
'Specification-Vendor' : mod_authors,
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_authors
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
// Example configuration to allow publishing using the maven-publish plugin
|
||||
publishing {
|
||||
publications {
|
||||
register('mavenJava', MavenPublication) {
|
||||
artifact jar
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://${project.projectDir}/mcmodsrepo"
|
||||
}
|
||||
}
|
||||
implementation minecraft.dependency('net.minecraftforge:forge:@MC_VERSION@-@FORGE_VERSION@')
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
eclipse {
|
||||
// Run everytime eclipse builds the code
|
||||
//autoBuildTasks genEclipseRuns
|
||||
// Run when importing the project
|
||||
synchronizationTasks 'genEclipseRuns'
|
||||
}
|
||||
|
||||
// Merge the resources and classes into the same directory.
|
||||
// This is done because java expects modules to be in a single directory.
|
||||
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
|
||||
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
|
||||
sourceSets.each {
|
||||
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
|
||||
it.output.resourcesDir = dir
|
||||
it.java.destinationDirectory = dir
|
||||
// Use the UTF-8 charset for Java compilation
|
||||
// This is done by default in Java 18+, but this ensures it no matter the Java or Gradle version
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
|
||||
Source installation information for modders
|
||||
-------------------------------------------
|
||||
This code follows the Minecraft Forge installation methodology. It will apply
|
||||
some small patches to the vanilla MCP source code, giving you and it access
|
||||
some small patches to the vanilla MCP source code, giving you and it access
|
||||
to some of the data and functions you need to build a successful mod.
|
||||
|
||||
Note also that the patches are built against "un-renamed" MCP source code (aka
|
||||
SRG Names) - this means that you will not be able to read them directly against
|
||||
normal code.
|
||||
Please note that this example MDK is a simple showcase for the most basic of mods.
|
||||
To see more examples see our dedicated examples repository under the "Additional Resources" section.
|
||||
|
||||
Setup Process:
|
||||
==============================
|
||||
@@ -17,30 +15,22 @@ Step 1: Open your command-line and browse to the folder where you extracted the
|
||||
Step 2: You're left with a choice.
|
||||
If you prefer to use Eclipse:
|
||||
1. Run the following command: `./gradlew genEclipseRuns`
|
||||
2. Open Eclipse, Import > Existing Gradle Project > Select Folder
|
||||
2. Open Eclipse, Import > Existing Gradle Project > Select Folder
|
||||
or run `gradlew eclipse` to generate the project.
|
||||
|
||||
If you prefer to use IntelliJ:
|
||||
1. Open IDEA, and import project.
|
||||
2. Select your build.gradle file and have it import.
|
||||
3. Run the following command: `./gradlew genIntellijRuns`
|
||||
4. Refresh the Gradle Project in IDEA if required.
|
||||
3. Use the run tasks located under the "Slime Launcher" Gradle task group.
|
||||
|
||||
If at any point you are missing libraries in your IDE, or you've run into problems you can
|
||||
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
|
||||
(this does not affect your code) and then start the process again.
|
||||
|
||||
Mapping Names:
|
||||
=============================
|
||||
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
|
||||
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
|
||||
license, if you do not agree with it you can change your mapping names to other crowdsourced names in your
|
||||
build.gradle. For the latest license text, refer to the mapping file itself, or the reference copy here:
|
||||
https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
|
||||
Additional Resources:
|
||||
=========================
|
||||
Community Documentation: https://docs.minecraftforge.net/en/latest/gettingstarted/
|
||||
Additional Examples: https://github.com/MinecraftForge/MDKExamples
|
||||
LexManos' Install Video: https://youtu.be/8VEdtQLuLO0
|
||||
Forge Forums: https://forums.minecraftforge.net/
|
||||
Forge Discord: https://discord.minecraftforge.net/
|
||||
@@ -22,4 +22,5 @@ eclipse
|
||||
run
|
||||
|
||||
# Files from Forge MDK
|
||||
forge_README.txt
|
||||
forge*changelog.txt
|
||||
+7
-57
@@ -1,59 +1,9 @@
|
||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
org.gradle.caching=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.configureondemand=true
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.configuration-cache.parallel=true
|
||||
org.gradle.configuration-cache.problems=warn
|
||||
|
||||
## Environment Properties
|
||||
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=@MC_VERSION@
|
||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||
# as they do not follow standard versioning conventions.
|
||||
minecraft_version_range=[@MC_VERSION@,@MC_NEXT_VERSION@)
|
||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||
forge_version=@FORGE_VERSION@
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[@FORGE_SPEC_VERSION@,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[@FORGE_SPEC_VERSION@,)
|
||||
# The mapping channel to use for mappings.
|
||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||
#
|
||||
# | Channel | Version | |
|
||||
# |-----------|----------------------|--------------------------------------------------------------------------------|
|
||||
# | official | MCVersion | Official field/method names from Mojang mapping files |
|
||||
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
|
||||
#
|
||||
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
#
|
||||
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
|
||||
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||
mapping_channel=@MAPPING_CHANNEL@
|
||||
# The mapping version to query from the mapping channel.
|
||||
# This must match the format required by the mapping channel.
|
||||
mapping_version=@MAPPING_VERSION@
|
||||
|
||||
|
||||
## Mod Properties
|
||||
|
||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||
mod_id=examplemod
|
||||
# The human-readable display name for the mod.
|
||||
mod_name=Example Mod
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=All Rights Reserved
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.0.0
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
mod_group_id=com.example.examplemod
|
||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||
mod_authors=YourNameHere, OtherNameHere
|
||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.
|
||||
net.minecraftforge.gradle.merge-source-sets=true
|
||||
+3
-11
@@ -1,13 +1,5 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'MinecraftForge'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||
}
|
||||
rootProject.name = 'examplemod'
|
||||
@@ -1,73 +1,37 @@
|
||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license="${mod_license}"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN),
|
||||
# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers.
|
||||
#clientSideOnly=true #optional - defaults to false if absent
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="${mod_id}" #mandatory
|
||||
# The version number of the mod
|
||||
version="${mod_version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
#logoFile="examplemod.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
#credits="" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="${mod_authors}" #optional
|
||||
# Display Test controls the display for your mod in the server connection screen
|
||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||
# 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)
|
||||
# See https://docs.minecraftforge.net/en/1.21.x/gettingstarted/modfiles/#modstoml
|
||||
# There are lots of things you can do with the mods.toml, and not all fields are included with this MDK
|
||||
# References: https://github.com/MinecraftForge/MDKExamples
|
||||
|
||||
# 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.
|
||||
[[dependencies.${mod_id}]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
modLoader="javafml"
|
||||
loaderVersion="[@FORGE_SPEC_VERSION@,)"
|
||||
license="All Rights Reserved"
|
||||
#issueTrackerURL="https://github.com/MyOrganization/MyMod/" #optional
|
||||
#clientSideOnly=true #optional, default=false
|
||||
|
||||
[[mods]]
|
||||
modId="examplemod"
|
||||
version="1.0.0"
|
||||
displayName="Example Mod"
|
||||
#updateJSONURL="https://example.com/updates.json" #optional
|
||||
#displayURL="https://example.com/" #optional
|
||||
#logoFile="examplemod.png" #optional
|
||||
#credits="" #optional
|
||||
authors="YourNameHere, OtherNameHere" #optional
|
||||
#displayTest="MATCH_VERSION" #optional, default=MATCH_VERSION when not clientSideOnly, else IGNORE_ALL_VERSION
|
||||
|
||||
description='''Example mod description.
|
||||
Newline characters can be used like this, and rendered on the mods screen properly.'''
|
||||
|
||||
[[dependencies.examplemod]] #recommended
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[@FORGE_SPEC_VERSION@,)"
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||
side="BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.${mod_id}]]
|
||||
|
||||
[[dependencies.examplemod]] #recommended
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="${minecraft_version_range}"
|
||||
versionRange="[@MC_VERSION@,@MC_NEXT_VERSION@,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
||||
# stop your mod loading on the server for example.
|
||||
#[features.${mod_id}]
|
||||
#openGLVersion="[3.2,)"
|
||||
@@ -145,6 +145,14 @@
|
||||
this.screen = p_91153_;
|
||||
if (this.screen != null) {
|
||||
this.screen.added();
|
||||
@@ -1146,6 +_,7 @@
|
||||
|
||||
FreeTypeUtil.destroy();
|
||||
Util.shutdownExecutors();
|
||||
+ net.minecraftforge.fml.config.ConfigTracker.INSTANCE.forceUnload();
|
||||
} catch (Throwable throwable) {
|
||||
LOGGER.error("Shutdown failure!", throwable);
|
||||
throw throwable;
|
||||
@@ -1215,9 +_,11 @@
|
||||
this.mouseHandler.handleAccumulatedMovement();
|
||||
profilerfiller.pop();
|
||||
|
||||
@@ -9,6 +9,40 @@
|
||||
private final SubtitleOverlay subtitleOverlay;
|
||||
private final SpectatorGui spectatorGui;
|
||||
private final PlayerTabOverlay tabList;
|
||||
@@ -167,7 +_,7 @@
|
||||
private int lastBubblePopSoundPlayed;
|
||||
private float autosaveIndicatorValue;
|
||||
private float lastAutosaveIndicatorValue;
|
||||
- private final LayeredDraw layers = new LayeredDraw();
|
||||
+ private final LayeredDraw layers = new net.minecraftforge.client.gui.overlay.ForgeLayeredDraw(net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.VANILLA_ROOT, net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.COMBINE_LIST);
|
||||
private float scopeScale;
|
||||
|
||||
public Gui(Minecraft p_330021_) {
|
||||
@@ -179,14 +_,14 @@
|
||||
this.bossOverlay = new BossHealthOverlay(p_330021_);
|
||||
this.subtitleOverlay = new SubtitleOverlay(p_330021_);
|
||||
this.resetTitleTimes();
|
||||
- LayeredDraw layereddraw = new LayeredDraw()
|
||||
+ LayeredDraw layereddraw = new net.minecraftforge.client.gui.overlay.ForgeLayeredDraw(net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.PRE_SLEEP_STACK, net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.PRE_LIST)
|
||||
.add(this::renderCameraOverlays)
|
||||
.add(this::renderCrosshair)
|
||||
.add(this::renderHotbarAndDecorations)
|
||||
.add(this::renderExperienceLevel)
|
||||
.add(this::renderEffects)
|
||||
.add((p_325313_, p_342678_) -> this.bossOverlay.render(p_325313_));
|
||||
- LayeredDraw layereddraw1 = new LayeredDraw()
|
||||
+ LayeredDraw layereddraw1 = new net.minecraftforge.client.gui.overlay.ForgeLayeredDraw(net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.POST_SLEEP_STACK,net.minecraftforge.client.gui.overlay.ForgeLayeredDraw.POST_LIST)
|
||||
.add(this::renderDemoOverlay)
|
||||
.add((p_325315_, p_344521_) -> {
|
||||
if (this.debugOverlay.showDebugScreen()) {
|
||||
@@ -203,6 +_,7 @@
|
||||
.add(layereddraw, () -> !p_330021_.options.hideGui)
|
||||
.add(this::renderSleepOverlay)
|
||||
.add(layereddraw1, () -> !p_330021_.options.hideGui);
|
||||
+ ((net.minecraftforge.client.gui.overlay.ForgeLayeredDraw) layers).resolveLayers();
|
||||
}
|
||||
|
||||
public void resetTitleTimes() {
|
||||
@@ -345,7 +_,7 @@
|
||||
Window window = this.minecraft.getWindow();
|
||||
int i = Mth.floor(this.minecraft.mouseHandler.xpos() * (double)window.getGuiScaledWidth() / (double)window.getScreenWidth());
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ /** @deprecated Forge: Use {@link net.minecraftforge.client.RenderTypeHelper#getEntityRenderType(RenderType, boolean)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)}. */
|
||||
+ /** @deprecated Forge: Use {@link net.minecraftforge.client.RenderTypeHelper#getEntityRenderType(RenderType)} while iterating through {@link net.minecraft.client.resources.model.BakedModel#getRenderTypes(BlockState, net.minecraft.util.RandomSource, net.minecraftforge.client.model.data.ModelData)}. */
|
||||
+ @Deprecated // Note: this method does NOT support model-based render types
|
||||
public static RenderType getRenderType(BlockState p_364446_) {
|
||||
RenderType rendertype = getChunkRenderType(p_364446_);
|
||||
return rendertype == RenderType.translucent() ? Sheets.translucentItemSheet() : Sheets.cutoutBlockSheet();
|
||||
@@ -385,12 +_,77 @@
|
||||
@@ -385,12 +_,82 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@
|
||||
renderCutout = p_109292_;
|
||||
+ }
|
||||
+
|
||||
+ /** 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());
|
||||
+ private static final Map<net.minecraft.core.Holder.Reference<Block>, net.minecraftforge.client.ChunkRenderTypeSet> BLOCK_RENDER_TYPES = Util.make(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(TYPE_BY_BLOCK.size(), 0.5F), map -> {
|
||||
@@ -75,7 +80,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", forRemoval = true)
|
||||
+ @Deprecated(since = "1.21.4", forRemoval = true)
|
||||
+ public static net.minecraftforge.client.ChunkRenderTypeSet getRenderLayers(BlockState state) {
|
||||
+ Block block = state.getBlock();
|
||||
+ if (block instanceof LeavesBlock) {
|
||||
@@ -86,20 +91,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", forRemoval = true)
|
||||
+ @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", forRemoval = true)
|
||||
+ @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", forRemoval = true)
|
||||
+ @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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/client/resources/model/ModelDiscovery.java
|
||||
+++ b/net/minecraft/client/resources/model/ModelDiscovery.java
|
||||
@@ -37,7 +_,8 @@
|
||||
private static Set<ModelResourceLocation> listMandatoryModels() {
|
||||
Set<ModelResourceLocation> set = new HashSet<>();
|
||||
BuiltInRegistries.ITEM.listElements().forEach(p_368638_ -> {
|
||||
- ResourceLocation resourcelocation = p_368638_.value().components().get(DataComponents.ITEM_MODEL);
|
||||
+ // Forge: Force use vanilla components without gathering mod components in the event
|
||||
+ ResourceLocation resourcelocation = p_368638_.value().vanillaComponents().get(DataComponents.ITEM_MODEL);
|
||||
if (resourcelocation != null) {
|
||||
set.add(ModelResourceLocation.inventory(resourcelocation));
|
||||
}
|
||||
+92
-23
@@ -1,74 +1,142 @@
|
||||
--- a/net/minecraft/client/resources/model/SimpleBakedModel.java
|
||||
+++ b/net/minecraft/client/resources/model/SimpleBakedModel.java
|
||||
@@ -25,6 +_,15 @@
|
||||
@@ -25,7 +_,32 @@
|
||||
protected final boolean usesBlockLight;
|
||||
protected final TextureAtlasSprite particleIcon;
|
||||
protected final ItemTransforms transforms;
|
||||
-
|
||||
+ /** 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, net.minecraftforge.client.RenderTypeGroup) variant with RenderTypeGroup} **/
|
||||
+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, 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_) {
|
||||
+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ }
|
||||
|
||||
+
|
||||
+ /** @deprecated Forge: Use {@linkplain #SimpleBakedModel(List, Map, boolean, boolean, boolean, TextureAtlasSprite, ItemTransforms, 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_, net.minecraftforge.client.RenderTypeGroup renderTypes) {
|
||||
+ this(p_119489_, p_119490_, p_119491_, p_119492_, p_119493_, p_119494_, p_119495_, 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_,
|
||||
@@ -33,7 +_,8 @@
|
||||
Map<Direction, List<BakedQuad>> p_119490_,
|
||||
@@ -33,7 +_,9 @@
|
||||
boolean p_119492_,
|
||||
boolean p_119493_,
|
||||
TextureAtlasSprite p_119494_,
|
||||
- ItemTransforms p_119495_
|
||||
+ ItemTransforms p_119495_,
|
||||
+ net.minecraftforge.client.RenderTypeGroup renderTypes
|
||||
+ net.minecraftforge.client.RenderTypeGroup renderTypes,
|
||||
+ net.minecraftforge.client.RenderTypeGroup renderTypesFast
|
||||
) {
|
||||
this.unculledFaces = p_119489_;
|
||||
this.culledFaces = p_119490_;
|
||||
@@ -42,6 +_,9 @@
|
||||
@@ -42,6 +_,15 @@
|
||||
this.usesBlockLight = p_119492_;
|
||||
this.particleIcon = p_119494_;
|
||||
this.transforms = p_119495_;
|
||||
+ 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());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,6 +_,25 @@
|
||||
@@ -79,6 +_,38 @@
|
||||
return this.transforms;
|
||||
}
|
||||
|
||||
+ 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(BlockState state, RandomSource rand, net.minecraftforge.client.model.data.ModelData data) {
|
||||
+ return blockRenderTypes != null ? blockRenderTypes : BakedModel.super.getRenderTypes(state, rand, 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;
|
||||
+ }
|
||||
+ return blockRenderTypes != null ? blockRenderTypes : BakedModel.super.getRenderTypes(state, rand, data);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<net.minecraft.client.renderer.RenderType> getRenderTypes(net.minecraft.world.item.ItemStack itemStack, boolean fabulous) {
|
||||
+ if (!fabulous) {
|
||||
+ if (itemRenderTypes != null) {
|
||||
+ return itemRenderTypes;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (fabulousItemRenderTypes != null) {
|
||||
+ return fabulousItemRenderTypes;
|
||||
+ }
|
||||
+ }
|
||||
+ return BakedModel.super.getRenderTypes(itemStack, 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;
|
||||
+ } else {
|
||||
+ if (fabulousItemRenderTypes != null)
|
||||
+ return fabulousItemRenderTypes;
|
||||
+ }
|
||||
+ return BakedModel.super.getRenderTypes(itemStack, fabulous);
|
||||
+ }
|
||||
+
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class Builder {
|
||||
private final ImmutableList.Builder<BakedQuad> unculledFaces = ImmutableList.builder();
|
||||
@@ -124,13 +_,19 @@
|
||||
@@ -124,13 +_,50 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
+ private net.minecraftforge.client.RenderTypeGroup renderTypes = net.minecraftforge.client.RenderTypeGroup.EMPTY;
|
||||
+ private net.minecraftforge.client.RenderTypeGroup renderTypesFast = net.minecraftforge.client.RenderTypeGroup.EMPTY;
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the render type to be used for this model, and 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 #renderTypes(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 #renderTypes(net.minecraftforge.client.RenderTypeGroup, net.minecraftforge.client.RenderTypeGroup)
|
||||
+ * renderTypes(RenderTypeGroup, RenderTypeGroup)
|
||||
+ */
|
||||
+ public SimpleBakedModel.Builder renderTypes(net.minecraftforge.client.RenderTypeGroup renderTypes) {
|
||||
+ return this.renderTypes(renderTypes, net.minecraftforge.client.RenderTypeGroup.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets 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 #renderTypes(net.minecraftforge.client.RenderTypeGroup)
|
||||
+ */
|
||||
+ public SimpleBakedModel.Builder renderTypes(net.minecraftforge.client.RenderTypeGroup renderTypes, net.minecraftforge.client.RenderTypeGroup renderTypesFast) {
|
||||
+ this.renderTypes = renderTypes;
|
||||
+ this.renderTypesFast = renderTypesFast;
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
@@ -79,7 +147,8 @@
|
||||
Map<Direction, List<BakedQuad>> map = Maps.transformValues(this.culledFaces, ImmutableList.Builder::build);
|
||||
return new SimpleBakedModel(
|
||||
- this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms
|
||||
+ this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.renderTypes
|
||||
+ // Forge: Account for render types in model JSONs
|
||||
+ this.unculledFaces.build(), new EnumMap<>(map), this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.renderTypes, this.renderTypesFast
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
--- a/net/minecraft/core/Direction.java
|
||||
+++ b/net/minecraft/core/Direction.java
|
||||
@@ -49,6 +_,10 @@
|
||||
@@ -49,6 +_,15 @@
|
||||
private final Vec3i normal;
|
||||
private final Vec3 normalVec3;
|
||||
private static final Direction[] VALUES = values();
|
||||
+ private static final List<Direction> VALUES_VIEW = java.util.Collections.unmodifiableList(Arrays.asList(VALUES));
|
||||
+ public static final List<Direction> valuesView() {
|
||||
+ return VALUES_VIEW;
|
||||
+ }
|
||||
+ // In vanilla updates are notified only on the horizontal plane, in Forge we also notify up and down
|
||||
+ private static final List<Direction> UPDATE_ORDER = java.util.Collections.unmodifiableList(Stream.concat(Plane.HORIZONTAL.stream(), Plane.VERTICAL.stream()).toList());
|
||||
+ public static final List<Direction> getUpdateOrder() {
|
||||
+ return UPDATE_ORDER;
|
||||
+ }
|
||||
private static final Direction[] BY_3D_DATA = Arrays.stream(VALUES)
|
||||
.sorted(Comparator.comparingInt(p_235687_ -> p_235687_.data3d))
|
||||
|
||||
@@ -9,3 +9,29 @@
|
||||
private final GameTestInfo testInfo;
|
||||
private boolean finalCheckAdded;
|
||||
|
||||
@@ -996,5 +_,25 @@
|
||||
if (either.right().isPresent()) {
|
||||
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, GameTestRunner runner) {
|
||||
+ handler.accept(true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void testFailed(GameTestInfo info, GameTestRunner runner) {
|
||||
+ handler.accept(false);
|
||||
+ }
|
||||
+
|
||||
+ @Override public void testStructureLoaded(GameTestInfo info) { }
|
||||
+ @Override public void testAddedForRerun(GameTestInfo oldInfo, GameTestInfo newInfo, GameTestRunner runner) { }
|
||||
+ });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/gametest/framework/GameTestInfo.java
|
||||
+++ b/net/minecraft/gametest/framework/GameTestInfo.java
|
||||
@@ -265,7 +_,7 @@
|
||||
BlockPos blockpos = this.getOrCalculateNorthwestCorner();
|
||||
this.structureBlockEntity = StructureUtils.prepareTestStructure(this, blockpos, this.getRotation(), this.level);
|
||||
this.structureBlockPos = this.structureBlockEntity.getBlockPos();
|
||||
- StructureUtils.addCommandBlockAndButtonToStartTest(this.structureBlockPos, new BlockPos(1, 0, -1), this.getRotation(), this.level);
|
||||
+ StructureUtils.addCommandBlockAndButtonToStartTest(this.structureBlockPos, new BlockPos(1, 0, -1), Rotation.NONE, this.level); // Forge: The control blocks are always in the North West Corner
|
||||
StructureUtils.encaseStructure(this.getStructureBounds(), this.level, !this.testFunction.skyAccess());
|
||||
this.listeners.forEach(p_127630_ -> p_127630_.testStructureLoaded(this));
|
||||
return this;
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/gametest/framework/ReportGameListener.java
|
||||
+++ b/net/minecraft/gametest/framework/ReportGameListener.java
|
||||
@@ -151,7 +_,7 @@
|
||||
private static BlockPos getBeaconPos(GameTestInfo p_344999_) {
|
||||
BlockPos blockpos = p_344999_.getStructureBlockPos();
|
||||
BlockPos blockpos1 = new BlockPos(-1, -2, -1);
|
||||
- return StructureTemplate.transform(blockpos.offset(blockpos1), Mirror.NONE, p_344999_.getRotation(), blockpos);
|
||||
+ return blockpos.offset(blockpos1); // Forge: The control blocks are always in the North West Corner
|
||||
}
|
||||
|
||||
private static void updateBeaconGlass(GameTestInfo p_343978_, Block p_344076_) {
|
||||
@@ -167,8 +_,8 @@
|
||||
ServerLevel serverlevel = p_177739_.getLevel();
|
||||
BlockPos blockpos = p_177739_.getStructureBlockPos();
|
||||
BlockPos blockpos1 = new BlockPos(-1, 0, -1);
|
||||
- BlockPos blockpos2 = StructureTemplate.transform(blockpos.offset(blockpos1), Mirror.NONE, p_177739_.getRotation(), blockpos);
|
||||
- serverlevel.setBlockAndUpdate(blockpos2, Blocks.LECTERN.defaultBlockState().rotate(p_177739_.getRotation()));
|
||||
+ BlockPos blockpos2 = blockpos.offset(blockpos1); // Forge: The control blocks are always in the North West Corner
|
||||
+ serverlevel.setBlockAndUpdate(blockpos2, Blocks.LECTERN.defaultBlockState());
|
||||
BlockState blockstate = serverlevel.getBlockState(blockpos2);
|
||||
ItemStack itemstack = createBook(p_177739_.getTestName(), p_177739_.isRequired(), p_177740_);
|
||||
LecternBlock.tryPlaceBook(null, serverlevel, blockpos2, blockstate, itemstack);
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/gametest/framework/StructureUtils.java
|
||||
+++ b/net/minecraft/gametest/framework/StructureUtils.java
|
||||
@@ -132,10 +_,16 @@
|
||||
.orElseThrow(() -> new IllegalStateException("Missing test structure: " + p_311701_.getStructureName()))
|
||||
.getSize();
|
||||
BoundingBox boundingbox = getStructureBoundingBox(p_311042_, vec3i, p_310584_);
|
||||
- BlockPos blockpos = getStartCorner(p_311701_, p_311042_, p_310584_, p_312330_);
|
||||
+ BlockPos blockpos = getStartCorner(p_311701_, p_311042_, Rotation.NONE, p_312330_); // Forge: The control blocks are always in the North West Corner
|
||||
forceLoadChunks(boundingbox, p_312330_);
|
||||
clearSpaceForStructure(boundingbox, p_312330_);
|
||||
- return createStructureBlock(p_311701_, blockpos.below(), p_310584_, p_312330_);
|
||||
+ var entity = createStructureBlock(p_311701_, blockpos.below(), p_310584_, p_312330_);
|
||||
+ //Forge: We need to offset the structure so that it will load within bounds.
|
||||
+ if (p_310584_ != Rotation.NONE) {
|
||||
+ var rotated = StructureTemplate.getZeroPositionWithTransform(BlockPos.ZERO, Mirror.NONE, p_310584_, entity.getStructureSize().getX(), entity.getStructureSize().getZ());
|
||||
+ entity.setStructurePos(rotated.offset(new BlockPos(0, 1, 0)));
|
||||
+ }
|
||||
+ return entity;
|
||||
}
|
||||
|
||||
public static void encaseStructure(AABB p_330422_, ServerLevel p_331249_, boolean p_328180_) {
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/gametest/framework/TestCommand.java
|
||||
+++ b/net/minecraft/gametest/framework/TestCommand.java
|
||||
@@ -313,7 +_,11 @@
|
||||
return Optional.empty();
|
||||
} else {
|
||||
TestFunction testfunction = optional.get();
|
||||
- GameTestInfo gametestinfo = new GameTestInfo(testfunction, structureblockentity.getRotation(), p_328153_, p_330368_);
|
||||
+ // Forge: The rotation is stored in the structure block, and added in the GameTestInfo constructor.
|
||||
+ // So reverse it to find the manually specified rotation so the test runs the same every time.
|
||||
+ var steps = StructureUtils.getRotationStepsForRotation(structureblockentity.getRotation()) - StructureUtils.getRotationStepsForRotation(testfunction.rotation());
|
||||
+ if (steps < 0) steps += 4;
|
||||
+ GameTestInfo gametestinfo = new GameTestInfo(testfunction, StructureUtils.getRotationForRotationSteps(steps), p_328153_, p_330368_);
|
||||
gametestinfo.setStructureBlockPos(p_332856_);
|
||||
return !verifyStructureExists(p_328153_, gametestinfo.getStructureName()) ? Optional.empty() : Optional.of(gametestinfo);
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
p_358539_.layers(), p_358539_.lookupWithUpdatedTags(), p_250212_, p_249301_, p_366334_, p_251126_
|
||||
);
|
||||
+ var listeners = new java.util.ArrayList<>(reloadableserverresources.listeners());
|
||||
+ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_330376_.compositeAccess()));
|
||||
+ listeners.addAll(net.minecraftforge.event.ForgeEventFactory.onResourceReload(reloadableserverresources, p_358539_.lookupWithUpdatedTags(), p_330376_.compositeAccess()));
|
||||
return SimpleReloadInstance.create(
|
||||
- p_248588_, reloadableserverresources.listeners(), p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled()
|
||||
+ p_248588_, listeners, p_249136_, p_249601_, DATA_RELOAD_INITIAL_TASK, LOGGER.isDebugEnabled()
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,6 +_,11 @@
|
||||
@@ -275,6 +_,13 @@
|
||||
if (this.queryThreadGs4 != null) {
|
||||
this.queryThreadGs4.stop();
|
||||
}
|
||||
@@ -54,6 +54,8 @@
|
||||
+ this.dediLanPinger.interrupt();
|
||||
+ this.dediLanPinger = null;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraftforge.fml.config.ConfigTracker.INSTANCE.forceUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,35 @@
|
||||
this.write(chunkpos, completablefuture::join).handle((p_358676_, p_358677_) -> {
|
||||
if (p_358677_ != null) {
|
||||
this.level.getServer().reportChunkSaveFailure(p_358677_, this.storageInfo(), chunkpos);
|
||||
@@ -934,10 +_,27 @@
|
||||
void forEachSpawnCandidateChunk(Consumer<ChunkHolder> p_364582_) {
|
||||
LongIterator longiterator = this.distanceManager.getSpawnCandidateChunks();
|
||||
|
||||
+ // FORGE: separated forEach logic into its own method
|
||||
+ this.forEachChunk(longiterator, this::anyPlayerCloseEnoughForSpawningInternal, p_364582_);
|
||||
+ }
|
||||
+
|
||||
+ /** FORGE: grab forced chunks, use forEachChunk to avoid duplicate logic */
|
||||
+ void forEachForcedChunk(Consumer<ChunkHolder> callback) {
|
||||
+ LongIterator longiterator = this.distanceManager.forcedTickets.keySet().iterator();
|
||||
+ this.forEachChunk(longiterator, pos -> true, callback);
|
||||
+ }
|
||||
+
|
||||
+ /** FORGE: check if there are any forced chunks */
|
||||
+ boolean hasForcedChunks() {
|
||||
+ return !this.distanceManager.forcedTickets.isEmpty();
|
||||
+ }
|
||||
+
|
||||
+ /** FORGE: commonize logic between forEachSpawnCandidateChunk and forEachForcedChunk */
|
||||
+ private void forEachChunk(LongIterator longiterator, java.util.function.Predicate<ChunkPos> filter, Consumer<ChunkHolder> p_364582_) {
|
||||
while (longiterator.hasNext()) {
|
||||
long i = longiterator.nextLong();
|
||||
ChunkHolder chunkholder = this.visibleChunkMap.get(i);
|
||||
- if (chunkholder != null && this.anyPlayerCloseEnoughForSpawningInternal(chunkholder.getPos())) {
|
||||
+ if (chunkholder != null && filter.test(chunkholder.getPos())) {
|
||||
p_364582_.accept(chunkholder);
|
||||
}
|
||||
}
|
||||
@@ -1102,7 +_,7 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
final Executor mainThreadExecutor;
|
||||
private long ticketTickCounter;
|
||||
private int simulationDistance = 10;
|
||||
+ private final Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> forcedTickets = new Long2ObjectOpenHashMap<>();
|
||||
+ final Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> forcedTickets = new Long2ObjectOpenHashMap<>();
|
||||
|
||||
protected DistanceManager(Executor p_140774_, Executor p_140775_) {
|
||||
TaskScheduler<Runnable> taskscheduler = TaskScheduler.wrapExecutor("player ticket throttler", p_140775_);
|
||||
@@ -44,7 +44,7 @@
|
||||
+ }
|
||||
+
|
||||
+ public <T> void addRegionTicket(TicketType<T> p_140841_, ChunkPos p_140842_, int p_140843_, T p_140844_, boolean forceTicks) {
|
||||
+ Ticket<T> ticket = new Ticket<>(p_140841_, ChunkLevel.byStatus(FullChunkStatus.FULL) - p_140843_, p_140844_, forceTicks);
|
||||
+ Ticket<T> ticket = new Ticket<>(p_140841_, ChunkLevel.byStatus(FullChunkStatus.FULL) - p_140843_, p_140844_, forceTicks);
|
||||
long i = p_140842_.toLong();
|
||||
this.addTicket(i, ticket);
|
||||
this.tickingTicketsTracker.addTicket(i, ticket);
|
||||
|
||||
@@ -11,6 +11,34 @@
|
||||
ChunkAccess chunkaccess1 = chunkholder.getChunkIfPresent(ChunkStatus.FULL);
|
||||
if (chunkaccess1 != null) {
|
||||
this.storeInCache(i, chunkaccess1, ChunkStatus.FULL);
|
||||
@@ -368,9 +_,25 @@
|
||||
}
|
||||
|
||||
private void collectTickingChunks(List<LevelChunk> p_368970_) {
|
||||
- this.chunkMap.forEachSpawnCandidateChunk(p_358696_ -> {
|
||||
+ // FORGE: If there are no forced chunks, just do the vanilla logic
|
||||
+ if (!this.chunkMap.hasForcedChunks()) {
|
||||
+ this.chunkMap.forEachSpawnCandidateChunk(this.getChunkCollector(p_368970_, chunk -> this.level.isNaturalSpawningAllowed(chunk.getPos())));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // FORGE: We have forced chunks? Ok, use a linked hash set to preserve order
|
||||
+ Set<LevelChunk> set = new java.util.LinkedHashSet<>();
|
||||
+ this.chunkMap.forEachSpawnCandidateChunk(this.getChunkCollector(set, chunk -> this.level.isNaturalSpawningAllowed(chunk.getPos())));
|
||||
+ this.chunkMap.forEachForcedChunk(this.getChunkCollector(set, chunk -> true));
|
||||
+ p_368970_.addAll(set);
|
||||
+ }
|
||||
+
|
||||
+ /** FORGE: Isolate chunk collection callback */
|
||||
+ private Consumer<ChunkHolder> getChunkCollector(java.util.Collection<LevelChunk> p_368970_, java.util.function.Predicate<LevelChunk> predicate) {
|
||||
+ return (p_358696_ -> {
|
||||
LevelChunk levelchunk = p_358696_.getTickingChunk();
|
||||
- if (levelchunk != null && this.level.isNaturalSpawningAllowed(p_358696_.getPos())) {
|
||||
+ // FORGE: Use custom predicate instead of only checking isNaturalSpawningAllowed
|
||||
+ if (levelchunk != null && predicate.test(levelchunk)) {
|
||||
p_368970_.add(levelchunk);
|
||||
}
|
||||
});
|
||||
@@ -466,11 +_,19 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
+++ b/net/minecraft/world/entity/npc/VillagerTrades.java
|
||||
@@ -1359,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_ -> !p_35672_.containsKey(p_35680_)).findAny().ifPresent(p_327046_ -> {
|
||||
throw new IllegalStateException("Missing trade for villager type: " + BuiltInRegistries.VILLAGER_TYPE.getKey(p_327046_));
|
||||
});
|
||||
@@ -1372,7 +_,9 @@
|
||||
@Override
|
||||
public MerchantOffer getOffer(Entity p_219685_, RandomSource p_219686_) {
|
||||
if (p_219685_ instanceof VillagerDataHolder villagerdataholder) {
|
||||
- ItemCost itemcost = new ItemCost(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
|
||||
+ ItemCost itemcost = new ItemCost(item, this.cost);
|
||||
return new MerchantOffer(itemcost, 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
|
||||
@@ -69,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);
|
||||
+ }
|
||||
}
|
||||
@@ -129,7 +129,7 @@
|
||||
super.blockUsingShield(p_36295_);
|
||||
ItemStack itemstack = this.getItemBlockingWith();
|
||||
- if (p_36295_.canDisableShield() && itemstack != null) {
|
||||
+ if (itemstack != null && itemstack.canDisableShield(this.useItem, this, p_36295_)) {
|
||||
+ if (itemstack != null && p_36295_.getWeaponItem().canDisableShield(itemstack, this, p_36295_)) {
|
||||
this.disableShield(itemstack);
|
||||
}
|
||||
}
|
||||
@@ -142,6 +142,19 @@
|
||||
if (!this.level().isClientSide) {
|
||||
this.awardStat(Stats.ITEM_USED.get(this.useItem.getItem()));
|
||||
}
|
||||
@@ -928,8 +_,11 @@
|
||||
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, getSlotForHand(interactionhand));
|
||||
- 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 {
|
||||
@@ -946,10 +_,13 @@
|
||||
@Override
|
||||
protected void actuallyHurt(ServerLevel p_365751_, DamageSource p_36312_, float p_36313_) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
if (optional.isEmpty()) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
@@ -115,5 +_,16 @@
|
||||
@@ -115,5 +_,21 @@
|
||||
private Optional<BlockState> getStripped(BlockState p_150691_) {
|
||||
return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock()))
|
||||
.map(p_359378_ -> p_359378_.defaultBlockState().setValue(RotatedPillarBlock.AXIS, p_150691_.getValue(RotatedPillarBlock.AXIS)));
|
||||
@@ -25,5 +25,10 @@
|
||||
+ public static BlockState getAxeStrippingState(BlockState originalState) {
|
||||
+ Block block = STRIPPABLES.get(originalState.getBlock());
|
||||
+ return block != null ? block.defaultBlockState().setValue(RotatedPillarBlock.AXIS, originalState.getValue(RotatedPillarBlock.AXIS)) : null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) {
|
||||
+ return true;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -123,17 +_,25 @@
|
||||
@@ -123,17 +_,35 @@
|
||||
return this.builtInRegistryHolder;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,16 @@
|
||||
+ }
|
||||
+
|
||||
+ return builtComponents;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Forge: Hack fix used in
|
||||
+ * {@link net.minecraft.client.resources.model.ModelDiscovery#listMandatoryModels ModelBakery.listMandatoryModels},
|
||||
+ * during mod loading, before the Forge event bus is ready.
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.ApiStatus.Internal
|
||||
+ public DataComponentMap vanillaComponents() {
|
||||
+ return components;
|
||||
}
|
||||
|
||||
public int getDefaultMaxStackSize() {
|
||||
|
||||
@@ -5,10 +5,27 @@
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-public final class ItemStack implements DataComponentHolder {
|
||||
+public final class ItemStack implements DataComponentHolder, net.minecraftforge.common.extensions.IForgeItemStack {
|
||||
+public final class ItemStack extends net.minecraftforge.common.capabilities.CapabilityProvider<ItemStack> implements DataComponentHolder, net.minecraftforge.common.extensions.IForgeItemStack {
|
||||
public static final Codec<ItemStack> CODEC = Codec.lazyInitialized(
|
||||
() -> RecordCodecBuilder.create(
|
||||
p_359412_ -> p_359412_.group(
|
||||
@@ -252,13 +_,16 @@
|
||||
}
|
||||
|
||||
private ItemStack(ItemLike p_331826_, int p_332766_, PatchedDataComponentMap p_333722_) {
|
||||
+ super(ItemStack.class, true);
|
||||
this.item = p_331826_.asItem();
|
||||
this.count = p_332766_;
|
||||
this.components = p_333722_;
|
||||
this.getItem().verifyComponentsAfterLoad(this);
|
||||
+ gatherCapabilities(() -> this.item.getCapabilityProvider(this));
|
||||
}
|
||||
|
||||
private ItemStack(@Nullable Void p_282703_) {
|
||||
+ super(ItemStack.class, false);
|
||||
this.item = null;
|
||||
this.components = new PatchedDataComponentMap(DataComponentMap.EMPTY);
|
||||
}
|
||||
@@ -348,13 +_,22 @@
|
||||
}
|
||||
|
||||
@@ -33,6 +50,34 @@
|
||||
if (player != null && interactionresult instanceof InteractionResult.Success interactionresult$success && interactionresult$success.wasItemInteraction()) {
|
||||
player.awardStat(Stats.ITEM_USED.get(item));
|
||||
}
|
||||
@@ -459,18 +_,26 @@
|
||||
}
|
||||
|
||||
public void hurtAndBreak(int p_220158_, ServerLevel p_342197_, @Nullable ServerPlayer p_220160_, Consumer<Item> p_343361_) {
|
||||
- int i = this.processDurabilityChange(p_220158_, p_342197_, p_220160_);
|
||||
+ // FORGE: use context-sensitive sister of processDurabilityChange that calls IForgeItem.damageItem
|
||||
+ int i = this.processDurabilityChange(p_220158_, p_342197_, p_220160_, true, p_343361_);
|
||||
if (i != 0) {
|
||||
this.applyDamage(this.getDamageValue() + i, p_220160_, p_343361_);
|
||||
}
|
||||
}
|
||||
|
||||
private int processDurabilityChange(int p_362423_, ServerLevel p_364910_, @Nullable ServerPlayer p_365570_) {
|
||||
+ return this.processDurabilityChange(p_362423_, p_364910_, p_365570_, false, p_359411_ -> { });
|
||||
+ }
|
||||
+
|
||||
+ /** FORGE: context-sensitive sister of processDurabilityChange that calls IForgeItem.damageItem */
|
||||
+ private int processDurabilityChange(int p_362423_, ServerLevel p_364910_, @Nullable ServerPlayer p_365570_, boolean canBreak, Consumer<Item> onBreak) {
|
||||
if (!this.isDamageableItem()) {
|
||||
return 0;
|
||||
} else if (p_365570_ != null && p_365570_.hasInfiniteMaterials()) {
|
||||
return 0;
|
||||
} else {
|
||||
+ // FORGE: modify the base damage based on the item's impl of IForgeItem.damageItem
|
||||
+ p_362423_ = this.damageItem(p_362423_, p_364910_, p_365570_, canBreak, onBreak);
|
||||
return p_362423_ > 0 ? EnchantmentHelper.processDurabilityChange(p_364910_, this, p_362423_) : p_362423_;
|
||||
}
|
||||
}
|
||||
@@ -507,7 +_,13 @@
|
||||
p_41623_,
|
||||
serverlevel,
|
||||
@@ -41,7 +86,7 @@
|
||||
+ p_341563_ -> {
|
||||
+ if (p_41624_ instanceof Player player) {
|
||||
+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, this, p_335324_);
|
||||
+ player.stopUsingItem(); // Forge: fix MC-168573
|
||||
+ if (player.getUseItem() == this) player.stopUsingItem(); // Forge: fix MC-168573
|
||||
+ }
|
||||
+ p_41624_.onEquippedItemBroken(p_341563_, p_335324_);
|
||||
+ }
|
||||
|
||||
@@ -157,12 +157,12 @@
|
||||
T t = p_261885_.tryCast(enderdragonpart);
|
||||
if (t != null && p_261688_.test(t)) {
|
||||
p_262071_.add(t);
|
||||
@@ -919,16 +_,15 @@
|
||||
@@ -919,17 +_,16 @@
|
||||
public abstract Scoreboard getScoreboard();
|
||||
|
||||
public void updateNeighbourForOutputSignal(BlockPos p_46718_, Block p_46719_) {
|
||||
- for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||
+ for (Direction direction : Direction.valuesView()) {
|
||||
+ for (Direction direction : Direction.getUpdateOrder()) {
|
||||
BlockPos blockpos = p_46718_.relative(direction);
|
||||
if (this.hasChunkAt(blockpos)) {
|
||||
BlockState blockstate = this.getBlockState(blockpos);
|
||||
@@ -174,10 +174,12 @@
|
||||
blockpos = blockpos.relative(direction);
|
||||
blockstate = this.getBlockState(blockpos);
|
||||
- if (blockstate.is(Blocks.COMPARATOR)) {
|
||||
- this.neighborChanged(blockstate, blockpos, p_46719_, null, false);
|
||||
+ if (blockstate.getWeakChanges(this, blockpos)) {
|
||||
this.neighborChanged(blockstate, blockpos, p_46719_, null, false);
|
||||
+ blockstate.onNeighborChange(this, blockpos, p_46718_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1031,6 +_,20 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/block/ChorusFlowerBlock.java
|
||||
+++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java
|
||||
@@ -66,7 +_,7 @@
|
||||
@@ -66,11 +_,11 @@
|
||||
BlockPos blockpos = p_220982_.above();
|
||||
if (p_220981_.isEmptyBlock(blockpos) && blockpos.getY() <= p_220981_.getMaxY()) {
|
||||
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;
|
||||
@@ -78,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;
|
||||
@@ -122,6 +_,7 @@
|
||||
} else {
|
||||
this.placeDeadFlower(p_220981_, p_220982_);
|
||||
@@ -17,3 +31,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +_,7 @@
|
||||
@Override
|
||||
protected 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
|
||||
@@ -50,7 +_,7 @@
|
||||
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))
|
||||
+ 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)))
|
||||
@@ -74,7 +_,7 @@
|
||||
p_364837_.scheduleTick(p_51732_, this, 1);
|
||||
return super.updateShape(p_51728_, p_369826_, p_364837_, p_51732_, p_51729_, p_51733_, p_51730_, p_368636_);
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
@@ -100,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);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/world/level/block/CrafterBlock.java
|
||||
+++ b/net/minecraft/world/level/block/CrafterBlock.java
|
||||
@@ -192,12 +_,15 @@
|
||||
ServerLevel p_336186_, BlockPos p_312358_, CrafterBlockEntity p_309887_, ItemStack p_310474_, BlockState p_310667_, RecipeHolder<?> p_329387_
|
||||
) {
|
||||
Direction direction = p_310667_.getValue(ORIENTATION).front();
|
||||
+ var itemhandler = net.minecraftforge.items.VanillaInventoryCodeHooks.getItemHandler(p_336186_, p_312358_.relative(direction), direction.getOpposite()).orElse(null);
|
||||
Container container = HopperBlockEntity.getContainerAt(p_336186_, p_312358_.relative(direction));
|
||||
ItemStack itemstack = p_310474_.copy();
|
||||
if (container != null && (container instanceof CrafterBlockEntity || p_310474_.getCount() > container.getMaxStackSize(p_310474_))) {
|
||||
while (!itemstack.isEmpty()) {
|
||||
ItemStack itemstack2 = itemstack.copyWithCount(1);
|
||||
ItemStack itemstack1 = HopperBlockEntity.addItem(p_309887_, container, itemstack2, direction.getOpposite());
|
||||
+ if (itemhandler != null && !itemstack1.isEmpty()) // Vanilla insert failed, try IItemHandler
|
||||
+ itemstack1 = net.minecraftforge.items.ItemHandlerHelper.insertItem(itemhandler, itemstack1, false);
|
||||
if (!itemstack1.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
@@ -208,10 +_,14 @@
|
||||
while (!itemstack.isEmpty()) {
|
||||
int i = itemstack.getCount();
|
||||
itemstack = HopperBlockEntity.addItem(p_309887_, container, itemstack, direction.getOpposite());
|
||||
+ if (itemhandler != null && i == itemstack.getCount()) // Vanilla insert failed, try IItemHandler
|
||||
+ itemstack = net.minecraftforge.items.ItemHandlerHelper.insertItem(itemhandler, itemstack, false);
|
||||
if (i == itemstack.getCount()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
+ } else {
|
||||
+ itemstack = net.minecraftforge.items.ItemHandlerHelper.insertItem(itemhandler, itemstack, false);
|
||||
}
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
@@ -31,12 +31,12 @@
|
||||
p_368198_.addFreshEntity(primedtnt);
|
||||
}
|
||||
|
||||
+ @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_, 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(
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
+++ b/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
@@ -56,7 +_,7 @@
|
||||
private static <T, C extends PalettedContainerRO<T>> Codec<C> codec(
|
||||
IdMap<T> p_238428_, Codec<T> p_238429_, PalettedContainer.Strategy p_238430_, T p_238431_, PalettedContainerRO.Unpacker<T, C> p_238432_
|
||||
) {
|
||||
- return RecordCodecBuilder.<PalettedContainerRO.PackedData>create(
|
||||
+ return RecordCodecBuilder.<PalettedContainerRO.PackedData<T>>create(
|
||||
p_327417_ -> p_327417_.group(
|
||||
p_238429_.mapResult(ExtraCodecs.orElsePartial(p_238431_))
|
||||
.listOf()
|
||||
@@ -1,13 +1,24 @@
|
||||
--- a/net/minecraft/world/level/storage/LevelSummary.java
|
||||
+++ b/net/minecraft/world/level/storage/LevelSummary.java
|
||||
@@ -277,6 +_,10 @@
|
||||
}
|
||||
}
|
||||
@@ -14,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;
|
||||
@@ -275,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);
|
||||
+10
-10
@@ -24,33 +24,33 @@ dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
libs {
|
||||
library('forgespi', 'net.minecraftforge:forgespi:7.1.5') // Needs modlauncher
|
||||
library('modlauncher', 'net.minecraftforge:modlauncher:10.2.2') // Needs securemodules
|
||||
library('securemodules', 'net.minecraftforge:securemodules:2.2.20') // Needs unsafe
|
||||
library('modlauncher', 'net.minecraftforge:modlauncher:10.2.4') // Needs securemodules
|
||||
library('securemodules', 'net.minecraftforge:securemodules:2.2.24') // Needs unsafe
|
||||
library('unsafe', 'net.minecraftforge:unsafe:0.9.2')
|
||||
library('accesstransformers', 'net.minecraftforge:accesstransformers:8.2.0')
|
||||
library('coremods', 'net.minecraftforge:coremods:5.2.1')
|
||||
library('accesstransformers', 'net.minecraftforge:accesstransformers:8.2.2')
|
||||
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.8')
|
||||
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.7')
|
||||
library('nulls', 'org.jetbrains:annotations:24.1.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.3')
|
||||
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.7.1')
|
||||
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')
|
||||
@@ -60,14 +60,14 @@ 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
|
||||
bundle('terminalconsoleappender', ['terminalconsoleappender', 'jline-reader', 'jline-terminal', 'jline-terminal-jna'])
|
||||
|
||||
// The core of our configuration system, it has many flaws, but it works for the most part
|
||||
version('night-config', '3.7.3')
|
||||
version('night-config', '3.7.4')
|
||||
library('night-config-toml', 'com.electronwill.night-config', 'toml').versionRef('night-config')
|
||||
library('night-config-core', 'com.electronwill.night-config', 'core').versionRef('night-config')
|
||||
bundle('night-config', ['night-config-toml', 'night-config-core'])
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"values": [
|
||||
"#forge:end_stones"
|
||||
]
|
||||
}
|
||||
@@ -108,7 +108,11 @@ public class ClientCommandHandler {
|
||||
new CommandSource() {
|
||||
@Override
|
||||
public void sendSystemMessage(Component message) {
|
||||
mc.gui.getChat().addMessage(message);
|
||||
var chat = mc.gui.getChat();
|
||||
if (mc.isSameThread())
|
||||
chat.addMessage(message);
|
||||
else
|
||||
mc.execute(() -> chat.addMessage(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -346,7 +346,10 @@ public class ForgeHooksClient {
|
||||
return LazyInit.INSTANCE;
|
||||
}
|
||||
|
||||
// NO-OP method, kept for bin-compat. Used in TitleScreen.java
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
public static void renderMainMenu(TitleScreen gui, GuiGraphics graphics, Font font, int width, int height, int alpha) {
|
||||
/*
|
||||
VersionChecker.Status status = getForgeVersionStatus();
|
||||
|
||||
if (status == VersionChecker.Status.BETA || status == VersionChecker.Status.BETA_OUTDATED) {
|
||||
@@ -356,6 +359,7 @@ public class ForgeHooksClient {
|
||||
line = Component.translatable("forge.update.beta.2");
|
||||
graphics.drawCenteredString(font, line, width / 2, 4 + (font.lineHeight + 1), 0xFFFFFF | alpha);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static String forgeStatusLine;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fml.event.IModBusEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Fired when the {@linkplain ForgeLayeredDraw#VANILLA_ROOT}'s order is resolved during{@link ForgeLayeredDraw#resolveLayers().
|
||||
* This can be used to add additional or move gui layers and entire layer stacks as needed.
|
||||
*
|
||||
* <p> This event is not {@linkplain net.minecraftforge.eventbus.api.Cancelable cancellable} and does not {@linkplain net.minecraftforge.eventbus.api.Event.HasResult have a result}</p>
|
||||
*
|
||||
* <p> This event is fired on the {@linkplain IModBusEvent mod event bus},
|
||||
* only on the {@linkplain net.minecraftforge.fml.LogicalSide logical client}.</p>
|
||||
*/
|
||||
public final class AddGuiOverlayLayersEvent extends Event implements IModBusEvent {
|
||||
@NotNull
|
||||
private final ForgeLayeredDraw layeredDraw;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AddGuiOverlayLayersEvent(ForgeLayeredDraw layeredDraw) {
|
||||
this.layeredDraw = layeredDraw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the layered draw.
|
||||
* @return the draw layer stack
|
||||
*/
|
||||
@NotNull
|
||||
public ForgeLayeredDraw getLayeredDraw() {
|
||||
return layeredDraw;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ package net.minecraftforge.client.event;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -279,4 +281,8 @@ public final class ForgeEventFactoryClient {
|
||||
public static ComputeFovModifierEvent fireFovModifierEvent(Player entity, float modifier, float scale) {
|
||||
return fire(new ComputeFovModifierEvent(entity, modifier, scale));
|
||||
}
|
||||
|
||||
public static void onComputeLayerOrder(ForgeLayeredDraw layeredDraw) {
|
||||
postModBus(new AddGuiOverlayLayersEvent(layeredDraw));
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,6 @@ import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
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;
|
||||
@@ -37,7 +35,6 @@ import java.util.function.Consumer;
|
||||
* @see MouseInput
|
||||
* @see KeyInput
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract class ScreenEvent extends Event {
|
||||
private final Screen screen;
|
||||
|
||||
|
||||
@@ -12,14 +12,11 @@ import net.minecraft.client.renderer.RenderType;
|
||||
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 {
|
||||
|
||||
private static final ResourceLocation VERSION_CHECK_ICONS = ResourceLocation.fromNamespaceAndPath(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
|
||||
|
||||
@@ -0,0 +1,426 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.gui.overlay;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.FieldsAreNonnullByDefault;
|
||||
import net.minecraft.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.LayeredDraw;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ForgeEventFactoryClient;
|
||||
import net.minecraftforge.client.event.AddGuiOverlayLayersEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.*;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
/**
|
||||
* As vanilla has switched to a layered drawing system for overlays, this system replaces ForgeGui and its associated headaches.
|
||||
* Vanilla will now have resource locations to represent its render layers which modders can order against.
|
||||
* This class is effectively a pseudo-registry for Layers. Add what you need during {@linkplain AddGuiOverlayLayersEvent}
|
||||
* Layers must be uniquely named per ForgeLayeredDraw, but may be duplicated across different instances.
|
||||
* Any change which would result in a duplicate will not be applied.
|
||||
* All methods which return a {@linkplain ForgeLayeredDraw} will return its caller's instance.
|
||||
* To select a specific instance, use {@linkplain ForgeLayeredDraw#locateStack(ResourceLocation)} before adding
|
||||
* or use the methods that include a stack identifier.
|
||||
*/
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
public final class ForgeLayeredDraw extends LayeredDraw {
|
||||
private static int unknown = 0;
|
||||
private final Map<ResourceLocation, Layer> namedLayers = new HashMap<>();
|
||||
private final Map<ResourceLocation, Map.Entry<LayeredDraw, BooleanSupplier>> subLayerStacks = new HashMap<>();
|
||||
private final List<ResourceLocation> order = new LinkedList<>();
|
||||
private final List<ResourceLocation> expectedNames = new ArrayList<>();
|
||||
private final ResourceLocation name;
|
||||
|
||||
public static final ResourceLocation PRE_SLEEP_STACK = ResourceLocation.withDefaultNamespace("pre_sleep_phase");
|
||||
public static final ResourceLocation CAMERA_OVERLAY = ResourceLocation.withDefaultNamespace("camera_overlay");
|
||||
public static final ResourceLocation CROSSHAIR = ResourceLocation.withDefaultNamespace("crosshair");
|
||||
public static final ResourceLocation HOTBAR = ResourceLocation.withDefaultNamespace("hotbar");
|
||||
public static final ResourceLocation EXPERIENCE = ResourceLocation.withDefaultNamespace("experience");
|
||||
public static final ResourceLocation POTION_EFFECTS = ResourceLocation.withDefaultNamespace("potion_effects");
|
||||
public static final ResourceLocation BOSS_OVERLAY = ResourceLocation.withDefaultNamespace("boss_overlay");
|
||||
|
||||
public static final ResourceLocation POST_SLEEP_STACK = ResourceLocation.withDefaultNamespace("post_sleep_phase");
|
||||
public static final ResourceLocation DEMO_OVERLAY = ResourceLocation.withDefaultNamespace("demo");
|
||||
public static final ResourceLocation DEBUG_OVERLAY = ResourceLocation.withDefaultNamespace("debug");
|
||||
public static final ResourceLocation SCOREBOARD = ResourceLocation.withDefaultNamespace("scoreboard");
|
||||
public static final ResourceLocation HOTBAR_MESSAGE = ResourceLocation.withDefaultNamespace("hotbar_message");
|
||||
public static final ResourceLocation TITLE_OVERLAY = ResourceLocation.withDefaultNamespace("title");
|
||||
public static final ResourceLocation CHAT_OVERLAY = ResourceLocation.withDefaultNamespace("chat_overlay");
|
||||
public static final ResourceLocation TAB_LIST = ResourceLocation.withDefaultNamespace("tab_list");
|
||||
public static final ResourceLocation SUBTITLE_OVERLAY = ResourceLocation.withDefaultNamespace("subtitle");
|
||||
|
||||
public static final ResourceLocation VANILLA_ROOT = ResourceLocation.withDefaultNamespace("vanilla_root");
|
||||
public static final ResourceLocation SLEEP_OVERLAY = ResourceLocation.withDefaultNamespace("sleep_overlay");
|
||||
|
||||
|
||||
public static final ImmutableList<ResourceLocation> PRE_LIST = ImmutableList.of(CAMERA_OVERLAY, CROSSHAIR, HOTBAR, EXPERIENCE, POTION_EFFECTS, BOSS_OVERLAY);
|
||||
public static final ImmutableList<ResourceLocation> POST_LIST = ImmutableList.of(DEMO_OVERLAY, DEBUG_OVERLAY, SCOREBOARD, HOTBAR_MESSAGE, TITLE_OVERLAY, CHAT_OVERLAY, TAB_LIST, SUBTITLE_OVERLAY);
|
||||
public static final ImmutableList<ResourceLocation> COMBINE_LIST = ImmutableList.of(PRE_SLEEP_STACK, SLEEP_OVERLAY, POST_SLEEP_STACK);
|
||||
|
||||
/**
|
||||
* Creates a stack of pre-named layers for vanilla.
|
||||
* Not intended for modder use. Use {@linkplain ForgeLayeredDraw(ResourceLocation, Boolean, String...)} instead.
|
||||
* @param name Stack identifier
|
||||
* @param layers locations of layers to add
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ForgeLayeredDraw(ResourceLocation name, List<ResourceLocation> layers) {
|
||||
this.name = name;
|
||||
expectedNames.addAll(layers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty draw list. Add entries with {@linkplain ForgeLayeredDraw#add(ResourceLocation, Layer)}
|
||||
* @param name marker for which phase this is.
|
||||
*/
|
||||
public ForgeLayeredDraw(ResourceLocation name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a full, pre-named draw stack.
|
||||
* @param layeredDraw layer stack to be added.
|
||||
* @param booleanSupplier requirement for it to render.
|
||||
* @deprecated Modders should be using {@linkplain ForgeLayeredDraw#add(ResourceLocation, LayeredDraw, BooleanSupplier)}
|
||||
* @return this
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public ForgeLayeredDraw add(LayeredDraw layeredDraw, BooleanSupplier booleanSupplier) {
|
||||
return add(getNextPreName(), layeredDraw, booleanSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a full draw stack with its provided condition.
|
||||
* Use {@linkplain ForgeLayeredDraw#putAbove} and {@linkplain ForgeLayeredDraw#putBelow} for fine location adjustment.
|
||||
* @param name RL of the name to identify this stack with.
|
||||
* @param layeredDraw the draw stack
|
||||
* @param supplier condition for this stack to render
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw add(ResourceLocation name, LayeredDraw layeredDraw, BooleanSupplier supplier) {
|
||||
if (isNameAvailable(name)) {
|
||||
subLayerStacks.put(name, Map.entry(layeredDraw, supplier));
|
||||
order.add(name);
|
||||
} else {
|
||||
nameTakenWarning(name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a layer with an already known name provided by {@linkplain ForgeLayeredDraw(ResourceLocation, List)}
|
||||
* The layer will be rendered last (on top) of already added layers.
|
||||
* @param layer layer render code, see {@linkplain Layer} and example usages in {@linkplain Gui}
|
||||
* @deprecated Use {@linkplain ForgeLayeredDraw#add(ResourceLocation, Layer)} for adding individual layers.
|
||||
* @return this
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public LayeredDraw add(Layer layer) {
|
||||
add(getNextPreName(), layer);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a layer to the layer list. This layer will be at the end of the list, which means
|
||||
* it will be rendered last (on top) of already added layers.
|
||||
* @param name RL for other mods to order against.
|
||||
* @param layer layer render code, see {@linkplain Layer} and example usages in {@linkplain Gui}
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw add(ResourceLocation targetStack, ResourceLocation name, Layer layer) {
|
||||
locateStack(targetStack).ifPresentOrElse((stack) -> stack.add(name, layer), () -> stackNotPresentWarning(targetStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method, assumes the intended draw stack instance is the caller.
|
||||
* Use any of the non-deprecated add methods if you want a specific instance,
|
||||
* or call {@linkplain ForgeLayeredDraw#locateStack(ResourceLocation)} to get a reference to an instance.
|
||||
* @param name RL of layer to add
|
||||
* @param layer layer render code, see {@linkplain Layer} and example usages in {@linkplain Gui}
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw add(ResourceLocation name, Layer layer) {
|
||||
if (isNameAvailable(name)) {
|
||||
namedLayers.put(name, layer);
|
||||
order.add(name);
|
||||
} else {
|
||||
nameTakenWarning(name);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to specify where your custom draw stack should go. Can also be used to re-order layers.
|
||||
* Both target and destination must be in the same draw stack.
|
||||
* @param expectedStack Which ForgeLayeredDraw the target is expected to be in. If you already have a reference to it, you can use {@linkplain ForgeLayeredDraw#move(ResourceLocation, ResourceLocation, LayerOffset)}
|
||||
* @param target layer name to move
|
||||
* @param destination layer name to order against
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw putAbove(ResourceLocation expectedStack, ResourceLocation target, ResourceLocation destination) {
|
||||
locateStack(expectedStack).ifPresentOrElse((stack) -> stack.move(target, destination, LayerOffset.ABOVE), () -> stackNotPresentWarning(expectedStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to specify where your custom draw stack should go. Can also be used to re-order layers.
|
||||
* Both target and destination must be in the same draw stack.
|
||||
* @param expectedStack Which ForgeLayeredDraw the target is expected to be in. If you already have a reference to it, you can use {@linkplain ForgeLayeredDraw#move(ResourceLocation, ResourceLocation, LayerOffset)}
|
||||
* @param target layer name to move
|
||||
* @param destination layer name to order against
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw putBelow(ResourceLocation expectedStack, ResourceLocation target, ResourceLocation destination) {
|
||||
locateStack(expectedStack).ifPresentOrElse((stack) -> stack.move(target, destination, LayerOffset.BELOW), () -> stackNotPresentWarning(expectedStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method, assumes the intended draw stack instance is the caller.
|
||||
* Moves pre-existing names around within the order.
|
||||
* @param target Layer being moved.
|
||||
* @param destination Layer being ordered against
|
||||
* @param offset Self-explanatory
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw move(ResourceLocation target, ResourceLocation destination, LayerOffset offset) {
|
||||
if (!order.contains(target)) {
|
||||
layerNotPresentWarning(target);
|
||||
return this;
|
||||
}
|
||||
int loc = order.indexOf(destination);
|
||||
if (loc == -1) {
|
||||
layerNotPresentWarning(destination);
|
||||
return this;
|
||||
}
|
||||
order.remove(target);
|
||||
order.add(loc + (offset == LayerOffset.ABOVE ? 1 : 0), target);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an overlay layer to be rendered above the other provided layer.
|
||||
* To render "above" another layer means thisLayer will be rendered after otherLayer
|
||||
* If the current stack does not contain otherLayer, no changes will be made.
|
||||
* @param newLayer name of the layer to be added
|
||||
* @param otherLayer name of the layer being ordered against
|
||||
* @param layer layer render code, see {@linkplain Layer} and example usages in {@linkplain Gui}
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw addAbove(ResourceLocation expectedStack, ResourceLocation newLayer, ResourceLocation otherLayer, Layer layer) {
|
||||
locateStack(expectedStack).ifPresentOrElse((stack) -> {
|
||||
if (!stack.isNameAvailable(otherLayer)) {
|
||||
stack.add(newLayer, layer).move(newLayer, otherLayer, LayerOffset.ABOVE);
|
||||
} else {
|
||||
layerNotPresentWarning(otherLayer);
|
||||
}
|
||||
}, () -> stackNotPresentWarning(expectedStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method, assumes intended draw stack is the caller
|
||||
*/
|
||||
public ForgeLayeredDraw addAbove(ResourceLocation newLayer, ResourceLocation otherLayer, Layer layer) {
|
||||
return addAbove(name, newLayer, otherLayer, layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an overlay layer to be rendered below the other provided layer.
|
||||
* To render "below" another layer means thisLayer will be rendered before otherLayer
|
||||
* If the current stack does not contain otherLayer, no changes will be made.
|
||||
* @param newLayer name of the layer to be added
|
||||
* @param otherLayer name of the layer being ordered against
|
||||
* @param layer layer render code, see {@linkplain Layer} and example usages in {@linkplain Gui}
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw addBelow(ResourceLocation expectedStack, ResourceLocation newLayer, ResourceLocation otherLayer, Layer layer) {
|
||||
locateStack(expectedStack).ifPresentOrElse((stack) -> {
|
||||
if (!stack.isNameAvailable(otherLayer)) {
|
||||
stack.add(newLayer, layer).move(newLayer, otherLayer, LayerOffset.BELOW);
|
||||
} else {
|
||||
layerNotPresentWarning(otherLayer);
|
||||
}
|
||||
}, () -> stackNotPresentWarning(expectedStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method, assumes intended draw stack is the caller
|
||||
*/
|
||||
public ForgeLayeredDraw addBelow(ResourceLocation newLayer, ResourceLocation otherLayer, Layer layer) {
|
||||
return addBelow(name, newLayer, otherLayer, layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new layer that will only be rendered when the condition is met. The layer will be added
|
||||
* at the end of the list, which means it will render last (on top) of already added layers
|
||||
* @param name name of the layer to be added
|
||||
* @param layer render code of layer being added
|
||||
* @param condition supplier for the condition
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw addWithCondition(ResourceLocation targetStack, ResourceLocation name, Layer layer, BooleanSupplier condition) {
|
||||
locateStack(targetStack).ifPresentOrElse((stack) -> stack.addWithCondition(name, layer, condition), () -> stackNotPresentWarning(targetStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assumes the correct stack is the caller of this method, otherwise functions the same as other method.
|
||||
* @param name name of layer to be added
|
||||
* @param layer render code of layer being added
|
||||
* @param condition supplier for the condition
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw addWithCondition(ResourceLocation name, Layer layer, BooleanSupplier condition) {
|
||||
add(name, layer).addConditionTo(name, condition);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a condition to a pre-existing layer in the specified stack, its render order is not changed.
|
||||
* If the target is not present, no changes are made.
|
||||
* @param targetStack name of the draw stack the target is expected to be in
|
||||
* @param targetLayer name of layer to add a condition to
|
||||
* @param condition supplier for the condition
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw addConditionTo(ResourceLocation targetStack, ResourceLocation targetLayer, BooleanSupplier condition) {
|
||||
locateStack(targetStack).ifPresentOrElse((stack) -> stack.addConditionTo(targetLayer, condition), () -> stackNotPresentWarning(targetStack));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assumes the correct stack is the caller of this method.
|
||||
* Use {@linkplain ForgeLayeredDraw#addConditionTo(ResourceLocation, ResourceLocation, BooleanSupplier)}
|
||||
* if you do not have a reference to the draw stack you want.
|
||||
* @param targetLayer name of layer to add condition to
|
||||
* @param condition supplier for the condition
|
||||
* @return this
|
||||
*/
|
||||
public ForgeLayeredDraw addConditionTo(ResourceLocation targetLayer, BooleanSupplier condition) {
|
||||
var result = namedLayers.computeIfPresent(targetLayer,
|
||||
(name, layer) -> (guiGraphics, deltaTracker) -> {
|
||||
if (condition.getAsBoolean()) {
|
||||
layer.render(guiGraphics, deltaTracker);
|
||||
}
|
||||
});
|
||||
if (result == null) {
|
||||
layerNotPresentWarning(targetLayer);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Propagate the layer order down to the inner render list after providing modders an opportunity to alter the list as they wish.
|
||||
* @apiNote Modders should <emph>NEVER</emph> be calling this method.
|
||||
* @return this
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public ForgeLayeredDraw resolveLayers() {
|
||||
if (!order.isEmpty()) {
|
||||
ForgeEventFactoryClient.onComputeLayerOrder(this);
|
||||
}
|
||||
if (namedLayers.size() + subLayerStacks.size() < order.size()) {
|
||||
LogUtils.getLogger().warn("Found {} unbound pre-defined layer names when resolving gui overlay order. This is not an error, but potentially indicates a mod directly modifying Gui instead of using this api.", order.size() - namedLayers.size());
|
||||
}
|
||||
resolveNested();
|
||||
order.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the layer order per stack, recursively as needed.
|
||||
* Parent layer stack {@linkplain ForgeLayeredDraw#VANILLA_ROOT} holds the results.
|
||||
*/
|
||||
private void resolveNested() {
|
||||
for (ResourceLocation layerName : order) {
|
||||
if (subLayerStacks.containsKey(layerName)) {
|
||||
var entry = subLayerStacks.get(layerName);
|
||||
if (entry.getKey() instanceof ForgeLayeredDraw resolveable) {
|
||||
resolveable.resolveNested();
|
||||
// Although unlikely, a LayeredDraw could be in the list, and we can't call resolveNested on one.
|
||||
}
|
||||
super.add((gg, tr) -> {
|
||||
if (entry.getValue().getAsBoolean()) entry.getKey().render(gg,tr);
|
||||
});
|
||||
} else {
|
||||
super.add(namedLayers.get(layerName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to locate a particular draw stack. Search starts at caller's instance. For global search call on VANILLA_ROOT
|
||||
* i.e. {@linkplain net.minecraftforge.client.event.AddGuiOverlayLayersEvent#getLayeredDraw()}
|
||||
* Entries which don't extend ForgeLayeredDraw may not have the proper fields to support internal list adjustment, so they are skipped.
|
||||
* @param targetStack Name of ForgeLayeredDraw to find
|
||||
* @return Filled Optional if target exists, empty otherwise.
|
||||
*/
|
||||
public Optional<ForgeLayeredDraw> locateStack(ResourceLocation targetStack) {
|
||||
if (!name.equals(targetStack)) {
|
||||
for (Map.Entry<LayeredDraw, BooleanSupplier> value : subLayerStacks.values()) {
|
||||
if (value.getKey() instanceof ForgeLayeredDraw searchable) {
|
||||
var res = searchable.locateStack(targetStack);
|
||||
if(res.isPresent()) return res;
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
} else {
|
||||
return Optional.of(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LayeredDraw getChild(ResourceLocation childName) {
|
||||
return locateStack(childName).orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Layer getLayer(ResourceLocation layerName) {
|
||||
return namedLayers.get(layerName);
|
||||
}
|
||||
|
||||
private ResourceLocation getNextPreName() {
|
||||
return expectedNames.isEmpty() ? ResourceLocation.fromNamespaceAndPath("unknown", "layer_" + unknown++) : expectedNames.removeFirst();
|
||||
}
|
||||
|
||||
public ResourceLocation getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private void stackNotPresentWarning(ResourceLocation stackName) {
|
||||
LogUtils.getLogger().warn("Target stack {} was not present anywhere. Is your ResourceLocation correct?", stackName);
|
||||
}
|
||||
|
||||
private void layerNotPresentWarning(ResourceLocation layer) {
|
||||
LogUtils.getLogger().warn("Expected layer {} was not found in stack {}, no layer modifications have been made.", layer, name);
|
||||
}
|
||||
|
||||
private void nameTakenWarning(ResourceLocation layer) {
|
||||
LogUtils.getLogger().warn("Name {} was already present in {} and cannot be re-used.", layer, name);
|
||||
}
|
||||
|
||||
private boolean isNameAvailable(ResourceLocation name) {
|
||||
return !namedLayers.containsKey(name) && !subLayerStacks.containsKey(name);
|
||||
}
|
||||
|
||||
public enum LayerOffset {
|
||||
ABOVE,
|
||||
BELOW
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,12 @@ import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
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;
|
||||
|
||||
@@ -208,6 +208,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, ItemTransforms transforms) {
|
||||
this.isAmbientOcclusion = isAmbientOcclusion;
|
||||
@@ -218,23 +219,32 @@ 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, 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, 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.isEmpty()) {
|
||||
addLayer(lastRenderTypes, quads);
|
||||
addLayer(lastRenderTypes, lastRenderTypesFast, quads);
|
||||
quads.clear();
|
||||
}
|
||||
lastRenderTypes = renderTypes;
|
||||
lastRenderTypesFast = renderTypesFast;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,20 +254,28 @@ 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;
|
||||
}
|
||||
|
||||
public BakedModel build() {
|
||||
if (!quads.isEmpty()) {
|
||||
addLayer(lastRenderTypes, quads);
|
||||
addLayer(lastRenderTypes, lastRenderTypesFast, quads);
|
||||
}
|
||||
var childrenBuilder = ImmutableMap.<String, BakedModel>builder();
|
||||
var itemPassesBuilder = ImmutableList.<BakedModel>builder();
|
||||
|
||||
@@ -50,7 +50,7 @@ public class EmptyModel extends SimpleUnbakedGeometry<EmptyModel> {
|
||||
private static final Material MISSING_TEXTURE = new Material(InventoryMenu.BLOCK_ATLAS, MissingTextureAtlasSprite.getLocation());
|
||||
|
||||
public Baked() {
|
||||
super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, RenderTypeGroup.EMPTY);
|
||||
super(List.of(), Map.of(), false, false, false, UnitTextureAtlasSprite.INSTANCE, ItemTransforms.NO_TRANSFORMS, RenderTypeGroup.EMPTY, RenderTypeGroup.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,6 +73,12 @@ public class ExtendedBlockModelDeserializer extends BlockModel.Deserializer
|
||||
model.customData.setRenderTypeHint(ResourceLocation.parse(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");
|
||||
|
||||
@@ -32,6 +32,18 @@ public interface IModelBuilder<T extends IModelBuilder<T>> {
|
||||
return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes);
|
||||
}
|
||||
|
||||
static IModelBuilder<?> of(
|
||||
boolean hasAmbientOcclusion,
|
||||
boolean usesBlockLight,
|
||||
boolean isGui3d,
|
||||
ItemTransforms transforms,
|
||||
TextureAtlasSprite particle,
|
||||
RenderTypeGroup renderTypes,
|
||||
RenderTypeGroup renderTypesFast
|
||||
){
|
||||
return new Simple(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, 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()}.
|
||||
@@ -49,12 +61,20 @@ public interface IModelBuilder<T extends IModelBuilder<T>> {
|
||||
class Simple implements IModelBuilder<Simple> {
|
||||
private final SimpleBakedModel.Builder builder;
|
||||
private final RenderTypeGroup renderTypes;
|
||||
private final RenderTypeGroup renderTypesFast;
|
||||
|
||||
private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d,
|
||||
ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes
|
||||
) {
|
||||
this(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms, particle, renderTypes, RenderTypeGroup.EMPTY);
|
||||
}
|
||||
|
||||
private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGui3d,
|
||||
ItemTransforms transforms, TextureAtlasSprite particle, RenderTypeGroup renderTypes, RenderTypeGroup renderTypesFast
|
||||
) {
|
||||
this.builder = new SimpleBakedModel.Builder(hasAmbientOcclusion, usesBlockLight, isGui3d, transforms).particle(particle);
|
||||
this.renderTypes = renderTypes;
|
||||
this.renderTypesFast = renderTypesFast;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,10 +39,16 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel> {
|
||||
@Nullable
|
||||
private ImmutableList<Material> textures;
|
||||
private final Int2ObjectMap<ResourceLocation> renderTypeNames;
|
||||
private final Int2ObjectMap<ResourceLocation> renderTypeFastNames;
|
||||
|
||||
private ItemLayerModel(@Nullable ImmutableList<Material> textures, Int2ObjectMap<ResourceLocation> renderTypeNames) {
|
||||
this(textures, renderTypeNames, new Int2ObjectOpenHashMap<>());
|
||||
}
|
||||
|
||||
private ItemLayerModel(@Nullable ImmutableList<Material> textures, Int2ObjectMap<ResourceLocation> renderTypeNames, Int2ObjectMap<ResourceLocation> renderTypeFastNames) {
|
||||
this.textures = textures;
|
||||
this.renderTypeNames = renderTypeNames;
|
||||
this.renderTypeFastNames = renderTypeFastNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,7 +75,9 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel> {
|
||||
var quads = UnbakedGeometryHelper.bakeElements(unbaked, $ -> sprite, modelState);
|
||||
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();
|
||||
@@ -80,20 +88,27 @@ public class ItemLayerModel implements IUnbakedGeometry<ItemLayerModel> {
|
||||
|
||||
@Override
|
||||
public ItemLayerModel read(JsonObject jsonObject, JsonDeserializationContext deserializationContext) {
|
||||
var renderTypeNames = readRenderTypeNames(jsonObject, "render_types");
|
||||
var renderTypeFastNames = readRenderTypeNames(jsonObject, "render_types_fast");
|
||||
return new ItemLayerModel(null, renderTypeNames, renderTypeFastNames);
|
||||
}
|
||||
|
||||
private static Int2ObjectMap<ResourceLocation> readRenderTypeNames(JsonObject jsonObject, String key) {
|
||||
var renderTypeNames = new Int2ObjectOpenHashMap<ResourceLocation>();
|
||||
if (jsonObject.has("render_types")) {
|
||||
var renderTypes = jsonObject.getAsJsonObject("render_types");
|
||||
if (jsonObject.has(key)) {
|
||||
var renderTypes = jsonObject.getAsJsonObject(key);
|
||||
for (var entry : renderTypes.entrySet()) {
|
||||
var renderType = ResourceLocation.parse(entry.getKey());
|
||||
for (var layer : entry.getValue().getAsJsonArray())
|
||||
if (renderTypeNames.put(layer.getAsInt(), renderType) != null)
|
||||
throw new JsonParseException("Registered duplicate render type for layer " + layer);
|
||||
throw new JsonParseException("Registered duplicate " + key + " for layer " + layer);
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemLayerModel(null, renderTypeNames);
|
||||
return renderTypeNames;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
protected void readLayerData(JsonObject jsonObject, String name, Int2ObjectOpenHashMap<ResourceLocation> renderTypeNames, Int2ObjectMap<ForgeFaceData> layerData, boolean logWarning) {
|
||||
if (!jsonObject.has(name))
|
||||
return;
|
||||
|
||||
@@ -250,6 +250,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)
|
||||
@@ -381,6 +417,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);
|
||||
@@ -395,6 +463,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 -> {
|
||||
@@ -532,6 +607,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);
|
||||
}
|
||||
@@ -556,6 +657,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);
|
||||
@@ -572,6 +689,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;
|
||||
@@ -613,6 +738,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),
|
||||
@@ -625,6 +766,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)
|
||||
@@ -677,6 +824,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);
|
||||
@@ -695,6 +858,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();
|
||||
@@ -734,6 +906,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);
|
||||
@@ -758,6 +946,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;
|
||||
@@ -824,6 +1024,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);
|
||||
@@ -838,6 +1054,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -366,7 +366,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
@@ -34,6 +34,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)
|
||||
@@ -116,6 +117,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.
|
||||
*
|
||||
@@ -145,6 +163,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)
|
||||
{
|
||||
@@ -171,6 +208,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;
|
||||
}
|
||||
}
|
||||
+15
@@ -34,6 +34,8 @@ public class BlockGeometryBakingContext implements IGeometryBakingContext {
|
||||
private Transformation rootTransform;
|
||||
@Nullable
|
||||
private ResourceLocation renderTypeHint;
|
||||
@Nullable
|
||||
private ResourceLocation renderTypeFastHint;
|
||||
private boolean gui3d = true;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -115,10 +117,22 @@ 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;
|
||||
}
|
||||
@@ -128,6 +142,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,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.
|
||||
*
|
||||
@@ -89,4 +96,20 @@ public interface IGeometryBakingContext {
|
||||
default RenderTypeGroup getRenderType(ResourceLocation name) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -25,10 +25,8 @@ public abstract class SimpleUnbakedGeometry<T extends SimpleUnbakedGeometry<T>>
|
||||
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelState) {
|
||||
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(), particle, renderTypes);
|
||||
context.getTransforms(), particle, context.getRenderType(), context.getRenderTypeFast());
|
||||
|
||||
addQuads(context, builder, baker, spriteGetter, modelState);
|
||||
|
||||
|
||||
+31
-1
@@ -51,6 +51,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(
|
||||
@@ -60,6 +62,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;
|
||||
@@ -70,6 +84,7 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext {
|
||||
this.transforms = transforms;
|
||||
this.rootTransform = rootTransform;
|
||||
this.renderTypeHint = renderTypeHint;
|
||||
this.renderTypeFastHint = renderTypeFastHint;
|
||||
this.visibilityTest = visibilityTest;
|
||||
}
|
||||
|
||||
@@ -119,6 +134,12 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext {
|
||||
return renderTypeHint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getRenderTypeFastHint() {
|
||||
return renderTypeFastHint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComponentVisible(String component, boolean fallback) {
|
||||
return visibilityTest.test(component, fallback);
|
||||
@@ -143,6 +164,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() { }
|
||||
@@ -156,6 +179,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;
|
||||
}
|
||||
|
||||
@@ -205,6 +229,12 @@ public class StandaloneGeometryBakingContext implements IGeometryBakingContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withRenderTypeHint(ResourceLocation renderTypeHint, ResourceLocation renderTypeFastHint) {
|
||||
this.renderTypeHint = renderTypeHint;
|
||||
this.renderTypeFastHint = renderTypeFastHint;
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Builder withVisibleComponents(Object2BooleanMap<String> parts) {
|
||||
this.visibilityTest = parts::getOrDefault;
|
||||
@@ -212,7 +242,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,7 @@ public class ForgeConfig {
|
||||
}
|
||||
|
||||
public final ForgeConfigSpec.EnumValue<MigrationHelperMode> migrationHelperMode;
|
||||
public final ForgeConfigSpec.LongValue channelListLimit;
|
||||
|
||||
Common(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("General configuration settings")
|
||||
@@ -86,6 +87,17 @@ public class ForgeConfig {
|
||||
.translation("forge.configgui.migrationHelperMode")
|
||||
.defineEnum("logLegacyTagWarnings", MigrationHelperMode.OFF);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -98,6 +110,8 @@ public class ForgeConfig {
|
||||
|
||||
public final BooleanValue showLoadWarnings;
|
||||
|
||||
public final BooleanValue allowMipmapLowering;
|
||||
|
||||
Client(ForgeConfigSpec.Builder builder) {
|
||||
builder.comment("Client only settings, mostly things related to rendering")
|
||||
.push("client");
|
||||
@@ -112,6 +126,11 @@ public class ForgeConfig {
|
||||
.translation("forge.configgui.showLoadWarnings")
|
||||
.define("showLoadWarnings", 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();
|
||||
}
|
||||
|
||||
@@ -120,6 +139,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;
|
||||
|
||||
@@ -94,7 +94,7 @@ public class ForgeInternalHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onResourceReload(AddReloadListenerEvent event) {
|
||||
INSTANCE = new LootModifierManager(event.getRegistryAccess());
|
||||
INSTANCE = new LootModifierManager(event.getRegistries());
|
||||
event.addListener(INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ public class Tags {
|
||||
|
||||
public static final TagKey<Block> CHESTS_ENDER = forgeTag("chests/ender");
|
||||
public static final TagKey<Block> CHESTS_TRAPPED = forgeTag("chests/trapped");
|
||||
public static final TagKey<Block> CHORUS_ADDITIONALLY_GROWS_ON = forgeTag("chorus_additionally_grows_on");
|
||||
public static final TagKey<Block> COBBLESTONE_NORMAL = forgeTag("cobblestone/normal");
|
||||
public static final TagKey<Block> COBBLESTONE_INFESTED = forgeTag("cobblestone/infested");
|
||||
public static final TagKey<Block> COBBLESTONE_MOSSY = forgeTag("cobblestone/mossy");
|
||||
|
||||
@@ -55,6 +55,8 @@ public final class ForgeBlockTagsProvider extends BlockTagsProvider {
|
||||
tag(CHESTS_WOODEN)
|
||||
.add(Blocks.CHEST, Blocks.TRAPPED_CHEST)
|
||||
.addOptionalTag(forgeTagKey("chests/wooden"));
|
||||
tag(CHORUS_ADDITIONALLY_GROWS_ON)
|
||||
.addTag(END_STONES);
|
||||
tag(CLUSTERS).add(Blocks.AMETHYST_CLUSTER);
|
||||
tag(COBBLESTONES)
|
||||
.addTags(COBBLESTONE_NORMAL, COBBLESTONE_INFESTED, COBBLESTONE_MOSSY, COBBLESTONE_DEEPSLATE)
|
||||
|
||||
@@ -5,49 +5,143 @@
|
||||
|
||||
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.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
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.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.game.GameProtocols;
|
||||
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.minecraft.world.level.block.entity.BaseContainerBlockEntity;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public interface IForgeGameTestHelper {
|
||||
private GameTestHelper self() {
|
||||
return (GameTestHelper)this;
|
||||
return (GameTestHelper) this;
|
||||
}
|
||||
|
||||
default GameTestAssertException throwing(String message) {
|
||||
return new GameTestAssertException(Component.literal(message).getString());
|
||||
}
|
||||
|
||||
default void say(String message) {
|
||||
this.say(message, Style.EMPTY);
|
||||
}
|
||||
|
||||
default void say(String message, Style style) {
|
||||
this.say(this.getMessage(message).withStyle(style));
|
||||
}
|
||||
|
||||
default void say(String message, ChatFormatting style) {
|
||||
this.say(this.getMessage(message).withStyle(style));
|
||||
}
|
||||
|
||||
default void say(String message, int color) {
|
||||
this.say(this.getMessage(message).withColor(color));
|
||||
}
|
||||
|
||||
default void say(Component component) {
|
||||
this.self().getLevel().players().forEach(p -> p.sendSystemMessage(component));
|
||||
}
|
||||
|
||||
private MutableComponent getMessage(String message) {
|
||||
return ForgeI18n.getPattern(message) != null ? Component.translatable(message) : Component.literal(message);
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
default <N> void assertValueNotEqual(N expected, N actual, String name, String message) {
|
||||
this.assertValueNotEqual(expected, actual, name, () -> message);
|
||||
}
|
||||
|
||||
default <N> void assertValueNotEqual(N expected, N actual, String name, Supplier<String> message) {
|
||||
if (Objects.equals(expected, actual))
|
||||
throw new GameTestAssertException("%s -- Expected %s to NOT be %s, but was".formatted(message.get(), name, expected));
|
||||
}
|
||||
|
||||
default <N> void assertValueNotEqual(N[] expected, N[] actual, String name, String message) {
|
||||
this.assertValueNotEqual(expected, actual, name, () -> message);
|
||||
}
|
||||
|
||||
default <N> void assertValueNotEqual(N[] expected, N[] actual, String name, Supplier<String> message) {
|
||||
if (!Objects.deepEquals(expected, actual))
|
||||
throw new GameTestAssertException("%s -- Expected %s to NOT be %s, but was".formatted(message.get(), name, Arrays.toString(expected)));
|
||||
}
|
||||
|
||||
default <E> Registry<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"), false);
|
||||
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);
|
||||
@SuppressWarnings("unused") // The constructor has side effects
|
||||
@@ -59,4 +153,301 @@ public interface IForgeGameTestHelper {
|
||||
connection.setupInboundProtocol(info, listener);
|
||||
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 void removeAllItemEntitiesInRange(BlockPos pos, double range) {
|
||||
BlockPos blockpos = this.self().absolutePos(pos);
|
||||
for (ItemEntity itemEntity : this.self().getLevel().getEntities(EntityType.ITEM, new AABB(blockpos).inflate(range), Entity::isAlive)) {
|
||||
itemEntity.remove(Entity.RemovalReason.DISCARDED);
|
||||
}
|
||||
}
|
||||
|
||||
default void assertContainerContains(BlockPos pos, Item item, int expected) {
|
||||
BaseContainerBlockEntity basecontainerblockentity = self().getBlockEntity(pos);
|
||||
var actual = basecontainerblockentity.countItem(item);
|
||||
assertTrue(actual == expected, () -> "Failed to find %s x %d in container at %s, found %d".formatted(item, expected, pos, actual));
|
||||
}
|
||||
|
||||
default void assertItemHandlerContains(BlockPos pos, Item item) {
|
||||
assertItemHandlerContains(pos, null, item);
|
||||
}
|
||||
|
||||
default void assertItemHandlerContains(BlockPos pos, @Nullable Direction side, Item item) {
|
||||
assertFalse(countItemHandler(self(), pos, side, item) == 0, () -> "Failed to find any %s in IItemHandler at %s".formatted(item, pos));
|
||||
}
|
||||
|
||||
default void assertItemHandlerContains(BlockPos pos, Item item, int expected) {
|
||||
assertItemHandlerContains(pos, null, item, expected);
|
||||
}
|
||||
|
||||
default void assertItemHandlerContains(BlockPos pos, @Nullable Direction side, Item item, int expected) {
|
||||
int actual = countItemHandler(self(), pos, side, item);
|
||||
assertTrue(actual == expected, () -> "Failed to find %s x %d in IItemHandler at %s, found %d".formatted(item, expected, pos, actual));
|
||||
}
|
||||
|
||||
private static int countItemHandler(GameTestHelper self, BlockPos pos, @Nullable Direction side, Item item) {
|
||||
var blockEntity = self.getBlockEntity(pos);
|
||||
var handler = blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, side).orElseThrow(
|
||||
() -> self.throwing("Block at %s has no item handler capability on side %s".formatted(pos, side)));
|
||||
|
||||
int actual = 0;
|
||||
for (int slot = 0; slot < handler.getSlots(); slot++) {
|
||||
var stack = handler.getStackInSlot(slot);
|
||||
if (stack.getItem().equals(item))
|
||||
actual += stack.getCount();
|
||||
}
|
||||
return actual;
|
||||
}
|
||||
|
||||
default void tickBlock(BlockPos pos) {
|
||||
var blentity = self().getBlockEntity(pos);
|
||||
blentity.getBlockState().tick(self().getLevel(), self().absolutePos(pos), self().getLevel().random);
|
||||
}
|
||||
|
||||
default <T> Flag<T> flag(String name) {
|
||||
return new Flag<>(name);
|
||||
}
|
||||
|
||||
default IntFlag intFlag(String name) {
|
||||
return new IntFlag(name);
|
||||
}
|
||||
|
||||
default IntFlag intFlag(String name, int value) {
|
||||
return this.intFlag(name, (long) value);
|
||||
}
|
||||
|
||||
default IntFlag intFlag(String name, long value) {
|
||||
return Util.make(new IntFlag(name), flag -> flag.set(value));
|
||||
}
|
||||
|
||||
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 void increment() {
|
||||
this.decrement(1L);
|
||||
}
|
||||
|
||||
public void increment(int amount) {
|
||||
this.decrement((long) amount);
|
||||
}
|
||||
|
||||
public void increment(long amount) {
|
||||
if (this.value != null)
|
||||
this.set(this.value + amount);
|
||||
}
|
||||
|
||||
public void decrement() {
|
||||
this.decrement(1L);
|
||||
}
|
||||
|
||||
public void decrement(int amount) {
|
||||
this.decrement((long) amount);
|
||||
}
|
||||
|
||||
public void decrement(long amount) {
|
||||
if (this.value != null)
|
||||
this.set(this.value - amount);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ package net.minecraftforge.common.extensions;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.*;
|
||||
@@ -31,6 +33,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.ToolAction;
|
||||
import net.minecraftforge.common.ToolActions;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -459,7 +462,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -481,6 +484,28 @@ public interface IForgeItem {
|
||||
*/
|
||||
default void onHorseArmorTick(ItemStack stack, Level level, Mob horse) { }
|
||||
|
||||
/**
|
||||
* Called when this item is to be damaged, such as use a tool being used or a shield blocking damage. The damage
|
||||
* parameter has not yet been processed, so enchantments are not taken into account.
|
||||
*
|
||||
* @param stack The processed amount of damage the item will take
|
||||
* @param damage The amount of damage the item will take before processing
|
||||
* @param level The level where the damage is taking place
|
||||
* @param player The player holding the item
|
||||
* @param canBreak If the item can break from this damage instance ({@code true} if this is called from
|
||||
* {@link ItemStack#hurtAndBreak(int, ServerLevel, ServerPlayer, Consumer)}, {@code false} if from
|
||||
* {@link ItemStack#hurtWithoutBreaking(int, Player)})
|
||||
* @param onBroken The callback for when an item is broken (use this if you plan on cancelling damage that will
|
||||
* break an item)
|
||||
* @return The amount of damage the item should take, after processing
|
||||
*
|
||||
* @apiNote If the item stack is not {@linkplain ItemStack#isDamageableItem() damageable} or the player
|
||||
* {@linkplain Player#hasInfiniteMaterials() has infinite materials}, this method will not be called.
|
||||
*/
|
||||
default int damageItem(ItemStack stack, int damage, ServerLevel level, @Nullable ServerPlayer player, boolean canBreak, Consumer<Item> onBroken) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item entity for this stack is destroyed. Note: The {@link ItemStack} can be retrieved from the item entity.
|
||||
*
|
||||
@@ -587,4 +612,12 @@ public interface IForgeItem {
|
||||
default boolean canGrindstoneRepair(ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The Default Capability Provider for this item, if any, accounting for the given itemstack.
|
||||
*/
|
||||
@Nullable
|
||||
default ICapabilityProvider getCapabilityProvider(ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@@ -32,6 +34,8 @@ import net.minecraftforge.common.ToolActions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/*
|
||||
* Extension added to ItemStack that bounces to ItemSack sensitive Item methods. Typically this is just for convince.
|
||||
*/
|
||||
@@ -377,6 +381,28 @@ public interface IForgeItemStack {
|
||||
return self().getItem().getSweepHitBox(self(), player, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this item is to be damaged, such as use a tool being used or a shield blocking damage. The damage
|
||||
* parameter has not yet been processed, so enchantments are not taken into account.
|
||||
*
|
||||
* @param damage The amount of damage the item will take before processing
|
||||
* @param level The level where the damage is taking place
|
||||
* @param player The player holding the item
|
||||
* @param canBreak If the item can break from this damage instance ({@code true} if this is called from
|
||||
* {@link ItemStack#hurtAndBreak(int, ServerLevel, ServerPlayer, Consumer)}, {@code false} if from
|
||||
* {@link ItemStack#hurtWithoutBreaking(int, Player)})
|
||||
* @param onBroken The callback for when an item is broken (use this if you plan on cancelling damage that will
|
||||
* break an item)
|
||||
* @return The amount of damage the item should take
|
||||
*
|
||||
* @apiNote If the item stack is not {@linkplain ItemStack#isDamageableItem() damageable} or the player
|
||||
* {@linkplain Player#hasInfiniteMaterials() has infinite materials}, this method will not be called.
|
||||
* @see IForgeItem#damageItem(ItemStack, int, ServerLevel, ServerPlayer, boolean, Consumer)
|
||||
*/
|
||||
default int damageItem(int damage, ServerLevel level, @Nullable ServerPlayer player, boolean canBreak, Consumer<Item> onBroken) {
|
||||
return self().getItem().damageItem(self(), damage, level, player, canBreak, onBroken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item entity for this stack is destroyed. Note: The {@link ItemStack} can be retrieved from the item entity.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
package net.minecraftforge.event;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
@@ -29,10 +32,31 @@ import java.util.concurrent.Executor;
|
||||
public class AddReloadListenerEvent extends Event {
|
||||
private final List<PreparableReloadListener> listeners = new ArrayList<>();
|
||||
private final ReloadableServerResources serverResources;
|
||||
|
||||
private final HolderLookup.Provider registries;
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
private final RegistryAccess registryAccess;
|
||||
|
||||
public AddReloadListenerEvent(ReloadableServerResources serverResources, RegistryAccess registryAccess) {
|
||||
/** @deprecated Does not provide additional context. Use {@link #AddReloadListenerEvent(ReloadableServerResources, HolderLookup.Provider, RegistryAccess)} instead. */
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
public AddReloadListenerEvent(
|
||||
ReloadableServerResources serverResources,
|
||||
RegistryAccess registryAccess
|
||||
) {
|
||||
this(
|
||||
serverResources,
|
||||
registryAccess,
|
||||
registryAccess
|
||||
);
|
||||
}
|
||||
|
||||
public AddReloadListenerEvent(
|
||||
ReloadableServerResources serverResources,
|
||||
HolderLookup.Provider registries,
|
||||
@Deprecated(forRemoval = true, since = "1.21.4") RegistryAccess registryAccess
|
||||
) {
|
||||
this.serverResources = serverResources;
|
||||
this.registries = registries;
|
||||
this.registryAccess = registryAccess;
|
||||
}
|
||||
|
||||
@@ -62,21 +86,27 @@ public class AddReloadListenerEvent extends Event {
|
||||
return serverResources.getConditionContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A holder lookup provider containing the registries with updated tags.
|
||||
*
|
||||
* @see net.minecraft.server.ReloadableServerRegistries.LoadResult#lookupWithUpdatedTags()
|
||||
*/
|
||||
public HolderLookup.Provider getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides access to the loaded registries associated with these server resources.
|
||||
* All built-in and dynamic registries are loaded and frozen by this point.
|
||||
* @return The RegistryAccess context for the currently active reload.
|
||||
* @deprecated Does not contain updated tags. Use {@link #getRegistries()} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
public RegistryAccess getRegistryAccess() {
|
||||
return registryAccess;
|
||||
}
|
||||
|
||||
private static class WrappedStateAwareListener implements PreparableReloadListener {
|
||||
private final PreparableReloadListener wrapped;
|
||||
|
||||
private WrappedStateAwareListener(final PreparableReloadListener wrapped) {
|
||||
this.wrapped = wrapped;
|
||||
}
|
||||
private record WrappedStateAwareListener(PreparableReloadListener wrapped) implements PreparableReloadListener {
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(final PreparationBarrier stage, final ResourceManager resourceManager, final Executor backgroundExecutor, final Executor gameExecutor) {
|
||||
@@ -85,5 +115,10 @@ public class AddReloadListenerEvent extends Event {
|
||||
else
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return wrapped.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,10 @@ import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.component.DataComponentMap;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.world.entity.*;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.chunk.storage.SerializableChunkData;
|
||||
@@ -712,10 +715,15 @@ public final class ForgeEventFactory {
|
||||
return fire(new SleepFinishedTimeEvent(level, newTime, minTime)).getNewTime();
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "1.21.4")
|
||||
public static List<PreparableReloadListener> onResourceReload(ReloadableServerResources serverResources, RegistryAccess registryAccess) {
|
||||
return fire(new AddReloadListenerEvent(serverResources, registryAccess)).getListeners();
|
||||
}
|
||||
|
||||
public static List<PreparableReloadListener> onResourceReload(ReloadableServerResources serverResources, HolderLookup.Provider lookupProvider, @Deprecated(forRemoval = true, since = "1.21.4") RegistryAccess registryAccess) {
|
||||
return fire(new AddReloadListenerEvent(serverResources, lookupProvider, registryAccess)).getListeners();
|
||||
}
|
||||
|
||||
public static void onCommandRegister(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection environment, CommandBuildContext context) {
|
||||
post(new RegisterCommandsEvent(dispatcher, environment, context));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package net.minecraftforge.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.ObjIntConsumer;
|
||||
@@ -17,6 +18,9 @@ import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||
|
||||
/**
|
||||
* Controls the title screen brandings for the game.
|
||||
*/
|
||||
public final class BrandingControl {
|
||||
private BrandingControl() {}
|
||||
|
||||
@@ -25,13 +29,29 @@ public final class BrandingControl {
|
||||
|
||||
private static void computeBranding() {
|
||||
if (brandings == null) {
|
||||
brandings = List.of(
|
||||
"Forge " + ForgeVersion.getVersion(),
|
||||
"Minecraft " + MCPVersion.getMCVersion(),
|
||||
"MCP " + MCPVersion.getMCPVersion(),
|
||||
ForgeI18n.parseMessage("fml.menu.loadingmods", ModList.get().size())
|
||||
);
|
||||
brandingsNoMC = brandings.subList(1, brandings.size());
|
||||
var list = new ArrayList<String>();
|
||||
|
||||
// Forge
|
||||
var forge = ForgeVersion.getVersion().split("-", 2);
|
||||
|
||||
// I don't want to use VersionChecker to check for this, so I'm just going to use the version string.
|
||||
// We only have Forge Betas on the "XX.0.XX" versions anyways.
|
||||
boolean beta = "0".equals(forge[0].split("\\.")[1]);
|
||||
var name = beta ? "§eForge Beta§f " : "Forge ";
|
||||
list.add(name + forge[0] + " (" + ForgeI18n.parseMessage("fml.menu.loadingmods", ModList.get().size()) + ")");
|
||||
|
||||
// Extra forge version info (like branch)
|
||||
if (forge.length > 1) list.add("Branch " + forge[1]);
|
||||
|
||||
// TODO [Forge][FML] When FML is rewritten, add its version here behind a config value to show it (debugBrandingVersions)
|
||||
// this is how to check if we are in ForgeDev:
|
||||
// FMLLoader.launcherHandlerName().startsWith("forge_dev")
|
||||
|
||||
// Minecraft
|
||||
list.add("Minecraft " + MCPVersion.getMCVersion());
|
||||
|
||||
brandings = List.copyOf(list);
|
||||
brandingsNoMC = brandings.subList(0, brandings.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +63,11 @@ public final class BrandingControl {
|
||||
return reverse ? brandingsNoMC.reversed() : brandingsNoMC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the branding lines to display over the copyright line. This is usually a message when Forge has an update.
|
||||
*
|
||||
* @return The branding lines to display
|
||||
*/
|
||||
public static List<String> getOverCopyrightBrandings() {
|
||||
final class LazyInit {
|
||||
private static final List<String> INSTANCE = ForgeHooksClient.forgeStatusLine == null
|
||||
@@ -55,22 +80,46 @@ public final class BrandingControl {
|
||||
return LazyInit.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over each branding line, passing the line and its index to the consumer.
|
||||
*
|
||||
* @param includeMC Whether to include the Minecraft version line
|
||||
* @param reverse Whether to iterate in reverse order
|
||||
* @param lineConsumer The consumer to accept each line and its index
|
||||
*/
|
||||
public static void forEachLine(boolean includeMC, boolean reverse, ObjIntConsumer<String> lineConsumer) {
|
||||
var brandings = getBrandings(includeMC, reverse);
|
||||
for (int idx = 0; idx < brandings.size(); idx++)
|
||||
lineConsumer.accept(brandings.get(idx), idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over each branding line that should be displayed above the copyright line, passing the line and its
|
||||
* index to the consumer.
|
||||
*
|
||||
* @param lineConsumer The consumer to accept each line and its index
|
||||
*/
|
||||
public static void forEachAboveCopyrightLine(ObjIntConsumer<String> lineConsumer) {
|
||||
var overCopyrightBrandings = getOverCopyrightBrandings();
|
||||
for (int idx = 0; idx < overCopyrightBrandings.size(); idx++)
|
||||
lineConsumer.accept(overCopyrightBrandings.get(idx), idx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the branding to use in place of the default {@code "vanilla"} branding.
|
||||
*
|
||||
* @return The branding to use
|
||||
*/
|
||||
public static String getBranding() {
|
||||
return "forge";
|
||||
}
|
||||
|
||||
/**
|
||||
* The reload listener for the branding control. On reload, the brandings are recomputed in
|
||||
* {@link #computeBranding()}.
|
||||
*
|
||||
* @return The reload listener
|
||||
*/
|
||||
public static ResourceManagerReloadListener resourceManagerReloadListener() {
|
||||
return BrandingControl::onResourceManagerReload;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,12 @@ import net.minecraft.world.level.block.entity.Hopper;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.DispenserBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
@@ -25,169 +27,129 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class VanillaInventoryCodeHooks
|
||||
{
|
||||
//TODO: [Forge][1.21.9][Cleanup] Mark as @ApiStatus.Internal
|
||||
public class VanillaInventoryCodeHooks {
|
||||
/**
|
||||
* Copied from TileEntityHopper#captureDroppedItems and added capability support
|
||||
* Copied from HopperBlockEntity#suckInItems and added capability support
|
||||
* @return Null if we did nothing {no IItemHandler}, True if we moved an item, False if we moved no items
|
||||
*/
|
||||
@Nullable
|
||||
public static Boolean extractHook(Level level, Hopper dest)
|
||||
{
|
||||
return getItemHandler(level, dest, Direction.UP)
|
||||
.map(itemHandlerResult -> {
|
||||
IItemHandler handler = itemHandlerResult.getKey();
|
||||
public static Boolean extractHook(Level level, Hopper dest) {
|
||||
var handler = getItemHandler(level, dest, Direction.UP).map(Pair::getKey).orElse(null);
|
||||
if (handler == null)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
{
|
||||
ItemStack extractItem = handler.extractItem(i, 1, true);
|
||||
if (!extractItem.isEmpty())
|
||||
{
|
||||
for (int j = 0; j < dest.getContainerSize(); j++)
|
||||
{
|
||||
ItemStack destStack = dest.getItem(j);
|
||||
if (dest.canPlaceItem(j, extractItem) && (destStack.isEmpty() || destStack.getCount() < destStack.getMaxStackSize() && destStack.getCount() < dest.getMaxStackSize() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack)))
|
||||
{
|
||||
extractItem = handler.extractItem(i, 1, false);
|
||||
if (destStack.isEmpty())
|
||||
dest.setItem(j, extractItem);
|
||||
else
|
||||
{
|
||||
destStack.grow(1);
|
||||
dest.setItem(j, destStack);
|
||||
}
|
||||
dest.setChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack extractItem = handler.extractItem(i, 1, true);
|
||||
if (!extractItem.isEmpty()) {
|
||||
for (int j = 0; j < dest.getContainerSize(); j++) {
|
||||
ItemStack destStack = dest.getItem(j);
|
||||
if (dest.canPlaceItem(j, extractItem) && (destStack.isEmpty() || destStack.getCount() < destStack.getMaxStackSize() && destStack.getCount() < dest.getMaxStackSize() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack))) {
|
||||
extractItem = handler.extractItem(i, 1, false);
|
||||
if (destStack.isEmpty())
|
||||
dest.setItem(j, extractItem);
|
||||
else {
|
||||
destStack.grow(1);
|
||||
dest.setItem(j, destStack);
|
||||
}
|
||||
dest.setChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
.orElse(null); // TODO bad null
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from BlockDropper#dispense and added capability support
|
||||
*/
|
||||
public static boolean dropperInsertHook(Level level, BlockPos pos, DispenserBlockEntity dropper, int slot, @NotNull ItemStack stack)
|
||||
{
|
||||
Direction enumfacing = level.getBlockState(pos).getValue(DropperBlock.FACING);
|
||||
BlockPos blockpos = pos.relative(enumfacing);
|
||||
return getItemHandler(level, (double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), enumfacing.getOpposite())
|
||||
.map(destinationResult -> {
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
Object destination = destinationResult.getValue();
|
||||
ItemStack dispensedStack = stack.copy().split(1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(dropper, destination, itemHandler, dispensedStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
{
|
||||
remainder = stack.copy();
|
||||
remainder.shrink(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
remainder = stack.copy();
|
||||
}
|
||||
|
||||
dropper.setItem(slot, remainder);
|
||||
return false;
|
||||
})
|
||||
.orElse(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from TileEntityHopper#transferItemsOut and added capability support
|
||||
*/
|
||||
public static boolean insertHook(HopperBlockEntity hopper)
|
||||
{
|
||||
Direction hopperFacing = hopper.getBlockState().getValue(HopperBlock.FACING);
|
||||
return getItemHandler(hopper.getLevel(), hopper, hopperFacing)
|
||||
.map(destinationResult -> {
|
||||
IItemHandler itemHandler = destinationResult.getKey();
|
||||
Object destination = destinationResult.getValue();
|
||||
if (isFull(itemHandler))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < hopper.getContainerSize(); ++i)
|
||||
{
|
||||
if (!hopper.getItem(i).isEmpty())
|
||||
{
|
||||
ItemStack originalSlotContents = hopper.getItem(i).copy();
|
||||
ItemStack insertStack = hopper.removeItem(i, 1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(hopper, destination, itemHandler, insertStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
hopper.setItem(i, originalSlotContents);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
private static ItemStack putStackInInventoryAllSlots(BlockEntity source, Object destination, IItemHandler destInventory, ItemStack stack)
|
||||
{
|
||||
for (int slot = 0; slot < destInventory.getSlots() && !stack.isEmpty(); slot++)
|
||||
{
|
||||
stack = insertStack(source, destination, destInventory, stack, slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from DropperBlock#dispenseFrom and added capability support
|
||||
*/
|
||||
public static boolean dropperInsertHook(Level level, BlockPos pos, DispenserBlockEntity dropper, int slot, @NotNull ItemStack stack) {
|
||||
var direction = level.getBlockState(pos).getValue(DropperBlock.FACING);
|
||||
var handler = getItemHandlerPair(level, pos.relative(direction), direction.getOpposite());
|
||||
if (handler.isEmpty())
|
||||
return true;
|
||||
|
||||
var itemHandler = handler.get().getKey();
|
||||
var destination = handler.get().getValue();
|
||||
|
||||
ItemStack dispensedStack = stack.copy().split(1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(dropper, destination, itemHandler, dispensedStack);
|
||||
|
||||
if (remainder.isEmpty()) {
|
||||
remainder = stack.copy();
|
||||
remainder.shrink(1);
|
||||
} else
|
||||
remainder = stack.copy();
|
||||
|
||||
dropper.setItem(slot, remainder);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from HopperBlockEntity#ejectItems and added capability support
|
||||
*/
|
||||
public static boolean insertHook(HopperBlockEntity hopper) {
|
||||
var handler = getItemHandler(hopper.getLevel(), hopper, hopper.getBlockState().getValue(HopperBlock.FACING));
|
||||
if (handler.isEmpty())
|
||||
return false;
|
||||
|
||||
var itemHandler = handler.get().getKey();
|
||||
var destination = handler.get().getValue();
|
||||
|
||||
if (isFull(itemHandler))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < hopper.getContainerSize(); ++i) {
|
||||
if (!hopper.getItem(i).isEmpty()) {
|
||||
ItemStack originalSlotContents = hopper.getItem(i).copy();
|
||||
ItemStack insertStack = hopper.removeItem(i, 1);
|
||||
ItemStack remainder = putStackInInventoryAllSlots(hopper, destination, itemHandler, insertStack);
|
||||
|
||||
if (remainder.isEmpty())
|
||||
return true;
|
||||
|
||||
hopper.setItem(i, originalSlotContents);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ItemStack putStackInInventoryAllSlots(BlockEntity source, Object destination, IItemHandler destInventory, ItemStack stack) {
|
||||
for (int slot = 0; slot < destInventory.getSlots() && !stack.isEmpty(); slot++)
|
||||
stack = insertStack(source, destination, destInventory, stack, slot);
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from TileEntityHopper#insertStack and added capability support
|
||||
* Copied from HopperBlockEntity#tryMoveInItem and added capability support
|
||||
*/
|
||||
private static ItemStack insertStack(BlockEntity source, Object destination, IItemHandler destInventory, ItemStack stack, int slot)
|
||||
{
|
||||
private static ItemStack insertStack(BlockEntity source, Object destination, IItemHandler destInventory, ItemStack stack, int slot) {
|
||||
ItemStack itemstack = destInventory.getStackInSlot(slot);
|
||||
|
||||
if (destInventory.insertItem(slot, stack, true).isEmpty())
|
||||
{
|
||||
if (destInventory.insertItem(slot, stack, true).isEmpty()) {
|
||||
boolean insertedItem = false;
|
||||
boolean inventoryWasEmpty = isEmpty(destInventory);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
if (itemstack.isEmpty()) {
|
||||
destInventory.insertItem(slot, stack, false);
|
||||
stack = ItemStack.EMPTY;
|
||||
insertedItem = true;
|
||||
}
|
||||
else if (ItemHandlerHelper.canItemStacksStack(itemstack, stack))
|
||||
{
|
||||
} else if (ItemHandlerHelper.canItemStacksStack(itemstack, stack)) {
|
||||
int originalSize = stack.getCount();
|
||||
stack = destInventory.insertItem(slot, stack, false);
|
||||
insertedItem = originalSize < stack.getCount();
|
||||
}
|
||||
|
||||
if (insertedItem)
|
||||
{
|
||||
if (inventoryWasEmpty && destination instanceof HopperBlockEntity)
|
||||
{
|
||||
HopperBlockEntity destinationHopper = (HopperBlockEntity)destination;
|
||||
|
||||
if (!destinationHopper.isOnCustomCooldown())
|
||||
{
|
||||
if (insertedItem) {
|
||||
if (inventoryWasEmpty && destination instanceof HopperBlockEntity dHopper) {
|
||||
if (!dHopper.isOnCustomCooldown()) {
|
||||
int k = 0;
|
||||
if (source instanceof HopperBlockEntity)
|
||||
{
|
||||
if (destinationHopper.getLastUpdateTime() >= ((HopperBlockEntity) source).getLastUpdateTime())
|
||||
{
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
destinationHopper.setCooldown(8 - k);
|
||||
if (source instanceof HopperBlockEntity sHopper && dHopper.getLastUpdateTime() >= sHopper.getLastUpdateTime())
|
||||
k = 1;
|
||||
dHopper.setCooldown(8 - k);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,53 +158,90 @@ public class VanillaInventoryCodeHooks
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static Optional<Pair<IItemHandler, Object>> getItemHandler(Level level, Hopper hopper, Direction hopperFacing)
|
||||
{
|
||||
private static Optional<Pair<IItemHandler, Object>> getItemHandler(Level level, Hopper hopper, Direction hopperFacing) {
|
||||
double x = hopper.getLevelX() + (double) hopperFacing.getStepX();
|
||||
double y = hopper.getLevelY() + (double) hopperFacing.getStepY();
|
||||
double z = hopper.getLevelZ() + (double) hopperFacing.getStepZ();
|
||||
return getItemHandler(level, x, y, z, hopperFacing.getOpposite());
|
||||
}
|
||||
|
||||
private static boolean isFull(IItemHandler itemHandler)
|
||||
{
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++)
|
||||
{
|
||||
private static boolean isFull(IItemHandler itemHandler) {
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = itemHandler.getStackInSlot(slot);
|
||||
if (stackInSlot.isEmpty() || stackInSlot.getCount() < itemHandler.getSlotLimit(slot))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isEmpty(IItemHandler itemHandler)
|
||||
{
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++)
|
||||
{
|
||||
private static boolean isEmpty(IItemHandler itemHandler) {
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++) {
|
||||
ItemStack stackInSlot = itemHandler.getStackInSlot(slot);
|
||||
if (stackInSlot.getCount() > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Optional<Pair<IItemHandler, Object>> getItemHandler(Level worldIn, double x, double y, double z, final Direction side)
|
||||
{
|
||||
/**
|
||||
* Gets the IItemHandler at the given position, checking for both BlockEntities
|
||||
* and Entities. If both are present, the BlockEntity is preferred.
|
||||
*
|
||||
* This is equivalent to HopperBlockEntity#getContainerAt
|
||||
*
|
||||
* @param level The level to check
|
||||
* @param pos The position to check
|
||||
* @param side The side to check from. Can be null.
|
||||
* @return An IItemHandler and the object it was obtained from, or an empty
|
||||
* Optional if none was found.
|
||||
*/
|
||||
public static Optional<IItemHandler> getItemHandler(Level level, BlockPos pos, @Nullable Direction side) {
|
||||
var handler = getItemHandlerBlock(level, pos, side);
|
||||
if (!handler.isPresent())
|
||||
handler = getItemHandlerEntity(level, pos, side);
|
||||
return handler;
|
||||
}
|
||||
|
||||
public static Optional<IItemHandler> getItemHandlerEntity(Level level, BlockPos pos, @Nullable Direction side) {
|
||||
var entities = level.getEntities((Entity)null, new AABB(pos), e -> e.getCapability(ForgeCapabilities.ITEM_HANDLER, side).isPresent());
|
||||
|
||||
if (entities.isEmpty())
|
||||
return Optional.empty();
|
||||
|
||||
var rand = level.random.nextInt(entities.size());
|
||||
var entity = entities.get(rand);
|
||||
return entity.getCapability(ForgeCapabilities.ITEM_HANDLER, side).resolve();
|
||||
}
|
||||
|
||||
public static Optional<IItemHandler> getItemHandlerBlock(Level level, BlockPos pos, @Nullable Direction side) {
|
||||
if (!level.getBlockState(pos).hasBlockEntity())
|
||||
return Optional.empty();
|
||||
|
||||
var entity = level.getBlockEntity(pos);
|
||||
if (entity == null)
|
||||
return Optional.empty();
|
||||
|
||||
return entity.getCapability(ForgeCapabilities.ITEM_HANDLER, side).resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* I don't think anyone should be using this. If they are they probably want the non-pair version.
|
||||
* As the only use for knowing the object holding the IItemHandler is for hopper cooldowns
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.8")
|
||||
public static Optional<Pair<IItemHandler, Object>> getItemHandler(Level worldIn, double x, double y, double z, final Direction side) {
|
||||
int i = Mth.floor(x);
|
||||
int j = Mth.floor(y);
|
||||
int k = Mth.floor(z);
|
||||
BlockPos blockpos = new BlockPos(i, j, k);
|
||||
net.minecraft.world.level.block.state.BlockState state = worldIn.getBlockState(blockpos);
|
||||
return getItemHandlerPair(worldIn, new BlockPos(i, j, k), side);
|
||||
}
|
||||
|
||||
if (state.hasBlockEntity())
|
||||
{
|
||||
BlockEntity blockEntity = worldIn.getBlockEntity(blockpos);
|
||||
if (blockEntity != null)
|
||||
{
|
||||
private static Optional<Pair<IItemHandler, Object>> getItemHandlerPair(Level level, BlockPos pos, Direction side) {
|
||||
var state = level.getBlockState(pos);
|
||||
|
||||
if (state.hasBlockEntity()) {
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
if (blockEntity != null) {
|
||||
return blockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, side)
|
||||
.map(capability -> ImmutablePair.<IItemHandler, Object>of(capability, blockEntity));
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeConfig;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.network.ChannelRegistrationChangeEvent;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
@@ -26,6 +28,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ApiStatus.Internal // TODO: Decide what I want to have public, Right now it should just be add/remove channels.
|
||||
public class ChannelListManager {
|
||||
@@ -70,7 +73,7 @@ public class ChannelListManager {
|
||||
}
|
||||
|
||||
private static void register(Register payload, CustomPayloadEvent.Context ctx) {
|
||||
updateFrom(ctx, payload.channels(), ChannelRegistrationChangeEvent.Type.REGISTER);
|
||||
updateFrom(ctx, payload.channels(), ChannelRegistrationChangeEvent.Type.REGISTER, ctx.isClientSide());
|
||||
ctx.setPacketHandled(true);
|
||||
// Send the client's channels to the server whenever asked. If we're in the login state then our login wrapper will unwrap for us.
|
||||
if (ctx.isClientSide())
|
||||
@@ -78,7 +81,7 @@ public class ChannelListManager {
|
||||
}
|
||||
|
||||
private static void unregister(Unregister payload, CustomPayloadEvent.Context ctx) {
|
||||
updateFrom(ctx, payload.channels(), ChannelRegistrationChangeEvent.Type.UNREGISTER);
|
||||
updateFrom(ctx, payload.channels(), ChannelRegistrationChangeEvent.Type.UNREGISTER, ctx.isClientSide());
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
|
||||
@@ -145,7 +148,7 @@ public class ChannelListManager {
|
||||
return Collections.unmodifiableList(channels);
|
||||
}
|
||||
|
||||
private static void updateFrom(CustomPayloadEvent.Context source, List<String> channels, final ChannelRegistrationChangeEvent.Type changeType) {
|
||||
private static void updateFrom(CustomPayloadEvent.Context source, List<String> channels, final ChannelRegistrationChangeEvent.Type changeType, boolean isClient) {
|
||||
var changed = new HashSet<ResourceLocation>();
|
||||
for (var channel : channels) {
|
||||
// It also says nothing about the format of channels so ignore bad channels.
|
||||
@@ -162,11 +165,20 @@ public class ChannelListManager {
|
||||
|
||||
ForgeEventFactory.onChannelRegistrationChange(source.getConnection(), changeType, changed);
|
||||
|
||||
// It is a known issue, that I don't really care about, that we don't get the true in-memory size of each channel due to character encoding.
|
||||
// A sane limit of 1KB will be enough to catch any malicious actors even with non-8-bit strings.
|
||||
var list = NetworkContext.get(source.getConnection());
|
||||
for (var channel : changed) {
|
||||
boolean fire = changeType == ChannelRegistrationChangeEvent.Type.UNREGISTER
|
||||
? list.remoteChannels.remove(channel)
|
||||
: list.remoteChannels.add(channel);
|
||||
boolean fire = false;
|
||||
if (changeType == ChannelRegistrationChangeEvent.Type.UNREGISTER) {
|
||||
fire = list.remoteChannels.remove(channel);
|
||||
if (fire)
|
||||
list.remoteChannelsSize -= channel.toString().length();
|
||||
} else {
|
||||
fire = list.remoteChannels.add(channel);
|
||||
if (fire)
|
||||
list.remoteChannelsSize += channel.toString().length();
|
||||
}
|
||||
|
||||
if (fire) {
|
||||
var target = NetworkRegistry.findTarget(channel);
|
||||
@@ -174,5 +186,21 @@ public class ChannelListManager {
|
||||
target.registrationChange(channel, changeType == ChannelRegistrationChangeEvent.Type.REGISTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (list.remoteChannelsSize >= NetworkRegistry.getChannelMemorySize() && list.remoteChannelsSize >= ForgeConfig.COMMON.channelListLimit.get()) {
|
||||
LOGGER.warn("Received too many network channels, {} channels using {} bytes, Limit is currently {}, to change edit the Forge {} in config\forge_common.toml",
|
||||
list.remoteChannels.size(), list.remoteChannelsSize, ForgeConfig.COMMON.channelListLimit.get(), ForgeConfig.COMMON.channelListLimit.getPath().stream().collect(Collectors.joining("."))
|
||||
);
|
||||
|
||||
if (isClient) {
|
||||
// We don't want to allow the server to screw with us, so just remove the added channels
|
||||
for (var channel : changed) {
|
||||
if (list.remoteChannels.remove(channel))
|
||||
list.remoteChannelsSize -= channel.toString().length();
|
||||
}
|
||||
} else {
|
||||
source.getSender().connection.disconnect(Component.translatable("forge.server.channellistlimit.kick"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,8 @@ public class NetworkContext {
|
||||
|
||||
@ApiStatus.Internal
|
||||
Set<ResourceLocation> remoteChannels = new HashSet<>();
|
||||
@ApiStatus.Internal
|
||||
long remoteChannelsSize = 0;
|
||||
private Set<ResourceLocation> remoteChannelsView = Collections.unmodifiableSet(this.remoteChannels);
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user