Skip to content

Commit 1eab223

Browse files
authored
feat: 1.21.1 support (#418)
* feat: initial 1.21.1 support * chore: move rrp logic into new library mod (YARRP) * feat: add more links to modmenu * chore: add json formatter * fix: crash on NeoForge startup * fix: compat with curios * fix(curios): make sure slot is always within range
1 parent d0aaa4f commit 1eab223

File tree

76 files changed

+823
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+823
-227
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ jobs:
172172
run: |
173173
echo 'value<<EOF' >> "$GITHUB_OUTPUT"
174174
echo 'cloth-config(required){modrinth:9s6osm5g}{curseforge:348521}' >> "$GITHUB_OUTPUT"
175+
echo 'yarrp(required){modrinth:Z2RtCqwR}{curseforge:1385339}' >> "$GITHUB_OUTPUT"
175176
if [ "${{ endsWith(matrix.subproject, '-fabric') }}" = "true" ]; then
176177
# shellcheck disable=SC2129
177178
echo 'fabric-api(required){modrinth:P7dR8mSH}{curseforge:306612}' >> "$GITHUB_OUTPUT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is my vision of the Inventory Update for Minecraft. Of
1515
[features](#Features) I believe are in line with Mojang's vision and could be
1616
potentially added to the game.
1717

18-
Available for both Fabric and (Neo)Forge.
18+
Available for both Fabric and NeoForge.
1919

2020
## Installation
2121

build.gradle.kts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ preprocess {
3131
// which we would need for strict mappings to work
3232
strictExtraMappings = false
3333

34-
val mc12006_common = createNode("1.20.6-common", 1_20_06, "yarn")
3534
val mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "yarn")
3635
val mc12006_neoforge = createNode("1.20.6-neoforge", 1_20_06, "yarn")
3736

37+
val mc12101_common = createNode("1.21.1-common", 1_21_01, "yarn")
38+
val mc12101_fabric = createNode("1.21.1-fabric", 1_21_01, "yarn")
39+
val mc12101_neoforge = createNode("1.21.1-neoforge", 1_21_01, "yarn")
40+
3841
// 1.20.6
39-
mc12006_common.link(mc12006_fabric, null)
40-
mc12006_common.link(mc12006_neoforge, file("versions/mappings-common-neoforge.txt"))
42+
mc12101_fabric.link(mc12006_fabric, null)
43+
mc12101_neoforge.link(mc12006_neoforge, file("versions/mappings-neoforge-1.21.1-1.20.6.txt"))
44+
// 1.21.1
45+
mc12101_common.link(mc12101_fabric, null)
46+
mc12101_common.link(mc12101_neoforge, file("versions/mappings-common-neoforge.txt"))
4147
}
4248

4349
spotless {
@@ -46,12 +52,13 @@ spotless {
4652
"ktlint_standard_no-wildcard-imports" to "disabled",
4753
"ktlint_standard_blank-line-before-declaration" to "disabled",
4854
"ktlint_standard_spacing-between-declarations-with-annotations" to "disabled",
55+
"ktlint_standard_no-empty-file" to "disabled",
4956
// these are replaced by the custom rule set
5057
"ktlint_standard_import-ordering" to "disabled",
5158
"ktlint_standard_comment-spacing" to "disabled",
5259
"ktlint_standard_chain-wrapping" to "disabled",
5360
),
54-
).customRuleSets(listOf("com.github.RubixDev:ktlint-ruleset-mc-preprocessor:2c5a3687bb"))
61+
).customRuleSets(listOf("com.github.RubixDev:ktlint-ruleset-mc-preprocessor:54d81aa9b4"))
5562

5663
kotlinGradle {
5764
target("**/*.gradle.kts")
@@ -73,6 +80,10 @@ spotless {
7380
eclipse("4.31").configFile("eclipse-prefs.xml")
7481
formatAnnotations()
7582
}
83+
json {
84+
target("**/*.json")
85+
gson().indentWithSpaces(2)
86+
}
7687
}
7788

