Skip to content

Commit

Permalink
a lot of things
Browse files Browse the repository at this point in the history
 - config
 - qodana
 - rebuild .idea folder lol
  • Loading branch information
rhysdh540 committed Aug 1, 2023
1 parent 9411c1f commit 1a7ecf1
Show file tree
Hide file tree
Showing 20 changed files with 683 additions and 62 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- multiversion

jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ classes/
.metadata
.vscode
.settings
*.launch
*.launch

build.properties
common/src/main/resources/*.accesswidener
18 changes: 9 additions & 9 deletions 1.19.2.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ lazydfu=0.1.3
smoothboot_fabric=3821513
modmenu=7.2.1

### Forge Mods
## Better Mods Button - https://www.curseforge.com/minecraft/mc-mods/better-mods-button/files
#bmb = 4613425
## Catalogue - https://www.curseforge.com/minecraft/mc-mods/catalogue/files
#catalogue = 4590890
## FerriteCore - https://www.curseforge.com/minecraft/mc-mods/ferritecore/files
#ferritecore = 4574361
## Smooth Boot
#smoothboot_forge = 4162940
## Forge Mods
# Better Mods Button - https://www.curseforge.com/minecraft/mc-mods/better-mods-button/files
bmb = 4665753
# Catalogue - https://www.curseforge.com/minecraft/mc-mods/catalogue/files
catalogue = 4171024
# FerriteCore - https://www.curseforge.com/minecraft/mc-mods/ferritecore/files
ferritecore = 4117906
# Smooth Boot - https://www.curseforge.com/minecraft/mc-mods/smooth-boot-reloaded/files/
smoothboot_forge = 4162940
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +0,0 @@
# Ranplate
A template repo for my minecraft mods which is multi-loader & multi-versioned

Current Preprocessor System:
- MC_`<version>`
- so `MC_1_19_2` would mean if 1.19.2 is the current version
- POST_MC_`<version>`
- so `POST_MC_1_19_2` would mean if the version is after 1.19.2
- POST_CURRENT_MC_`<version>`
- so `POST_CURRENT_MC_1_19_2` would mean if the current version is after 1.19.2 or is 1.19.2
- PRE_MC_`<version>`
- so `PRE_MC_1_19_2` would mean if the version is before 1.19.2
- PRE_CURRENT_MC_`<version>`
- so `PRE_CURRENT_MC_1_19_2` would mean if the current version is before 1.19.2 or is 1.19.2

Remember to install the [Manifold](https://plugins.jetbrains.com/plugin/10057-manifold) plugin in IntelliJ!\
Also could look in this [class](https://github.com/Ran-helo/Ranplate/blob/master/common/src/main/java/net/examplemod/ExampleMod.java) if you need an example of how to use it!

This repo contains [MixinExtras](https://github.com/LlamaLad7/MixinExtras) so remember to [check](https://github.com/LlamaLad7/MixinExtras/wiki) that out!\
It also contains a lot of optimization mods to run the development environment a bit better.\
And also contains [Forgix](https://github.com/PacifistMC/Forgix) which basically merges the mod-loaders into one jar!

---
When adding more versions, remember to edit the `.github/workflows/build.yml` file and make sure the merged jars doesn't overwrite each other!\
And do note that if you're going to use Architectury API then `dev.architectury` is `me.shedaniel.architectury` in 1.16.5 and below.
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,11 @@ def setupManifoldProcessors(List<String> mcVers, int mcIndex) {
}

StringBuilder sb = new StringBuilder()
sb.append("# No need to edit this file since it's generated by the build script\n")
sb.append("# If you need to change versions then edit \"mc_versions\" in gradle.properties\n\n")
sb.append("# DO NOT EDIT\n")
.append("# Generated by the build script. Change mcVer property to change minecraft version.\n\n")

for (String redefinedVersion : redefineList) {
sb.append(redefinedVersion)
sb.append("=\n")
sb.append(redefinedVersion).append("=\n")
}

new File(projectDir, "build.properties").text = sb.toString()
Expand Down Expand Up @@ -281,7 +280,7 @@ def makeAccessWidener() {
rename "${rootProject.accessWidenerVersion}.createunlimited.aw", "createunlimited.accesswidener"
}
def text = accessWidenerFile.text
text = text + "\n# Do not edit this file. It is automatically generated by the build script. Edit ${versionAccessWidenerFile.name} instead!"
text = text + "\n# DO NOT EDIT\n# Generated by the build script. Edit ${versionAccessWidenerFile.name} instead!"

accessWidenerFile.text = text
} else {
Expand Down
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# No need to edit this file since it's generated by the build script
# If you need to change versions then edit "mc_versions" in gradle.properties
# DO NOT EDIT
# Generated by the build script. Change mcVer property to change minecraft version.

POST_MC_1_19_2=
POST_CURRENT_MC_1_19_2=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
package dev.rdh.createunlimited;

import com.simibubi.create.Create;

import dev.rdh.createunlimited.config.CUConfig;

import dev.rdh.createunlimited.config.command.CUCommands;
import dev.rdh.createunlimited.config.command.EnumArgument;
import dev.rdh.createunlimited.util.Util;

import net.minecraft.resources.ResourceLocation;

import net.minecraftforge.fml.config.ModConfig;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CreateUnlimited {
public static final String ID = "createunlimited";
public static final String ID = "createunlimited";
public static final String NAME = "Create Unlimited";
public static final String VERSION = "0.4.1";
public static final Logger LOGGER = LoggerFactory.getLogger(NAME);

public static void init() {
LOGGER.info("{} initializing! Create version: {} on platform: {}", NAME, Create.VERSION, Util.platformName());

Util.registerConfig(ID, ModConfig.Type.SERVER, CUConfig.SPEC, "createunlimited.toml");
CUConfig.init(Util.getConfigDirectory().resolve("createunlimited-IGNOREME.toml"));

CUCommands.registerConfigCommand();
Util.registerArgument("enumargument", EnumArgument.class, new EnumArgument.Info(), asResource("enumargument"));
}

public static ResourceLocation asResource(String path) {
return new ResourceLocation(ID, path);
}
}
136 changes: 136 additions & 0 deletions common/src/main/java/dev/rdh/createunlimited/config/CUConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
package dev.rdh.createunlimited.config;

import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.io.WritingMode;

import com.simibubi.create.foundation.config.ui.BaseConfigScreen;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;

import net.minecraftforge.common.ForgeConfigSpec;

import dev.rdh.createunlimited.CreateUnlimited;

import org.jetbrains.annotations.Nullable;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;

public class CUConfig {
private CUConfig() { throw new UnsupportedOperationException(); }
public static final ForgeConfigSpec SPEC;
public static ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();

public enum PlacementCheck {
ON,
SURVIVAL_ONLY,
OFF,
}

public static final Map<String, String> comments = new HashMap<>();
static {
comments.put("trains", "Train Settings");
comments.put("placementChecks", "Whether or not to enable the placement checks for train tracks.");
comments.put("extendedDriving", "Whether or not to allow trains to drive on tracks with very small turn radii. Slightly buggy.");
comments.put("extendedDrivingValue", "The minimum turn that trains can drive on. Only works if extendedDriving is enabled.");
comments.put("maxTrainRelocationDistance", "Maximum distance a train can be relocated using the wrench.");
comments.put("maxAllowedStress", "Maximum stress from couplings before train derails. Set to -1 to disable.");

comments.put("glue", "Glue Settings");
comments.put("maxGlueConnectionRange", "Maximum distance between two blocks for them to be considered for glue connections.");
comments.put("physicalBlockConnection", "Require blocks to be connected for glue connections.");

comments.put("extendo", "Extendo Grip Settings");
comments.put("singleExtendoGripRange", "How much to extend your reach when holding an Extendo-Grip. Adds to your base reach.");
comments.put("doubleExtendoGripRange", "How much to extend your reach when holding two Extendo-Grips. Adds to your base reach.");

comments.put("copycat", "Copycat Settings");
comments.put("allowAllCopycatBlocks", "Whether or not to allow all blocks to be inserted into Copycat blocks.");
}

public static String trains;
public static ForgeConfigSpec.EnumValue<PlacementCheck> placementChecks;
public static ForgeConfigSpec.BooleanValue extendedDriving;
public static ForgeConfigSpec.DoubleValue extendedDrivingValue;
public static ForgeConfigSpec.IntValue maxTrainRelocationDistance;
public static ForgeConfigSpec.DoubleValue maxAllowedStress;

public static String glue;
public static ForgeConfigSpec.IntValue maxGlueConnectionRange;
public static ForgeConfigSpec.BooleanValue physicalBlockConnection;

// public static String extendo;
// public static ForgeConfigSpec.IntValue singleExtendoGripRange;
// public static ForgeConfigSpec.IntValue doubleExtendoGripRange;

public static String copycat;
public static ForgeConfigSpec.BooleanValue allowAllCopycatBlocks;

static {
BUILDER.comment("Create Unlimited Config").push("CreateUnlimited");

cat("Trains");
placementChecks = BUILDER.comment(comments.get("placementChecks")).defineEnum("placementChecks", PlacementCheck.ON);
extendedDriving = b(false, "extendedDriving");
extendedDrivingValue = d(0.1, 0.0, 0.875, "extendedDrivingValue");
maxTrainRelocationDistance = i(24, 0, "maxTrainRelocationDistance");
maxAllowedStress = d(4.0, -1.0, "maxAllowedStress");

BUILDER.pop();
cat("Glue");
maxGlueConnectionRange = i(24, 0, "maxGlueConnectionRange");
physicalBlockConnection = b(true, "physicalBlockConnection");

// BUILDER.pop().comment(comments.get("extendo")).push("ExtendoGrip");
// singleExtendoGripRange = i(3, 0, "singleExtendoGripRange", comments.get("singleExtendoGripRange"));
// doubleExtendoGripRange = i(5, 0, "doubleExtendoGripRange", comments.get("doubleExtendoGripRange"));

BUILDER.pop();
cat("Copycat");
allowAllCopycatBlocks = b(false, "allowAllCopycatBlocks");
BUILDER.pop(2);

SPEC = BUILDER.build();
}

public static void init(Path path) {
CreateUnlimited.LOGGER.info("Loading Create Unlimited config!");
final CommentedFileConfig configData = CommentedFileConfig.builder(path)
.sync()
.autosave()
.writingMode(WritingMode.REPLACE)
.build();
configData.load();
SPEC.setConfig(configData);
}

// helper methods for initializing config values
private static ForgeConfigSpec.BooleanValue b(boolean normal, String path) {
return BUILDER.comment(comments.get(path)).define(path, normal);
}
private static ForgeConfigSpec.IntValue i(int normal, int min, String path) {
return BUILDER.comment(comments.get(path)).defineInRange(path, normal, min, Integer.MAX_VALUE);
}
private static ForgeConfigSpec.DoubleValue d(double normal, double min, String path) {
return d(normal, min, Double.MAX_VALUE, path);
}
private static ForgeConfigSpec.DoubleValue d(double normal, double min, double max, String path) {
return BUILDER.comment(comments.get(path)).defineInRange(path, normal, min, max);
}
private static void cat(String path) {
BUILDER.comment(comments.get(path.toLowerCase())).push(path);
}

public static BaseConfigScreen createConfigScreen(Screen parent) {
BaseConfigScreen.setDefaultActionFor(CreateUnlimited.ID, (base) ->
base.withSpecs(null, null, CUConfig.SPEC)
.withTitles("", "", "Settings")
);
return new BaseConfigScreen(parent, CreateUnlimited.ID);
}
public static BaseConfigScreen createConfigScreen(@Nullable Minecraft mc, Screen parent) {
return createConfigScreen(parent);
}
}
Loading

0 comments on commit 1a7ecf1

Please sign in to comment.