Skip to content

Commit

Permalink
add new Patches for submods
Browse files Browse the repository at this point in the history
  • Loading branch information
ToCraft committed Jul 16, 2024
1 parent 86e2616 commit 0b12b1d
Show file tree
Hide file tree
Showing 43 changed files with 799 additions and 709 deletions.
26 changes: 1 addition & 25 deletions .github/workflows/build_current.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,6 @@ permissions:
actions: write

jobs:
clear-cache:
name: "Clear Cache"
runs-on: ubuntu-latest
if: |
github.event.inputs.clear_cache == 'true'
steps:
- name: Clear cache
uses: actions/github-script@v6
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
build:
name: "Build"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -69,7 +45,7 @@ jobs:
name: "${{ env.archives_base_name }}-${{ env.mod_version }}"
path: |
build/**/**/libs/
!build/**/temp/
!build/*/libs/
!build/**/craftedcore/libs/
!build/libs/
!**/*-dev.jar
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/clear_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
clear-cache:
name: "Clear Cache"
runs-on: ubuntu-latest
if: |
github.event.inputs.clear_cache == 'true'
steps:
- name: Clear cache
uses: actions/github-script@v6
Expand Down
67 changes: 26 additions & 41 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ on:
- "master"
workflow_dispatch:
inputs:
clear_cache:
description: 'Clear Cache'
required: false
default: 'true'
release:
description: 'Release'
required: false
Expand All @@ -29,30 +25,6 @@ permissions:
actions: write

jobs:
clear-cache:
name: "Clear Cache"
runs-on: ubuntu-latest
if: |
github.event.inputs.clear_cache == 'true'
steps:
- name: Clear cache
uses: actions/github-script@v6
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
release:
name: "Release"
runs-on: ubuntu-latest
Expand All @@ -72,43 +44,56 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Extract Artifact Type
- name: Extract Artifact Type, Archive Base Name & Mod Version
run: |
cat $GITHUB_WORKSPACE/gradle.properties | grep ^artifact_type= >> $GITHUB_ENV
cat $GITHUB_WORKSPACE/gradle.properties | grep ^archives_base_name= >> $GITHUB_ENV
cat $GITHUB_WORKSPACE/gradle.properties | grep ^mod_version= >> $GITHUB_ENV
- name: Publish to Maven, Modrinth & CurseForge
run: ./gradlew publish modrinth curseforge --parallel
- name: Build + Publish to Maven, Modrinth & CurseForge
run: ./gradlew check build publish modrinth curseforge --parallel
env:
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: "${{ env.archives_base_name }}-${{ env.mod_version }}"
path: |
build/**/**/libs/
!build/*/libs/
!build/**/craftedcore/libs/
!build/libs/
!**/*-dev.jar
!**/*-shadow.jar
!**/*-transformProduction*.jar
!**/testmod*/
- name: Extract Changelog for GitHub
run: ./gradlew extractNewestChangelog --parallel
- name: Create version data
run: |
cat $GITHUB_WORKSPACE/gradle.properties | grep ^archives_base_name= >> $GITHUB_ENV
cat $GITHUB_WORKSPACE/gradle.properties | grep ^mod_version= >> $GITHUB_ENV
- name: Create GitHub Tag
if: |
${{ env.artifact_type }} == 'release'
uses: EndBug/latest-tag@latest
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v6
with:
ref: "${{ env.$mod_version }}"
skip_unpack: true
- name: Create GitHub Release
if: |
${{ env.artifact_type }} == 'release'
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ env.$mod_version }}"
tag_name: "${{ env.mod_version }}"
files: |
fabric/build/libs/${{ env.archives_base_name }}-${{ env.mod_version }}-fabric.jar,
forge/build/libs/${{ env.archives_base_name }}-${{ env.mod_version }}-forge.jar,
neoforge/build/libs/${{ env.archives_base_name }}-${{ env.mod_version }}-neoforge.jar
build/**/fabric/build/libs/${{ env.archives_base_name }}-${{ env.mod_version }}-*-fabric.jar,
build/**/forge/build/libs/${{ env.archives_base_name }}-${{ env.mod_version }}-*-forge.jar,
build/**/neoforge/build/libs/${{ env.archives_base_name }}-${{ env.mod_version }}-*-neoforge.jar
body_path: ${{ github.workspace }}/extracted.CHANGELOG.md
discord_message:
name: "Send Discord Release Message"
needs: build
runs-on: ubuntu-latest
if: |
github.event.inputs.discord_message == 'true'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
craftedcore 5
================

- **rework multi-version structure**
- fix crash on NeoForge 1.20.4 with Server

craftedcore 4.3.1
================

Expand Down
98 changes: 1 addition & 97 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath group: 'com.diluv.schoomp', name: 'Schoomp', version: '1.2.6+'
classpath "dev.tocraft:preprocessor:0.79-SNAPSHOT"
classpath "dev.tocraft:preprocessor:0.91-SNAPSHOT"
}
}

Expand Down Expand Up @@ -100,107 +100,11 @@ allprojects {
options.release.set Integer.parseInt(project.props.java)
}

ext {
// Original by Flemmli97
releaseChangelog = { int versions ->
try {
String changelog = ""
int match = 0
String previousIT = ""
project.file("CHANGELOG.md").eachLine {
if (it.contains("================")) {
match++
//changelog += previousIT
}
if (match <= versions) {
changelog += previousIT + "\n"
}
previousIT = it
return
}
return changelog + "\n\n"
} catch (exception) {
return "${project.archives_base_name} ${project.mod_version}\n==========\nThere was an error generating the changelog" + exception.getLocalizedMessage()
}
}
}

