Skip to content

Commit

Permalink
Update forge to 40.2.21 and fix #24
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed May 20, 2024
1 parent 05f7383 commit 98cd29b
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 16 deletions.
32 changes: 19 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plugins {
id 'com.github.ben-manes.versions' version '0.36.0'
id 'net.minecraftforge.gradleutils' version '2.1.3'
id 'eclipse'
id 'de.undercouch.download' version '4.1.2'
id 'de.undercouch.download' version '5.1.3'
id 'net.nemerosa.versioning' version '3.0.0'
}

Expand All @@ -58,19 +58,19 @@ ext {
MODLAUNCHER_VERSION = '9.1.3'
SECUREJARHANDLER_VERSION = '1.0.8'
BOOTSTRAPLAUNCHER_VERSION = '1.0.0'
ASM_VERSION = '9.5'
INSTALLER_VERSION = '2.1.+'
ASM_VERSION = '9.7'
INSTALLER_VERSION = '2.2.+'
MIXIN_VERSION = '0.8.5'
JARJAR_VERSION = '0.3.19'

GIT_INFO = gradleutils.gitInfo
FORGE_VERSION = '40.2.17'
FORGE_VERSION = '40.2.21'
MAGMA_VERSION = "1.18.2-$FORGE_VERSION-" + versioning.info.commit.substring(0, 7) // Use 8 characters for the commit hash
VERSION = "1.18.2-$FORGE_VERSION"

SPECIAL_SOURCE = 'net.md-5:SpecialSource:1.10.0'
BINPATCH_TOOL = 'net.minecraftforge:binarypatcher:1.0.12:fatjar'
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.3.0'
INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.4.1'
JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4'
FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.25:all'
MIN_TAG_FOR_CHANGELOG = "39.0"
Expand Down Expand Up @@ -345,7 +345,7 @@ def sharedFmlonlyForge = { Project prj ->
}

prj.task([type: DownloadMavenArtifact], 'downloadInstaller') {
artifact = "net.minecraftforge:installer:${INSTALLER_VERSION}:shrunk"
artifact = "net.minecraftforge:installer:${INSTALLER_VERSION}:fatjar"
changing = true
}

Expand Down Expand Up @@ -743,9 +743,12 @@ project(':forge') {
]
}