7889
tasks.register("buildAndGather") {

common.gradle.kts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Props {
8686
val neoforge_version_range: String by prop
8787

8888
val cloth_version: String by prop
89+
val yarrp_version: String by prop
8990
val clumps_version: String by prop
9091

9192
val early_loading_screen_version: String by prop
@@ -135,11 +136,12 @@ repositories {
135136

136137
// Mixin
137138
maven("https://repo.spongepowered.org/maven/")
139+
// Conditional Mixin
140+
maven("https://maven.fallenbreath.me/releases")
138141
// Cloth Config
139142
maven("https://maven.shedaniel.me/")
140-
// Conditional Mixin
143+
// YARRP
141144
maven("https://jitpack.io")
142-
maven("https://maven.fallenbreath.me/releases")
143145
// Other mods from Modrinth
144146
maven("https://api.modrinth.com/maven")
145147
}
@@ -171,6 +173,7 @@ dependencies {
171173
exclude(group = "net.fabricmc.fabric-api")
172174
}
173175
modCompileOnly("me.fallenbreath:conditional-mixin-common:${props.conditional_mixin_version}")
176+
modCompileOnly("com.github.RubixDev.YARRP:yarrp-mc${props.minecraft_version}-fabric:${props.yarrp_version}")
174177
}
175178
Loader.FABRIC -> {
176179
modLocalRuntime("maven.modrinth:early-loading-screen:${props.early_loading_screen_version}")
@@ -185,6 +188,7 @@ dependencies {
185188
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${props.cloth_version}") {
186189
exclude(group = "net.fabricmc.fabric-api")
187190
}
191+
modImplementation("com.github.RubixDev.YARRP:yarrp-mc${props.minecraft_version}-fabric:${props.yarrp_version}")
188192

189193
// other mods we do integration with
190194
// - Trinkets
@@ -200,6 +204,7 @@ dependencies {
200204
exclude(group = "net.neoforged.fancymodloader", module = "loader")
201205
}
202206
modImplementation("me.shedaniel.cloth:cloth-config-neoforge:${props.cloth_version}")
207+
modImplementation("com.github.RubixDev.YARRP:yarrp-mc${props.minecraft_version}-neoforge:${props.yarrp_version}")
203208

204209
// other mods we do integration with
205210
// - Curios API
@@ -227,7 +232,14 @@ tasks.named<ProcessResources>("processResources") {
227232

228233
// See https://minecraft.wiki/w/Pack_format#List_of_resource_pack_formats
229234
val resourcePackVersions = mapOf(
230-
12006 to 32,
235+
12006 to "32",
236+
12101 to "34",
237+
12103 to "42",
238+
12104 to "46",
239+
12105 to "55",
240+
12106 to "63",
241+
12108 to "64",
242+
12110 to "69.0",
231243
)
232244

233245
val replaceProperties = mapOf(

settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"versions": [
3-
"1.20.6-common",
43
"1.20.6-fabric",
5-
"1.20.6-neoforge"
4+
"1.20.6-neoforge",
5+
"1.21.1-common",
6+
"1.21.1-fabric",
7+
"1.21.1-neoforge"
68
]
79
}

src/main/java/de/rubixdev/inventorio/mixin/PlayerEntityMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private void inventorioDisplayOffhand(EquipmentSlot slot, CallbackInfoReturnable
6161
* hands. First, the offhand is attached to the utility belt, rather than a
6262
* vanilla slot. Second, a player can swap the main hand and the offhand.
6363
*/
64-
@SuppressWarnings({ "unchecked", "MixinExtrasOperationParameters" })
64+
@SuppressWarnings("unchecked")
6565
@WrapOperation(
6666
method = "equipStack",
6767
at = @At(
@@ -102,7 +102,7 @@ private <E> E inventorioEquipOffhand(DefaultedList<E> defaultedList, int index,
102102
*/
103103
@Inject(method = "equipStack", at = @At(value = "RETURN"))
104104
private void inventorioOnEquipArmor(EquipmentSlot slot, ItemStack stack, CallbackInfo ci) {
105-
if (slot.getType() == EquipmentSlot.Type.ARMOR) MixinHelpers
105+
if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) MixinHelpers
106106
.withScreenHandler((PlayerEntity) (Object) this, InventorioScreenHandler::updateDeepPocketsCapacity);
107107
}
108108

src/main/java/de/rubixdev/inventorio/mixin/PlayerManagerMixin.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1313
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1414

15+
//#if MC >= 12101
16+
import net.minecraft.entity.Entity;
17+
//#endif
18+
1519
@Mixin(PlayerManager.class)
1620
public class PlayerManagerMixin {
1721
/**
@@ -34,9 +38,12 @@ private void inventorioSetPlayerSettings(
3438
* server to the client
3539
*/
3640
@Inject(method = "respawnPlayer", at = @At(value = "RETURN"), require = 0)
37-
private void inventorioSetPlayerSettings(
41+
private void inventorioSetPlayerSettings(/* #if <- hack around formatter */
3842
ServerPlayerEntity oldPlayer,
3943
boolean alive,
44+
//#if MC >= 12101
45+
Entity.RemovalReason removalReason,
46+
//#endif
4047
CallbackInfoReturnable<ServerPlayerEntity> cir
4148
) {
4249
ServerPlayerEntity newPlayer = cir.getReturnValue();

src/main/java/de/rubixdev/inventorio/mixin/accessor/CraftingScreenHandlerAccessor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
import org.spongepowered.asm.mixin.Mixin;
1010
import org.spongepowered.asm.mixin.gen.Invoker;
1111

12+
//#if MC >= 12101
13+
import net.minecraft.recipe.CraftingRecipe;
14+
import net.minecraft.recipe.RecipeEntry;
15+
import org.jetbrains.annotations.Nullable;
16+
//#endif
17+
1218
@Mixin(CraftingScreenHandler.class)
1319
public interface CraftingScreenHandlerAccessor {
1420
@Invoker("updateResult")
@@ -18,5 +24,8 @@ static void updateTheResult(
1824
PlayerEntity player,
1925
RecipeInputInventory craftingInventory,
2026
CraftingResultInventory resultInventory
27+
//#if MC >= 12101
28+
, @Nullable RecipeEntry<CraftingRecipe> recipe
29+
//#endif
2130
) {}
2231
}

src/main/java/de/rubixdev/inventorio/mixin/client/InGameHudMixinHP.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,27 @@
1313
import org.spongepowered.asm.mixin.injection.Redirect;
1414
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1515

16+
//#if MC >= 12101
17+
import net.minecraft.client.render.RenderTickCounter;
18+
//#endif
19+
1620
@Mixin(value = InGameHud.class, priority = 1500)
1721
@Environment(EnvType.CLIENT)
1822
public class InGameHudMixinHP {
1923
/**
2024
* This mixin calls the renderer of hotbar addons. Note: this mixin doesn't
21-
* work in (Neo)Forge and is substituted with a (Neo)Forge event.
25+
* work in NeoForge and is substituted with a NeoForge event.
2226
*/
2327
@Inject(method = "render", at = @At(value = "RETURN"))
24-
private void inventorioRenderHotbarAddons(DrawContext context, float tickDelta, CallbackInfo ci) {
28+
private void inventorioRenderHotbarAddons(/* #if <- hack around formatter */
29+
DrawContext context,
30+
//#if MC >= 12101
31+
RenderTickCounter tickCounter,
32+
//#else
33+
//$$ float tickDelta,
34+
//#endif
35+
CallbackInfo ci
36+
) {
2537
HotbarHUDRenderer.INSTANCE.renderHotbarAddons(context);
2638
}
2739

src/main/java/de/rubixdev/inventorio/mixin/client/InGameHudMixinLP.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
import org.spongepowered.asm.mixin.injection.Inject;
1515
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1616

17+
//#if MC >= 12101
18+
import net.minecraft.client.render.RenderTickCounter;
19+
//#endif
20+
1721
@Mixin(value = InGameHud.class, priority = 99)
1822
@Environment(EnvType.CLIENT)
1923
public class InGameHudMixinLP {
@@ -22,12 +26,28 @@ public class InGameHudMixinLP {
2226
* is selected.
2327
*/
2428
@Inject(method = "renderHotbar", at = @At(value = "HEAD"), cancellable = true, require = 0)
25-
private void inventorioRenderSegmentedHotbar(DrawContext context, float tickDelta, CallbackInfo ci) {
29+
private void inventorioRenderSegmentedHotbar(/* #if <- hack around formatter */
30+
DrawContext context,
31+
//#if MC >= 12101
32+
RenderTickCounter tickCounter,
33+
//#else
34+
//$$ float tickDelta,
35+
//#endif
36+
CallbackInfo ci
37+
) {
2638
if (HotbarHUDRenderer.INSTANCE.renderSegmentedHotbar(context)) ci.cancel();
2739
}
2840

2941
@Inject(method = "renderHotbar", at = @At(value = "RETURN"), require = 0)
30-
private void inventorioRenderFunctionOnlySelector(DrawContext context, float tickDelta, CallbackInfo ci) {
42+
private void inventorioRenderFunctionOnlySelector(/* #if <- hack around formatter */
43+
DrawContext context,
44+
//#if MC >= 12101
45+
RenderTickCounter tickCounter,
46+
//#else
47+
//$$ float tickDelta,
48+
//#endif
49+
CallbackInfo ci
50+
) {
3151
HotbarHUDRenderer.INSTANCE.renderFunctionOnlySelector(context);
3252
}
3353

0 commit comments

Comments
 (0)