Skip to content

Commit

Permalink
WIP getting 1.20.4 fabric to build on the new system
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Jan 7, 2024
1 parent 6ea849a commit 0ca1024
Show file tree
Hide file tree
Showing 65 changed files with 1,185 additions and 846 deletions.
31 changes: 18 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,27 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 17
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlecw
# to cache gradle files
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
gradle-home-cache-cleanup: true
# Already needs to be executable, so the dirty check is correct
# - name: make gradle wrapper executable
# if: ${{ runner.os != 'Windows' }}
# run: chmod +x ./gradlecw
- name: build
run: ./gradlecw build
- name: capture build artifacts
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: |
FPFabric/build/libs/*
FPForge/build/libs/*
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: JUnit Tests
path: '**/build/test-results/test/TEST-*.xml'
reporter: java-junit
path: 'versions/**/build/libs/*.jar'
# - name: Test Report
# uses: dorny/test-reporter@v1
# if: success() || failure()
# with:
# name: JUnit Tests
# path: '**/build/test-results/test/TEST-*.xml'
# reporter: java-junit
35 changes: 12 additions & 23 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,26 @@ jobs:
- name: make gradle wrapper executable
run: chmod +x ./gradlecw
- name: build
run: ./gradlecw build
run: ./gradlecw build -Pbuild.release=true
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
FPFabric/build/libs/*
FPForge/build/libs/*
- name: Publish-Forge-Curseforge
files: 'versions/**/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
- name: Publish-1.20.4-fabric-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 333287
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: forge
name: ${{github.ref_name}} - Forge
version-type: beta
files: '*Forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
- name: Publish-Forge-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: H5XMjpHi
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: forge
name: ${{github.ref_name}} - Forge
files: '*Forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
- name: Publish-Fabric
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.20.4 - Fabric
files: 'versions/1.20.4-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.20.4
- name: Publish-1.20.4-fabric-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: H5XMjpHi
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: 333287
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}} - Fabric
files: '*Fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
name: ${{github.ref_name}}-1.20.4 - Fabric
files: 'versions/1.20.4-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.20.4
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ logs/
*.properties
gradle/wrapper
VersionShared
UtilityCode
UtilityCode
formatter.xml
src/main/fabric-resources/fabric.mod.json
src/main/forge-resources/META-INF/mods.toml
src/main/neoforge-resources/META-INF/mods.toml
**/src/main/java/dev/tr7zw/config/CustomConfigScreen.java
**/src/main/java/dev/tr7zw/util/ComponentProvider.java
src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> {
return FirstPersonModelCore.instance.createConfigScreen(parent);
};
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public FreecamSupport() {
// making sure the constructor throws an exception, in case something is wrong.
Freecam.isEnabled();
}

