Skip to content

Commit

Permalink
add NEI hotkeys support when mouse over ore vein
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmetriy committed Sep 24, 2024
1 parent 579e905 commit 869d69c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
api('com.github.GTNewHorizons:Navigator:1.0.12:dev')
api('com.github.GTNewHorizons:Navigator:1.0.13:dev')
api('com.github.GTNewHorizons:GTNHLib:0.5.11:dev')
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.50.09:dev')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ public int getColor() {
public IIcon getIconFromPrimaryOre() {
return oreVeinPosition.veinType.oreMaterialProvider.getIcon();
}

public short getPrimaryOreMeta() {
return oreVeinPosition.veinType.primaryOreMeta;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;

Expand All @@ -13,8 +15,12 @@
import com.sinthoras.visualprospecting.Tags;
import com.sinthoras.visualprospecting.integration.model.locations.OreVeinLocation;

import codechicken.nei.api.ShortcutInputHandler;
import gregtech.api.GregTechAPI;

public class OreVeinRenderStep extends UniversalInteractableStep<OreVeinLocation> {

private static final ResourceLocation clickSound = new ResourceLocation("gui.button.press");
private static final ResourceLocation depletedTextureLocation = new ResourceLocation(
Tags.MODID,
"textures/depleted.png");
Expand Down Expand Up @@ -90,4 +96,23 @@ public void onActionKeyPressed() {
location.toggleOreVein();
}

@Override
public boolean onKeyPressed(int keyCode) {

if (super.onKeyPressed(keyCode)) {
return true;
}

final var itemStack = new ItemStack(GregTechAPI.sBlockOres1, 1, location.getPrimaryOreMeta());
if (ShortcutInputHandler.handleKeyEvent(itemStack)) {
playClickSound();
return true;
}

return false;
}

private void playClickSound() {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(clickSound, 1.0F));
}
}

0 comments on commit 869d69c

Please sign in to comment.