Skip to content

Commit

Permalink
Item Registry + Creative Tab Registry working on Forge + Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteMasterEric committed Apr 7, 2023
1 parent d552045 commit a126362
Show file tree
Hide file tree
Showing 64 changed files with 1,857 additions and 433 deletions.
8 changes: 7 additions & 1 deletion ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ https://fabricmc.net/wiki/tutorial:vscode_setup#generating_minecraft_source

Minecraft JavaDocs:
- Fabric: https://maven.fabricmc.net/docs/yarn-1.19.3+build.5/
- Forge: https://nekoyue.github.io/ForgeJavaDocs-NG/
- Forge: https://nekoyue.github.io/ForgeJavaDocs-NG/

Mappings Lookups:
- https://wagyourtail.xyz/Projects/MinecraftMappingViewer/App?version=1.19.4

Common Bugs:
- https://github.com/orgs/FabricMC/discussions/2394#discussioncomment-3148700
29 changes: 26 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [0.2.0] - 2023-04-??
## Added
- Implemented basic support for Forge 1.19.4
- Added incomplete implementations of `ClientMod` and `ServerMod`, for eventual use for side-only mod events.
## Changed
- Implemented basic support for Forge 1.19.3.
- `Mod` has been moved to `CommonMod`, and is now a class rather than an interface.
- `onInitialize` has been renamed to `onModInitialize`.
- New functions you can override: `onCreativeModeTabRegister` to register Creative Mode tabs and `onRegister` to register anything else (blocks, items, fluids).
- Added incomplete implementations of `ClientMod` and `ServerMod`, for eventual use for side-only mod events.
- Added the `--mappings` argument to `pickhaxe make`.
- Added the `net.pickhaxe.compat.world.item.Item` class.
- This class is an abstract wrapper for `net.minecraft.world.item.Item`, adding new functionality and cross-loader/cross-version convenience functions.
- Use it in place of `Item` where you can.
- Added the `item.register(resourceLocation)` method to correctly add the item to the `ITEMS` registry.
- Make sure this function is called from the `CommonMod.onRegister` function to ensure the item is registered in time.
- Replaced the `net.minecraft.world.item.CreativeModeTab` class with an abstract wrapper.
- This abstract wrapper automatically adds new functionality and cross-loader/cross-version convenience functions.
- You do not need to change the class you are importing to take advantage of this functionality.
- Added the static `CreativeModeTab.builder()` method to generate a proper CreativeModeTab Builder class.
- Added the `creativeModeTab.register(resourceLocation)` method to correctly add the item to the list of Creative Mode tabs.
- Make sure this function is called from the `CommonMod.onRegister` function to ensure the item is registered in time.
- Also assigns a proper display name for the tab as necessary.
## Changes
- Refactored the Made in Haxe sample project to use the new `CommonMod` lifecycle functions.
- PickHaxe and Haxe are now shaded properly in the mod JAR.
- This prevents a crash error caused by including two Forge mods that both used PickHaxe.
- The `pickhaxe build` and `pickhaxe make` commands now properly report and exit early if one or more Gradle tasks fails, instead of continuing to perform more Gradle tasks.
## Fixes
- Fixed a bug where the build script would attempt to access the `generated/generated` directory.


## [0.1.1] - 2023-04-02
A day 1 patch to resolve a couple of issues people were having.
Expand Down Expand Up @@ -50,6 +71,7 @@ A day 1 patch to resolve a couple of issues people were having.
- Fixed an issue where the wrong template path for `project.xml` would be used.
- Fixed an issue where the `clean` command actually called the `build` command.


## [0.1.0] - 2023-03-31
Initial release.
## Added
Expand All @@ -59,6 +81,7 @@ Initial release.
- Added Made in Haxe sample project.
- Added Obsidian Armor sample project.


## Pending Tasks
- [ ] The `build` command now automatically calls the `make` command once it completes. This means the build process is now a single step by default. Yay!
- [ ] Added the `--no-make` to disable this behavior for testing.
Expand Down
43 changes: 43 additions & 0 deletions gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ plugins {
// Common
//
id 'maven-publish'

// For Gradle 7+
id 'com.github.johnrengelman.shadow' version '7.1.2'
// For Gradle 8+
// id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
}

// Select the Gradle plugin based on the loader.
Expand Down Expand Up @@ -106,6 +111,8 @@ if (System.getProperty('pickhaxe.loader.current').equals('forge')) {
}
break;
}

accessTransformer = file('resources/META-INF/accesstransformer.cfg')
}
}

Expand All @@ -120,6 +127,11 @@ repositories {
maven { url = 'https://maven.parchmentmc.org' }
}

configurations {
shade
implementation.extendsFrom shade
}

