-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NK
committed
Feb 21, 2023
1 parent
d80acf0
commit 0dec3da
Showing
8 changed files
with
151 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package me.night0721.lilase.features.ah; | ||
|
||
public enum States { | ||
OPEN, NONE, CLICK, CONFIRM, STOP | ||
OPEN, NONE, CLICK, CONFIRM, EXECUTE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package me.night0721.lilase.gui; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
import java.awt.*; | ||
|
||
public class TextRenderer { | ||
public TextRenderer(Minecraft mc, String text, int x, int y, double scale) { | ||
double scaleReset = Math.pow(scale, -1); | ||
|
||
GL11.glScaled(scale, scale, scale); | ||
y -= mc.fontRendererObj.FONT_HEIGHT; | ||
for (String line : text.split("\n")) { | ||
y += mc.fontRendererObj.FONT_HEIGHT * scale; | ||
/*if (ToggleCommand.outlineTextToggled) { | ||
String noColorLine = StringUtils.stripControlCodes(line); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale) - 1, (int) Math.round(y / scale), 0x000000, false); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale) + 1, (int) Math.round(y / scale), 0x000000, false); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale), (int) Math.round(y / scale) - 1, 0x000000, false); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale), (int) Math.round(y / scale) + 1, 0x000000, false); | ||
mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, false); | ||
} else {*/ | ||
mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, true); | ||
//} | ||
} | ||
GL11.glScaled(scaleReset, scaleReset, scaleReset); | ||
GlStateManager.color(1, 1, 1, 1); | ||
} | ||
|
||
public TextRenderer(Minecraft mc, String text, int x, int y, double scale, Color color) { | ||
double scaleReset = Math.pow(scale, -1); | ||
|
||
GL11.glScaled(scale, scale, scale); | ||
y -= mc.fontRendererObj.FONT_HEIGHT; | ||
for (String line : text.split("\n")) { | ||
y += mc.fontRendererObj.FONT_HEIGHT * scale; | ||
/*if (ToggleCommand.outlineTextToggled) { | ||
String noColorLine = StringUtils.stripControlCodes(line); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale) - 1, (int) Math.round(y / scale), 0x000000, false); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale) + 1, (int) Math.round(y / scale), 0x000000, false); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale), (int) Math.round(y / scale) - 1, 0x000000, false); | ||
mc.fontRendererObj.drawString(noColorLine, (int) Math.round(x / scale), (int) Math.round(y / scale) + 1, 0x000000, false); | ||
mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), 0xFFFFFF, false); | ||
} else {*/ | ||
mc.fontRendererObj.drawString(line, (int) Math.round(x / scale), (int) Math.round(y / scale), color.getRGB(), true); | ||
//} | ||
} | ||
GL11.glScaled(scaleReset, scaleReset, scaleReset); | ||
GlStateManager.color(1, 1, 1, 1); | ||
} | ||
|
||
public static void drawString(String text, int x, int y, double scale) { | ||
new TextRenderer(Minecraft.getMinecraft(), text, x, y, scale); | ||
} | ||
|
||
public static void drawString(String text, int x, int y, double scale, Color color) { | ||
new TextRenderer(Minecraft.getMinecraft(), text, x, y, scale, color); | ||
} | ||
|
||
public void drawCenteredString(String text, int x, int y, double scale) { | ||
drawString(text, x - Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) / 2, y - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
src/main/java/me/night0721/lilase/managers/KeyBindingManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
package me.night0721.lilase.managers; | ||
|
||
import me.night0721.lilase.Lilase; | ||
import me.night0721.lilase.utils.PlayerUtils; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.client.settings.KeyBinding; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraftforge.fml.client.registry.ClientRegistry; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.InputEvent; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
public class KeyBindingManager { | ||
private static final KeyBinding[] keyBindings = new KeyBinding[4]; | ||
private static final ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(Blocks.acacia_door, Blocks.anvil, Blocks.beacon, Blocks.bed, Blocks.birch_door, Blocks.brewing_stand, Blocks.command_block, Blocks.crafting_table, Blocks.chest, Blocks.dark_oak_door, Blocks.daylight_detector, Blocks.daylight_detector_inverted, Blocks.dispenser, Blocks.dropper, Blocks.enchanting_table, Blocks.ender_chest, Blocks.furnace, Blocks.hopper, Blocks.jungle_door, Blocks.lever, Blocks.noteblock, Blocks.powered_comparator, Blocks.unpowered_comparator, Blocks.powered_repeater, Blocks.unpowered_repeater, Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.trapped_chest, Blocks.wooden_button, Blocks.stone_button, Blocks.oak_door, Blocks.skull)); | ||
// private static final ArrayList<Block> interactables = new ArrayList<>(Arrays.asList(Blocks.acacia_door, Blocks.anvil, Blocks.beacon, Blocks.bed, Blocks.birch_door, Blocks.brewing_stand, Blocks.command_block, Blocks.crafting_table, Blocks.chest, Blocks.dark_oak_door, Blocks.daylight_detector, Blocks.daylight_detector_inverted, Blocks.dispenser, Blocks.dropper, Blocks.enchanting_table, Blocks.ender_chest, Blocks.furnace, Blocks.hopper, Blocks.jungle_door, Blocks.lever, Blocks.noteblock, Blocks.powered_comparator, Blocks.unpowered_comparator, Blocks.powered_repeater, Blocks.unpowered_repeater, Blocks.standing_sign, Blocks.wall_sign, Blocks.trapdoor, Blocks.trapped_chest, Blocks.wooden_button, Blocks.stone_button, Blocks.oak_door, Blocks.skull)); | ||
|
||
public static void registerKeyBindings() { | ||
keyBindings[0] = new KeyBinding("Ghost Block Bind", Keyboard.KEY_G, Lilase.MOD_NAME); | ||
keyBindings[1] = new KeyBinding("Hub", Keyboard.KEY_DIVIDE, Lilase.MOD_NAME); | ||
keyBindings[2] = new KeyBinding("Auction House", Keyboard.KEY_END, Lilase.MOD_NAME); | ||
keyBindings[3] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME); | ||
//keyBindings[0] = new KeyBinding("Ghost Block Bind", Keyboard.KEY_G, Lilase.MOD_NAME); | ||
keyBindings[0] = new KeyBinding("Auction House", Keyboard.KEY_END, Lilase.MOD_NAME); | ||
keyBindings[1] = new KeyBinding("Config", Keyboard.KEY_MULTIPLY, Lilase.MOD_NAME); | ||
for (KeyBinding keyBinding : keyBindings) { | ||
ClientRegistry.registerKeyBinding(keyBinding); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onKeyPress(InputEvent.KeyInputEvent event) { | ||
if (keyBindings[0].isKeyDown()) { | ||
if (PlayerUtils.mc.objectMouseOver.getBlockPos() == null) return; | ||
Block block = PlayerUtils.mc.theWorld.getBlockState(PlayerUtils.mc.objectMouseOver.getBlockPos()).getBlock(); | ||
if (!interactables.contains(block)) { | ||
PlayerUtils.mc.theWorld.setBlockToAir(PlayerUtils.mc.objectMouseOver.getBlockPos()); | ||
} | ||
} | ||
if (keyBindings[1].isKeyDown()) { | ||
PlayerUtils.mc.thePlayer.sendChatMessage("/hub"); | ||
} | ||
if (keyBindings[2].isPressed()) { | ||
// if (keyBindings[0].isKeyDown()) { | ||
// if (PlayerUtils.mc.objectMouseOver.getBlockPos() == null) return; | ||
// Block block = PlayerUtils.mc.theWorld.getBlockState(PlayerUtils.mc.objectMouseOver.getBlockPos()).getBlock(); | ||
// if (!interactables.contains(block)) { | ||
// PlayerUtils.mc.theWorld.setBlockToAir(PlayerUtils.mc.objectMouseOver.getBlockPos()); | ||
// } | ||
// } | ||
// if (keyBindings[1].isKeyDown()) { | ||
// List<String> lines = new ArrayList<>(); | ||
// lines.add("X: " + Math.round(PlayerUtils.mc.thePlayer.posX)); | ||
// lines.add("Y: " + Math.round(PlayerUtils.mc.thePlayer.posY)); | ||
// lines.add("Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ)); | ||
// for (String line : lines) { | ||
// TextRenderer.drawString(line, 0, 0, 1); | ||
// } | ||
// } | ||
if (keyBindings[0].isPressed()) { | ||
Lilase.auctionHouse.toggleAuction(); | ||
} | ||
if (keyBindings[3].isPressed()) { | ||
if (keyBindings[1].isPressed()) { | ||
Lilase.config.openGui(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.