Skip to content

Commit

Permalink
Revert "Port to Forge using Architectury"
Browse files Browse the repository at this point in the history
This reverts commit abb7542.
  • Loading branch information
19MisterX98 committed Apr 30, 2022
1 parent abb7542 commit 568f3e2
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 142 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# SeedCrackerX [![Github All Releases](https://img.shields.io/github/downloads/19MisterX98/SeedCrackerX/total.svg)]

## CHANGES
- Ported to Forge 1.18.2-40.0.52+
- Depends on cloth config externally
- Changed API from entrypoint system to Forge EventBus system
- Usage is like so:
```java
public class ExampleHandler {
@SubscribeEvent
public void onSeed(SeedPushEvent event) {
MinecraftClient.getInstance().player.sendMessage(String.format("World Seed is: %d", event.seed));
}
}
```

## Readme Language

[中文](./READMEzh.md)
Expand Down
66 changes: 24 additions & 42 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import net.fabricmc.loom.task.RemapJarTask

plugins {
id 'dev.architectury.loom' version '0.11.0-SNAPSHOT'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

sourceCompatibility = JavaVersion.VERSION_17
Expand All @@ -13,11 +12,6 @@ archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

configurations {
// configuration that holds jars to include in the jar
jarLibs
}

sourceSets {
api {
java {
Expand Down Expand Up @@ -45,10 +39,18 @@ repositories {
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+${project.mappings_version}:v2"
forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

include("net.fabricmc.fabric-api:fabric-resource-loader-v0:${project.resource_loader_version}")

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}")

modApi ("me.shedaniel.cloth:cloth-config-forge:${project.cloth_config_version}")
modImplementation ("com.terraformersmc:modmenu:${project.modmenu_version}") {transitive = false}

implementation('com.seedfinding:mc_math:0eb505174da8a92550f8ec6efe254e0fa936cc0d') { transitive = false }
implementation('com.seedfinding:mc_seed:5518e3ba3ee567fb0b51c15958967f70a6a19e02') { transitive = false }
Expand All @@ -61,30 +63,22 @@ dependencies {

implementation('com.seedfinding:latticg:1.06')

jarLibs ('com.seedfinding:mc_math:0eb505174da8a92550f8ec6efe254e0fa936cc0d') { transitive = false }
jarLibs ('com.seedfinding:mc_seed:5518e3ba3ee567fb0b51c15958967f70a6a19e02') { transitive = false }
jarLibs ('com.seedfinding:mc_core:706e4f1b7aa6b42b3627f682a311d06280d80b5c') { transitive = false }
jarLibs ('com.seedfinding:mc_noise:a6ab8e6c688491829f8d2adf845392da22ef8e9c') { transitive = false }
jarLibs ('com.seedfinding:mc_biome:b2271807a047bb43ac60c8c20ad47e315f19b9a6') { transitive = false }
jarLibs ('com.seedfinding:mc_terrain:9e937ddb838e28e79423c287fa18b1ce66f061d7') { transitive = false }
jarLibs ('com.seedfinding:mc_feature:ef939c0dd7d66ab1bd290d6aab1e42a12cb3dbf1') { transitive = false }
jarLibs ('com.seedfinding:mc_reversal:2.0.0') { transitive = false }

jarLibs ('com.seedfinding:latticg:1.06')
}
include('com.seedfinding:mc_math:0eb505174da8a92550f8ec6efe254e0fa936cc0d') { transitive = false }
include('com.seedfinding:mc_seed:5518e3ba3ee567fb0b51c15958967f70a6a19e02') { transitive = false }
include('com.seedfinding:mc_core:706e4f1b7aa6b42b3627f682a311d06280d80b5c') { transitive = false }
include('com.seedfinding:mc_noise:a6ab8e6c688491829f8d2adf845392da22ef8e9c') { transitive = false }
include('com.seedfinding:mc_biome:b2271807a047bb43ac60c8c20ad47e315f19b9a6') { transitive = false }
include('com.seedfinding:mc_terrain:9e937ddb838e28e79423c287fa18b1ce66f061d7') { transitive = false }
include('com.seedfinding:mc_feature:ef939c0dd7d66ab1bd290d6aab1e42a12cb3dbf1') { transitive = false }
include('com.seedfinding:mc_reversal:2.0.0') { transitive = false }

loom {
forge {
mixinConfigs = [
"seedcracker.mixins.json"
]
}
include('com.seedfinding:latticg:1.06')
}

processResources {
inputs.property "version", project.version

filesMatching("META-INF/mods.toml") {
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
Expand All @@ -99,19 +93,13 @@ tasks.withType(JavaCompile) {
}

tasks.withType(Jar) {
from "LICENSE.md"
from "LICENSE.txt"
from sourceSets.api.output
}

tasks.jar {
from {
configurations.jarLibs.filter{ it.exists() && !it.name.contains("kotlin") && !it.name.contains("annotations") }.collect { it.isDirectory() ? it : zipTree(it) }
}
}

task apiJar(type: Jar) {
classifier "api-dev"
destinationDirectory.set(file("$buildDir/devlibs"))

from sourceSets.api.output
}

Expand All @@ -122,7 +110,6 @@ task remapApiJar(type: RemapJarTask, dependsOn: apiJar) {
addNestedDependencies = false
}


publishing {
publications {
def configurePom = {
Expand Down Expand Up @@ -150,10 +137,6 @@ publishing {
name = 'Kap'
id = 'KaptainWutax'
}
developer {
name = 'CanadianBacon'
id = 'CanadianBacon'
}
}
}

Expand Down Expand Up @@ -186,5 +169,4 @@ publishing {
}
}

prepareRemapApiJar.dependsOn apiJar
build.dependsOn remapApiJar
10 changes: 6 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use

minecraft_version=1.18.2
mappings_version=build.3
forge_version=40.0.52
yarn_mappings=1.18.2+build.1
loader_version=0.13.3

# Mod Properties
mod_version = 2.12
maven_group = kaptainwutax
archives_base_name = seedcrackerX
loom.platform=forge

# Dependencies
fabric_version=0.47.8+1.18.2
resource_loader_version=0.4.16+55dca1a4d2
modmenu_version=3.0.1
cloth_config_version=6.2.57
3 changes: 1 addition & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven { url "https://maven.architectury.dev/" }
maven { url "https://files.minecraftforge.net/maven/" }
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package kaptainwutax.seedcrackerX.api;

public interface SeedCrackerAPI {

void pushWorldSeed(long seed);

}
15 changes: 0 additions & 15 deletions src/api/java/kaptainwutax/seedcrackerX/api/SeedPushEvent.java

This file was deleted.

20 changes: 12 additions & 8 deletions src/main/java/kaptainwutax/seedcrackerX/SeedCracker.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package kaptainwutax.seedcrackerX;

import kaptainwutax.seedcrackerX.api.SeedCrackerAPI;
import kaptainwutax.seedcrackerX.config.Config;
import kaptainwutax.seedcrackerX.cracker.storage.DataStorage;
import kaptainwutax.seedcrackerX.finder.FinderQueue;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;

@Mod("seedcrackerx")
public class SeedCracker {
import java.util.ArrayList;

public class SeedCracker implements ModInitializer {

public static final ArrayList<SeedCrackerAPI> entrypoints = new ArrayList<>();
private static SeedCracker INSTANCE;
private final DataStorage dataStorage = new DataStorage();

public static SeedCracker get() {
return INSTANCE;
}

public SeedCracker()
{
@Override
public void onInitialize() {
INSTANCE = this;
Config.load();
Features.init(Config.get().getVersion());

MinecraftForge.EVENT_BUS.register(this);
FabricLoader.getInstance().getEntrypointContainers("seedcrackerx", SeedCrackerAPI.class).forEach(entrypoint ->
entrypoints.add(entrypoint.getEntrypoint()));
}

public DataStorage getDataStorage() {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/kaptainwutax/seedcrackerX/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import com.seedfinding.mccore.version.MCVersion;
import kaptainwutax.seedcrackerX.Features;
import kaptainwutax.seedcrackerX.util.FeatureToggle;
import net.minecraft.client.MinecraftClient;

import java.io.*;

public class Config {
private static final File file = new File(new File(MinecraftClient.getInstance().runDirectory, "config"), "seedcracker.json");
private static final File file = new File(net.fabricmc.loader.api.FabricLoader.getInstance().getConfigDir().toFile(), "seedcracker.json");
private static Config INSTANCE = new Config();
public FeatureToggle buriedTreasure = new FeatureToggle(true);
public FeatureToggle desertTemple = new FeatureToggle(true);
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/kaptainwutax/seedcrackerX/config/ScModMenuEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kaptainwutax.seedcrackerX.config;


import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;


@Environment(EnvType.CLIENT)
public class ScModMenuEntry implements ModMenuApi {
ConfigScreen configscreen = new ConfigScreen();

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return configscreen::getConfigScreenByCloth;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import kaptainwutax.seedcrackerX.Features;
import kaptainwutax.seedcrackerX.cracker.storage.DataStorage;
import kaptainwutax.seedcrackerX.cracker.storage.ScheduledSet;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.ClientConnection;
import net.minecraft.util.WorldSavePath;
Expand All @@ -17,7 +18,7 @@

public class StructureSave {

public static final File saveDir = new File(new File(MinecraftClient.getInstance().runDirectory, "config"), "SeedCrackerX_Structures");
public static final File saveDir = new File(FabricLoader.getInstance().getConfigDir().toFile(), "SeedCrackerX saved structures");
private static final List<RegionStructure<?,?>> structureTypes = List.of(Features.IGLOO,Features.BURIED_TREASURE,
Features.PILLAGER_OUTPOST,Features.DESERT_PYRAMID, Features.JUNGLE_PYRAMID, Features.END_CITY,
Features.MONUMENT, Features.SHIPWRECK, Features.SWAMP_HUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.seedfinding.mcfeature.structure.Shipwreck;
import com.seedfinding.mcfeature.structure.UniformStructure;
import com.seedfinding.mcseed.lcg.LCG;
import kaptainwutax.seedcrackerX.api.SeedPushEvent;
import kaptainwutax.seedcrackerX.SeedCracker;
import kaptainwutax.seedcrackerX.config.Config;
import kaptainwutax.seedcrackerX.cracker.BiomeData;
import kaptainwutax.seedcrackerX.cracker.decorator.Decorator;
Expand All @@ -22,7 +22,6 @@
import net.minecraft.text.Text;
import net.minecraft.world.gen.random.ChunkRandom;
import net.minecraft.world.gen.random.Xoroshiro128PlusPlusRandom;
import net.minecraftforge.common.MinecraftForge;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -77,7 +76,7 @@ public void poke(Phase phase) {
}
if (this.worldSeeds.size() == 1 && !this.shouldTerminate) {
long seed = worldSeeds.stream().findFirst().get();
MinecraftForge.EVENT_BUS.post(new SeedPushEvent(seed));
SeedCracker.entrypoints.forEach(entrypoint -> entrypoint.pushWorldSeed(seed));
MinecraftClient client = MinecraftClient.getInstance();
if (Config.get().databaseSubmits && client.getNetworkHandler().getPlayerList().size() > 10 &&
!client.getNetworkHandler().getConnection().isLocal()) {
Expand Down
45 changes: 0 additions & 45 deletions src/main/resources/META-INF/mods.toml

This file was deleted.

File renamed without changes
Loading

0 comments on commit 568f3e2

Please sign in to comment.