Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"1.21.8-fabric",
"1.21.10-forge",
"1.21.10-neoforge",
"1.21.10-fabric"
"1.21.10-fabric",
"1.21.11-neoforge",
"1.21.11-fabric"
]
}
8 changes: 2 additions & 6 deletions src/main/java/dev/tr7zw/firstperson/FirstPersonModelCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.tr7zw.firstperson.modsupport.*;
import dev.tr7zw.firstperson.versionless.*;
import dev.tr7zw.transition.loader.*;
import dev.tr7zw.transition.mc.*;
import lombok.*;
import net.minecraft.client.*;
//? if >= 1.21.2
Expand All @@ -18,12 +19,7 @@ public abstract class FirstPersonModelCore extends FirstPersonBase {
private LogicHandler logicHandler;
public static FirstPersonModelCore instance;
private boolean isHeld = false;
private KeyMapping keyBinding = new KeyMapping("key.firstperson.toggle", 295,
//? if >= 1.21.9 {
new KeyMapping.Category(ResourceLocation.fromNamespaceAndPath("firstperson", "keybind")));
//? } else {
/*"firstperson.keybind");
*///? }
private KeyMapping keyBinding = GeneralUtil.createKeyMapping("key.firstperson.toggle", 295, "firstperson:keybind");
private boolean lateInit = true;
@Deprecated
public static boolean enabled = true;
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/dev/tr7zw/firstperson/LogicHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
import net.minecraft.util.*;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.player.*;
import net.minecraft.world.entity.vehicle.*;
//? if >=1.21.11 {
import net.minecraft.world.entity.vehicle.minecart.*;
import net.minecraft.world.entity.vehicle.boat.*;
//?} else {
/*import net.minecraft.world.entity.vehicle.*;*/
//?}
import net.minecraft.world.item.*;
import net.minecraft.world.phys.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.network.chat.*;
import net.minecraft.resources.*;
import net.minecraft.world.item.*;
import org.jetbrains.annotations.*;

import java.util.*;
import java.util.Map.*;
Expand Down Expand Up @@ -72,22 +73,20 @@ public CustomConfigScreen(Screen previous) {
.icon(new ItemIcon(Items.COMPARATOR)));

List<Entry<ResourceKey<Item>, Item>> items = new ArrayList<>(ItemUtil.getItems());
items.sort((a, b) -> a.getKey().location().toString().compareTo(b.getKey().location().toString()));
items.sort(Comparator.comparing(CustomConfigScreen::getStringItem));

WListPanel<Entry<ResourceKey<Item>, Item>, WToggleButton> itemList = new WListPanel<Entry<ResourceKey<Item>, Item>, WToggleButton>(
items, () -> new WToggleButton(ComponentProvider.EMPTY), (s, l) -> {
l.setLabel(s.getValue().getName(s.getValue().getDefaultInstance()));
l.setToolip(ComponentProvider.literal(s.getKey().location().toString()));
l.setToolip(ComponentProvider.literal(getStringItem(s)));
l.setIcon(new ItemIcon(s.getValue()));
l.setToggle(FirstPersonModelCore.instance.getConfig().autoVanillaHands
.contains(s.getKey().location().toString()));
l.setToggle(
FirstPersonModelCore.instance.getConfig().autoVanillaHands.contains(getStringItem(s)));
l.setOnToggle(b -> {
if (b) {
FirstPersonModelCore.instance.getConfig().autoVanillaHands
.add(s.getKey().location().toString());
FirstPersonModelCore.instance.getConfig().autoVanillaHands.add(getStringItem(s));
} else {
FirstPersonModelCore.instance.getConfig().autoVanillaHands
.remove(s.getKey().location().toString());
FirstPersonModelCore.instance.getConfig().autoVanillaHands.remove(getStringItem(s));
}
FirstPersonModelCore.instance.getLogicHandler().reloadAutoVanillaHandsSettings();
save();
Expand All @@ -99,7 +98,7 @@ public CustomConfigScreen(Screen previous) {
itemTab.add(itemList, 0, 0, 17, 7);
WTextField searchField = new WTextField();
searchField.setChangedListener(s -> {
itemList.setFilter(e -> e.getKey().location().toString().toLowerCase().contains(s.toLowerCase()));
itemList.setFilter(e -> getStringItem(e).toLowerCase().contains(s.toLowerCase()));
itemList.layout();
});
itemTab.add(searchField, 0, 7, 17, 1);
Expand All @@ -109,17 +108,15 @@ public CustomConfigScreen(Screen previous) {
WListPanel<Entry<ResourceKey<Item>, Item>, WToggleButton> disableList = new WListPanel<Entry<ResourceKey<Item>, Item>, WToggleButton>(
items, () -> new WToggleButton(ComponentProvider.EMPTY), (s, l) -> {
l.setLabel(s.getValue().getName(s.getValue().getDefaultInstance()));
l.setToolip(ComponentProvider.literal(s.getKey().location().toString()));
l.setToolip(ComponentProvider.literal(getStringItem(s)));
l.setIcon(new ItemIcon(s.getValue()));
l.setToggle(FirstPersonModelCore.instance.getConfig().autoToggleModItems
.contains(s.getKey().location().toString()));
.contains(getStringItem(s)));
l.setOnToggle(b -> {
if (b) {
FirstPersonModelCore.instance.getConfig().autoToggleModItems
.add(s.getKey().location().toString());
FirstPersonModelCore.instance.getConfig().autoToggleModItems.add(getStringItem(s));
} else {
FirstPersonModelCore.instance.getConfig().autoToggleModItems
.remove(s.getKey().location().toString());
FirstPersonModelCore.instance.getConfig().autoToggleModItems.remove(getStringItem(s));
}
FirstPersonModelCore.instance.getLogicHandler().reloadAutoVanillaHandsSettings();
save();
Expand All @@ -131,7 +128,7 @@ public CustomConfigScreen(Screen previous) {
disableTab.add(disableList, 0, 0, 17, 7);
WTextField searchDisableField = new WTextField();
searchDisableField.setChangedListener(s -> {
disableList.setFilter(e -> e.getKey().location().toString().toLowerCase().contains(s.toLowerCase()));
disableList.setFilter(e -> getStringItem(e).toLowerCase().contains(s.toLowerCase()));
disableList.layout();
});
disableTab.add(searchDisableField, 0, 7, 17, 1);
Expand Down Expand Up @@ -206,6 +203,10 @@ public CustomConfigScreen(Screen previous) {
root.setHost(this);
}

private static @NotNull String getStringItem(Entry<ResourceKey<Item>, Item> a) {
return a.getKey()/*? >= 1.21.11 {*/.identifier() /*?} else {*//* .location() *//*?}*/.toString();
}
Comment on lines +206 to +208
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the ResourceKey accessor method for Minecraft 1.21.11.

The helper method uses .identifier() instead of .location() for version 1.21.11+. Please confirm that ResourceKey<Item> provides an identifier() method in the target Minecraft version and that it returns the expected identifier format.


🌐 Web query:

Minecraft 1.21.11 fabric ResourceKey identifier method

💡 Result:

Use ResourceKey#location() to get its ResourceLocation, then call ResourceLocation#toString() (or getNamespace()/getPath()).

Example (Mojang mappings / Fabric):
java
ResourceKey key = ...;
ResourceLocation id = key.location(); // ResourceLocation
String full = id.toString(); // "modid:name"
String ns = id.getNamespace(); // "modid"
String path = id.getPath(); // "name"

Sources: mappings.dev (ResourceKey & ResourceLocation docs) and NeoForged ResourceKey doc. [1][2]


Use .location() instead of .identifier() on ResourceKey; verify against actual Minecraft mappings for version 1.21.11.

The documented ResourceKey API uses .location() to get its ResourceLocation, not .identifier(). The code currently calls .identifier() for version 1.21.11+, which does not match the documented API. Verify against the actual Minecraft Fabric mappings artifact for version 1.21.11 to confirm the correct accessor method, or update the code to use .location() as shown in the documentation.

🤖 Prompt for AI Agents
In src/main/java/dev/tr7zw/firstperson/config/ConfigScreenProvider.java around
lines 210 to 212, the code calls ResourceKey.identifier() which does not match
the documented/mapped API for Minecraft 1.21.11 — use ResourceKey.location()
instead; update the method to call .location().toString() (or adjust to whatever
mapping exposes the ResourceLocation), recompile against the 1.21.11 Fabric
mappings to confirm the accessor name, and run the build to ensure no other
compilation errors from the change.


@Override
public void reset() {
FirstPersonModelCore.instance.resetSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.renderer.entity.state.*;
import net.minecraft.client.renderer.item.*;
import net.minecraft.world.entity.*;
import net.minecraft.world.item.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;
Expand Down Expand Up @@ -41,12 +42,16 @@ public class HeldItemFeatureRendererMixin {
//? } else {
/*@Inject(at = @At("HEAD"), method = "renderArmWithItem", cancellable = true)
*///? }
//? if >= 1.21.9 {
//? if >= 1.21.11 {

private void renderArmWithItem(ArmedEntityRenderState armedEntityRenderState,
ItemStackRenderState itemStackRenderState, ItemStack stack, HumanoidArm humanoidArm, PoseStack poseStack,
SubmitNodeCollector submitNodeCollector, int i, CallbackInfo ci) {
//? } else if >= 1.21.9 {
/*private void renderArmWithItem(ArmedEntityRenderState armedEntityRenderState,
ItemStackRenderState itemStackRenderState, HumanoidArm humanoidArm, PoseStack poseStack,
SubmitNodeCollector submitNodeCollector, int i, CallbackInfo ci) {
//? } else if >= 1.21.4 {
*///? } else if >= 1.21.4 {
/*private void renderArmWithItem(ArmedEntityRenderState livingEntityRenderState,
ItemStackRenderState itemStackRenderState, HumanoidArm humanoidArm, PoseStack poseStack,
MultiBufferSource multiBufferSource, int i, CallbackInfo ci) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void renderFirstPersonItem(AbstractClientPlayer player, float deltaTick,
* FirstPersonModelCore.instance.getLogicHandler().showVanillaHands(); }
*/

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getAttackStrengthScale(F)F", shift = At.Shift.BEFORE), method = "tick", cancellable = true)
@Inject(at = @At(value = "INVOKE", target = /*? if >=1.21.11 {*/ "Lnet/minecraft/client/player/LocalPlayer;getItemSwapScale(F)F" /*?} else {*//*"Lnet/minecraft/client/player/LocalPlayer;getAttackStrengthScale(F)F"*//*?}*/, shift = At.Shift.BEFORE), method = "tick", cancellable = true)
public void tick(CallbackInfo ci) {// TODO DYNAMIC HAND
if (FirstPersonModelCore.instance.isEnabled()
&& FirstPersonModelCore.instance.getLogicHandler().showVanillaHands()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package dev.tr7zw.firstperson.mixins;

import dev.tr7zw.firstperson.access.*;
import net.minecraft.client.model.*;
//? if >=1.21.11 {
import net.minecraft.client.model.player.*;
//?} else {
/*import net.minecraft.client.model.*;
*///?}
import net.minecraft.world.entity.*;
import org.spongepowered.asm.mixin.*;
//? if < 1.21.3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import dev.tr7zw.firstperson.access.*;
import dev.tr7zw.transition.mc.*;
import net.minecraft.client.*;
import net.minecraft.client.model.*;
//? if >=1.21.11 {
import net.minecraft.client.model.player.*;
//?} else {
/*import net.minecraft.client.model.*;
*///?}
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.entity.layers.*;
Expand Down Expand Up @@ -74,7 +78,8 @@ public void extractRenderState(Avatar avatar, AvatarRenderState avatarRenderStat
if (FirstPersonModelCore.instance.getLogicHandler().hideArmsAndItems(avatar, avatar.getMainHandItem(),
avatar.getOffhandItem()))
access.setHideArms(true);
avatarRenderState.hitboxesRenderState = null;
//? if <1.21.11
/*avatarRenderState.hitboxesRenderState = null;*/
}
//? }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ private void renderEntities(Camera camera, Frustum frustum, DeltaTracker deltaTr
if (camera.isDetached() || !FirstPersonModelCore.instance.getLogicHandler().shouldApplyThirdPerson(false)) {
return;
}
Vec3 vec3d = camera.getPosition();
Vec3 vec3d = /*? if >=1.21.11 {*/ camera.position() /*?} else {*//*camera.getPosition()*//*?}*/;
MultiBufferSource.BufferSource immediate = renderBuffers.bufferSource();
FirstPersonModelCore.instance.setRenderingPlayer(true);
FirstPersonModelCore.instance.setRenderingPlayerPost(true);
// Store position and apply offset
var ent = camera.getEntity();
var ent = /*? if >=1.21.11 {*/ camera.entity() /*?} else {*//*camera.getEntity()*//*?}*/;
var pos = ((EntityAccessor) ent).entityCulling$getRawPosition();
var xO = ent.xo;
var yO = ent.yo;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/firstperson/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"text.firstperson.title": "FirstPerson Settings",
"key.category.firstperson.keybind": "FirstPerson Mod",
"firstperson.keybind": "Firstperson",
"key.firstperson.toggle": "Toggle Firstperson",
"category.firstperson.firstperson": "FirstPerson",
Expand Down
2 changes: 1 addition & 1 deletion versions/mainProject
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.10-fabric
1.21.11-fabric
Loading