Skip to content

Commit

Permalink
Merge branch 'pr429' into with-pr-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Dec 27, 2023
2 parents dce6e60 + 735053b commit 6d69e6a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ jobs:
with:
arguments: build
cache-read-only: false

- name: Publish artifacts
uses: neoforged/action-pr-publishing/upload@v1
72 changes: 36 additions & 36 deletions .github/workflows/publish-prs.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
name: Publish PRs

on:
pull_request:
types:
- opened
- synchronize

permissions:
contents: read
statuses: write

jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

- name: Make Gradle executable
# language=bash
run: chmod +x ./gradlew # Thanks Windows

- name: Setup Java 17
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java
# language=bash
run: export JAVA_HOME=$(echo $JAVA_HOME_17_X64)

- uses: gradle/gradle-build-action@v2
name: Setup
with:
arguments: :neoforge:setup

- uses: ForgeForce/action-pr-publishing/upload@mainff
name: Publish PRs

on:
pull_request:
types:
- opened
- synchronize

permissions:
contents: read
statuses: write

jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

- name: Make Gradle executable
# language=bash
run: chmod +x ./gradlew # Thanks Windows

- name: Setup Java 17
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java
# language=bash
run: export JAVA_HOME=$(echo $JAVA_HOME_17_X64)

- uses: gradle/gradle-build-action@v2
name: Setup
with:
arguments: :neoforge:setup

- uses: ForgeForce/action-pr-publishing/upload@mainff
20 changes: 19 additions & 1 deletion src/main/java/net/neoforged/neoforge/common/NeoForgeMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.CrashReportCallables;
import net.neoforged.fml.IExtensionPoint;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoader;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.ModLoadingStage;
import net.neoforged.fml.ModLoadingWarning;
import net.neoforged.fml.StartupMessageManager;
import net.neoforged.fml.VersionChecker;
import net.neoforged.fml.common.Mod;
Expand Down Expand Up @@ -448,7 +452,7 @@ public static void enableMilkFluid() {
enableMilkFluid = true;
}

public NeoForgeMod(IEventBus modEventBus, Dist dist) {
public NeoForgeMod(IEventBus modEventBus, Dist dist, ModContainer container) {
LOGGER.info(NEOFORGEMOD, "NeoForge mod loading, version {}, for MC {} with MCP {}", NeoForgeVersion.getVersion(), NeoFormVersion.getMCVersion(), NeoFormVersion.getMCPVersion());
ForgeSnapshotsMod.logStartupWarning();

Expand Down Expand Up @@ -507,6 +511,12 @@ public NeoForgeMod(IEventBus modEventBus, Dist dist) {
NeoForge.EVENT_BUS.addListener(CapabilityHooks::invalidateCapsOnChunkLoad);
NeoForge.EVENT_BUS.addListener(CapabilityHooks::invalidateCapsOnChunkUnload);
NeoForge.EVENT_BUS.addListener(CapabilityHooks::cleanCapabilityListenerReferencesOnTick);

if (isPRBuild(container.getModInfo().getVersion().toString())) {
ModLoader.get().addWarning(new ModLoadingWarning(
container.getModInfo(), ModLoadingStage.CONSTRUCT,
"loadwarning.neoforge.prbuild"));
}
}

public void preInit(FMLCommonSetupEvent evt) {
Expand Down Expand Up @@ -614,4 +624,12 @@ public void registerLootData(RegisterEvent event) {
public void registerPermissionNodes(PermissionGatherEvent.Nodes event) {
event.addNodes(USE_SELECTORS_PERMISSION);
}

public static boolean isPRBuild(String neoVersion) {
// The -pr- being inside the actual version and a branch name is important.
// Since we checkout PRs on a branch named `pr-<number>-<headname>`, this assures that
// the regex will match PR builds published to Packages, but that it will not match local PR branches
// since those usually have the name `pr|pull/<number>`
return neoVersion.matches("\\d+\\.\\d+\\.\\d+(-beta)?-pr-\\d+-[\\w-]+");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.common.NeoForgeMod;

public class ForgeSnapshotsModClient {
public static void renderMainMenuWarning(String neoForgeVersion, GuiGraphics graphics, Font font, int width, int height, int alpha) {
if (neoForgeVersion.contains("-beta")) {
if (NeoForgeMod.isPRBuild(neoForgeVersion)) {
graphics.drawCenteredString(font, Component.translatable("loadwarning.neoforge.prbuild"), width / 2, 4, 0xFFFFFF | alpha);
} else if (neoForgeVersion.contains("-beta")) {
// Render a warning at the top of the screen
Component line = Component.translatable("neoforge.update.beta.1", ChatFormatting.RED, ChatFormatting.RESET).withStyle(ChatFormatting.RED);
graphics.drawCenteredString(font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/neoforge/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
"fml.messages.version.restriction.bounded.lowerexclusive":"above {0}, and {1} or below",
"fml.messages.version.restriction.bounded.upperexclusive":"{0} or above, and below {1}",

"loadwarning.neoforge.prbuild": "This build of NeoForge is coming from a Pull Request and is §c§lUNSUPPORTED§r",

"commands.neoforge.arguments.enum.invalid": "Enum constant must be one of {0}, found {1}",
"commands.neoforge.dimensions.list": "Currently registered dimensions by type:",
"commands.neoforge.entity.list.invalid": "Invalid filter, does not match any entities. Use /neoforge entity list for a proper list",
Expand Down

0 comments on commit 6d69e6a

Please sign in to comment.