Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Keybinds implements ClientModInitializer {

final Minecraft mc = Minecraft.getInstance();

public static boolean showingTags = false;
public static KeyMapping showTags;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
package io.github.homchom.recode.mod.mixin.inventory;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.platform.InputConstants.Key;
import io.github.homchom.recode.mod.features.keybinds.Keybinds;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -35,13 +29,8 @@ private void getTooltipLines(Player player, TooltipFlag context,
if (player == null) return;

try {
String cname = FabricLoader.getInstance().isDevelopmentEnvironment() ? "key" : "field_1655";

int keycode = ((Key) FieldUtils.getField(KeyMapping.class,cname,true).get(Keybinds.showTags)).getValue();

if (keycode == -1) return;

if (InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(),keycode)) {
if (Keybinds.showingTags) {
List<Component> t = cir.getReturnValue();

CompoundTag tags = getTagElement("PublicBukkitValues");
Expand Down
Copy link
Owner

Choose a reason for hiding this comment

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

could you make this an Event instead? so showingTags can be in the other mixin

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.github.homchom.recode.mod.mixin.inventory;

import io.github.homchom.recode.mod.features.keybinds.Keybinds;
import net.minecraft.client.KeyboardHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(KeyboardHandler.class)
public class MKeyboardHandler {
@Inject(method = "keyPress", at = @At(value = "HEAD"))
public void onKeyPressed(long l, int i, int j, int k, int m, CallbackInfo ci) {
if(Keybinds.showTags.matches(i,j)) {
if (k != 1 && k != 2) {
if (k == 0) {
// released
Keybinds.showingTags = false;
}
} else {
// pressed
Keybinds.showingTags = true;
}
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/recodeLegacy.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"render.screen.MOptionsScreen"
],
"client": [
"inventory.MKeyboardHandler",
"render.MAbstractContainerScreen"
],
"server": [],
Expand Down