task crowdin(type: Crowdin) {
key = project.hasProperty('crowdinKey') ? project.crowdinKey : null
//TODO: Merge our english.json?
tasks.register('downloadCrowdin', Download) {
src 'https://files.minecraftforge.net/crowdin.zip'
dest file('build/crowdin.zip')
useETag 'all'
onlyIfModified true
quiet true
}

sharedFmlonlyForge.call(project)
Expand Down Expand Up @@ -1087,7 +1090,7 @@ project(':forge') {
'libraries/' + Util.getMavenPath(rootProject.tasks.findByPath(':fmlloader:jar')),
"libraries/net/minecraft/server/${MC_VERSION}-${MCP_VERSION}/server-${MC_VERSION}-${MCP_VERSION}-extra.jar",
"libraries/cpw/mods/bootstraplauncher/1.0.0/bootstraplauncher-1.0.0.jar",
"libraries/net/minecraftforge/installertools/1.3.0/installertools-1.3.0.jar"
"libraries/net/minecraftforge/installertools/1.4.1/installertools-1.4.1.jar"
]
def claimed = CLASS_PATH.collect { it.rsplit('/', 2)[0] }.toSet() // Allow us to override versions
if (rootProject.downloadServerRaw.dest.exists()) {
Expand Down Expand Up @@ -1184,9 +1187,12 @@ project(':forge') {
from extraTxts

// add crowdin locales
from { crowdin.output.present && crowdin.output.get().asFile.exists() ? zipTree(crowdin.output) : null}
dependsOn crowdin
duplicatesStrategy = 'exclude'
from zipTree(downloadCrowdin.dest).matching {
include 'assets/forge/lang/*.json'
}

dependsOn downloadCrowdin
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

doFirst {
MANIFESTS.each{ pkg, values ->
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/net/minecraftforge/client/ConfigGuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,29 @@

import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;

public class ConfigGuiHandler
{
public record ConfigGuiFactory(BiFunction<Minecraft, Screen, Screen> screenFunction) implements IExtensionPoint<ConfigGuiFactory> {}
/**
* @param screenFunction A function that takes the {@link Minecraft} client instance and the mods screen as
* arguments and returns your config screen to show when the player clicks the config button
* for your mod on the mods screen.
* <p>You should call {@link Minecraft#setScreen(Screen)} with the provided client instance
* and mods screen for the action of your close button.</p>
*/
public record ConfigGuiFactory(BiFunction<Minecraft, Screen, Screen> screenFunction) implements IExtensionPoint<ConfigGuiFactory> {
/**
* @param screenFunction A function that takes the mods screen as an argument and returns your config screen to
* show when the player clicks the config button for your mod on the mods screen.
* <p>You should call {@link Minecraft#setScreen(Screen)} with the provided mods screen
* for the action of your close button, using {@link Screen#minecraft} to get the client
* instance.</p>
*/
public ConfigGuiFactory(Function<Screen, Screen> screenFunction) {
this((mcClient, modsScreen) -> screenFunction.apply(modsScreen));
}
}
public static Optional<BiFunction<Minecraft, Screen, Screen>> getGuiFactoryFor(IModInfo selectedMod)
{
return ModList.get().getModContainerById(selectedMod.getModId()).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public <T> ConfigValue<T> defineInList(List<String> path, T defaultValue, Collec
return defineInList(path, () -> defaultValue, acceptableValues);
}
public <T> ConfigValue<T> defineInList(List<String> path, Supplier<T> defaultSupplier, Collection<? extends T> acceptableValues) {
return define(path, defaultSupplier, acceptableValues::contains);
return define(path, defaultSupplier, o -> o != null && acceptableValues.contains(o));
}
public <T> ConfigValue<List<? extends T>> defineList(String path, List<? extends T> defaultValue, Predicate<Object> elementValidator) {
return defineList(split(path), defaultValue, elementValidator);
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/net/minecraftforge/common/MinecraftForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

package net.minecraftforge.common;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.ConfigGuiHandler;
import net.minecraftforge.eventbus.api.BusBuilder;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.IConfigSpec;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.loading.FMLEnvironment;
import net.minecraftforge.network.DualStackUtils;
import net.minecraftforge.versions.forge.ForgeVersion;
Expand All @@ -17,6 +23,10 @@
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

public class MinecraftForge
{
/**
Expand Down Expand Up @@ -46,6 +56,36 @@ public static void initialize()
DualStackUtils.initialise();
}

/**
* Register a config screen for the active mod container.
* @param screenFunction A function that takes the mods screen as an argument and returns your config screen to
* show when the player clicks the config button for your mod on the mods screen.
* <p>You should call {@link Minecraft#setScreen(Screen)} with the provided mods screen for the
* action of your close button, using {@link Screen#minecraft} to get the client instance.</p>
* @see ModLoadingContext#registerExtensionPoint(Class, Supplier)
* @see ModLoadingContext#registerConfig(ModConfig.Type, IConfigSpec)
*/
public static void registerConfigScreen(Function<Screen, Screen> screenFunction) {
registerConfigScreen((mcClient, modsScreen) -> screenFunction.apply(modsScreen));
}

/**
* Register a config screen for the active mod container.
* @param screenFunction A function that takes the {@link Minecraft} client instance and the mods screen as
* arguments and returns your config screen to show when the player clicks the config button
* for your mod on the mods screen.
* <p>You should call {@link Minecraft#setScreen(Screen)} with the provided client instance
* and mods screen for the action of your close button.</p>
* @see ModLoadingContext#registerExtensionPoint(Class, Supplier)
* @see ModLoadingContext#registerConfig(ModConfig.Type, IConfigSpec)
*/
public static void registerConfigScreen(BiFunction<Minecraft, Screen, Screen> screenFunction) {
ModLoadingContext.get().registerExtensionPoint(
ConfigGuiHandler.ConfigGuiFactory.class,
() -> new ConfigGuiHandler.ConfigGuiFactory(screenFunction)
);
}

/*
public static void preloadCrashClasses(ASMDataTable table, String modID, Set<String> classes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ public static ItemMeta getItemMeta(net.minecraft.world.item.ItemStack item) {
}

static Material getType(net.minecraft.world.item.ItemStack item) {
return item == null ? Material.AIR : CraftMagicNumbers.getMaterial(item.getItem());
Material material = CraftMagicNumbers.getMaterial(item.getItem());
return material == null ? Material.AIR : material;
}

@Override
Expand Down

0 comments on commit 98cd29b

Please sign in to comment.