mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 09:05:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ccfaf4812 | ||
|
|
3ed3d2b9cf | ||
|
|
3d374fe732 | ||
|
|
a02f3f9841 | ||
|
|
c5e462f7d2 | ||
|
|
d1f79d6655 | ||
|
|
9d5e81b1a9 | ||
|
|
a1c275df46 | ||
|
|
4ef7fe8bd8 | ||
|
|
ce8838e721 | ||
|
|
b7e2593d48 | ||
|
|
33d177f02e | ||
|
|
5d2186df63 | ||
|
|
77af36b807 | ||
|
|
54eeca0aed | ||
|
|
3de0566425 | ||
|
|
a5ebf3b645 | ||
|
|
63d0496cc4 | ||
|
|
31f623e794 | ||
|
|
eb001a6382 | ||
|
|
504dcad849 | ||
|
|
81f7f029c3 | ||
|
|
207c1997c9 | ||
|
|
e348ae5b84 | ||
|
|
0f3b8ee830 | ||
|
|
b4b6e48a7a |
No files matched your search
@@ -231,7 +231,6 @@ patcher {
|
||||
args '--launchTarget', 'forge_dev_client_data',
|
||||
'--mod', 'forge',
|
||||
'--all',
|
||||
'--validate',
|
||||
'--output', rootProject.file('src/main/generated/'),
|
||||
'--existing', sourceSets.main.resources.srcDirs[0],
|
||||
'--assetsDir', downloadAssets.output,
|
||||
|
||||
+7
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
MinecraftForge
|
||||
=============
|
||||
[][Download]
|
||||
[][Download]
|
||||
[][Download] [][Discord] [][Patreon]
|
||||
|
||||
@@ -70,6 +70,11 @@ Please ensure you have a valid email address associated with your GitHub account
|
||||
to use and modify. However, it costs money to run such a large project as this, so please consider
|
||||
[becoming a patron][Patreon].*
|
||||
|
||||
### Thanks
|
||||
[](https://www.yourkit.com/)
|
||||
|
||||
YourKit for providing us accesss to their [YourKit Java Profiler] which helps identify bottlenecks and places for improvment.
|
||||
|
||||
[Contributing]: ./CONTRIBUTING.md
|
||||
[CLA]: https://cla-assistant.io/MinecraftForge/MinecraftForge
|
||||
|
||||
@@ -93,3 +98,4 @@ Please ensure you have a valid email address associated with your GitHub account
|
||||
[Pull-Requests]: https://docs.minecraftforge.net/en/latest/forgedev/#making-changes-and-pull-requests
|
||||
|
||||
[Patreon]: https://www.patreon.com/LexManos
|
||||
[YourKit Java Profiler]: https://www.yourkit.com/java/profiler/
|
||||
@@ -25,7 +25,18 @@ import java.util.function.Supplier;
|
||||
* <li>When you want to call one thing on one side, another thing on the other and return a result {@link #safeRunForDist(Supplier, Supplier)}</li>
|
||||
* <li>When you want to run something on one side {@link #safeRunWhenOn(Dist, Supplier)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @deprecated Historically, this allowed for safe execution of code on the correct side by exploiting a low-level
|
||||
* detail in Java 8, but in newer versions a simple if check is enough.
|
||||
* <br>
|
||||
* For example:
|
||||
* <pre>{@code
|
||||
* if (FMLEnvironment.dist.isClient()) {
|
||||
* // client code here
|
||||
* }
|
||||
* }</pre>
|
||||
*/
|
||||
@Deprecated(since = "1.21.5", forRemoval = true)
|
||||
public final class DistExecutor
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
+11
-12
@@ -90,7 +90,12 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
// The GL ID of the window. Used for all operations
|
||||
private long window;
|
||||
// The thread that contains and ticks the window while Forge is loading mods
|
||||
private ScheduledExecutorService renderScheduler;
|
||||
private static final ScheduledExecutorService renderScheduler = Executors.newSingleThreadScheduledExecutor(r -> {
|
||||
final var thread = Executors.defaultThreadFactory().newThread(r);
|
||||
thread.setName("EarlyDisplay");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
private int fbWidth;
|
||||
private int fbHeight;
|
||||
private int fbScale;
|
||||
@@ -149,7 +154,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
}
|
||||
this.maximized = parsed.has(maximizedopt) || FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_MAXIMIZED);
|
||||
|
||||
StartupNotificationManager.modLoaderConsumer().ifPresent(c->c.accept("Forge loading " + forgeVersion));
|
||||
StartupNotificationManager.modLoaderConsumer().ifPresent(c->c.accept("Forge loading " + FMLLoader.versionInfo().forgeVersion()));
|
||||
performanceInfo = new PerformanceInfo();
|
||||
return start(mcVersion, forgeVersion);
|
||||
}
|
||||
@@ -238,7 +243,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
|
||||
var date = Calendar.getInstance();
|
||||
if (FMLConfig.getBoolConfigValue(FMLConfig.ConfigValue.EARLY_WINDOW_SQUIR) || (date.get(Calendar.MONTH) == Calendar.APRIL && date.get(Calendar.DAY_OF_MONTH) == 1))
|
||||
this.elements.add(0, RenderElement.squir());
|
||||
this.elements.addFirst(RenderElement.squir());
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -287,12 +292,6 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
* Start the window and Render Thread; we're ready to go.
|
||||
*/
|
||||
public Runnable start(@Nullable String mcVersion, final String forgeVersion) {
|
||||
renderScheduler = Executors.newSingleThreadScheduledExecutor(r -> {
|
||||
final var thread = Executors.defaultThreadFactory().newThread(r);
|
||||
thread.setName("EarlyDisplay");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
initWindow(mcVersion);
|
||||
this.initializationFuture = renderScheduler.schedule(() -> initRender(mcVersion, forgeVersion), 1, TimeUnit.MILLISECONDS);
|
||||
return this::periodicTick;
|
||||
@@ -304,7 +303,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
return this.glVersion;
|
||||
}
|
||||
|
||||
private void crashElegantly(String errorDetails) {
|
||||
private static void crashElegantly(String errorDetails) {
|
||||
StringBuilder msgBuilder = new StringBuilder(2000);
|
||||
msgBuilder.append("Failed to initialize graphics window with current settings.\n");
|
||||
msgBuilder.append("\n\n");
|
||||
@@ -512,7 +511,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
this.winY = y;
|
||||
}
|
||||
}
|
||||
private void handleLastGLFWError(BiConsumer<Integer, String> handler) {
|
||||
private static void handleLastGLFWError(BiConsumer<Integer, String> handler) {
|
||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
||||
PointerBuffer pointerbuffer = memorystack.mallocPointer(1);
|
||||
int error = glfwGetError(pointerbuffer);
|
||||
@@ -640,7 +639,7 @@ public class DisplayWindow implements ImmediateWindowProvider {
|
||||
}
|
||||
|
||||
public void addMojangTexture(final int textureId) {
|
||||
this.elements.add(0, RenderElement.mojang(textureId, framecount));
|
||||
this.elements.addFirst(RenderElement.mojang(textureId, framecount));
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
||||
+30
-29
@@ -22,8 +22,8 @@ public class RenderElement {
|
||||
static int globalAlpha = 255;
|
||||
private int retireCount;
|
||||
|
||||
@FunctionalInterface
|
||||
interface Renderer {
|
||||
|
||||
void accept(SimpleBufferBuilder bb, DisplayContext context, int frame);
|
||||
|
||||
default Renderer then(Renderer r) {
|
||||
@@ -38,6 +38,9 @@ public class RenderElement {
|
||||
interface TextureRenderer {
|
||||
void accept(SimpleBufferBuilder bb, DisplayContext context, int[] size, int frame);
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link Renderer} directly. This was always eagerly resolved, making it an unnecessary wrapper. */
|
||||
@Deprecated(since = "1.21.5", forRemoval = true)
|
||||
@FunctionalInterface
|
||||
interface Initializer extends Supplier<Renderer> {}
|
||||
|
||||
@@ -56,11 +59,18 @@ public class RenderElement {
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated Use {@link RenderElement#RenderElement(Renderer)} instead */
|
||||
@Deprecated(since = "1.21.5", forRemoval = true)
|
||||
public RenderElement(final Initializer rendererInitializer) {
|
||||
this.bb = new SimpleBufferBuilder(1);
|
||||
this.renderer = rendererInitializer.get();
|
||||
}
|
||||
|
||||
public RenderElement(Renderer renderer) {
|
||||
this.bb = new SimpleBufferBuilder(1);
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
public boolean render(DisplayContext ctx, int count) {
|
||||
this.renderer.accept(bb, ctx, count);
|
||||
return this.retireCount == 0 || this.retireCount < count;
|
||||
@@ -75,7 +85,7 @@ public class RenderElement {
|
||||
List<SimpleFont.DisplayText> texts = new ArrayList<>();
|
||||
for (int i = messages.size() - 1; i >= 0; i--) {
|
||||
final StartupNotificationManager.AgeMessage pair = messages.get(i);
|
||||
final float fade = clamp((4000.0f - (float) pair.age() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f);
|
||||
final float fade = Math.clamp((4000.0f - (float) pair.age() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f);
|
||||
if (fade <0.01f) continue;
|
||||
Message msg = pair.message();
|
||||
int colour = Math.min((int)(fade * 255f), globalAlpha) << 24 | 0xFFFFFF;
|
||||
@@ -86,7 +96,7 @@ public class RenderElement {
|
||||
}
|
||||
|
||||
public static RenderElement mojang(final int textureId, final int frameStart) {
|
||||
return new RenderElement(()->(bb, ctx, frame) -> {
|
||||
return new RenderElement((bb, ctx, frame) -> {
|
||||
var size = 256 * ctx.scale();
|
||||
var x0 = (ctx.scaledWidth() - 2 * size) / 2;
|
||||
var y0 = 64 * ctx.scale() + 32;
|
||||
@@ -138,11 +148,11 @@ public class RenderElement {
|
||||
}));
|
||||
}
|
||||
public static RenderElement progressBars(SimpleFont font) {
|
||||
return new RenderElement(() -> (bb, ctx, frame) -> RenderElement.startupProgressBars(font, bb, ctx, frame));
|
||||
return new RenderElement((bb, ctx, frame) -> RenderElement.startupProgressBars(font, bb, ctx, frame));
|
||||
}
|
||||
|
||||
public static RenderElement performanceBar(SimpleFont font) {
|
||||
return new RenderElement(() -> (bb, ctx, frame) -> RenderElement.memoryInfo(font, bb, ctx, frame));
|
||||
return new RenderElement((bb, ctx, frame) -> RenderElement.memoryInfo(font, bb, ctx, frame));
|
||||
}
|
||||
|
||||
public static void startupProgressBars(SimpleFont font, final SimpleBufferBuilder buffer, final DisplayContext context, final int frameNumber) {
|
||||
@@ -177,10 +187,10 @@ public class RenderElement {
|
||||
}
|
||||
private static float[] indeterminateBar(int frame, boolean isActive) {
|
||||
if (RenderElement.globalAlpha != 0xFF || !isActive) {
|
||||
return new float[] {0f,1f};
|
||||
return new float[] { 0f, 1f };
|
||||
} else {
|
||||
var progress = frame % 100;
|
||||
return new float[]{clamp((progress - 2) / 100f, 0f, 1f), clamp((progress + 2) / 100f, 0f, 1f)};
|
||||
int progress = frame % 100;
|
||||
return new float[] { Math.clamp((progress - 2) / 100f, 0f, 1f), Math.clamp((progress + 2) / 100f, 0f, 1f) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,8 +249,8 @@ public class RenderElement {
|
||||
};
|
||||
}
|
||||
|
||||
private static Initializer initializeText(SimpleFont font, TextGenerator textGenerator) {
|
||||
return () -> (bb, context, frame) -> renderText(font, textGenerator, bb, context);
|
||||
private static Renderer initializeText(SimpleFont font, TextGenerator textGenerator) {
|
||||
return (bb, context, frame) -> renderText(font, textGenerator, bb, context);
|
||||
}
|
||||
|
||||
private static void renderText(final SimpleFont font, final TextGenerator textGenerator, final SimpleBufferBuilder bb, final DisplayContext context) {
|
||||
@@ -254,14 +264,13 @@ public class RenderElement {
|
||||
private static TextGenerator text(int x, int y, String text, int colour) {
|
||||
return (bb, font, context) -> font.generateVerticesForTexts(x, y, bb, new SimpleFont.DisplayText(text, colour));
|
||||
}
|
||||
private static Initializer initializeTexture(final String textureFileName, int size, int textureNumber, TextureRenderer positionAndColour) {
|
||||
return ()->{
|
||||
int[] imgSize = STBHelper.loadTextureFromClasspath(textureFileName, size, GL_TEXTURE0 + textureNumber + INDEX_TEXTURE_OFFSET);
|
||||
return (bb, ctx, frame) -> {
|
||||
ctx.elementShader().updateTextureUniform(textureNumber + INDEX_TEXTURE_OFFSET);
|
||||
ctx.elementShader().updateRenderTypeUniform(ElementShader.RenderType.TEXTURE);
|
||||
renderTexture(bb, ctx, frame, imgSize, positionAndColour);
|
||||
};
|
||||
|
||||
private static Renderer initializeTexture(final String textureFileName, int size, int textureNumber, TextureRenderer positionAndColour) {
|
||||
int[] imgSize = STBHelper.loadTextureFromClasspath(textureFileName, size, GL_TEXTURE0 + textureNumber + INDEX_TEXTURE_OFFSET);
|
||||
return (bb, ctx, frame) -> {
|
||||
ctx.elementShader().updateTextureUniform(textureNumber + INDEX_TEXTURE_OFFSET);
|
||||
ctx.elementShader().updateRenderTypeUniform(ElementShader.RenderType.TEXTURE);
|
||||
renderTexture(bb, ctx, frame, imgSize, positionAndColour);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -271,21 +280,13 @@ public class RenderElement {
|
||||
bb.draw();
|
||||
}
|
||||
|
||||
|
||||
@Deprecated(since = "1.21.5", forRemoval = true)
|
||||
public static float clamp(float num, float min, float max) {
|
||||
if (num < min) {
|
||||
return min;
|
||||
} else {
|
||||
return Math.min(num, max);
|
||||
}
|
||||
return Math.clamp(num, min, max);
|
||||
}
|
||||
|
||||
public static int clamp(int num, int min, int max) {
|
||||
if (num < min) {
|
||||
return min;
|
||||
} else {
|
||||
return Math.min(num, max);
|
||||
}
|
||||
return Math.min(max, Math.max(num, min));
|
||||
}
|
||||
|
||||
public static int hsvToRGB(float hue, float saturation, float value) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SimpleFont {
|
||||
private final int textureNumber;
|
||||
private final int lineSpacing;
|
||||
private final int descent;
|
||||
private final int GLYPH_COUNT = 127-32;
|
||||
private static final int GLYPH_COUNT = 127 - 32;
|
||||
private final Glyph[] glyphs;
|
||||
|
||||
private record Glyph(char c, int charwidth, int[] pos, float[] uv) {
|
||||
@@ -120,7 +120,7 @@ public class SimpleFont {
|
||||
case '\n', '\t' -> 0;
|
||||
case ' ' -> glyphs[0].charwidth();
|
||||
default -> {
|
||||
if (c - 32 < this.GLYPH_COUNT && c > 32) {
|
||||
if (c - 32 < GLYPH_COUNT && c > 32) {
|
||||
yield this.glyphs[c - 32].charwidth();
|
||||
} else {
|
||||
yield 0;
|
||||
@@ -151,7 +151,7 @@ public class SimpleFont {
|
||||
case '\t' -> new Pos(pos.x()+font.glyphs[0].charwidth() * 4, pos.y(), pos.minx());
|
||||
case ' ' -> new Pos(pos.x()+font.glyphs[0].charwidth(), pos.y(), pos.minx());
|
||||
default -> {
|
||||
if (c-32 < font.GLYPH_COUNT && c > 32) {
|
||||
if (c-32 < GLYPH_COUNT && c > 32) {
|
||||
pos = font.glyphs[c - 32].loadQuad(pos, colour(), bb);
|
||||
}
|
||||
yield pos;
|
||||
|
||||
+33
-22
@@ -2,7 +2,7 @@ plugins {
|
||||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.36,6.2)'
|
||||
}
|
||||
|
||||
version = mod_version
|
||||
@@ -22,17 +22,13 @@ minecraft {
|
||||
// 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.
|
||||
|
||||
// Forge 1.20.6 and newer use official mappings at runtime, so we shouldn't reobf from official to SRG
|
||||
reobf = false
|
||||
|
||||
// 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.
|
||||
@@ -50,8 +46,7 @@ minecraft {
|
||||
// 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.
|
||||
// This property enables access transformers for use in development, 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.
|
||||
@@ -65,17 +60,15 @@ minecraft {
|
||||
configureEach {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be added/remove as needed separated by commas.
|
||||
// Optional additional logging. 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'
|
||||
// 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'
|
||||
|
||||
// arg "-mixin.config=${mod_id}.mixins.json"
|
||||
}
|
||||
|
||||
client {
|
||||
@@ -110,7 +103,26 @@ sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
repositories {
|
||||
// Put repositories for dependencies here
|
||||
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'Forge'
|
||||
url = 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
name = 'Minecraft libraries'
|
||||
url = 'https://libraries.minecraft.net'
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Sponge'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('org.spongepowered')
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -147,7 +159,7 @@ dependencies {
|
||||
// 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 {
|
||||
tasks.named('processResources', ProcessResources) {
|
||||
var replaceProperties = [
|
||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version: forge_version, forge_version_range: forge_version_range,
|
||||
@@ -163,7 +175,7 @@ tasks.named('processResources', ProcessResources).configure {
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
tasks.named('jar', Jar).configure {
|
||||
tasks.named('jar', Jar) {
|
||||
manifest {
|
||||
attributes([
|
||||
'Specification-Title' : mod_id,
|
||||
@@ -173,6 +185,7 @@ tasks.named('jar', Jar).configure {
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_authors
|
||||
])
|
||||
// attributes['MixinConfigs'] = "${mod_id}.mixins.json"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +207,7 @@ tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
// IntelliJ no longer downloads javadocs and sources by default.
|
||||
// This tells Gradle to force IDEA to do it.
|
||||
// IntelliJ no longer downloads javadocs and sources by default, this tells Gradle to force IntelliJ to do it.
|
||||
idea.module { downloadJavadoc = downloadSources = true }
|
||||
|
||||
eclipse {
|
||||
@@ -205,8 +217,7 @@ eclipse {
|
||||
synchronizationTasks 'genEclipseRuns'
|
||||
}
|
||||
|
||||
// Merge the resources and classes into the same directory.
|
||||
// This is done because java expects modules to be in a single directory.
|
||||
// Merge the resources and classes into the same directory, 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 {
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# 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.jvmargs=-Xmx5G
|
||||
org.gradle.daemon=false
|
||||
|
||||
# In the case that Gradle needs to fork to recompile, this will set the memory for that process.
|
||||
systemProp.net.minecraftforge.gradle.repo.recompile.fork=true
|
||||
systemProp.net.minecraftforge.gradle.repo.recompile.fork.args=-Xmx5G
|
||||
|
||||
# Opts-out of ForgeGradle automatically adding mavenCentral(), Forge's maven and MC libs maven to the repositories block
|
||||
systemProp.net.minecraftforge.gradle.repo.attach=false
|
||||
|
||||
|
||||
## Environment Properties
|
||||
|
||||
|
||||
+2
-2
@@ -9,5 +9,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||
}
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
|
||||
}
|
||||
@@ -10,6 +10,14 @@
|
||||
? Optional.empty()
|
||||
: Optional.of(p_232011_),
|
||||
Codec.STRING
|
||||
@@ -683,6 +_,7 @@
|
||||
public boolean onboardAccessibility = true;
|
||||
public boolean syncWrites;
|
||||
public boolean startedCleanly = true;
|
||||
+ private final Map<String, String> unknownKeys = new java.util.HashMap<>();
|
||||
|
||||
public OptionInstance<Boolean> darkMojangStudiosBackground() {
|
||||
return this.darkMojangStudiosBackground;
|
||||
@@ -1050,6 +_,7 @@
|
||||
}
|
||||
|
||||
@@ -18,15 +26,16 @@
|
||||
this.minecraft = p_92138_;
|
||||
this.optionsFile = new File(p_92139_, "options.txt");
|
||||
boolean flag = Runtime.getRuntime().maxMemory() >= 1000000000L;
|
||||
@@ -1181,12 +_,22 @@
|
||||
@@ -1181,15 +_,28 @@
|
||||
this.onboardAccessibility = p_168428_.process("onboardAccessibility", this.onboardAccessibility);
|
||||
p_168428_.process("menuBackgroundBlurriness", this.menuBackgroundBlurriness);
|
||||
this.startedCleanly = p_168428_.process("startedCleanly", this.startedCleanly);
|
||||
+ processOptionsForge(p_168428_);
|
||||
+ processOptionsKeysOnly(p_168428_);
|
||||
+ processOptionsEnd(p_168428_);
|
||||
+ }
|
||||
|
||||
+ // FORGE: split off to allow reloading options after mod loading is done
|
||||
+ private void processOptionsForge(Options.FieldAccess p_168428_) {
|
||||
+ // FORGE: split off to allow reloading keys after mod loading is done
|
||||
+ private void processOptionsKeysOnly(Options.FieldAccess p_168428_) {
|
||||
for (KeyMapping keymapping : this.keyMappings) {
|
||||
- String s = keymapping.saveString();
|
||||
+ String s = keymapping.saveString() + (keymapping.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? ":" + keymapping.getKeyModifier() : "");
|
||||
@@ -41,7 +50,12 @@
|
||||
+ }
|
||||
}
|
||||
}
|
||||
+ }
|
||||
|
||||
+ private void processOptionsEnd(Options.FieldAccess p_168428_) {
|
||||
for (SoundSource soundsource : SoundSource.values()) {
|
||||
p_168428_.process("soundCategory_" + soundsource.getName(), this.soundSourceVolumes.get(soundsource));
|
||||
}
|
||||
@@ -1204,6 +_,10 @@
|
||||
}
|
||||
|
||||
@@ -58,11 +72,54 @@
|
||||
}
|
||||
|
||||
- this.processOptions(
|
||||
+ java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsForge : this::processOptions;
|
||||
+ java.util.function.Consumer<FieldAccess> processor = limited ? this::processOptionsKeysOnly : this::processOptions;
|
||||
+ processor.accept(
|
||||
new Options.FieldAccess() {
|
||||
@Nullable
|
||||
private String getValue(String p_394210_) {
|
||||
@@ -1310,6 +_,17 @@
|
||||
);
|
||||
compoundtag1.getString("fullscreenResolution").ifPresent(p_389133_ -> this.fullscreenVideoModeString = p_389133_);
|
||||
KeyMapping.resetMapping();
|
||||
+
|
||||
+ if (limited) {
|
||||
+ this.unknownKeys.clear();
|
||||
+ } else {
|
||||
+ var knownKeys = Arrays.stream(this.keyMappings).map(k -> "key_" + k.getName()).collect(Collectors.toSet());
|
||||
+ for (var entry : compoundtag1.entrySet()) {
|
||||
+ if (entry.getKey().startsWith("key_") && entry.getValue().asString().isPresent() && !knownKeys.contains(entry.getKey()))
|
||||
+ this.unknownKeys.put(entry.getKey(), entry.getValue().asString().get());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("Failed to load options", (Throwable)exception);
|
||||
}
|
||||
@@ -1337,9 +_,11 @@
|
||||
public void save() {
|
||||
try (final PrintWriter printwriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(this.optionsFile), StandardCharsets.UTF_8))) {
|
||||
printwriter.println("version:" + SharedConstants.getCurrentVersion().getDataVersion().getVersion());
|
||||
+ var seen = new java.util.HashSet<String>();
|
||||
this.processOptions(
|
||||
new Options.FieldAccess() {
|
||||
public void writePrefix(String p_168491_) {
|
||||
+ seen.add(p_168491_);
|
||||
printwriter.print(p_168491_);
|
||||
printwriter.print(':');
|
||||
}
|
||||
@@ -1395,6 +_,12 @@
|
||||
if (s != null) {
|
||||
printwriter.println("fullscreenResolution:" + s);
|
||||
}
|
||||
+ // Forge add any unknown keys so that Mods can add keybindings between vanilla loading/saving its config.
|
||||
+ for (var entry : this.unknownKeys.entrySet()) {
|
||||
+ if (!seen.contains(entry.getKey()))
|
||||
+ printwriter.println(entry.getKey() + ":" + entry.getValue());
|
||||
+ }
|
||||
+
|
||||
} catch (Exception exception) {
|
||||
LOGGER.error("Failed to save options", (Throwable)exception);
|
||||
}
|
||||
@@ -1433,6 +_,7 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
boolean flag1 = flag || optionset.has(optionspec1);
|
||||
Bootstrap.bootStrap();
|
||||
ClientBootstrap.bootstrap();
|
||||
+ if (!loader.run(optionset, path, input, flag, flag1, flag, flag, false))
|
||||
+ if (!loader.run(optionset, path, input, flag, flag1, flag, flag, true))
|
||||
+ return;
|
||||
DataGenerator datagenerator = new DataGenerator(path, SharedConstants.getCurrentVersion(), true);
|
||||
addClientProviders(datagenerator, flag1);
|
||||
|
||||
@@ -9,6 +9,40 @@
|
||||
private final SubtitleOverlay subtitleOverlay;
|
||||
private final SpectatorGui spectatorGui;
|
||||
private final PlayerTabOverlay tabList;
|
||||
@@ -168,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_) {
|
||||
@@ -180,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()) {
|
||||
@@ -204,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() {
|
||||
@@ -347,7 +_,7 @@
|
||||
Window window = this.minecraft.getWindow();
|
||||
int i = Mth.floor(this.minecraft.mouseHandler.getScaledXPos(window));
|
||||
|
||||
@@ -33,25 +33,17 @@
|
||||
.tooltip(tooltip)
|
||||
.build()
|
||||
)
|
||||
@@ -289,6 +_,7 @@
|
||||
if ((i & -67108864) != 0) {
|
||||
super.render(p_282860_, p_281753_, p_283539_, p_282628_);
|
||||
this.logoRenderer.renderLogo(p_282860_, this.width, f);
|
||||
+ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, p_282860_, this.font, this.width, this.height, i);
|
||||
if (this.splash != null && !this.minecraft.options.hideSplashTexts().get()) {
|
||||
this.splash.render(p_282860_, this.width, this.font, i);
|
||||
}
|
||||
@@ -304,10 +_,18 @@
|
||||
s = s + I18n.get("menu.modded");
|
||||
}
|
||||
|
||||
- p_282860_.drawString(this.font, s, 2, this.height - 10, 16777215 | i);
|
||||
+ net.minecraftforge.internal.BrandingControl.forEachLine(true, true, (brd, brdline) ->
|
||||
+ p_282860_.drawString(this.font, brd, 2, this.height - ( 10 + brdline * (this.font.lineHeight + 1)), 16777215 | i)
|
||||
+ p_282860_.drawString(this.font, brd, 2, this.height - ( 10 + brdline * (this.font.lineHeight + 1)), 16777215 | i)
|
||||
+ );
|
||||
+
|
||||
+ net.minecraftforge.internal.BrandingControl.forEachAboveCopyrightLine((brd, brdline) ->
|
||||
+ p_282860_.drawString(this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * ( this.font.lineHeight + 1)), 16777215 | i)
|
||||
+ p_282860_.drawString(this.font, brd, this.width - font.width(brd), this.height - (10 + (brdline + 1) * ( this.font.lineHeight + 1)), 16777215 | i)
|
||||
+ );
|
||||
+
|
||||
if (this.realmsNotificationsEnabled() && f >= 1.0F) {
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@
|
||||
|
||||
for (CreativeModeTab creativemodetab : CreativeModeTabs.tabs()) {
|
||||
- if (creativemodetab.getType() != CreativeModeTab.Type.SEARCH && creativemodetab.contains(p_281769_)) {
|
||||
+ if (creativemodetab.hasSearchBar() && creativemodetab.contains(p_281769_)) {
|
||||
+ if (!creativemodetab.hasSearchBar() && creativemodetab.contains(p_281769_)) {
|
||||
list1.add(i++, creativemodetab.getDisplayName().copy().withStyle(ChatFormatting.BLUE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
public void playSeededSound(
|
||||
@Nullable Entity p_263536_, Entity p_396496_, Holder<SoundEvent> p_263518_, SoundSource p_263487_, float p_263538_, float p_263524_, long p_263509_
|
||||
) {
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_263536_, p_263518_, p_263487_, p_263538_, p_263524_);
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this.minecraft.level, p_263536_, p_263518_, p_263487_, p_263538_, p_263524_);
|
||||
+ if (event.isCanceled() || event.getSound() == null) return;
|
||||
+ p_263518_ = event.getSound();
|
||||
+ p_263487_ = event.getSource();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
public void playSound(SoundEvent p_108651_, float p_108652_, float p_108653_) {
|
||||
- this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), p_108651_, this.getSoundSource(), p_108652_, p_108653_, false);
|
||||
+ var holder = net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(p_108651_);
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, holder, this.getSoundSource(), p_108652_, p_108653_);
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this.level(), this, holder, this.getSoundSource(), p_108652_, p_108653_);
|
||||
+ if (event.isCanceled() || event.getSound() == null) return;
|
||||
+ this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), event.getSound().get(), event.getSource(), event.getNewVolume(), event.getNewPitch(), false);
|
||||
+
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/core/BlockPos.java
|
||||
+++ b/net/minecraft/core/BlockPos.java
|
||||
@@ -31,7 +_,7 @@
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@Immutable
|
||||
-public class BlockPos extends Vec3i {
|
||||
+public class BlockPos extends Vec3i implements net.minecraftforge.common.extensions.IForgeBlockPos {
|
||||
public static final Codec<BlockPos> CODEC = Codec.INT_STREAM
|
||||
.<BlockPos>comapFlatMap(
|
||||
p_325638_ -> Util.fixedSize(p_325638_, 3).map(p_175270_ -> new BlockPos(p_175270_[0], p_175270_[1], p_175270_[2])),
|
||||
@@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/core/MappedRegistry.java
|
||||
+++ b/net/minecraft/core/MappedRegistry.java
|
||||
@@ -30,6 +_,8 @@
|
||||
import net.minecraft.util.RandomSource;
|
||||
|
||||
public class MappedRegistry<T> implements WritableRegistry<T> {
|
||||
+ private static final org.apache.logging.log4j.Logger LOGGER = org.apache.logging.log4j.LogManager.getLogger();
|
||||
+ private static final org.apache.logging.log4j.Marker MARKER = net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
|
||||
private final ResourceKey<? extends Registry<T>> key;
|
||||
private final ObjectList<Holder.Reference<T>> byId = new ObjectArrayList<>(256);
|
||||
private final Reference2IntMap<T> toId = Util.make(new Reference2IntOpenHashMap<>(), p_308420_ -> p_308420_.defaultReturnValue(-1));
|
||||
@@ -85,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
@@ -35,6 +44,32 @@
|
||||
}
|
||||
|
||||
if (this.allTags.isBound()) {
|
||||
@@ -304,8 +_,9 @@
|
||||
.sorted()
|
||||
.toList();
|
||||
if (!list1.isEmpty()) {
|
||||
- throw new IllegalStateException("Unbound tags in registry " + this.key() + ": " + list1);
|
||||
- } else {
|
||||
+ LOGGER.debug(MARKER, "Unbound tags in registry " + this.key() + ": " + list1);
|
||||
+ bindAllUnboundTagsToEmpty();
|
||||
+ } /* else */ {
|
||||
this.allTags = MappedRegistry.TagSet.fromMap(this.frozenTags);
|
||||
this.refreshTagsInHolders();
|
||||
return this;
|
||||
@@ -315,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ private void bindAllUnboundTagsToEmpty() {
|
||||
+ for (var tag : this.frozenTags.values()) {
|
||||
+ if (!tag.isBound())
|
||||
+ tag.bind(List.of());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public Holder.Reference<T> createIntrusiveHolder(T p_205915_) {
|
||||
if (this.unregisteredIntrusiveHolders == null) {
|
||||
@@ -389,6 +_,31 @@
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,50 @@
|
||||
--- a/net/minecraft/core/RegistrySetBuilder.java
|
||||
+++ b/net/minecraft/core/RegistrySetBuilder.java
|
||||
@@ -74,6 +_,10 @@
|
||||
@@ -22,7 +_,8 @@
|
||||
import net.minecraft.tags.TagKey;
|
||||
import org.apache.commons.lang3.mutable.MutableObject;
|
||||
|
||||
-public class RegistrySetBuilder {
|
||||
+public class RegistrySetBuilder implements net.minecraftforge.common.extensions.IForgeRegistrySetBuilder {
|
||||
+ private final it.unimi.dsi.fastutil.objects.Object2IntMap<ResourceKey<? extends Registry<?>>> indexes = new it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap<>();
|
||||
private final List<RegistrySetBuilder.RegistryStub<?>> entries = new ArrayList<>();
|
||||
|
||||
static <T> HolderGetter<T> wrapContextLookup(final HolderLookup.RegistryLookup<T> p_255625_) {
|
||||
@@ -66,14 +_,43 @@
|
||||
public <T> RegistrySetBuilder add(
|
||||
ResourceKey<? extends Registry<T>> p_256446_, Lifecycle p_256394_, RegistrySetBuilder.RegistryBootstrap<T> p_256638_
|
||||
) {
|
||||
- this.entries.add(new RegistrySetBuilder.RegistryStub<>(p_256446_, p_256394_, p_256638_));
|
||||
+ add(new RegistrySetBuilder.RegistryStub<>(p_256446_, p_256394_, p_256638_));
|
||||
return this;
|
||||
}
|
||||
|
||||
+ // Forge: This merges two entries in this builder together, so that we can reuse vanilla boostrap methods, or potentially other modder's methods.
|
||||
+ private <T> RegistrySetBuilder.RegistryStub<T> add(RegistrySetBuilder.RegistryStub<T> entry) {
|
||||
+ int idx = indexes.getOrDefault(entry.key(), -1);
|
||||
+ if (idx != -1) {
|
||||
+ var _oldB = ((RegistrySetBuilder.RegistryStub<T>)this.entries.get(idx)).bootstrap();
|
||||
+ var _newB = entry.bootstrap();
|
||||
+ var _new = new RegistrySetBuilder.RegistryStub<>(entry.key(), entry.lifecycle(), ctx -> {
|
||||
+ _oldB.run(ctx);
|
||||
+ _newB.run(ctx);
|
||||
+ });
|
||||
+ this.entries.set(idx, _new);
|
||||
+ return _new;
|
||||
+ } else {
|
||||
+ this.indexes.put(entry.key(), this.entries.size());
|
||||
+ this.entries.add(entry);
|
||||
+ return entry;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public RegistrySetBuilder copy() {
|
||||
+ var ret = new RegistrySetBuilder();
|
||||
+ this.entries.forEach(ret::add);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
public <T> RegistrySetBuilder add(ResourceKey<? extends Registry<T>> p_256261_, RegistrySetBuilder.RegistryBootstrap<T> p_256010_) {
|
||||
return this.add(p_256261_, Lifecycle.stable(), p_256010_);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
boolean flag2 = flag || optionset.has(optionspec2);
|
||||
boolean flag3 = flag || optionset.has(optionspec3);
|
||||
Collection<Path> collection = optionset.valuesOf(optionspec6).stream().map(p_129659_ -> Paths.get(p_129659_)).toList();
|
||||
+ if (!loader.run(optionset, path, collection, flag1, flag, flag2, flag3, false))
|
||||
+ if (!loader.run(optionset, path, collection, flag1, flag, flag2, flag3, true))
|
||||
+ return;
|
||||
DataGenerator datagenerator = new DataGenerator(path, SharedConstants.getCurrentVersion(), true);
|
||||
addServerProviders(datagenerator, collection, flag1, flag2, flag3);
|
||||
|
||||
+12
-1
@@ -36,7 +36,18 @@
|
||||
PackOutput.PathProvider packoutput$pathprovider = this.output.createRegistryElementsPathProvider(resourcekey);
|
||||
return CompletableFuture.allOf(
|
||||
p_358460_.listElements()
|
||||
+ .filter(holder -> this.namespacePredicate.test(holder.key().location().getNamespace()))
|
||||
+ .filter(holder -> shouldDump(holder.key()))
|
||||
.map(
|
||||
p_256105_ -> dumpValue(
|
||||
packoutput$pathprovider.json(p_256105_.key().location()),
|
||||
@@ -65,6 +_,10 @@
|
||||
);
|
||||
}
|
||||
);
|
||||
+ }
|
||||
+
|
||||
+ protected boolean shouldDump(ResourceKey<?> key) {
|
||||
+ return this.namespacePredicate.test(key.location().getNamespace());
|
||||
}
|
||||
|
||||
private static <E> CompletableFuture<?> dumpValue(
|
||||
@@ -8,3 +8,13 @@
|
||||
|
||||
private static void validateThatAllBiomeFeaturesHaveBiomeFilter(HolderLookup.Provider p_256242_) {
|
||||
validateThatAllBiomeFeaturesHaveBiomeFilter(p_256242_.lookupOrThrow(Registries.PLACED_FEATURE), p_256242_.lookupOrThrow(Registries.BIOME));
|
||||
@@ -119,5 +_,9 @@
|
||||
HolderLookup.Provider holderlookup$provider = BUILDER.build(registryaccess$frozen);
|
||||
validateThatAllBiomeFeaturesHaveBiomeFilter(holderlookup$provider);
|
||||
return holderlookup$provider;
|
||||
+ }
|
||||
+
|
||||
+ public static RegistrySetBuilder builder() {
|
||||
+ return BUILDER.copy();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,9 @@
|
||||
--- a/net/minecraft/resources/DelegatingOps.java
|
||||
+++ b/net/minecraft/resources/DelegatingOps.java
|
||||
@@ -218,12 +_,30 @@
|
||||
|
||||
@Override
|
||||
public ListBuilder<T> listBuilder() {
|
||||
- return new DelegatingOps.DelegateListBuilder(this.delegate.listBuilder());
|
||||
+ return new ListBuilder.Builder<>(this);
|
||||
@@ -226,6 +_,24 @@
|
||||
return new DelegatingOps.DelegateRecordBuilder(this.delegate.mapBuilder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordBuilder<T> mapBuilder() {
|
||||
return new DelegatingOps.DelegateRecordBuilder(this.delegate.mapBuilder());
|
||||
+ }
|
||||
+
|
||||
+ // Forge start
|
||||
+ java.util.Map<ResourceLocation, Object> ctx = new java.util.HashMap<>();
|
||||
+
|
||||
@@ -29,6 +20,8 @@
|
||||
+ public <R> R withContext(ResourceLocation key, Object ctx) {
|
||||
+ this.ctx.put(key, ctx);
|
||||
+ return (R)this;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
protected class DelegateListBuilder implements ListBuilder<T> {
|
||||
private final ListBuilder<T> original;
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
public void playSeededSound(
|
||||
@Nullable Entity p_392657_, Entity p_394285_, Holder<SoundEvent> p_263412_, SoundSource p_263338_, float p_263352_, float p_263390_, long p_263403_
|
||||
) {
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_394285_, p_263412_, p_263338_, p_263352_, p_263390_);
|
||||
+ var event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_394285_.level(), p_394285_, p_263412_, p_263338_, p_263352_, p_263390_);
|
||||
+ if (event.isCanceled() || event.getSound() == null) return;
|
||||
+ p_263412_ = event.getSound();
|
||||
+ p_263338_ = event.getSource();
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/level/ThreadedLevelLightEngine.java
|
||||
+++ b/net/minecraft/server/level/ThreadedLevelLightEngine.java
|
||||
@@ -171,6 +_,7 @@
|
||||
}, () -> "lightChunk " + chunkpos + " " + p_9355_));
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
p_9354_.setLightCorrect(true);
|
||||
+ net.minecraftforge.common.ForgeHooks.fireLightingCalculatedEvent(p_9354_);
|
||||
return p_9354_;
|
||||
}, p_280982_ -> this.addTask(chunkpos.x, chunkpos.z, ThreadedLevelLightEngine.TaskType.POST_UPDATE, p_280982_));
|
||||
}
|
||||
@@ -1,15 +1,43 @@
|
||||
--- a/net/minecraft/world/item/AxeItem.java
|
||||
+++ b/net/minecraft/world/item/AxeItem.java
|
||||
@@ -62,7 +_,8 @@
|
||||
@@ -62,7 +_,7 @@
|
||||
if (playerHasBlockingItemUseIntent(p_40529_)) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
- Optional<BlockState> optional = this.evaluateNewBlockState(level, blockpos, player, level.getBlockState(blockpos));
|
||||
+ var modded = level.getBlockState(blockpos).getToolModifiedState(p_40529_, net.minecraftforge.common.ToolActions.AXE_STRIP, false);
|
||||
+ Optional<BlockState> optional = modded != null ? Optional.of(modded) : this.evaluateNewBlockState(level, blockpos, player, level.getBlockState(blockpos));
|
||||
+ Optional<BlockState> optional = this.evaluateNewBlockState(level, blockpos, player, level.getBlockState(blockpos), p_40529_);
|
||||
if (optional.isEmpty()) {
|
||||
return InteractionResult.PASS;
|
||||
} else {
|
||||
@@ -88,18 +_,25 @@
|
||||
}
|
||||
|
||||
private Optional<BlockState> evaluateNewBlockState(Level p_312809_, BlockPos p_313114_, @Nullable Player p_312029_, BlockState p_311198_) {
|
||||
- Optional<BlockState> optional = this.getStripped(p_311198_);
|
||||
+ return this.evaluateNewBlockState(p_312809_, p_313114_, p_312029_, p_311198_, null);
|
||||
+ }
|
||||
+
|
||||
+ private Optional<BlockState> evaluateNewBlockState(Level p_312809_, BlockPos p_313114_, @Nullable Player p_312029_, BlockState p_311198_, @Nullable UseOnContext ctx) {
|
||||
+ var strip = ctx == null ? null : p_311198_.getToolModifiedState(ctx, net.minecraftforge.common.ToolActions.AXE_STRIP, false);
|
||||
+ Optional<BlockState> optional = strip != null ? Optional.of(strip) : this.getStripped(p_311198_);
|
||||
if (optional.isPresent()) {
|
||||
p_312809_.playSound(p_312029_, p_313114_, SoundEvents.AXE_STRIP, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return optional;
|
||||
} else {
|
||||
- Optional<BlockState> optional1 = WeatheringCopper.getPrevious(p_311198_);
|
||||
+ var scrape = ctx == null ? null : p_311198_.getToolModifiedState(ctx, net.minecraftforge.common.ToolActions.AXE_STRIP, false);
|
||||
+ Optional<BlockState> optional1 = scrape != null ? Optional.of(scrape) : WeatheringCopper.getPrevious(p_311198_);
|
||||
if (optional1.isPresent()) {
|
||||
p_312809_.playSound(p_312029_, p_313114_, SoundEvents.AXE_SCRAPE, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
p_312809_.levelEvent(p_312029_, 3005, p_313114_, 0);
|
||||
return optional1;
|
||||
} else {
|
||||
- Optional<BlockState> optional2 = Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(p_311198_.getBlock()))
|
||||
+ var waxOff = ctx == null ? null : p_311198_.getToolModifiedState(ctx, net.minecraftforge.common.ToolActions.AXE_WAX_OFF, false);
|
||||
+ Optional<BlockState> optional2 = waxOff != null ? Optional.of(waxOff) : Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(p_311198_.getBlock()))
|
||||
.map(p_150694_ -> p_150694_.withPropertiesOf(p_311198_));
|
||||
if (optional2.isPresent()) {
|
||||
p_312809_.playSound(p_312029_, p_313114_, SoundEvents.AXE_WAX_OFF, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
@@ -115,5 +_,21 @@
|
||||
private Optional<BlockState> getStripped(BlockState p_150691_) {
|
||||
return Optional.ofNullable(STRIPPABLES.get(p_150691_.getBlock()))
|
||||
@@ -21,7 +49,7 @@
|
||||
+ return net.minecraftforge.common.ToolActions.DEFAULT_AXE_ACTIONS.contains(toolAction);
|
||||
+ }
|
||||
+
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ @Nullable
|
||||
+ 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;
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
}
|
||||
|
||||
public boolean hasDynamicShape() {
|
||||
@@ -556,5 +_,74 @@
|
||||
@@ -556,5 +_,78 @@
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(this.first) * 31 + System.identityHashCode(this.second);
|
||||
}
|
||||
@@ -148,18 +148,22 @@
|
||||
+ return state.is(Blocks.CACTUS) || state.is(BlockTags.SAND);
|
||||
+ } else if (plant.getBlock() == Blocks.SUGAR_CANE && this == Blocks.SUGAR_CANE) {
|
||||
+ return true;
|
||||
+ } else if (plantable instanceof BushBlock bush && bush.mayPlaceOn(state, world, pos)) {
|
||||
+ } else if (plantable instanceof VegetationBlock veg && veg.mayPlaceOn(state, world, pos)) {
|
||||
+ return true;
|
||||
+ } else if (net.minecraftforge.common.PlantType.DESERT.equals(type)) {
|
||||
+ return state.is(BlockTags.SAND) || this == Blocks.TERRACOTTA || this instanceof GlazedTerracottaBlock;
|
||||
+ return state.is(BlockTags.SAND) || state.is(BlockTags.TERRACOTTA) || state.is(BlockTags.DIRT);
|
||||
+ } else if (net.minecraftforge.common.PlantType.NETHER.equals(type)) {
|
||||
+ return this == Blocks.SOUL_SAND;
|
||||
+ } else if (net.minecraftforge.common.PlantType.FUNGUS.equals(type)) {
|
||||
+ return state.is(BlockTags.NYLIUM) || this == Blocks.MYCELIUM || this == Blocks.SOUL_SOIL;
|
||||
+ } else if (net.minecraftforge.common.PlantType.CROP.equals(type)) {
|
||||
+ return state.is(Blocks.FARMLAND);
|
||||
+ } else if (net.minecraftforge.common.PlantType.CAVE.equals(type)) {
|
||||
+ return state.isFaceSturdy(world, pos, Direction.UP);
|
||||
+ return state.isFaceSturdy(world, pos, Direction.UP) && state.canOcclude();
|
||||
+ } else if (net.minecraftforge.common.PlantType.PLAINS.equals(type)) {
|
||||
+ return state.is(BlockTags.DIRT) || this == Blocks.FARMLAND;
|
||||
+ return state.is(BlockTags.DIRT) || this == Blocks.FARMLAND;
|
||||
+ } else if (net.minecraftforge.common.PlantType.MOIST.equals(type)) {
|
||||
+ return state.is(BlockTags.DIRT) || this == Blocks.CLAY || this == Blocks.FARMLAND;
|
||||
+ } else if (net.minecraftforge.common.PlantType.WATER.equals(type)) {
|
||||
+ return (state.is(Blocks.WATER) || state.getBlock() instanceof IceBlock) && world.getFluidState(pos.relative(facing)).isEmpty();
|
||||
+ } else if (net.minecraftforge.common.PlantType.BEACH.equals(type)) {
|
||||
|
||||
@@ -17,15 +17,6 @@
|
||||
}
|
||||
|
||||
public LevelChunk(ServerLevel p_196850_, ProtoChunk p_196851_, @Nullable LevelChunk.PostLoadProcessor p_196852_) {
|
||||
@@ -291,7 +_,7 @@
|
||||
profilerfiller.pop();
|
||||
}
|
||||
|
||||
- boolean flag4 = !blockstate.is(block);
|
||||
+ boolean flag4 = !blockstate.is(block) || !p_62866_.hasBlockEntity();
|
||||
boolean flag2 = (p_393998_ & 64) != 0;
|
||||
boolean flag3 = (p_393998_ & 256) == 0;
|
||||
if (flag4 && blockstate.hasBlockEntity()) {
|
||||
@@ -312,7 +_,7 @@
|
||||
if (!levelchunksection.getBlockState(j, k, l).is(block)) {
|
||||
return null;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplateManager.java
|
||||
@@ -76,6 +_,7 @@
|
||||
}
|
||||
|
||||
builder.add(new StructureTemplateManager.Source(this::loadFromResource, this::listResources));
|
||||
+ builder.add(new StructureTemplateManager.Source(net.minecraftforge.common.ForgeHooks::createEmptyStructure, Stream::empty));
|
||||
this.sources = builder.build();
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ dependencyResolutionManagement {
|
||||
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.27')
|
||||
library('eventbus', 'net.minecraftforge:eventbus:6.2.32')
|
||||
library('typetools', 'net.jodah:typetools:0.6.3') // Needed by EventBus because of lambdas
|
||||
library('mergetool-api', 'net.minecraftforge:mergetool-api:1.0')
|
||||
|
||||
@@ -124,7 +124,7 @@ include ':forge'
|
||||
project(":forge").projectDir = file("projects/forge")
|
||||
project(':forge').buildFileName = '../../build_forge.gradle'
|
||||
|
||||
if (!System.env.TEAMCITY_VERSION) {
|
||||
if (false && !System.env.TEAMCITY_VERSION) {
|
||||
include ':clean'
|
||||
project(':clean').projectDir = file('projects/clean')
|
||||
project(':clean').buildFileName = '../../build_clean.gradle'
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.client.gui.components.ChatComponent;
|
||||
import net.minecraft.client.gui.components.LerpingBossEvent;
|
||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
|
||||
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
|
||||
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
|
||||
@@ -50,7 +49,6 @@ import net.minecraft.client.renderer.entity.state.HumanoidRenderState;
|
||||
import net.minecraft.client.renderer.texture.SpriteContents;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.resources.metadata.animation.FrameSize;
|
||||
import net.minecraft.client.resources.model.ModelBaker;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
@@ -132,7 +130,6 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.network.NetworkContext;
|
||||
import net.minecraftforge.network.NetworkInitialization;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
@@ -293,50 +290,6 @@ public class ForgeHooksClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization of Forge Renderers.
|
||||
*/
|
||||
static {
|
||||
//FluidRegistry.renderIdFluid = RenderingRegistry.getNextAvailableRenderId();
|
||||
//RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance);
|
||||
}
|
||||
|
||||
private static VersionChecker.Status getForgeVersionStatus() {
|
||||
final class LazyInit {
|
||||
private static final VersionChecker.Status INSTANCE = ForgeVersion.getStatus();
|
||||
|
||||
static {
|
||||
forgeStatusLine = switch (INSTANCE) {
|
||||
// case FAILED -> " Version check failed";
|
||||
// case UP_TO_DATE -> "Forge up to date";
|
||||
// case AHEAD -> "Using non-recommended Forge build, issues may arise.";
|
||||
case OUTDATED, BETA_OUTDATED -> I18n.get("forge.update.newversion", ForgeVersion.getTarget());
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
private LazyInit() {}
|
||||
}
|
||||
|
||||
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) {
|
||||
// Render a warning at the top of the screen
|
||||
Component line = Component.translatable("forge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED);
|
||||
graphics.drawCenteredString(font, line, width / 2, 4, 0xFFFFFF | alpha);
|
||||
line = Component.translatable("forge.update.beta.2");
|
||||
graphics.drawCenteredString(font, line, width / 2, 4 + (font.lineHeight + 1), 0xFFFFFF | alpha);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static String forgeStatusLine;
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -412,7 +412,8 @@ public enum ForgeRenderTypes {
|
||||
/**
|
||||
* Use {@link #TEXT_INTENSITY_SEE_THROUGH} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated(forRemoval = true, since = "1.21.5")
|
||||
public static Function<ResourceLocation, RenderType> TEXT_INTENSITY_SEETHROUGH = TEXT_INTENSITY_SEE_THROUGH;
|
||||
private static RenderType getTextIntensitySeeThrough(ResourceLocation locationIn) {
|
||||
return create(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
**/
|
||||
@Cancelable
|
||||
public class ClientChatEvent extends Event
|
||||
public final class ClientChatEvent extends Event
|
||||
{
|
||||
private String message;
|
||||
private final String originalMessage;
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.UUID;
|
||||
* @see ChatType
|
||||
*/
|
||||
@Cancelable
|
||||
public class ClientChatReceivedEvent extends Event {
|
||||
public sealed class ClientChatReceivedEvent extends Event {
|
||||
private Component message;
|
||||
private final ChatType.Bound boundChatType;
|
||||
private final UUID sender;
|
||||
@@ -94,7 +94,7 @@ public class ClientChatReceivedEvent extends Event {
|
||||
*
|
||||
* @see ChatType
|
||||
*/
|
||||
public static class Player extends ClientChatReceivedEvent {
|
||||
public static final class Player extends ClientChatReceivedEvent {
|
||||
private final PlayerChatMessage playerChatMessage;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -119,7 +119,7 @@ public class ClientChatReceivedEvent extends Event {
|
||||
* So moved to it's own event. {@link SystemMessageReceivedEvent}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.1")
|
||||
public static class System extends ClientChatReceivedEvent {
|
||||
public static final class System extends ClientChatReceivedEvent {
|
||||
private final boolean overlay;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -21,7 +21,7 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* @see ClientPauseChangeEvent.Pre
|
||||
* @see ClientPauseChangeEvent.Post
|
||||
*/
|
||||
public abstract class ClientPauseChangeEvent extends Event {
|
||||
public abstract sealed class ClientPauseChangeEvent extends Event {
|
||||
private final boolean pause;
|
||||
|
||||
public ClientPauseChangeEvent(boolean pause) {
|
||||
@@ -38,7 +38,7 @@ public abstract class ClientPauseChangeEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends ClientPauseChangeEvent {
|
||||
public static final class Pre extends ClientPauseChangeEvent {
|
||||
|
||||
public Pre(boolean pause) {
|
||||
super(pause);
|
||||
@@ -53,7 +53,7 @@ public abstract class ClientPauseChangeEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends ClientPauseChangeEvent {
|
||||
public static final class Post extends ClientPauseChangeEvent {
|
||||
|
||||
public Post(boolean pause) {
|
||||
super(pause);
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class ClientPlayerChangeGameTypeEvent extends Event
|
||||
public final class ClientPlayerChangeGameTypeEvent extends Event
|
||||
{
|
||||
private final PlayerInfo info;
|
||||
private final GameType currentGameType;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @see LoggingOut
|
||||
* @see Clone
|
||||
**/
|
||||
public abstract class ClientPlayerNetworkEvent extends Event {
|
||||
public abstract sealed class ClientPlayerNetworkEvent extends Event {
|
||||
private final MultiPlayerGameMode multiPlayerGameMode;
|
||||
private final LocalPlayer player;
|
||||
private final Connection connection;
|
||||
@@ -67,7 +67,7 @@ public abstract class ClientPlayerNetworkEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class LoggingIn extends ClientPlayerNetworkEvent {
|
||||
public static final class LoggingIn extends ClientPlayerNetworkEvent {
|
||||
@ApiStatus.Internal
|
||||
public LoggingIn(final MultiPlayerGameMode controller, final LocalPlayer player, final Connection networkManager) {
|
||||
super(controller, player, networkManager);
|
||||
@@ -84,7 +84,7 @@ public abstract class ClientPlayerNetworkEvent extends Event {
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
// Shush IntelliJ, we override non-nullables as nullables in this specific event; see later comment
|
||||
public static class LoggingOut extends ClientPlayerNetworkEvent {
|
||||
public static final class LoggingOut extends ClientPlayerNetworkEvent {
|
||||
@ApiStatus.Internal
|
||||
public LoggingOut(@Nullable final MultiPlayerGameMode controller, @Nullable final LocalPlayer player, @Nullable final Connection networkManager) {
|
||||
//noinspection ConstantConditions we know these are nullable, but we don't want to annotate the super as nullable since this is the only event with nullables
|
||||
@@ -133,7 +133,7 @@ public abstract class ClientPlayerNetworkEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Clone extends ClientPlayerNetworkEvent {
|
||||
public static final class Clone extends ClientPlayerNetworkEvent {
|
||||
private final LocalPlayer oldPlayer;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see ViewportEvent.ComputeFov
|
||||
*/
|
||||
public class ComputeFovModifierEvent extends Event {
|
||||
public final class ComputeFovModifierEvent extends Event {
|
||||
private final Player player;
|
||||
private final float fovModifier;
|
||||
private final float scale;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see Render.Foreground
|
||||
* @see Render.Background
|
||||
*/
|
||||
public abstract class ContainerScreenEvent extends Event {
|
||||
public abstract sealed class ContainerScreenEvent extends Event {
|
||||
private final AbstractContainerScreen<?> containerScreen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -48,7 +48,7 @@ public abstract class ContainerScreenEvent extends Event {
|
||||
* @see Foreground
|
||||
* @see Background
|
||||
*/
|
||||
public static abstract class Render extends ContainerScreenEvent {
|
||||
public static abstract sealed class Render extends ContainerScreenEvent {
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
@@ -94,7 +94,7 @@ public abstract class ContainerScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Foreground extends Render {
|
||||
public static final class Foreground extends Render {
|
||||
@ApiStatus.Internal
|
||||
public Foreground(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
super(guiContainer, guiGraphics, mouseX, mouseY);
|
||||
@@ -110,7 +110,7 @@ public abstract class ContainerScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Background extends Render {
|
||||
public static final class Background extends Render {
|
||||
@ApiStatus.Internal
|
||||
public Background(AbstractContainerScreen<?> guiContainer, GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
super(guiContainer, guiGraphics, mouseX, mouseY);
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.client.renderer.special.SpecialModelRenderer;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class CreateSpecialBlockRendererEvent extends Event {
|
||||
public final class CreateSpecialBlockRendererEvent extends Event {
|
||||
private final Map<Block, SpecialModelRenderer.Unbaked> map;
|
||||
|
||||
public CreateSpecialBlockRendererEvent(Map<Block, SpecialModelRenderer.Unbaked> map) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
* @see DebugText
|
||||
* @see Chat
|
||||
*/
|
||||
public abstract class CustomizeGuiOverlayEvent extends Event {
|
||||
public abstract sealed class CustomizeGuiOverlayEvent extends Event {
|
||||
private final Window window;
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final float partialTick;
|
||||
@@ -57,7 +57,7 @@ public abstract class CustomizeGuiOverlayEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class BossEventProgress extends CustomizeGuiOverlayEvent {
|
||||
public static final class BossEventProgress extends CustomizeGuiOverlayEvent {
|
||||
private final LerpingBossEvent bossEvent;
|
||||
private final int x;
|
||||
private final int y;
|
||||
@@ -119,7 +119,7 @@ public abstract class CustomizeGuiOverlayEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class DebugText extends CustomizeGuiOverlayEvent {
|
||||
public static final class DebugText extends CustomizeGuiOverlayEvent {
|
||||
private final List<String> text;
|
||||
|
||||
private final Side side;
|
||||
@@ -159,7 +159,7 @@ public abstract class CustomizeGuiOverlayEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Chat extends CustomizeGuiOverlayEvent {
|
||||
public static final class Chat extends CustomizeGuiOverlayEvent {
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ import java.util.function.Supplier;
|
||||
* @see EntityRenderersEvent.RegisterRenderers
|
||||
* @see EntityRenderersEvent.AddLayers
|
||||
*/
|
||||
public abstract class EntityRenderersEvent extends Event implements IModBusEvent {
|
||||
public abstract sealed class EntityRenderersEvent extends Event implements IModBusEvent {
|
||||
@ApiStatus.Internal
|
||||
protected EntityRenderersEvent() {}
|
||||
|
||||
@@ -65,7 +65,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterLayerDefinitions extends EntityRenderersEvent {
|
||||
public static final class RegisterLayerDefinitions extends EntityRenderersEvent {
|
||||
@ApiStatus.Internal
|
||||
public RegisterLayerDefinitions() {}
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterRenderers extends EntityRenderersEvent {
|
||||
public static final class RegisterRenderers extends EntityRenderersEvent {
|
||||
@ApiStatus.Internal
|
||||
public RegisterRenderers() {}
|
||||
|
||||
@@ -127,7 +127,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class AddLayers extends EntityRenderersEvent {
|
||||
public static final class AddLayers extends EntityRenderersEvent {
|
||||
private final Map<EntityType<?>, EntityRenderer<?, ?>> renderers;
|
||||
private final Map<PlayerSkin.Model, EntityRenderer<? extends Player, ?>> skinMap;
|
||||
private final EntityRendererProvider.Context context;
|
||||
@@ -201,7 +201,7 @@ public abstract class EntityRenderersEvent extends Event implements IModBusEvent
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class CreateSkullModels extends EntityRenderersEvent {
|
||||
public static final class CreateSkullModels extends EntityRenderersEvent {
|
||||
private final ImmutableMap.Builder<Type, Function<EntityModelSet, SkullModelBase>> builder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.minecraftforge.client.gui.overlay.ForgeLayeredDraw;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
@@ -303,4 +304,8 @@ public final class ForgeEventFactoryClient {
|
||||
// This is on the mod bus because it happens during the initial texture reload, which is while the Forge bus is shut down.
|
||||
return fireModBus(new ModelEvent.RegisterModelStateDefinitions());
|
||||
}
|
||||
|
||||
public static void onComputeLayerOrder(ForgeLayeredDraw layeredDraw) {
|
||||
fireModBus(new AddGuiOverlayLayersEvent(layeredDraw));
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.lwjgl.glfw.GLFW;
|
||||
* @see Key
|
||||
* @see InteractionKeyMappingTriggered
|
||||
*/
|
||||
public abstract class InputEvent extends Event {
|
||||
public abstract sealed class InputEvent extends Event {
|
||||
@ApiStatus.Internal
|
||||
protected InputEvent() {}
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class InputEvent extends Event {
|
||||
* @see Pre
|
||||
* @see Post
|
||||
*/
|
||||
public static abstract class MouseButton extends InputEvent {
|
||||
public static abstract sealed class MouseButton extends InputEvent {
|
||||
private final int button;
|
||||
private final int action;
|
||||
private final int modifiers;
|
||||
@@ -97,7 +97,7 @@ public abstract class InputEvent extends Event {
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseButton {
|
||||
public static final class Pre extends MouseButton {
|
||||
@ApiStatus.Internal
|
||||
public Pre(int button, int action, int modifiers) {
|
||||
super(button, action, modifiers);
|
||||
@@ -114,7 +114,7 @@ public abstract class InputEvent extends Event {
|
||||
*
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static class Post extends MouseButton {
|
||||
public static final class Post extends MouseButton {
|
||||
@ApiStatus.Internal
|
||||
public Post(int button, int action, int modifiers) {
|
||||
super(button, action, modifiers);
|
||||
@@ -135,7 +135,7 @@ public abstract class InputEvent extends Event {
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class MouseScrollingEvent extends InputEvent {
|
||||
public static final class MouseScrollingEvent extends InputEvent {
|
||||
private final double deltaX;
|
||||
private final double deltaY;
|
||||
private final double mouseX;
|
||||
@@ -213,7 +213,7 @@ public abstract class InputEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Key extends InputEvent {
|
||||
public static final class Key extends InputEvent {
|
||||
private final int key;
|
||||
private final int scanCode;
|
||||
private final int action;
|
||||
@@ -297,7 +297,7 @@ public abstract class InputEvent extends Event {
|
||||
*/
|
||||
// TODO: Change the 'button' to sub events. - Lex 0422202
|
||||
@Cancelable
|
||||
public static class InteractionKeyMappingTriggered extends InputEvent {
|
||||
public static final class InteractionKeyMappingTriggered extends InputEvent {
|
||||
private final int button;
|
||||
private final KeyMapping keyMapping;
|
||||
private final InteractionHand hand;
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
/**
|
||||
* Houses events related to models.
|
||||
*/
|
||||
public abstract class ModelEvent extends Event {
|
||||
public abstract sealed class ModelEvent extends Event {
|
||||
@ApiStatus.Internal
|
||||
protected ModelEvent() { }
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class ModelEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class ModifyBakingResult extends ModelEvent implements IModBusEvent {
|
||||
public static final class ModifyBakingResult extends ModelEvent implements IModBusEvent {
|
||||
private final ModelBakery modelBakery;
|
||||
private final ModelBakery.BakingResult results;
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class ModelEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class BakingCompleted extends ModelEvent implements IModBusEvent {
|
||||
public static final class BakingCompleted extends ModelEvent implements IModBusEvent {
|
||||
private final ModelManager modelManager;
|
||||
private final ModelBakery modelBakery;
|
||||
|
||||
@@ -118,7 +118,7 @@ public abstract class ModelEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterModelStateDefinitions extends ModelEvent implements IModBusEvent {
|
||||
public static final class RegisterModelStateDefinitions extends ModelEvent implements IModBusEvent {
|
||||
private final Map<ResourceLocation, StateDefinition<Block, BlockState>> states = new HashMap<>();
|
||||
private final Map<ResourceLocation, StateDefinition<Block, BlockState>> view = Collections.unmodifiableMap(states);
|
||||
|
||||
@@ -148,7 +148,7 @@ public abstract class ModelEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent {
|
||||
public static final class RegisterGeometryLoaders extends ModelEvent implements IModBusEvent {
|
||||
private final Map<ResourceLocation, IGeometryLoader> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class MovementInputUpdateEvent extends PlayerEvent {
|
||||
public final class MovementInputUpdateEvent extends PlayerEvent {
|
||||
private final ClientInput input;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RecipesUpdatedEvent extends Event {
|
||||
public final class RecipesUpdatedEvent extends Event {
|
||||
private final ClientRecipeBook recipeBook;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see net.minecraftforge.event.RegisterCommandsEvent
|
||||
*/
|
||||
public class RegisterClientCommandsEvent extends Event
|
||||
public final class RegisterClientCommandsEvent extends Event
|
||||
{
|
||||
private final CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
private final CommandBuildContext context;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterClientReloadListenersEvent extends Event implements IModBusEvent
|
||||
public final class RegisterClientReloadListenersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ReloadableResourceManager resourceManager;
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import java.util.function.Function;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterClientTooltipComponentFactoriesEvent extends Event implements IModBusEvent
|
||||
public final class RegisterClientTooltipComponentFactoriesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<Class<? extends TooltipComponent>, Function<TooltipComponent, ClientTooltipComponent>> factories;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see RegisterColorHandlersEvent.Block
|
||||
* @see RegisterColorHandlersEvent.Item
|
||||
*/
|
||||
public abstract class RegisterColorHandlersEvent extends Event implements IModBusEvent {
|
||||
public abstract sealed class RegisterColorHandlersEvent extends Event implements IModBusEvent {
|
||||
@ApiStatus.Internal
|
||||
protected RegisterColorHandlersEvent() {}
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class RegisterColorHandlersEvent extends Event implements IModBu
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Block extends RegisterColorHandlersEvent {
|
||||
public static final class Block extends RegisterColorHandlersEvent {
|
||||
private final BlockColors blockColors;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -72,7 +72,7 @@ public abstract class RegisterColorHandlersEvent extends Event implements IModBu
|
||||
* Allows registration of custom {@link ColorResolver} implementations to be used with
|
||||
* {@link net.minecraft.world.level.BlockAndTintGetter#getBlockTint(BlockPos, ColorResolver)}.
|
||||
*/
|
||||
public static class ColorResolvers extends RegisterColorHandlersEvent {
|
||||
public static final class ColorResolvers extends RegisterColorHandlersEvent {
|
||||
private final ImmutableList.Builder<ColorResolver> builder;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterDimensionSpecialEffectsEvent extends Event implements IModBusEvent
|
||||
public final class RegisterDimensionSpecialEffectsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, DimensionSpecialEffects> effects;
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterEntitySpectatorShadersEvent extends Event implements IModBusEvent
|
||||
public final class RegisterEntitySpectatorShadersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<EntityType<?>, ResourceLocation> shaders;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterItemDecorationsEvent extends Event implements IModBusEvent
|
||||
public final class RegisterItemDecorationsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
|
||||
private final Map<Item, List<IItemDecorator>> decorators;
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterKeyMappingsEvent extends Event implements IModBusEvent
|
||||
public final class RegisterKeyMappingsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Options options;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Map;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterNamedRenderTypesEvent extends Event implements IModBusEvent
|
||||
public final class RegisterNamedRenderTypesEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final Map<ResourceLocation, RenderTypeGroup> renderTypes;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterParticleProvidersEvent extends Event implements IModBusEvent
|
||||
public final class RegisterParticleProvidersEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final ParticleEngine particleEngine;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterPresetEditorsEvent extends Event implements IModBusEvent
|
||||
public final class RegisterPresetEditorsEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent {
|
||||
public final class RegisterTextureAtlasSpriteLoadersEvent extends Event implements IModBusEvent {
|
||||
private final BiMap<ResourceLocation, ITextureAtlasSpriteLoader> loaders;
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderArmEvent extends Event {
|
||||
public final class RenderArmEvent extends Event {
|
||||
private final PoseStack poseStack;
|
||||
private final MultiBufferSource multiBufferSource;
|
||||
private final int packedLight;
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderBlockScreenEffectEvent extends Event
|
||||
public final class RenderBlockScreenEffectEvent extends Event
|
||||
{
|
||||
/**
|
||||
* The type of the block overlay to be rendered.
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see RenderArmEvent
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderHandEvent extends Event
|
||||
public final class RenderHandEvent extends Event
|
||||
{
|
||||
private final InteractionHand hand;
|
||||
private final PoseStack poseStack;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see Entity
|
||||
*/
|
||||
@Cancelable
|
||||
public abstract class RenderHighlightEvent extends Event
|
||||
public abstract sealed class RenderHighlightEvent extends Event
|
||||
{
|
||||
private final LevelRenderer levelRenderer;
|
||||
private final Camera camera;
|
||||
@@ -104,7 +104,7 @@ public abstract class RenderHighlightEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Block extends RenderHighlightEvent
|
||||
public static final class Block extends RenderHighlightEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Block(LevelRenderer levelRenderer, Camera camera, BlockHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
@@ -130,7 +130,7 @@ public abstract class RenderHighlightEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Entity extends RenderHighlightEvent
|
||||
public static final class Entity extends RenderHighlightEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Entity(LevelRenderer levelRenderer, Camera camera, EntityHitResult target, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource)
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see ItemFrameRenderer
|
||||
*/
|
||||
@Cancelable
|
||||
public class RenderItemInFrameEvent extends Event {
|
||||
public final class RenderItemInFrameEvent extends Event {
|
||||
private final ItemFrameRenderState state;
|
||||
private final ItemFrameRenderer<?> renderer;
|
||||
private final PoseStack poseStack;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see RenderPlayerEvent
|
||||
* @see LivingEntityRenderer
|
||||
*/
|
||||
public abstract class RenderLivingEvent<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends Event {
|
||||
public abstract sealed class RenderLivingEvent<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends Event {
|
||||
private final S state;
|
||||
private final LivingEntityRenderer<T, S, M> renderer;
|
||||
private final PoseStack poseStack;
|
||||
@@ -100,7 +100,7 @@ public abstract class RenderLivingEvent<T extends LivingEntity, S extends Living
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> {
|
||||
public static final class Pre<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> {
|
||||
@ApiStatus.Internal
|
||||
public Pre(S state, LivingEntityRenderer<T, S, M> renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
@@ -118,7 +118,7 @@ public abstract class RenderLivingEvent<T extends LivingEntity, S extends Living
|
||||
* @param <T> the living entity that was rendered
|
||||
* @param <M> the model for the living entity
|
||||
*/
|
||||
public static class Post<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> {
|
||||
public static final class Post<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> extends RenderLivingEvent<T, S, M> {
|
||||
@ApiStatus.Internal
|
||||
public Post(S state, LivingEntityRenderer<T, S, M> renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see EntityRenderer
|
||||
*/
|
||||
@Event.HasResult
|
||||
public class RenderNameTagEvent extends Event {
|
||||
public final class RenderNameTagEvent extends Event {
|
||||
private Component nameplateContent;
|
||||
private final EntityRenderState state;
|
||||
private final Component originalContent;
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see RenderPlayerEvent.Post
|
||||
* @see PlayerRenderer
|
||||
*/
|
||||
public abstract class RenderPlayerEvent extends Event {
|
||||
public abstract sealed class RenderPlayerEvent extends Event {
|
||||
private final PlayerRenderState state;
|
||||
private final PlayerRenderer renderer;
|
||||
private final PoseStack poseStack;
|
||||
@@ -86,7 +86,7 @@ public abstract class RenderPlayerEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends RenderPlayerEvent {
|
||||
public static final class Pre extends RenderPlayerEvent {
|
||||
@ApiStatus.Internal
|
||||
public Pre(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
@@ -101,7 +101,7 @@ public abstract class RenderPlayerEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends RenderPlayerEvent {
|
||||
public static final class Post extends RenderPlayerEvent {
|
||||
@ApiStatus.Internal
|
||||
public Post(PlayerRenderState state, PlayerRenderer renderer, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight) {
|
||||
super(state, renderer, poseStack, multiBufferSource, packedLight);
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.List;
|
||||
* @see RenderTooltipEvent.Pre
|
||||
* @see RenderTooltipEvent.Background
|
||||
*/
|
||||
public abstract class RenderTooltipEvent extends Event
|
||||
public abstract sealed class RenderTooltipEvent extends Event
|
||||
{
|
||||
@NotNull
|
||||
protected final ItemStack itemStack;
|
||||
@@ -121,7 +121,7 @@ public abstract class RenderTooltipEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class GatherComponents extends Event
|
||||
public static final class GatherComponents extends Event
|
||||
{
|
||||
private final ItemStack itemStack;
|
||||
private final int screenWidth;
|
||||
@@ -210,7 +210,7 @@ public abstract class RenderTooltipEvent extends Event
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends RenderTooltipEvent
|
||||
public static final class Pre extends RenderTooltipEvent
|
||||
{
|
||||
private final int screenWidth;
|
||||
private final int screenHeight;
|
||||
@@ -289,7 +289,7 @@ public abstract class RenderTooltipEvent extends Event
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Background extends RenderTooltipEvent {
|
||||
public static final class Background extends RenderTooltipEvent {
|
||||
private final ResourceLocation originalBackground;
|
||||
private ResourceLocation background;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.function.Consumer;
|
||||
* @see MouseInput
|
||||
* @see KeyInput
|
||||
*/
|
||||
public abstract class ScreenEvent extends Event {
|
||||
public abstract sealed class ScreenEvent extends Event {
|
||||
private final Screen screen;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -61,7 +61,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see Init.Pre
|
||||
* @see Init.Post
|
||||
*/
|
||||
public static abstract class Init extends ScreenEvent {
|
||||
public static abstract sealed class Init extends ScreenEvent {
|
||||
private final Consumer<GuiEventListener> add;
|
||||
private final Consumer<GuiEventListener> remove;
|
||||
|
||||
@@ -111,7 +111,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends Init {
|
||||
public static final class Pre extends Init {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen, list, add, remove);
|
||||
@@ -126,7 +126,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends Init {
|
||||
public static final class Post extends Init {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, List<GuiEventListener> list, Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
|
||||
super(screen, list, add, remove);
|
||||
@@ -141,7 +141,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see Render.Pre
|
||||
* @see Render.Post
|
||||
*/
|
||||
public static abstract class Render extends ScreenEvent {
|
||||
public static abstract sealed class Render extends ScreenEvent {
|
||||
private final GuiGraphics guiGraphics;
|
||||
private final int mouseX;
|
||||
private final int mouseY;
|
||||
@@ -194,7 +194,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends Render {
|
||||
public static final class Pre extends Render {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
@@ -209,7 +209,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends Render {
|
||||
public static final class Post extends Render {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
super(screen, guiGraphics, mouseX, mouseY, partialTick);
|
||||
@@ -226,7 +226,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class BackgroundRendered extends ScreenEvent {
|
||||
public static final class BackgroundRendered extends ScreenEvent {
|
||||
private final GuiGraphics guiGraphics;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -255,7 +255,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RenderInventoryMobEffects extends ScreenEvent {
|
||||
public static final class RenderInventoryMobEffects extends ScreenEvent {
|
||||
private final int availableSpace;
|
||||
private boolean compact;
|
||||
private int horizontalOffset;
|
||||
@@ -320,7 +320,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see MouseDragged
|
||||
* @see MouseScrolled
|
||||
*/
|
||||
private static abstract class MouseInput extends ScreenEvent {
|
||||
private static abstract sealed class MouseInput extends ScreenEvent {
|
||||
private final double mouseX;
|
||||
private final double mouseY;
|
||||
|
||||
@@ -353,7 +353,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see MouseButtonPressed.Pre
|
||||
* @see MouseButtonPressed.Post
|
||||
*/
|
||||
public static abstract class MouseButtonPressed extends MouseInput {
|
||||
public static abstract sealed class MouseButtonPressed extends MouseInput {
|
||||
private final int button;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -383,7 +383,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseButtonPressed {
|
||||
public static final class Pre extends MouseButtonPressed {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -406,7 +406,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class Post extends MouseButtonPressed {
|
||||
public static final class Post extends MouseButtonPressed {
|
||||
private final boolean handled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -431,7 +431,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see MouseButtonReleased.Pre
|
||||
* @see MouseButtonReleased.Post
|
||||
*/
|
||||
public static abstract class MouseButtonReleased extends MouseInput {
|
||||
public static abstract sealed class MouseButtonReleased extends MouseInput {
|
||||
private final int button;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -461,7 +461,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseButtonReleased {
|
||||
public static final class Pre extends MouseButtonReleased {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int button) {
|
||||
super(screen, mouseX, mouseY, button);
|
||||
@@ -484,7 +484,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@HasResult
|
||||
public static class Post extends MouseButtonReleased {
|
||||
public static final class Post extends MouseButtonReleased {
|
||||
private final boolean handled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
@@ -509,7 +509,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see MouseDragged.Pre
|
||||
* @see MouseDragged.Post
|
||||
*/
|
||||
public static abstract class MouseDragged extends MouseInput {
|
||||
public static abstract sealed class MouseDragged extends MouseInput {
|
||||
private final int mouseButton;
|
||||
private final double dragX;
|
||||
private final double dragY;
|
||||
@@ -557,7 +557,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseDragged {
|
||||
public static final class Pre extends MouseDragged {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
@@ -574,7 +574,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends MouseDragged {
|
||||
public static final class Post extends MouseDragged {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, int mouseButton, double dragX, double dragY) {
|
||||
super(screen, mouseX, mouseY, mouseButton, dragX, dragY);
|
||||
@@ -589,7 +589,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see MouseScrolled.Pre
|
||||
* @see MouseScrolled.Post
|
||||
*/
|
||||
public static abstract class MouseScrolled extends MouseInput {
|
||||
public static abstract sealed class MouseScrolled extends MouseInput {
|
||||
private final double deltaX;
|
||||
private final double deltaY;
|
||||
|
||||
@@ -625,7 +625,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends MouseScrolled {
|
||||
public static final class Pre extends MouseScrolled {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY, deltaX, deltaY);
|
||||
@@ -642,7 +642,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends MouseScrolled {
|
||||
public static final class Post extends MouseScrolled {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY) {
|
||||
super(screen, mouseX, mouseY, deltaX, deltaY);
|
||||
@@ -659,7 +659,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see InputConstants
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_key" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
private static abstract class KeyInput extends ScreenEvent {
|
||||
private static abstract sealed class KeyInput extends ScreenEvent {
|
||||
private final int keyCode;
|
||||
private final int scanCode;
|
||||
private final int modifiers;
|
||||
@@ -719,7 +719,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see KeyPressed.Pre
|
||||
* @see KeyPressed.Post
|
||||
*/
|
||||
public static abstract class KeyPressed extends KeyInput {
|
||||
public static abstract sealed class KeyPressed extends KeyInput {
|
||||
@ApiStatus.Internal
|
||||
public KeyPressed(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -736,7 +736,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyPressed {
|
||||
public static final class Pre extends KeyPressed {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -754,7 +754,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyPressed {
|
||||
public static final class Post extends KeyPressed {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -769,7 +769,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see KeyReleased.Pre
|
||||
* @see KeyReleased.Post
|
||||
*/
|
||||
public static abstract class KeyReleased extends KeyInput {
|
||||
public static abstract sealed class KeyReleased extends KeyInput {
|
||||
@ApiStatus.Internal
|
||||
public KeyReleased(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -786,7 +786,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends KeyReleased {
|
||||
public static final class Pre extends KeyReleased {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -804,7 +804,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Post extends KeyReleased {
|
||||
public static final class Post extends KeyReleased {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, int keyCode, int scanCode, int modifiers) {
|
||||
super(screen, keyCode, scanCode, modifiers);
|
||||
@@ -820,7 +820,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* @see CharacterTyped.Post
|
||||
* @see <a href="https://www.glfw.org/docs/latest/input_guide.html#input_char" target="_top">the online GLFW documentation</a>
|
||||
*/
|
||||
public static class CharacterTyped extends ScreenEvent {
|
||||
public static sealed class CharacterTyped extends ScreenEvent {
|
||||
private final char codePoint;
|
||||
private final int modifiers;
|
||||
|
||||
@@ -864,7 +864,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends CharacterTyped {
|
||||
public static final class Pre extends CharacterTyped {
|
||||
@ApiStatus.Internal
|
||||
public Pre(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen, codePoint, modifiers);
|
||||
@@ -881,7 +881,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends CharacterTyped {
|
||||
public static final class Post extends CharacterTyped {
|
||||
@ApiStatus.Internal
|
||||
public Post(Screen screen, char codePoint, int modifiers) {
|
||||
super(screen, codePoint, modifiers);
|
||||
@@ -902,7 +902,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Opening extends ScreenEvent {
|
||||
public static final class Opening extends ScreenEvent {
|
||||
@Nullable
|
||||
private final Screen currentScreen;
|
||||
private Screen newScreen;
|
||||
@@ -949,7 +949,7 @@ public abstract class ScreenEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Closing extends ScreenEvent {
|
||||
public static final class Closing extends ScreenEvent {
|
||||
@ApiStatus.Internal
|
||||
public Closing(Screen screen) {
|
||||
super(screen);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.io.IOException;
|
||||
* @see Screenshot
|
||||
*/
|
||||
@Cancelable
|
||||
public class ScreenshotEvent extends Event {
|
||||
public final class ScreenshotEvent extends Event {
|
||||
public static final Component DEFAULT_CANCEL_REASON = Component.literal("Screenshot canceled");
|
||||
|
||||
private final NativeImage image;
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
*/
|
||||
@Cancelable
|
||||
public class SystemMessageReceivedEvent extends Event {
|
||||
public final class SystemMessageReceivedEvent extends Event {
|
||||
private Component message;
|
||||
private final boolean overlay;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see TextureStitchEvent.Post
|
||||
* @see TextureAtlas
|
||||
*/
|
||||
public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
public sealed class TextureStitchEvent extends Event implements IModBusEvent
|
||||
{
|
||||
private final TextureAtlas atlas;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class TextureStitchEvent extends Event implements IModBusEvent
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus()} mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class Post extends TextureStitchEvent
|
||||
public static final class Post extends TextureStitchEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public Post(TextureAtlas map)
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraftforge.fml.LogicalSide;
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public class ToastAddEvent extends Event {
|
||||
public final class ToastAddEvent extends Event {
|
||||
private final Toast toast;
|
||||
|
||||
public ToastAddEvent(Toast toast) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* @see ComputeCameraAngles
|
||||
* @see ComputeFov
|
||||
*/
|
||||
public abstract class ViewportEvent extends Event {
|
||||
public abstract sealed class ViewportEvent extends Event {
|
||||
private final GameRenderer renderer;
|
||||
private final Camera camera;
|
||||
private final double partialTick;
|
||||
@@ -73,7 +73,7 @@ public abstract class ViewportEvent extends Event {
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class RenderFog extends ViewportEvent {
|
||||
public static final class RenderFog extends ViewportEvent {
|
||||
private final FogMode mode;
|
||||
private final FogType type;
|
||||
private float farPlaneDistance;
|
||||
@@ -182,7 +182,7 @@ public abstract class ViewportEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class ComputeFogColor extends ViewportEvent {
|
||||
public static final class ComputeFogColor extends ViewportEvent {
|
||||
private float red;
|
||||
private float green;
|
||||
private float blue;
|
||||
@@ -254,7 +254,7 @@ public abstract class ViewportEvent extends Event {
|
||||
* <p>This event is fired on the {@linkplain MinecraftForge#EVENT_BUS main Forge event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public static class ComputeCameraAngles extends ViewportEvent {
|
||||
public static final class ComputeCameraAngles extends ViewportEvent {
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private float roll;
|
||||
@@ -327,7 +327,7 @@ public abstract class ViewportEvent extends Event {
|
||||
*
|
||||
* @see ComputeFovModifierEvent
|
||||
*/
|
||||
public static class ComputeFov extends ViewportEvent {
|
||||
public static final class ComputeFov extends ViewportEvent {
|
||||
private final boolean usedConfiguredFov;
|
||||
private float fov;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @see PlaySoundSourceEvent
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlaySoundEvent extends SoundEvent
|
||||
public final class PlaySoundEvent extends SoundEvent
|
||||
{
|
||||
private final String name;
|
||||
private final SoundInstance originalSound;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
public final class PlaySoundSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public PlaySoundSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
*
|
||||
* @see PlayStreamingSourceEvent
|
||||
*/
|
||||
public class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
public final class PlayStreamingSourceEvent extends SoundSourceEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public PlayStreamingSourceEvent(SoundEngine engine, SoundInstance sound, Channel channel)
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.ApiStatus;
|
||||
* <p>This event is fired on the {@linkplain FMLJavaModLoadingContext#getModEventBus() mod-specific event bus},
|
||||
* only on the {@linkplain LogicalSide#CLIENT logical client}.</p>
|
||||
*/
|
||||
public class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent
|
||||
public final class SoundEngineLoadEvent extends SoundEvent implements IModBusEvent
|
||||
{
|
||||
@ApiStatus.Internal
|
||||
public SoundEngineLoadEvent(SoundEngine manager)
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.textures.GpuTexture;
|
||||
|
||||
@@ -33,7 +33,8 @@ import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
import net.minecraft.client.gui.components.StringWidget;
|
||||
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
@@ -82,6 +83,7 @@ public class ModListScreen extends Screen {
|
||||
private static final int PADDING = 6;
|
||||
private static final int BUTTON_MARGIN = 1;
|
||||
private static final int NUM_BUTTONS = SortType.values().length;
|
||||
private static final int BUTTON_HEIGHT = 20;
|
||||
|
||||
private final Screen parentScreen;
|
||||
|
||||
@@ -95,6 +97,7 @@ public class ModListScreen extends Screen {
|
||||
|
||||
private String lastFilterText = "";
|
||||
|
||||
private StringWidget searchText;
|
||||
private EditBox search;
|
||||
|
||||
private boolean sorted = false;
|
||||
@@ -161,7 +164,6 @@ public class ModListScreen extends Screen {
|
||||
@Override
|
||||
protected void drawPanel(GuiGraphics guiGraphics, int entryRight, int relativeY, int mouseX, int mouseY) {
|
||||
if (logoPath != null) {
|
||||
//RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50
|
||||
int headerHeight = 50;
|
||||
@@ -170,11 +172,8 @@ public class ModListScreen extends Screen {
|
||||
}
|
||||
|
||||
for (FormattedCharSequence line : lines) {
|
||||
if (line != null) {
|
||||
//RenderSystem.enableBlend();
|
||||
if (line != null)
|
||||
guiGraphics.drawString(ModListScreen.this.font, line, left + PADDING, relativeY, 0xFFFFFF);
|
||||
//RenderSystem.disableBlend();
|
||||
}
|
||||
relativeY += font.lineHeight;
|
||||
}
|
||||
|
||||
@@ -225,40 +224,49 @@ public class ModListScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
var font = getFontRenderer();
|
||||
|
||||
for (IModInfo mod : mods) {
|
||||
listWidth = Math.max(listWidth,getFontRenderer().width(mod.getDisplayName()) + 10);
|
||||
listWidth = Math.max(listWidth,getFontRenderer().width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
|
||||
listWidth = Math.max(listWidth, font.width(mod.getDisplayName()) + 10);
|
||||
listWidth = Math.max(listWidth, font.width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
|
||||
}
|
||||
|
||||
listWidth = Math.max(Math.min(listWidth, width / 3), 100);
|
||||
listWidth += listWidth % NUM_BUTTONS != 0 ? (NUM_BUTTONS - listWidth % NUM_BUTTONS) : 0;
|
||||
|
||||
int modInfoWidth = this.width - this.listWidth - (PADDING * 3);
|
||||
int doneButtonWidth = Math.min(modInfoWidth, 200);
|
||||
int y = this.height - 20 - PADDING;
|
||||
int fullButtonHeight = PADDING + 20 + PADDING;
|
||||
final int fullButtonHeight = PADDING + BUTTON_HEIGHT + PADDING;
|
||||
final int modInfoWidth = this.width - this.listWidth - (PADDING * 3);
|
||||
final int doneButtonWidth = Math.min(modInfoWidth, 200);
|
||||
|
||||
int y = this.height - BUTTON_HEIGHT - PADDING;
|
||||
doneButton = Button.builder(Component.translatable("gui.done"), b -> ModListScreen.this.onClose())
|
||||
.bounds(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20)
|
||||
.bounds(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, BUTTON_HEIGHT)
|
||||
.build();
|
||||
|
||||
openModsFolderButton = Button.builder(Component.translatable("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile()))
|
||||
.bounds(6, y, this.listWidth, 20)
|
||||
.bounds(6, y, this.listWidth, BUTTON_HEIGHT)
|
||||
.build();
|
||||
|
||||
y -= 20 + PADDING;
|
||||
y -= BUTTON_HEIGHT + PADDING;
|
||||
configButton = Button.builder(Component.translatable("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig())
|
||||
.bounds(6, y, this.listWidth, 20)
|
||||
.bounds(6, y, this.listWidth, BUTTON_HEIGHT)
|
||||
.build();
|
||||
|
||||
y -= 14 + PADDING;
|
||||
search = new EditBox(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, Component.translatable("fml.menu.mods.search"));
|
||||
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.getY() - getFontRenderer().lineHeight * 4 - PADDING);
|
||||
y -= font.lineHeight;
|
||||
int width = font.width(search.getMessage().getVisualOrderText());
|
||||
searchText = new StringWidget(search.getX() + (search.getWidth() /2) - (width / 2), y, width, font.lineHeight, search.getMessage(), font);
|
||||
|
||||
int height = y - (PADDING + BUTTON_HEIGHT + PADDING) - PADDING;
|
||||
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, height);
|
||||
this.modList.setX(6);
|
||||
this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
|
||||
|
||||
this.addRenderableWidget(modList);
|
||||
this.addRenderableWidget(modInfo);
|
||||
this.addRenderableWidget(searchText);
|
||||
this.addRenderableWidget(search);
|
||||
this.addRenderableWidget(doneButton);
|
||||
this.addRenderableWidget(configButton);
|
||||
@@ -268,20 +276,20 @@ public class ModListScreen extends Screen {
|
||||
search.setCanLoseFocus(true);
|
||||
configButton.active = false;
|
||||
|
||||
final int width = listWidth / NUM_BUTTONS;
|
||||
width = listWidth / NUM_BUTTONS;
|
||||
int x = PADDING;
|
||||
addRenderableWidget(SortType.NORMAL.button = Button.builder(SortType.NORMAL.getButtonText(), b -> resortMods(SortType.NORMAL))
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, 20)
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, BUTTON_HEIGHT)
|
||||
.build());
|
||||
|
||||
x += width + BUTTON_MARGIN;
|
||||
addRenderableWidget(SortType.A_TO_Z.button = Button.builder(SortType.A_TO_Z.getButtonText(), b -> resortMods(SortType.A_TO_Z))
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, 20)
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, BUTTON_HEIGHT)
|
||||
.build());
|
||||
|
||||
x += width + BUTTON_MARGIN;
|
||||
addRenderableWidget(SortType.Z_TO_A.button = Button.builder(SortType.Z_TO_A.getButtonText(), b -> resortMods(SortType.Z_TO_A))
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, 20)
|
||||
.bounds(x, PADDING, width - BUTTON_MARGIN, BUTTON_HEIGHT)
|
||||
.build());
|
||||
|
||||
resortMods(SortType.NORMAL);
|
||||
@@ -354,15 +362,10 @@ public class ModListScreen extends Screen {
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
this.modList.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
if (this.modInfo != null)
|
||||
this.modInfo.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
|
||||
Component text = Component.translatable("fml.menu.mods.search");
|
||||
int x = modList.getX() + (modList.getWidth() / 2) - (getFontRenderer().width(text) / 2);
|
||||
this.search.render(guiGraphics, mouseX , mouseY, partialTick);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTick);
|
||||
guiGraphics.drawString(getFontRenderer(), text.getVisualOrderText(), x, search.getY() - getFontRenderer().lineHeight, 0xFFFFFF, false);
|
||||
}
|
||||
|
||||
public Minecraft getMinecraftInstance() {
|
||||
|
||||
@@ -18,8 +18,6 @@ import java.util.stream.Collectors;
|
||||
import net.minecraftforge.client.gui.widget.ScrollPanel;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.mojang.blaze3d.vertex.Tesselator;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,10 @@ public class ForgeSlider extends AbstractSliderButton {
|
||||
* @param value The new slider value
|
||||
*/
|
||||
public void setValue(double value) {
|
||||
double oldValue = this.value;
|
||||
this.value = this.snapToNearest((value - this.minValue) / (this.maxValue - this.minValue));
|
||||
if (!Mth.equal(oldValue, this.value))
|
||||
this.applyValue();
|
||||
this.updateMessage();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,19 +40,25 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
|
||||
return this.listWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int scrollBarX() {
|
||||
return this.getRowRight() - 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSelection(GuiGraphics gui, int top, int rowWidth, int height, int borderColor, int backgroundColor) {
|
||||
int barOffset = this.scrollbarVisible() ? 6 : 0;
|
||||
int left = this.getX() + (this.width - rowWidth) / 2;
|
||||
int right = this.getX() + (this.width + rowWidth) / 2 - barOffset;
|
||||
gui.fill(left, top - 2, right, top + height + 2, borderColor);
|
||||
gui.fill(left + 1, top - 1, right - 1, top + height + 1, backgroundColor);
|
||||
}
|
||||
|
||||
public void refreshList() {
|
||||
this.clearEntries();
|
||||
parent.buildModList(this::addEntry, mod->new ModEntry(mod, this.parent));
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.parent.renderBackground(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
*/
|
||||
|
||||
public class ModEntry extends ObjectSelectionList.Entry<ModEntry> {
|
||||
private final IModInfo modInfo;
|
||||
private final ModListScreen parent;
|
||||
@@ -68,20 +74,21 @@ public class ModListWidget extends ObjectSelectionList<ModListWidget.ModEntry> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isMouseOver, float partialTick)
|
||||
{
|
||||
public void render(GuiGraphics guiGraphics, int entryIdx, int top, int left, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isMouseOver, float partialTick) {
|
||||
Component name = Component.literal(stripControlCodes(modInfo.getDisplayName()));
|
||||
Component version = Component.literal(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
|
||||
Font font = this.parent.getFontRenderer();
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF, false);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC, false);
|
||||
var barOffset = ModListWidget.this.scrollbarVisible() ? 6 : 0;
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(name, listWidth - 6 - barOffset))), left + 3, top + 2, 0xFFFFFF, false);
|
||||
guiGraphics.drawString(font, Language.getInstance().getVisualOrder(FormattedText.composite(font.substrByWidth(version, listWidth - 6 - barOffset))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC, false);
|
||||
if (vercheck.status().shouldDraw()) {
|
||||
//TODO: Consider adding more icons for visualization
|
||||
//TODO: [Forge][ModList] Consider adding more icons for visualization
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, getX() + width - 12, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.blit(RenderType::guiTextured, VERSION_CHECK_ICONS, getX() + width - 12 - barOffset, top + entryHeight / 4, vercheck.status().getSheetOffset() * 8, (vercheck.status().isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
|
||||
guiGraphics.pose().popPose();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Abstract scroll panel class.
|
||||
* TODO: [Forge][Rendering] ScrollPanel could potentially be replaced by AbstractScrollArea
|
||||
*/
|
||||
public abstract class ScrollPanel extends AbstractContainerEventHandler implements Renderable, NarratableEntry {
|
||||
private final Minecraft client;
|
||||
@@ -146,22 +145,8 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
* Draws the background of the scroll panel. This runs AFTER Scissors are enabled.
|
||||
*/
|
||||
protected void drawBackground(GuiGraphics guiGraphics, float partialTick) {
|
||||
// BufferBuilder worldr = tess.getBuilder();
|
||||
|
||||
if (this.client.level != null) {
|
||||
if (this.client.level != null)
|
||||
this.drawGradientRect(guiGraphics, this.left, this.top, this.right, this.bottom, bgColorFrom, bgColorTo);
|
||||
} /* else { // Draw dark dirt background
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION);
|
||||
final float texScale = 32.0F;
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(this.left, this.bottom, 0.0D).uv(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.right, this.bottom, 0.0D).uv(this.right / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.right, this.top, 0.0D).uv(this.right / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.left, this.top, 0.0D).uv(this.left / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
tess.end();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,7 +247,7 @@ public abstract class ScrollPanel extends AbstractContainerEventHandler implemen
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) {
|
||||
guiGraphics.enableScissor(left, top, width, height);
|
||||
guiGraphics.enableScissor(left, top, left + width, top + height);
|
||||
|
||||
this.drawBackground(guiGraphics, partialTick);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -45,8 +46,11 @@ import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder.Reference;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.HolderSet.Named;
|
||||
import net.minecraft.core.component.DataComponentMap;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
@@ -83,6 +87,7 @@ import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
@@ -100,6 +105,7 @@ import net.minecraft.world.inventory.AnvilMenu;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
@@ -153,6 +159,7 @@ import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingGetProjectileEvent;
|
||||
import net.minecraftforge.event.level.BlockEvent;
|
||||
import net.minecraftforge.event.level.NoteBlockEvent;
|
||||
import net.minecraftforge.event.level.ChunkEvent;
|
||||
import net.minecraftforge.event.network.CustomPayloadEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
@@ -188,6 +195,9 @@ import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
|
||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -204,6 +214,10 @@ public final class ForgeHooks {
|
||||
|
||||
private ForgeHooks() {}
|
||||
|
||||
public static void fireLightingCalculatedEvent(ChunkAccess chunk) {
|
||||
MinecraftForge.EVENT_BUS.post(new ChunkEvent.LightingCalculated(chunk));
|
||||
}
|
||||
|
||||
public static boolean canContinueUsing(@NotNull ItemStack from, @NotNull ItemStack to) {
|
||||
if (!from.isEmpty() && !to.isEmpty()) {
|
||||
return from.getItem().canContinueUsing(from, to);
|
||||
@@ -1257,4 +1271,46 @@ public final class ForgeHooks {
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static final Pattern EMPTY_SIZE_PATTERN = Pattern.compile("^empty(\\d+)x(\\d+)x(\\d+)$");
|
||||
|
||||
/*
|
||||
* Creates a empty structure of any size requested using the pattern `forge:empty(x)x(y)x(z)`
|
||||
*
|
||||
* This is useful for game tests that need a structure, but want to create the contents in code.
|
||||
*/
|
||||
public static Optional<StructureTemplate> createEmptyStructure(ResourceLocation name) {
|
||||
if (name== null || !"forge".equals(name.getNamespace()))
|
||||
return Optional.empty();
|
||||
|
||||
var match = EMPTY_SIZE_PATTERN.matcher(name.getPath());
|
||||
if (!match.matches())
|
||||
return Optional.empty();
|
||||
|
||||
var size = new BlockPos(Integer.parseInt(match.group(1)), Integer.parseInt(match.group(2)), Integer.parseInt(match.group(3)));
|
||||
|
||||
var blocks = new ListTag();
|
||||
for (var pos : BlockPos.betweenClosed(BlockPos.ZERO, size)) {
|
||||
blocks.add(CompoundTag.builder()
|
||||
.tag("pos", pos.toListTag())
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
var ret = new StructureTemplate();
|
||||
ret.load(new HolderGetter<Block>() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Optional<Reference<Block>> get(ResourceKey<Block> key) {
|
||||
return Optional.of(Blocks.AIR.builtInRegistryHolder());
|
||||
}
|
||||
@Override public Optional<Named<Block>> get(TagKey<Block> key) { return Optional.empty(); }
|
||||
}, CompoundTag.builder()
|
||||
.tag("size", size.toListTag())
|
||||
.tag("blocks", blocks)
|
||||
.build()
|
||||
);
|
||||
|
||||
return Optional.of(ret);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import net.minecraftforge.server.command.ForgeCommand;
|
||||
import net.minecraftforge.server.permission.events.PermissionGatherEvent;
|
||||
import net.minecraftforge.server.command.ConfigCommand;
|
||||
|
||||
public class ForgeInternalHandler {
|
||||
public final class ForgeInternalHandler {
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onEntityJoinWorld(EntityJoinLevelEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
@@ -111,8 +111,8 @@ public class ForgeInternalHandler {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.HIGHEST)
|
||||
public void builtinMobSpawnBlocker(EntityJoinLevelEvent event) {
|
||||
if(event.getEntity() instanceof Mob mob && mob.isSpawnCancelled())
|
||||
event.setCanceled(true);
|
||||
if (event.getEntity() instanceof Mob mob && mob.isSpawnCancelled())
|
||||
event.cancel();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -5,12 +5,8 @@
|
||||
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import net.minecraft.world.level.block.CropBlock;
|
||||
import net.minecraft.world.level.block.FlowerBlock;
|
||||
import net.minecraft.world.level.block.SaplingBlock;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.AttachedStemBlock;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
|
||||
@@ -18,6 +14,8 @@ public interface IPlantable {
|
||||
default PlantType getPlantType(BlockGetter level, BlockPos pos) {
|
||||
if (this instanceof AttachedStemBlock) return PlantType.CROP;
|
||||
if (this instanceof CropBlock) return PlantType.CROP;
|
||||
if (this == Blocks.MANGROVE_PROPAGULE) return PlantType.MOIST;
|
||||
if (this instanceof AzaleaBlock) return PlantType.MOIST;
|
||||
if (this instanceof SaplingBlock) return PlantType.PLAINS;
|
||||
if (this instanceof FlowerBlock) return PlantType.PLAINS;
|
||||
if (this == Blocks.PITCHER_CROP) return PlantType.CROP;
|
||||
@@ -25,6 +23,8 @@ public interface IPlantable {
|
||||
if (this == Blocks.LILY_PAD) return PlantType.WATER;
|
||||
if (this == Blocks.RED_MUSHROOM) return PlantType.CAVE;
|
||||
if (this == Blocks.BROWN_MUSHROOM) return PlantType.CAVE;
|
||||
if (this == Blocks.CRIMSON_FUNGUS) return PlantType.FUNGUS;
|
||||
if (this == Blocks.WARPED_FUNGUS) return PlantType.FUNGUS;
|
||||
if (this == Blocks.NETHER_WART) return PlantType.NETHER;
|
||||
if (this == Blocks.TALL_GRASS) return PlantType.PLAINS;
|
||||
return PlantType.PLAINS;
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import net.minecraftforge.client.ConfigScreenHandler;
|
||||
import net.minecraftforge.eventbus.api.BusBuilder;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.config.IConfigSpec;
|
||||
@@ -30,11 +31,15 @@ import java.util.function.Supplier;
|
||||
public class MinecraftForge {
|
||||
/**
|
||||
* The EventBus for all the Forge Events.
|
||||
*
|
||||
* <br>
|
||||
* Events marked with {@link net.minecraftforge.fml.event.IModBusEvent}
|
||||
* belong on the ModBus and not this bus
|
||||
*/
|
||||
public static final IEventBus EVENT_BUS = BusBuilder.builder().startShutdown().useModLauncher().build();
|
||||
public static final IEventBus EVENT_BUS = BusBuilder.builder()
|
||||
.startShutdown()
|
||||
.useModLauncher()
|
||||
.setPhasesToTrack(EventPriority.MONITOR)
|
||||
.build();
|
||||
|
||||
static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@@ -27,6 +27,8 @@ public final class PlantType
|
||||
public static final PlantType WATER = get("water");
|
||||
public static final PlantType NETHER = get("nether");
|
||||
public static final PlantType CROP = get("crop");
|
||||
public static final PlantType FUNGUS = get("fungus");
|
||||
public static final PlantType MOIST = get("moist");
|
||||
|
||||
/**
|
||||
* Getting a custom {@link PlantType}, or an existing one if it has the same name as that one. Your plant should implement {@link IPlantable}
|
||||
|
||||
@@ -8,7 +8,6 @@ package net.minecraftforge.common;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraftforge.common.extensions.IForgeBlock;
|
||||
import net.minecraftforge.common.extensions.IForgeItem;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -113,15 +112,12 @@ public class ToolActions
|
||||
public static final Set<ToolAction> DEFAULT_AXE_ACTIONS = of(AXE_DIG, AXE_STRIP, AXE_SCRAPE, AXE_WAX_OFF);
|
||||
public static final Set<ToolAction> DEFAULT_HOE_ACTIONS = of(HOE_DIG, HOE_TILL);
|
||||
public static final Set<ToolAction> DEFAULT_SHOVEL_ACTIONS = of(SHOVEL_DIG, SHOVEL_FLATTEN);
|
||||
/** @deprecated See {@link #PICKAXE_DIG} for details */
|
||||
@Deprecated(forRemoval = true, since = "1.21.5")
|
||||
@Deprecated(since = "1.21.5")
|
||||
public static final Set<ToolAction> DEFAULT_PICKAXE_ACTIONS = of(PICKAXE_DIG);
|
||||
/** @deprecated See {@link #SWORD_DIG} and {@link #SWORD_SWEEP} for details */
|
||||
@Deprecated(forRemoval = true, since = "1.21.5")
|
||||
@Deprecated(since = "1.21.5")
|
||||
public static final Set<ToolAction> DEFAULT_SWORD_ACTIONS = of(SWORD_DIG, SWORD_SWEEP);
|
||||
public static final Set<ToolAction> DEFAULT_SHEARS_ACTIONS = of(SHEARS_DIG, SHEARS_HARVEST, SHEARS_CARVE, SHEARS_DISARM);
|
||||
/** @deprecated See {@link #SHIELD_BLOCK} for details */
|
||||
@Deprecated(forRemoval = true, since = "1.21.5")
|
||||
@Deprecated(since = "1.21.5")
|
||||
public static final Set<ToolAction> DEFAULT_SHIELD_ACTIONS = of(SHIELD_BLOCK);
|
||||
public static final Set<ToolAction> DEFAULT_FISHING_ROD_ACTIONS = of(FISHING_ROD_CAST);
|
||||
|
||||
|
||||
@@ -22,6 +22,18 @@ public class DatapackBuiltinEntriesProvider extends RegistriesDatapackGenerator
|
||||
|
||||
private final CompletableFuture<HolderLookup.Provider> fullRegistries;
|
||||
|
||||
/**
|
||||
* Constructs a new datapack provider which generates all registry objects
|
||||
* from the provided mods using the holder.
|
||||
*
|
||||
* @param output the target directory of the data generator
|
||||
* @param registries a future of patched registries
|
||||
* @param modId The mod id to generate the dynamic registry objects of
|
||||
*/
|
||||
public DatapackBuiltinEntriesProvider(PackOutput output, CompletableFuture<RegistrySetBuilder.PatchedRegistries> registries, String modId) {
|
||||
this(output, registries, Set.of(modId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new datapack provider which generates all registry objects
|
||||
* from the provided mods using the holder.
|
||||
@@ -35,6 +47,20 @@ public class DatapackBuiltinEntriesProvider extends RegistriesDatapackGenerator
|
||||
this.fullRegistries = registries.thenApply(RegistrySetBuilder.PatchedRegistries::full);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new datapack provider which generates all registry objects
|
||||
* from the provided mods using the holder. All entries that need to be
|
||||
* bootstrapped are provided within the {@link RegistrySetBuilder}.
|
||||
*
|
||||
* @param output the target directory of the data generator
|
||||
* @param registries a future of a lookup for registries and their objects
|
||||
* @param registryBuilder a builder containing the dynamic registry objects added by this provider
|
||||
* @param modId The mod id to generate the dynamic registry objects of
|
||||
*/
|
||||
public DatapackBuiltinEntriesProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries, RegistrySetBuilder registryBuilder, String modId) {
|
||||
this(output, registries, registryBuilder, Set.of(modId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new datapack provider which generates all registry objects
|
||||
* from the provided mods using the holder. All entries that need to be
|
||||
|
||||
@@ -159,9 +159,6 @@ public class ExistingFileHelper {
|
||||
* otherwise
|
||||
*/
|
||||
public boolean exists(ResourceLocation loc, PackType packType) {
|
||||
if (!enable) {
|
||||
return true;
|
||||
}
|
||||
return generated.get(packType).contains(loc) || getManager(packType).getResource(loc).isPresent();
|
||||
}
|
||||
|
||||
@@ -261,7 +258,9 @@ public class ExistingFileHelper {
|
||||
|
||||
/**
|
||||
* @return {@code true} if validation is enabled, {@code false} otherwise
|
||||
* @deprecated Validation is always enabled, check things as you deem fit.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.5")
|
||||
public boolean isEnabled() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public interface IForgeBlockEntity extends ICapabilityProvider {
|
||||
bb = AABB.encapsulatingFullBlocks(pos.offset(-1, 0, -1), pos.offset(1, 0, 1));
|
||||
} else if (block == Blocks.STRUCTURE_BLOCK) {
|
||||
bb = INFINITE_EXTENT_AABB;
|
||||
} else if (block != null && block != Blocks.BEACON) {
|
||||
} else if (block != null && block != Blocks.BEACON && block != Blocks.TEST_INSTANCE_BLOCK) {
|
||||
AABB cbb = null;
|
||||
try {
|
||||
VoxelShape collisionShape = state.getCollisionShape(self().getLevel(), pos);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.IntTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
||||
public interface IForgeBlockPos {
|
||||
private BlockPos self() { return (BlockPos) this; }
|
||||
|
||||
default ListTag toListTag() {
|
||||
var tag = new ListTag();
|
||||
tag.add(IntTag.valueOf(self().getX()));
|
||||
tag.add(IntTag.valueOf(self().getY()));
|
||||
tag.add(IntTag.valueOf(self().getZ()));
|
||||
return tag;
|
||||
}
|
||||
|
||||
default CompoundTag toCompoundTag() {
|
||||
return CompoundTag.builder()
|
||||
.putInt("x", self().getX())
|
||||
.putInt("y", self().getY())
|
||||
.putInt("z", self().getZ())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,31 @@
|
||||
|
||||
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.*;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.monster.piglin.PiglinAi;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.entity.monster.piglin.PiglinAi;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.ToolAction;
|
||||
import net.minecraftforge.common.ToolActions;
|
||||
@@ -38,6 +38,8 @@ import net.minecraftforge.registries.IForgeRegistry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// TODO systemic review of all extension functions. lots of unused -C
|
||||
public interface IForgeItem {
|
||||
private Item self() {
|
||||
@@ -315,6 +317,11 @@ public interface IForgeItem {
|
||||
* @return True if the stack can perform the action
|
||||
*/
|
||||
default boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
|
||||
if (stack.is(ItemTags.SWORDS))
|
||||
return ToolActions.DEFAULT_SWORD_ACTIONS.contains(toolAction);
|
||||
else if (stack.is(ItemTags.PICKAXES))
|
||||
return ToolActions.DEFAULT_PICKAXE_ACTIONS.contains(toolAction);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraftforge.registries.DeferredRegisterData;
|
||||
|
||||
public interface IForgeRegistrySetBuilder {
|
||||
private RegistrySetBuilder self() {
|
||||
return (RegistrySetBuilder)this;
|
||||
}
|
||||
|
||||
default <T> RegistrySetBuilder add(DeferredRegisterData<T> dr) {
|
||||
return self().add(dr.getRegistryKey(), dr);
|
||||
}
|
||||
|
||||
default <T> RegistrySetBuilder add(DeferredRegisterData<T> dr, Lifecycle lifecycle) {
|
||||
return self().add(dr.getRegistryKey(), lifecycle, dr);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.util.random.Weighted;
|
||||
|
||||
Loaded 100 of 357 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user