Skip to content

Commit

Permalink
Update to Minecraft 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Jul 8, 2023
1 parent a9b640a commit ec2a5de
Show file tree
Hide file tree
Showing 25 changed files with 405 additions and 499 deletions.
85 changes: 41 additions & 44 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath "org.parchmentmc:librarian:1.+"
}
plugins {
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'eclipse'

ext.buildnumber = 0

Expand All @@ -23,17 +15,18 @@ if (System.getenv('GITHUB_RUN_NUMBER')) {
}

group = 'com.lovetropics.gamemodebuild'
archivesBaseName = 'GamemodeBuild'
base {
archivesName = 'GamemodeBuild'
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

minecraft {
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
mappings channel: 'parchment', version: parchment_version

runs {
client {
taskName 'gb_client'

configureEach {
copyIdeResources = true
workingDirectory project.file('run')

property 'forge.logging.console.level', 'info'
Expand All @@ -45,35 +38,21 @@ minecraft {
}
}

client {
taskName 'gb_client'
}

server {
taskName 'gb_server'

workingDirectory project.file('run')

property 'forge.logging.console.level', 'info'

mods {
gamemodebuild {
source sourceSets.main
}
}
}

data {
taskName 'gb_data'

workingDirectory project.file('run')

property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'

args '--mod', 'gamemodebuild', '--all', '--output', file('src/generated/resources/')

mods {
gamemodebuild {
source sourceSets.main
}
}
}
}
}
Expand All @@ -82,16 +61,34 @@ dependencies {
minecraft "net.minecraftforge:forge:$minecraft_version-$forge_version"
}

jar {
tasks.named('jar', Jar).configure {
archiveClassifier = 'slim'
finalizedBy 'reobfJar'

manifest {
attributes([
"Specification-Title": "gamemodebuild",
"Specification-Vendor": "lovetropics",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"lovetropics",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
"Specification-Title": "gamemodebuild",
"Specification-Vendor": "lovetropics",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": archiveVersion,
"Implementation-Vendor" :"lovetropics",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
}
}

tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
mod_version: mod_version,
]
inputs.properties replaceProperties

filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
7 changes: 3 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
minecraft_version=1.18.2
forge_version=40.1.0
mod_version=1.2.0
parchment_version=2022.04.23-nightly-SNAPSHOT
minecraft_version=1.20.1
forge_version=47.1.0
parchment_version=2023.06.26-1.20.1

# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
12 changes: 12 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}
2 changes: 0 additions & 2 deletions src/main/java/com/lovetropics/gamemodebuild/GBConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ public boolean enabled() {
final Pair<Server, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Server::new);
serverSpec = specPair.getRight();
SERVER = specPair.getLeft();

SERVER.loadLists();
}

@SubscribeEvent
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/com/lovetropics/gamemodebuild/GBKeyBindings.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
import com.lovetropics.gamemodebuild.message.GBNetwork;
import com.lovetropics.gamemodebuild.message.SetActiveMessage;
import com.lovetropics.gamemodebuild.state.GBClientState;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ClientRegistry;
import net.minecraftforge.event.TickEvent.ClientTickEvent;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import org.lwjgl.glfw.GLFW;

@EventBusSubscriber(modid = GamemodeBuild.MODID, bus = Bus.FORGE, value = Dist.CLIENT)
public class GBKeyBindings {

public static final KeyMapping SWITCH_MODE = new KeyMapping("Enable/Disable Build Mode", GLFW.GLFW_KEY_B, "Build Mode");

public static final KeyMapping SWITCH_MODE = new KeyMapping("Enable/Disable Build Mode", InputConstants.KEY_B, "Build Mode");

@SubscribeEvent
public static void onKeyInput(ClientTickEvent event) {
if (event.phase == Phase.END && SWITCH_MODE.consumeClick()) {
Expand All @@ -31,8 +29,4 @@ public static void onKeyInput(ClientTickEvent event) {
}
}
}

public static void register() {
ClientRegistry.registerKeyBinding(SWITCH_MODE);
}
}
40 changes: 20 additions & 20 deletions src/main/java/com/lovetropics/gamemodebuild/GamemodeBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,49 @@

import com.lovetropics.gamemodebuild.command.GamemodeBuildCommand;
import com.lovetropics.gamemodebuild.command.ItemFilterArgument;
import com.lovetropics.gamemodebuild.container.BuildContainer;
import com.lovetropics.gamemodebuild.message.GBNetwork;
import net.minecraft.commands.synchronization.ArgumentTypes;
import net.minecraft.commands.synchronization.EmptyArgumentSerializer;
import net.minecraft.commands.synchronization.ArgumentTypeInfo;
import net.minecraft.commands.synchronization.ArgumentTypeInfos;
import net.minecraft.commands.synchronization.SingletonArgumentInfo;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.IExtensionPoint;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import java.util.regex.Pattern;

@Mod(GamemodeBuild.MODID)
public class GamemodeBuild {
public static final String MODID = "gamemodebuild";
public static final String NAME = "Build Mode";

private static final Logger LOGGER = LogManager.getLogger();

private static final DeferredRegister<ArgumentTypeInfo<?, ?>> ARGUMENT_REGISTER = DeferredRegister.create(ForgeRegistries.COMMAND_ARGUMENT_TYPES, MODID);

private static final RegistryObject<ArgumentTypeInfo<?, ?>> ITEM_FILTER_ARGUMENT = ARGUMENT_REGISTER.register("item_filter", () -> ArgumentTypeInfos.registerByClass(ItemFilterArgument.class, SingletonArgumentInfo.contextAware(ItemFilterArgument::new)));

public GamemodeBuild() {
// Compatible with all versions that match the semver (excluding the qualifier e.g. "-beta+42")
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(GamemodeBuild::getCompatVersion, (s, v) -> GamemodeBuild.isCompatibleVersion(s)));

// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
modBus.addListener(this::setup);
ARGUMENT_REGISTER.register(modBus);
BuildContainer.REGISTER.register(modBus);

// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);

ModLoadingContext.get().registerConfig(Type.SERVER, GBConfigs.serverSpec);
}

Expand All @@ -56,15 +61,10 @@ public static boolean isCompatibleVersion(String version) {

private void setup(final FMLCommonSetupEvent event) {
GBNetwork.register();
ArgumentTypes.register(GamemodeBuild.MODID + ":item_filter", ItemFilterArgument.class, new EmptyArgumentSerializer<>(ItemFilterArgument::itemFilter));
}

private void doClientStuff(final FMLClientSetupEvent event) {
GBKeyBindings.register();
}

@SubscribeEvent
public void registerCommands(RegisterCommandsEvent event) {
GamemodeBuildCommand.register(event.getDispatcher());
GamemodeBuildCommand.register(event.getDispatcher(), event.getBuildContext());
}
}
Loading

0 comments on commit ec2a5de

Please sign in to comment.