java {
withSourcesJar()
}
}

//Splits the changelog into multiple parts if they get bigger than discords embed field size (1024)
static def discordChangelog() {
def changelog = releaseChangelog(1)
List<String> res = new ArrayList()
if (changelog.size() < 1024) {
res.add(changelog)
return res
}
String temp = ""
changelog.split("\n" as Closure).each {
it = it + "\n"
if ((temp.size() + it.size()) >= 1024) {
res.add(temp)
temp = it
} else
temp += it
}
res.add(temp)
return res
}

// based on the code by Flemmli97
tasks.register('discordRelease') {
doLast {
try {
def webhook = new Webhook(System.getenv("DISCORD_WEB_HOOK"), "${project.name} Upload")

def message = new Message()
message.setUsername("Mod Release")
def content = "${project.name} ${project.mod_version} has been released!"
if (project.hasProperty("ping_role")) {
content = "<@&${project.getProperty("ping_role")}> " + content
}
message.setContent(content)
message.setAvatarUrl("https://avatars.githubusercontent.com/u/38883321")

def embed = new Embed()

def changelog = discordChangelog()
if (changelog.size() == 1)
embed.addField('Change Log', "```md\n${changelog.get(0) ?: 'Unavailable :('}```", false)
else
changelog.forEach {
embed.addField("Change Log", "```md\n${it}```", false)
}
embed.setColor(0xFF8000)
message.addEmbed(embed)

webhook.sendMessage(message)
}

catch (IOException ignored) {
println 'Failed to push to the Discord webhook.'
}
println "Send Changelog to Discord."
}
}

tasks.register('extractNewestChangelog') {
String fileName = "extracted.CHANGELOG.md";
// delete file if exists
delete fileName
doLast {
// write changelog
FileWriter fw = new FileWriter(fileName);
fw.write(releaseChangelog(1));
fw.close()
println "Extracted newest Changelog to \"extracted.CHANGELOG.md\""
}
}

ext {
mod_meta = [
minecraft: project.name,
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/java/tocraft/craftedcore/CraftedCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public void initialize() {
MixinExtrasBootstrap.init();

//#if MC>=1205
//$$ // register Network Types
//$$ ModernNetworking.registerType(ConfigLoader.CONFIG_SYNC);
//$$ ModernNetworking.registerType(PlayerDataSynchronizer.PLAYER_DATA_SYNC_ID);
// register Network Types
ModernNetworking.registerType(ConfigLoader.CONFIG_SYNC);
ModernNetworking.registerType(PlayerDataSynchronizer.PLAYER_DATA_SYNC_ID);
//#endif

// cache patreons in an extra thread to prevent longer loading times while connecting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
//#if MC>=1210
//$$ import net.minecraft.client.DeltaTracker;
import net.minecraft.client.DeltaTracker;
//#endif
//#if MC>1194
//$$ import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphics;
//#endif
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand All @@ -28,21 +28,21 @@ public final class RenderEvents {
@FunctionalInterface
public interface HUDRendering {
//#if MC>=1210
//$$ void render(GuiGraphics graphics, DeltaTracker tickCounter);
void render(GuiGraphics graphics, DeltaTracker tickCounter);
//#elseif MC>1194
//$$ void render(GuiGraphics graphics, float deltaTick);
//#else
void render(PoseStack poseStack, float tickDelta);
//$$ void render(PoseStack poseStack, float tickDelta);
//#endif
}

@Environment(EnvType.CLIENT)
@FunctionalInterface
public interface OverlayRendering {
//#if MC>1194
//$$ InteractionResult render(@Nullable GuiGraphics graphics, Player player);
InteractionResult render(@Nullable GuiGraphics graphics, Player player);
//#else
InteractionResult render(@Nullable PoseStack poseStack, Player player);
//$$ InteractionResult render(@Nullable PoseStack poseStack, Player player);
//#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.brigadier.CommandDispatcher;
//#if MC>1182
//$$ import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandBuildContext;
//#endif
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
Expand All @@ -16,9 +16,9 @@ public final class CommandEvents {
@FunctionalInterface
public interface CommandRegistration {
//#if MC>1182
//$$ void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext registry, Commands.CommandSelection selection);
void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext registry, Commands.CommandSelection selection);
//#else
void register(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection selection);
//$$ void register(CommandDispatcher<CommandSourceStack> dispatcher, Commands.CommandSelection selection);
//#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tocraft.craftedcore.event.common;

//#if MC>1201
//$$ import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.advancements.AdvancementHolder;
//#endif
import net.minecraft.advancements.Advancement;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -53,18 +53,18 @@ public interface PlayerRespawn {
@FunctionalInterface
public interface AwardAdvancement {
//#if MC>1201
//$$ void award(ServerPlayer player, AdvancementHolder advancement, String criterionKey);
void award(ServerPlayer player, AdvancementHolder advancement, String criterionKey);
//#else
void award(ServerPlayer player, Advancement advancement, String criterionKey);
//$$ void award(ServerPlayer player, Advancement advancement, String criterionKey);
//#endif
}

@FunctionalInterface
public interface RevokeAdvancement {
//#if MC>1201
//$$ void revoke(ServerPlayer player, AdvancementHolder advancement, String criterionKey);
void revoke(ServerPlayer player, AdvancementHolder advancement, String criterionKey);
//#else
void revoke(ServerPlayer player, Advancement advancement, String criterionKey);
//$$ void revoke(ServerPlayer player, Advancement advancement, String criterionKey);
//#endif
}

Expand Down
Loading

0 comments on commit 0b12b1d

Please sign in to comment.