@Override
public boolean preventFirstperson() {
return Freecam.isEnabled();
Expand Down
62 changes: 31 additions & 31 deletions FPFabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"schemaVersion": 1,
"id": "firstperson",
"version": "2.2.4",
"name": "FirstpersonModel",
"description": "Enables the third person Model in firstperson",
"authors": [
"tr7zw"
],
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/first-person-model",
"sources": "https://github.com/tr7zw/FirstPersonModel-Fabric",
"issues": "https://github.com/tr7zw/FirstPersonModel-Fabric/issues"
},
"license": "MIT",
"icon": "assets/firstperson/icon.png",
"environment": "client",
"entrypoints": {
"main": [
"dev.tr7zw.firstperson.fabric.FirstPersonModelMod"
"schemaVersion": 1,
"id": "firstperson",
"version": "2.2.4",
"name": "FirstpersonModel",
"description": "Enables the third person Model in firstperson",
"authors": [
"tr7zw"
],
"modmenu": [
"dev.tr7zw.firstperson.fabric.config.FirstPersonModMenu"
]
},
"mixins": [
"firstperson.mixins.json"
],
"depends": {
"minecraft": ">=1.20.2",
"fabric-api": "*"
}
}
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/first-person-model",
"sources": "https://github.com/tr7zw/FirstPersonModel-Fabric",
"issues": "https://github.com/tr7zw/FirstPersonModel-Fabric/issues"
},
"license": "MIT",
"icon": "assets/firstperson/icon.png",
"environment": "client",
"entrypoints": {
"main": [
"dev.tr7zw.firstperson.fabric.FirstPersonModelMod"
],
"modmenu": [
"dev.tr7zw.firstperson.fabric.config.FirstPersonModMenu"
]
},
"mixins": [
"firstperson.mixins.json"
],
"depends": {
"minecraft": ">=1.20.2",
"fabric-api": "*"
}
}
8 changes: 4 additions & 4 deletions FPFabric/src/test/java/dev/tr7zw/tests/MixinTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void setup() {
@Test
public void testInjectedInterfaces() {
Objenesis objenesis = new ObjenesisStd();
assertTrue((Object)objenesis.newInstance(ModelPart.class) instanceof ModelPartBase);
assertTrue((Object) objenesis.newInstance(ModelPart.class) instanceof ModelPartBase);
}

@Test
Expand All @@ -61,7 +61,7 @@ public void testMixins() {
objenesis.newInstance(ArrowLayer.class);
objenesis.newInstance(LevelRenderer.class);
}

@Test
public void langTests() throws Throwable {
Language lang = TestUtil.loadDefault("/assets/firstperson/lang/en_us.json");
Expand All @@ -70,9 +70,9 @@ public void langTests() throws Throwable {
CustomConfigScreen screen = (CustomConfigScreen) FirstPersonModelMod.instance.createConfigScreen(null);
List<OptionInstance<?>> options = TestUtil.bootStrapCustomConfigScreen(screen);
assertNotEquals(screen.getTitle().getString(), lang.getOrDefault(screen.getTitle().getString()));
for(OptionInstance<?> option : options) {
for (OptionInstance<?> option : options) {
Set<String> keys = TestUtil.getKeys(option, true);
for(String key : keys) {
for (String key : keys) {
System.out.println(key + " " + lang.getOrDefault(key));
assertNotEquals(key, lang.getOrDefault(key));
}
Expand Down
12 changes: 6 additions & 6 deletions FPFabric/src/test/java/dev/tr7zw/tests/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@ public String getOrDefault(String paramString1, String paramString2) {
}
};
}

public static Set<String> getKeys(OptionInstance<?> optionsInstance, boolean tooltips) {
Set<String> keys = new HashSet<>();
keys.add(optionsInstance.toString());
if(tooltips) {
if (tooltips) {
keys.add(optionsInstance.toString() + ".tooltip");
}
return keys;
}

public static List<OptionInstance<?>> bootStrapCustomConfigScreen(CustomConfigScreen screen) throws Exception {
Field optionsField = CustomConfigScreen.class.getDeclaredField("list");
optionsField.setAccessible(true);
Expand All @@ -117,11 +117,11 @@ public static List<OptionInstance<?>> bootStrapCustomConfigScreen(CustomConfigSc
init.invoke(screen);
return list.options;
}

private static class CustomOptionsList extends OptionsList {

public List<OptionInstance<?>> options = new ArrayList<>();

public CustomOptionsList() {
super(null, 0, 0, 0, 0, 0);
}
Expand All @@ -136,7 +136,7 @@ public int addBig(OptionInstance<?> optionInstance) {
public void addSmall(OptionInstance<?> optionInstance, OptionInstance<?> optionInstance2) {
options.add(optionInstance);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,48 @@
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@Mod(FirstPersonModelMod.MODID)
public class FirstPersonModelMod extends FirstPersonModelCore
{
public class FirstPersonModelMod extends FirstPersonModelCore {

public static final String MODID = "firstpersonmod";

public FirstPersonModelMod() {
try {
Class clientClass = net.minecraft.client.Minecraft.class;
}catch(Throwable ex) {
} catch (Throwable ex) {
System.out.println("Firstperson Mod installed on a Server. Going to sleep.");
return;
}
instance = this;
instance = this;
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
MinecraftForge.EVENT_BUS.addListener(new RenderHandEventListener()::onRender);
MinecraftForge.EVENT_BUS.addListener(this::doTick);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);

ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(
() -> ModLoadingContext.get().getActiveContainer().getModInfo().getVersion().toString(),
(remote, isServer) -> true));
ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory.class, () -> new ConfigScreenFactory((mc, screen) -> {
return createConfigScreen(screen);
}));
ModLoadingContext.get().registerExtensionPoint(ConfigScreenFactory.class,
() -> new ConfigScreenFactory((mc, screen) -> {
return createConfigScreen(screen);
}));

}

private void doTick(ClientTickEvent event) {
super.onTick();
super.onTick();
}

private void doClientStuff(final FMLClientSetupEvent event) {
sharedSetup();
sharedSetup();
}

@Override
public void registerKeybinds() {
Minecraft.getInstance().options.keyMappings = ArrayUtils.add(Minecraft.getInstance().options.keyMappings, keyBinding);
Minecraft.getInstance().options.keyMappings = ArrayUtils.add(Minecraft.getInstance().options.keyMappings,
keyBinding);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

public class RenderHandEventListener {

@SubscribeEvent
public void onRender(RenderHandEvent e) {
if(FirstPersonModelCore.enabled && !FirstPersonModelCore.instance.showVanillaHands()) {
e.setCanceled(true);
}
}
@SubscribeEvent
public void onRender(RenderHandEvent e) {
if (FirstPersonModelCore.enabled && !FirstPersonModelCore.instance.showVanillaHands()) {
e.setCanceled(true);
}
}

}
2 changes: 1 addition & 1 deletion FPForge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ Enables the third person Model in firstperson
mandatory=true
versionRange="[1.20.2,)"
ordering="NONE"
side="CLIENT"
side="CLIENT"
Loading

0 comments on commit 0ca1024

Please sign in to comment.