Some more crafting speed up. Now: faster interaction with ouput!

This commit is contained in:
0xSeb
2015-11-08 16:11:26 +01:00
parent 81ad571dfa
commit ac309fee9c
2 changed files with 31 additions and 12 deletions
@@ -13,11 +13,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import de.skate702.craftingkeys.config.Config;
import de.skate702.craftingkeys.config.GuiConfig;
import de.skate702.craftingkeys.config.GuiConfigHandler;
import de.skate702.craftingkeys.manager.*;
import de.skate702.craftingkeys.proxies.CraftingKeysProxy;
import de.skate702.craftingkeys.util.LanguageLocalizer;
import de.skate702.craftingkeys.util.Logger;
import de.skate702.craftingkeys.util.Util;
import net.minecraft.client.gui.*;
@@ -110,7 +108,7 @@ public class CraftingKeys {
@SubscribeEvent
public void onGuiOpened(GuiOpenEvent event) {
if (event.gui instanceof GuiMainMenu) {
event.gui = new GuiConfig(); // Delete this!
//event.gui = new GuiConfig(); // Delete this!
}
}
@@ -65,8 +65,10 @@ public abstract class ContainerManager {
} else if (Util.isHoldingStack()) { // MOVE FROM HAND
onHolding(slotIndex);
handleNumKey();
handleNumKey(currentHoveredSlot);
} else { // HANDLE NUM KEY MOVING (also with empty hand now -> speed-up)
handleNumKey(currentHoveredSlot);
}
}
@@ -148,8 +150,9 @@ public abstract class ContainerManager {
/**
* Handles what to do with NumKey-Inputs while holding a item.
* @param currentHoveredSlot
*/
protected void handleNumKey() {
protected void handleNumKey(Slot currentHoveredSlot) {
// hotbar-slots are always the last 9 slots of the currently opened inventory
int hotbarStartIndex = Util.client.thePlayer.openContainer.getInventory().size() - 9 - 1;
@@ -177,6 +180,21 @@ public abstract class ContainerManager {
return;
}
// If no stack is held and a num-key is pressed, get the output by interaction, but only
// if there could not be meant another stack at mouse position. cool logic!
if (!Util.isHoldingStack()) {
if (currentHoveredSlot == null || !currentHoveredSlot.getHasStack()) {
Logger.info("handleNumKey()", "Trying output to hotbar speedup.");
onInteractionKeyPressed();
}
}
// If held, move!
if (Util.isHoldingStack()) {
// TODO: Make place?
leftClick(hotbarStartIndex + inputdelta);
Logger.info("handleNumKey()", "Moved to hotbar slot " + inputdelta + ".");
@@ -188,6 +206,9 @@ public abstract class ContainerManager {
}
}
}
/**
* Converts the first specific pressed Key to the slot in a given Inventory.
* Does also accept Interaction (mapped to -101) and drop key (mapped to -102).