Added basic functionality. A lot of TODO's remaining.
This commit is contained in:
@@ -61,7 +61,7 @@ public class CraftingKeys {
|
|||||||
proxy.registerRenderers();
|
proxy.registerRenderers();
|
||||||
FMLCommonHandler.instance().bus().register(this);
|
FMLCommonHandler.instance().bus().register(this);
|
||||||
|
|
||||||
Helper.debugPrint("load(): Loaded Mod successful");
|
Helper.debugPrint("load(): Loaded CraftingKeys successful");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,31 +83,35 @@ public class CraftingKeys {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTick(TickEvent.ClientTickEvent tick) {
|
public void onTick(TickEvent.ClientTickEvent tick) {
|
||||||
|
|
||||||
// if (mc.currentScreen != null) {
|
// Case 1: Classic GUI Screen
|
||||||
// if (mc.currentScreen instanceof
|
if (Helper.isCraftingGUI(Helper.client.currentScreen)) {
|
||||||
// net.minecraft.client.gui.inventory.GuiCrafting) {
|
|
||||||
// Keyboard.isKeyDown(Keyboard.KEY_Q)
|
|
||||||
|
|
||||||
// DEBUGGIN TEST START
|
|
||||||
|
|
||||||
if (Helper.client.currentScreen != null) {
|
|
||||||
if (Helper.client.currentScreen instanceof GuiCrafting) {
|
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
|
||||||
|
|
||||||
GuiCrafting guiCrafting = (GuiCrafting) Helper.client.currentScreen;
|
GuiCrafting guiCrafting = (GuiCrafting) Helper.client.currentScreen;
|
||||||
Slot currentHoveredSlot = Helper.getSlotAtMousePosition(guiCrafting);
|
Slot currentHoveredSlot = Helper.getSlotAtMousePosition(guiCrafting);
|
||||||
|
int keyDown = Helper.craftingKeyDownToSlotNumber();
|
||||||
|
|
||||||
|
// Block Key Interval (avoid multiple Runs)
|
||||||
|
if (!Helper.isSameKey(keyDown)) {
|
||||||
|
|
||||||
|
// Good key, Mouse over Inventory
|
||||||
|
if (keyDown != -1 && currentHoveredSlot != null) {
|
||||||
|
|
||||||
ContainerManager con = new ContainerManager(guiCrafting.inventorySlots);
|
ContainerManager con = new ContainerManager(guiCrafting.inventorySlots);
|
||||||
if (currentHoveredSlot != null) {
|
con.move(currentHoveredSlot.slotNumber, keyDown, 1);
|
||||||
con.move(currentHoveredSlot.slotNumber, 8, 1);
|
|
||||||
} else {
|
// TODO: Move more/all!
|
||||||
Helper.debugPrint("onTick(): Outside of inventory");
|
|
||||||
}
|
// TODO: Strg -> Click on Output
|
||||||
|
|
||||||
|
// TODO: Shift -> Move all!
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUGGIN TEST END
|
// Case 2: Inventory (2x2 Crafting, Quick-Armor)
|
||||||
|
|
||||||
|
// TODO: Case 2
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package de.skate702.craftingkeys;
|
package de.skate702.craftingkeys;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiCrafting;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
|
|
||||||
@@ -47,6 +50,23 @@ public class Helper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if the current Screen is a instance of GUI-Screen.
|
||||||
|
*
|
||||||
|
* @param screen
|
||||||
|
* The input Screen
|
||||||
|
* @return True, if GuiScreen; False if null
|
||||||
|
*/
|
||||||
|
public static boolean isCraftingGUI(GuiScreen screen) {
|
||||||
|
|
||||||
|
if (screen != null) {
|
||||||
|
if (screen instanceof GuiCrafting) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Slot at the current Mouse Position. [FROM GUICONTAINER]
|
* Returns the Slot at the current Mouse Position. [FROM GUICONTAINER]
|
||||||
*
|
*
|
||||||
@@ -121,4 +141,62 @@ public class Helper {
|
|||||||
return guiContainer.height - (Mouse.getEventY() * guiContainer.height) / client.displayHeight - 1;
|
return guiContainer.height - (Mouse.getEventY() * guiContainer.height) / client.displayHeight - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the current Keyboard-Input and converts it to a Inventory-Slot.
|
||||||
|
*
|
||||||
|
* @return A Inventory-Slot (based on CraftingGUI)
|
||||||
|
*/
|
||||||
|
public static int craftingKeyDownToSlotNumber() {
|
||||||
|
|
||||||
|
// TODO: Make this dynamic! // Use Settings
|
||||||
|
|
||||||
|
int returnValue = -1;
|
||||||
|
|
||||||
|
if (Keyboard.isKeyDown(Keyboard.KEY_Q)) {
|
||||||
|
returnValue = 1;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
|
||||||
|
returnValue = 2;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_E)) {
|
||||||
|
returnValue = 3;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
|
||||||
|
returnValue = 4;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
|
||||||
|
returnValue = 5;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
|
||||||
|
returnValue = 6;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_Y)) {
|
||||||
|
returnValue = 7;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_X)) {
|
||||||
|
returnValue = 8;
|
||||||
|
} else if (Keyboard.isKeyDown(Keyboard.KEY_C)) {
|
||||||
|
returnValue = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the last Key that was Pressed
|
||||||
|
*/
|
||||||
|
private static int lastKeyDown = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns, if the current KeyValue is the same
|
||||||
|
*
|
||||||
|
* @param currentKey
|
||||||
|
* the new input value, saved in the method
|
||||||
|
* @return True, if these are the same keys
|
||||||
|
*/
|
||||||
|
public static boolean isSameKey(int currentKey) {
|
||||||
|
|
||||||
|
boolean returnValue = false;
|
||||||
|
|
||||||
|
if (lastKeyDown == currentKey && currentKey != -1) {
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastKeyDown = currentKey;
|
||||||
|
return returnValue;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package de.skate702.craftingkeys;
|
||||||
|
|
||||||
|
public class Settings {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user