dependencies {
switch(System.getProperty('pickhaxe.loader.current')) {
case 'forge':
Expand Down Expand Up @@ -189,6 +201,7 @@ copyBuildArtifacts.description = 'Copies the built Minecraft mod JAR to a place

// Modify the `build` task to include additional metadata in the MANIFEST.
tasks.jar {
archiveClassifier = 'slim'
manifest {
attributes(
'PickHaxe-Library-Version': System.getProperty('pickhaxe.version'),
Expand All @@ -209,7 +222,37 @@ tasks.jar {
}
}

shadowJar {
archiveClassifier = ''
configurations = [project.configurations.shade]

// Shadow the listed packages.
relocate ('net.pickhaxe', "${project.group}.shadow.net.pickhaxe") {
exclude "${project.group}"
}
relocate ('haxe', "${project.group}.shadow.haxe") {
exclude "${project.group}"
}

if (System.getProperty('pickhaxe.loader.current').equals('forge')) {
finalizedBy 'reobfShadowJar'
}
}

if (System.getProperty('pickhaxe.loader.current').equals('fabric')) {
loom {
accessWidenerPath = file("resources/META-INF/${System.getProperty('pickhaxe.mod.id')}.accesswidener")
}
}


if (System.getProperty('pickhaxe.loader.current').equals('forge')) {
assemble.dependsOn shadowJar

reobf {
shadowJar {}
}

jar.finalizedBy('reobfJar')
}

Expand Down
9 changes: 9 additions & 0 deletions metadata/versions/stable/release-1.19.1/mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "stable",
"version": "1.19.1",

"mojmap": null,
"yarn": null,
"parchment": null,
"mcp": null
}
11 changes: 11 additions & 0 deletions metadata/versions/stable/release-1.19.1/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "stable",
"version": "1.19.1",

"javaVersion": "17",

"forgeGradleVersion": "7.5.1",
"fabricGradleVersion": "8.0.1",

"forgeVersion": "42.0.9"
}
9 changes: 9 additions & 0 deletions metadata/versions/stable/release-1.19.2/mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "stable",
"version": "1.19.2",

"mojmap": null,
"yarn": null,
"parchment": null,
"mcp": null
}
11 changes: 11 additions & 0 deletions metadata/versions/stable/release-1.19.2/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "stable",
"version": "1.19.2",

"javaVersion": "17",

"forgeGradleVersion": "7.5.1",
"fabricGradleVersion": "8.0.1",

"forgeVersion": "43.2.8"
}
2 changes: 1 addition & 1 deletion metadata/versions/stable/release-1.19.4/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"forgeGradleVersion": "7.5.1",
"fabricGradleVersion": "8.0.1",

"forgeVersion": "45.0.40"
"forgeVersion": "45.0.41"
}
9 changes: 9 additions & 0 deletions metadata/versions/stable/release-1.19/mappings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "stable",
"version": "1.19",

"mojmap": null,
"yarn": null,
"parchment": null,
"mcp": null
}
11 changes: 11 additions & 0 deletions metadata/versions/stable/release-1.19/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": "stable",
"version": "1.19.0",

"javaVersion": "17",

"forgeGradleVersion": "7.5.1",
"fabricGradleVersion": "8.0.1",

"forgeVersion": "44.1.10"
}
7 changes: 0 additions & 7 deletions samples/made-in-haxe/README.md

This file was deleted.

This file was deleted.

This file was deleted.

30 changes: 30 additions & 0 deletions samples/madeinhaxe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Made in Haxe

Made in Haxe is a barebones sample mod, which adds a new item and a new Creative Mode tab to hold it.

## Compatibility

MC Version | Forge | Fabric
---|---|---
1.19.4 | ✓ |
1.19.3 | ✓ |
1.19.2 | ✗ | ?
1.19.1 | ? | ?
1.19.0 | ? | ?

**Legend**:
- ``: Builds and runs successfully in a modded game
- ``: Fails to build due to issues with external libraries
- ``: Fails to build due to issues with PickHaxe
- `?`: Not tested

**Issue List**:
- 1.19.4 Forge: Requires using `--mappings mojang` on build and make


## Building

- Make sure you have Haxe 4.3.0 installed.
- `haxelib run pickhaxe build fabric 1.19.3`
- `haxelib run pickhaxe gradlew fabric 1.19.3 build`
- Look in `./build/fabric/1.19.3/`
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<pickhaxe>
<mod
id="madeinhaxe"
version="1.0.0"
version="0.2.0"
parentPackage="com.elitemastereric.madeinhaxe"
classPath="./src/"
resourcePath="./resources/"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"itemGroup.madeinhaxe.made_in_haxe": "Made in Haxe",

"item.madeinhaxe.glyph_haxe": "Haxe Glyph"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "made-in-haxe:item/haxe_glyph"
"layer0": "madeinhaxe:item/glyph_haxe"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import net.pickhaxe.core.CommonMod;
import net.pickhaxe.core.Environment;

class MadeInHaxeMod extends CommonMod {
public override function onRegister():Void {
ModItems.register();
}

public override function onCreativeModeTabRegister():Void {
ModItems.registerCreativeTab();
}

public override function onModInitialize():Void {
#if fabric
LOGGER.info('Hello Fabric! Welcome to Minecraft ${Environment.MINECRAFT_VERSION}!');
Expand Down
Loading

0 comments on commit a126362

Please sign in to comment.