Skip to content

Commit

Permalink
Huge refactor + update to Minecraft 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
xpple committed Nov 1, 2024
1 parent fd1796f commit e9ac702
Show file tree
Hide file tree
Showing 55 changed files with 940 additions and 1,115 deletions.
74 changes: 32 additions & 42 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'com.gradleup.shadow' version '8.3.4'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
version = project.mod_version
group = project.maven_group
}

loom {
accessWidenerPath = file('src/main/resources/seedmapper.aw')
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenCentral()
maven {
url 'https://maven.xpple.dev/maven2/'
name = 'xpple'
url = 'https://maven.xpple.dev/maven2'
}
maven {
url 'https://nexus.seedfinding.com/repository/maven-seedfinding'
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
maven {
name = 'SeedFinding'
url 'https://nexus.seedfinding.com/repository/maven-seedfinding-snapshots'
}
}
Expand All @@ -39,20 +36,19 @@ configurations {
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
mappings loom.layered {
officialMojangMappings {
nameSyntheticMembers = true
}
parchment "org.parchmentmc.data:${project.parchment_mappings}"
}
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.

include modImplementation("dev.xpple:clientarguments:${project.clientarguments_version}")

include modImplementation("dev.xpple:betterconfig:${project.betterconfig_version}")
include modImplementation("dev.xpple:betterconfig-fabric:${project.betterconfig_version}")

extraLibs("com.seedfinding:mc_math:${project.mc_math_version}") {transitive = false}
extraLibs("com.seedfinding:mc_seed:${project.mc_seed_version}") {transitive = false}
Expand All @@ -67,28 +63,26 @@ dependencies {
}

processResources {
inputs.property "version", project.version
def props = [version: project.mod_version, loader_version: project.fabric_loader_version]
inputs.properties props
filteringCharset "UTF-8"

filesMatching("fabric.mod.json") {
expand "version": project.version
expand props
}

from("LICENSE") {
rename {"${it}_${project.base.archivesName.get()}"}
}
}

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

it.options.release = 21
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

shadowJar {
Expand All @@ -108,19 +102,15 @@ tasks.withType(Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.base.archivesName.get()
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.

}
}
25 changes: 14 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.21
yarn_mappings=1.21+build.9
loader_version=0.15.11
org.gradle.parallel=true

# Mod Properties
mod_version=1.6
maven_group=dev.xpple
archives_base_name=seedmapper

# Dependencies
fabric_api_version=0.100.7+1.21
# Minecraft properties
minecraft_version=1.21.3

clientarguments_version=1.9
# Fabric Properties
# check these on https://fabricmc.net/develop
# https://ldtteam.jfrog.io/ui/native/parchmentmc-public/org/parchmentmc/data/
fabric_api_version=0.107.0+1.21.3
parchment_mappings=parchment-1.21:2024.07.28@zip
fabric_loader_version=0.16.9

betterconfig_version=1.3
# Library dependencies
betterconfig_version=2.1.2
clientarguments_version=1.10.1

mc_math_version=851e9d0577dfdca50154e98f1d334bd31c641326
mc_seed_version=55f6242001f7eb4226df4ed0d023f1838a54a99d
mc_core_version=927e5e1fd4bbb6f8219473ef6dc0c1bb569a60e9
mc_core_version=b84ff1c38be399eda096dbde2819258c62f81275
mc_noise_version=dbab3996ea3abff5dd420db53c31d5498afd2fe5
mc_biome_version=17af8cb1110fdc983b7cb2b887d1fb2060e23ee3
mc_terrain_version=a03e440ec5b282e399382f2cc5ad0db91b438d2e
mc_feature_version=7a14acbf03225421750b8527c161186fecac71f7
mc_feature_version=1eedc2e2a0d1959f7f42915d557d78564985c4b4

mc_reversal_version=75aa6ce47a9f53a1aa212765e9830e08f6c86299
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
60 changes: 26 additions & 34 deletions src/main/java/dev/xpple/seedmapper/SeedMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,53 @@

import com.mojang.brigadier.CommandDispatcher;
import dev.xpple.betterconfig.api.ModConfigBuilder;
import dev.xpple.seedmapper.command.ClientCommand;
import dev.xpple.seedmapper.command.arguments.BlockArgumentType;
import dev.xpple.seedmapper.command.arguments.SeedResolutionArgumentType;
import dev.xpple.seedmapper.command.commands.*;
import dev.xpple.seedmapper.util.DatabaseHelper;
import dev.xpple.seedmapper.command.arguments.BlockArgument;
import dev.xpple.seedmapper.command.arguments.SeedResolutionArgument;
import dev.xpple.seedmapper.command.commands.CheckSeedCommand;
import dev.xpple.seedmapper.command.commands.ClearScreenCommand;
import dev.xpple.seedmapper.command.commands.HighlightCommand;
import dev.xpple.seedmapper.command.commands.LocateCommand;
import dev.xpple.seedmapper.command.commands.SeedOverlayCommand;
import dev.xpple.seedmapper.command.commands.SourceCommand;
import dev.xpple.seedmapper.command.commands.TerrainVersionCommand;
import dev.xpple.seedmapper.util.SeedDatabaseHelper;
import dev.xpple.seedmapper.util.config.BlockAdapter;
import dev.xpple.seedmapper.util.config.Configs;
import dev.xpple.seedmapper.util.config.SeedResolution;
import dev.xpple.seedmapper.util.config.SeedResolutionAdapter;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.world.level.block.Block;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

public class SeedMapper implements ClientModInitializer {

public static final String MOD_ID = "seedmapper";
public static final String MOD_NAME = "SeedMapper";
public static final String MOD_PREFIX = "sm";
public static final Path MOD_PATH = Paths.get(FabricLoader.getInstance().getConfigDir() + File.separator + MOD_ID);
public static final MinecraftClient CLIENT = MinecraftClient.getInstance();

public static final Path modConfigPath = FabricLoader.getInstance().getConfigDir().resolve(MOD_ID);

@Override
public void onInitializeClient() {
//noinspection ResultOfMethodCallIgnored
MOD_PATH.toFile().mkdirs();

new ModConfigBuilder(MOD_ID, Configs.class)
.registerTypeHierarchy(Block.class, new BlockAdapter(), BlockArgumentType::block)
.registerType(SeedResolution.class, new SeedResolutionAdapter(), SeedResolutionArgumentType::seedResolution)
new ModConfigBuilder<>(MOD_ID, Configs.class)
.registerTypeHierarchy(Block.class, new BlockAdapter(), BlockArgument::block)
.registerType(SeedResolutionArgument.SeedResolution.class, new SeedResolutionAdapter(), SeedResolutionArgument::seedResolution)
.build();

DatabaseHelper.fetchSeeds();
SeedDatabaseHelper.fetchSeeds();

ClientCommandRegistrationCallback.EVENT.register(SeedMapper::registerCommands);
}

public static void onTerminateClient() {
//
}

private static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess registryAccess) {
ClientCommand.instantiate(new SeedOverlayCommand(), dispatcher, registryAccess);
ClientCommand.instantiate(new TerrainVersionCommand(), dispatcher, registryAccess);
ClientCommand.instantiate(new LocateCommand(), dispatcher, registryAccess);
ClientCommand.instantiate(new HighlightCommand(), dispatcher, registryAccess);
ClientCommand.instantiate(new SourceCommand(), dispatcher, registryAccess);
ClientCommand.instantiate(new ClearScreenCommand(), dispatcher, registryAccess);
ClientCommand.instantiate(new CheckSeedCommand(), dispatcher, registryAccess);
private static void registerCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandBuildContext context) {
SeedOverlayCommand.register(dispatcher);
TerrainVersionCommand.register(dispatcher);
LocateCommand.register(dispatcher);
HighlightCommand.register(dispatcher);
SourceCommand.register(dispatcher);
ClearScreenCommand.register(dispatcher);
CheckSeedCommand.register(dispatcher);
}
}
52 changes: 0 additions & 52 deletions src/main/java/dev/xpple/seedmapper/command/ClientCommand.java

This file was deleted.

24 changes: 24 additions & 0 deletions src/main/java/dev/xpple/seedmapper/command/CommandExceptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.xpple.seedmapper.command;

import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.network.chat.Component;

public final class CommandExceptions {

private CommandExceptions() {
}

public static final DynamicCommandExceptionType UNKNOWN_DIMENSION_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownDimension", arg));
public static final DynamicCommandExceptionType UNKNOWN_VERSION_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownVersion", arg));
public static final DynamicCommandExceptionType UNKNOWN_BIOME_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownBiome", arg));
public static final DynamicCommandExceptionType UNKNOWN_STRUCTURE_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownStructure", arg));
public static final DynamicCommandExceptionType UNKNOWN_DECORATOR_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownDecorator", arg));
public static final DynamicCommandExceptionType UNKNOWN_BLOCK_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownBlock", arg));
public static final DynamicCommandExceptionType UNKNOWN_ITEM_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownItem", arg));
public static final DynamicCommandExceptionType UNKNOWN_LOOT_ITEM_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.unknownLootItem", arg));
public static final SimpleCommandExceptionType NO_SEED_AVAILABLE_EXCEPTION = new SimpleCommandExceptionType(Component.translatable("commands.exceptions.noSeedAvailable"));
public static final DynamicCommandExceptionType NO_BIOME_FOUND_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.noBiomeFound", arg));
public static final DynamicCommandExceptionType NO_STRUCTURE_FOUND_EXCEPTION = new DynamicCommandExceptionType(arg -> Component.translatable("commands.exceptions.noStructureFound", arg));
public static final SimpleCommandExceptionType INVALID_DIMENSION_EXCEPTION = new SimpleCommandExceptionType(Component.translatable("commands.exceptions.invalidDimension"));
}
Loading

0 comments on commit e9ac702

Please sign in to comment.