Skip to content

Commit

Permalink
you do not know how long it took for me to make that stupid neoforge …
Browse files Browse the repository at this point in the history
…jar (wrestling with gradle moment) (also some other pointless stupid things that i was doign)
  • Loading branch information
AnAwesomGuy committed Sep 16, 2024
1 parent 36ce350 commit 177086d
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 83 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
java: [
21, # Current Java LTS
]
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
Expand All @@ -34,8 +34,6 @@ jobs:
with:
name: ${{ github.event.repository.name }}-artifacts-${{ github.sha }}
path: |
common/build/libs/*.jar
!common/build/libs/*-transformProduction*.jar
fabric/build/libs/*.jar
!fabric/build/libs/*-dev*.jar
forge/build/libs/*.jar
Expand Down
49 changes: 23 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ plugins {
id "me.modmuss50.mod-publish-plugin" version "0.6.3"
}

architectury {
minecraft = minecraft_version
}
architectury.minecraft = minecraft_version

version = mod_version + "+" + minecraft_version

import groovy.json.JsonSlurper
import groovy.json.JsonOutput

Map<String, String> modProperties() {
[
version: mod_version, mod_id: mod_id, description: project.properties.description,
github_repo: 'http://github.com/' + github, display_name: display_name,
modrinth_id: modrinth_id, curseforge_id: curseforge_id
]
}

subprojects {
apply plugin: "dev.architectury.loom"

Expand All @@ -25,26 +31,18 @@ subprojects {
}

processResources {
def properties = [
version: mod_version, mod_id: mod_id, description: description,
github_repo: 'http://github.com/' + github, display_name: display_name,
modrinth_id: modrinth_id, curseforge_id: curseforge_id
]
def properties = modProperties()

inputs.properties properties

filesMatching(["META-INF/mods.toml", "fabric.mod.json", "pack.mcmeta"]) {
filesMatching(["META-INF/*mods.toml", "fabric.mod.json", "pack.mcmeta"]) {
expand properties
filter {
it.empty ? null : it
}
filter { it.empty ? null : it }
}

doLast {
fileTree(dir: outputs.files.asPath).each {
var name = it.name
if (name.endsWith(".json") || name.endsWith(".mcmeta"))
it.text = JsonOutput.toJson(new JsonSlurper().parse(it))
fileTree(dir: outputs.files.asPath, includes: ["**/*.json", "**/*.mcmeta"]).each {
it.text = JsonOutput.toJson(new JsonSlurper().parse(it))
}
}
}
Expand All @@ -55,9 +53,7 @@ allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

base {
archivesName = mod_id
}
base.archivesName = mod_id

version = mod_version
group = maven_group
Expand All @@ -74,14 +70,10 @@ allprojects {
options.release = 17
}

java {
withSourcesJar()
}
java.withSourcesJar()

[jar, sourcesJar].each {
it.configure {
from 'LICENSE'
}
[jar, sourcesJar]*.configure {
from 'LICENSE'
}
}

Expand Down Expand Up @@ -188,3 +180,8 @@ publishMods {
tagName = "release/" + version
}
}

allprojects {
repositories.flatDir { dir rootProject.file('customLibs') }
architectury.transformerVersion = "5.2.9999"
}
11 changes: 8 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import dev.architectury.plugin.TransformingTask
import dev.architectury.transformer.transformers.RemapInjectables

architectury {
common enabled_platforms.split(",")
injectInjectables = false
}

loom.mixin.useLegacyMixinAp = false
//loom.mixin.useLegacyMixinAp = false // doesnt remap Block

//tasks.withType(TransformingTask).configureEach {
// transformers.set transformers.get().findAll { !(it instanceof RemapInjectables) }
//}

sourcesJar {
archiveClassifier.set archiveClassifier.get() + '-common'
}

jar {
archiveClassifier.set 'common'

manifest.attributes.clear()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public BedrockBlock(Properties properties) {

@Override @SuppressWarnings("deprecation")
public float getDestroyProgress(BlockState state, Player player, BlockGetter level, BlockPos pos) {
return player.getInventory().getSelected().getItem() instanceof PickaxeItem item && item.getTier().getLevel() >= BreakingBedrock.BEDROCK_MINING_TIER ?
player.getDestroySpeed(state) / state.getDestroySpeed(level, pos) / 100F :
return player.getInventory().getSelected().getItem() instanceof PickaxeItem item && item.getTier().getLevel() >= BreakingBedrock.MINING_TIER ?
player.getDestroySpeed(state) / state.getDestroySpeed(level, pos) / 30 :
0F;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,63 @@ public final class BreakingBedrock {
public static final String MOD_ID = "breakingbedrock";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

public static final float BEDROCK_DESTROY_TIME;
public static final float BEDROCK_EXPLOSION_RESIST;
public static final int BEDROCK_MINING_TIER;
public static final float DESTROY_TIME;
public static final float EXPLOSION_RESIST;
public static final int MINING_TIER;

static {
LOGGER.info("Initializing Breaking Bedrock.\nThis mod overwrites bedrock, and may cause broken functionality with any other mods that do the same!");
LOGGER.info("Initializing Breaking Bedrock. This mod overwrites bedrock, and may break with other mods that do the same!");
Properties properties = new Properties();
float destroyTime, explosionResist;
int miningLevel;
File configFile = configDir().resolve(BreakingBedrock.MOD_ID + ".properties").toFile();
try {
Properties temp = new Properties();
temp.load(new FileInputStream(configFile));
String time = temp.getProperty("bedrockDestroyTime"),
resist = temp.getProperty("bedrockExplosionResist"),
level = temp.getProperty("bedrockMiningTier");
String time = temp.getProperty("destroy_time"),
resist = temp.getProperty("explosion_resist"),
level = temp.getProperty("mining_level");
if (time == null || !((destroyTime = Float.parseFloat(time)) > -1) || destroyTime == Float.POSITIVE_INFINITY) {
properties.setProperty("bedrockDestroyTime", "71");
destroyTime = 71F;
properties.setProperty("destroy_time", "100");
destroyTime = 100F;
LOGGER.debug("Correcting invalid config value {}!", time);
} else properties.setProperty("bedrockDestroyTime", time);
} else properties.setProperty("destroy_time", time);
if (resist == null || !((explosionResist = Float.parseFloat(resist)) > 0) || explosionResist == Float.POSITIVE_INFINITY) {
properties.setProperty("bedrockExplosionResist", "3600000");
properties.setProperty("explosion_resist", "3600000");
explosionResist = 3600000F;
LOGGER.debug("Correcting invalid config value {}!", resist);
} else properties.setProperty("bedrockExplosionResist", resist);
} else properties.setProperty("explosion_resist", resist);
if (level == null || !((miningLevel = Integer.parseInt(level)) > 0)) {
properties.setProperty("bedrockMiningLevel", "4");
properties.setProperty("mining_level", "4");
miningLevel = 4;
LOGGER.debug("Correcting invalid config value {}!", level);
} else properties.setProperty("bedrockMiningLevel", resist);
} else properties.setProperty("mining_level", resist);
} catch (IOException | IllegalArgumentException e) {
LOGGER.info("Could not read config file (likely corrupted or missing)! Attempting to (re)create it.");
properties.setProperty("bedrockDestroyTime", "71");
properties.setProperty("bedrockExplosionResist", "3600000");
properties.setProperty("bedrockMiningLevel", "4");
explosionResist = 71F;
destroyTime = 3600000F;
LOGGER.info("Couldn't read config file (likely corrupted or missing)! Attempting to (re)create it.");
properties.setProperty("destroy_time", "100");
properties.setProperty("explosion_resist", "3600000");
properties.setProperty("mining_level", "4");
destroyTime = 100F;
explosionResist = 3600000F;
miningLevel = 4;
}

BEDROCK_EXPLOSION_RESIST = explosionResist;
BEDROCK_DESTROY_TIME = destroyTime;
BEDROCK_MINING_TIER = miningLevel;
EXPLOSION_RESIST = explosionResist;
DESTROY_TIME = destroyTime;
MINING_TIER = miningLevel;

try {
properties.store(new FileOutputStream(configFile),
"""
bedrockDestroyTime: The destroy time for bedrock. (obsidian is 50, stone is 1.5, -1 means indestructible)
bedrockExplosionResist: The explosion resistance for bedrock. (stone is 6, glass is 0.3)
bedrockExplosionResist: The mining level required to mine bedrock. (netherite is 4)
destroy_time: The destroy time for bedrock. (obsidian is 50, stone is 1.5, -1 is indestructible)
explosion_resist: The explosion resistance for bedrock. (stone is 6, glass is 0.3)
mining_level: The mining level required to mine bedrock. (netherite is 4)
""");
} catch (IOException e) {
LOGGER.error("Unable to create/modify config file!", e);
}

LOGGER.debug("Config initialized with values: destroyTime={}, explosionResist={}, miningLevel={}", destroyTime, explosionResist, miningLevel);
}

@ExpectPlatform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
public abstract class BlocksMixin {
@Redirect(method = "<clinit>", at = @At(value = "NEW", target = "net/minecraft/world/level/block/Block", ordinal = 0), slice = @Slice(from = @At(value = "CONSTANT", args = "stringValue=bedrock")))
private static Block breakingbedrock$replaceBedrock(Properties properties) {
return new BedrockBlock(properties.strength(BreakingBedrock.BEDROCK_DESTROY_TIME, BreakingBedrock.BEDROCK_EXPLOSION_RESIST));
return new BedrockBlock(properties.strength(BreakingBedrock.DESTROY_TIME, BreakingBedrock.EXPLOSION_RESIST));
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added customLibs/architectury-transformer-5.2.9999.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions customLibs/architectury-transformer-5.2.9999.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>dev.architectury</groupId>
<artifactId>architectury-transformer</artifactId>
<version>5.2.9999</version>
<packaging>pom</packaging>
</project>
1 change: 0 additions & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ configurations {

dependencies {
modImplementation "net.fabricmc:fabric-loader:$fabric_loader_version"
modApi "net.fabricmc.fabric-api:fabric-api:$fabric_api_version"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
Expand Down
35 changes: 25 additions & 10 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,45 @@ dependencies {
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
}

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
processResources {
exclude "META-INF/neoforge.mods.toml"
}

build.dependsOn tasks.register("neoforgeJar", ShadowJar) {
shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
relocate('net.minecraftforge', 'net.neoforged')

from sourceSets.main.output
configurations = [project.configurations.shadowCommon]
archiveClassifier = "neoforge"
archiveClassifier = "dev-shadow"
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

build.dependsOn tasks.register("neoforgeJar", ShadowJar) {
dependsOn jar

from(sourceSets.main.output) { exclude "META-INF/mods.toml" }
from(sourceSets.main.resources.matching(new PatternSet().include("META-INF/neoforge.mods.toml")).singleFile) {
rename { "META-INF/mods.toml" }
filter { it.empty ? null : it }

def props = rootProject.modProperties()
inputs.properties props
expand props
}

configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
archiveClassifier = "neoforge"

exclude "fabric.mod.json"
exclude "architectury.common.json"
relocate 'net.minecraftforge', 'net.neoforged'
}

remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set('forge')
archiveClassifier.set 'forge'
}

sourcesJar {
Expand Down
9 changes: 2 additions & 7 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader="lowcodefml"
loaderVersion="[37,)"
loaderVersion="[37,51)"
license="Apache-2.0"
issueTrackerURL="${github_repo}/issues"

Expand All @@ -12,12 +12,7 @@ description="${description}"
logoFile="assets/${mod_id}/icon.png"
displayURL="http://modrinth.com/mod/${modrinth_id}"

[[dependencies.${mod_id}]]
modId="forge"
mandatory=true
versionRange="[37,)"

[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
versionRange="[1.17,)"
versionRange="(,1.20.5)"
21 changes: 21 additions & 0 deletions forge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
modLoader="lowcodefml"
loaderVersion="[1.0,)"
license="Apache-2.0"
issueTrackerURL="${github_repo}/issues"

[[mods]]
modId="${mod_id}"
version="${version}"
displayName="${display_name}"
authors="AnAwesomGuy"
description="${description}"
logoFile="assets/${mod_id}/icon.png"
displayURL="http://modrinth.com/mod/${modrinth_id}"

[[mixins]]
config="${mod_id}.mixins.json"

[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
versionRange="(,1.20.5)"
2 changes: 1 addition & 1 deletion forge/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "${display_name}",
"pack_format": 15
"pack_format": 7
}
}
9 changes: 6 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ description=Allow bedrock to be mined with a netherite pickaxe!
github=AnAwesomGuy/breakingbedrock
display_name=Breaking Bedrock

fabric_loader_version=0.15.11
fabric_loader_version=0.16.2
fabric_api_version=0.92.2+1.20.1

forge_version=47.3.5

changelog="first release"
changelog="set default break hardness of bedrock to 100\
fix bedrock mining being 3.33x slower than it is supposed to be\
neoforge support\
"
curseforge_id=1017910
modrinth_id=s0tNTkDN
modrinth_id=s0tNTkDN

0 comments on commit 177086d

Please sign in to comment.