update to official mappings code
This commit is contained in:
@@ -51,55 +51,55 @@ public class CraftingKeys {
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent tick) {
|
||||
|
||||
Screen currentScreen = Util.client.currentScreen;
|
||||
Screen currentScreen = Util.client.screen;
|
||||
|
||||
if (currentScreen != null) {
|
||||
|
||||
if (currentScreen instanceof CraftingScreen) {
|
||||
|
||||
ContainerManager con = CraftingManager.getInstance(
|
||||
((CraftingScreen) currentScreen).getContainer());
|
||||
((CraftingScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof InventoryScreen) {
|
||||
|
||||
ContainerManager con = InventoryManager.getInstance(
|
||||
((InventoryScreen) currentScreen).getContainer());
|
||||
((InventoryScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof MerchantScreen) {
|
||||
|
||||
ContainerManager con = VillagerManager.getInstance(
|
||||
((MerchantScreen) currentScreen).getContainer());
|
||||
((MerchantScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof FurnaceScreen) {
|
||||
|
||||
ContainerManager con = FurnaceManager.getInstance(
|
||||
((FurnaceScreen) currentScreen).getContainer());
|
||||
((FurnaceScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof DispenserScreen) {
|
||||
|
||||
ContainerManager con = DispenserManager.getInstance(
|
||||
((DispenserScreen) currentScreen).getContainer());
|
||||
((DispenserScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof BrewingStandScreen) {
|
||||
|
||||
ContainerManager con = BrewingManager.getInstance(
|
||||
((BrewingStandScreen) currentScreen).getContainer());
|
||||
((BrewingStandScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof EnchantmentScreen) {
|
||||
|
||||
ContainerManager con = EnchantmentManager.getInstance(
|
||||
((EnchantmentScreen) currentScreen).getContainer());
|
||||
((EnchantmentScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
|
||||
} else if (currentScreen instanceof AnvilScreen) {
|
||||
ContainerManager con = AnvilManager.getInstance(
|
||||
((AnvilScreen) currentScreen).getContainer());
|
||||
((AnvilScreen) currentScreen).getMenu());
|
||||
con.acceptKey();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ public class Config {
|
||||
private static int keyLowerLeft = KeyEvent.VK_Z;
|
||||
private static int keyLowerCenter = KeyEvent.VK_X;
|
||||
private static int keyLowerRight = KeyEvent.VK_C;
|
||||
private static int keyStack = Minecraft.getInstance().gameSettings.keyBindSneak.getKey().getKeyCode();
|
||||
private static int keyInteract = Minecraft.getInstance().gameSettings.keyBindSprint.getKey().getKeyCode();
|
||||
private static int keyStack = Minecraft.getInstance().options.keyShift.getKey().getValue();
|
||||
private static int keyInteract = Minecraft.getInstance().options.keySprint.getKey().getValue();
|
||||
private static final int keyDrop = KeyEvent.VK_SPACE;
|
||||
|
||||
public static boolean isKeyDown(int keyCode) {
|
||||
return InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), keyCode);
|
||||
return InputMappings.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), keyCode);
|
||||
}
|
||||
|
||||
public static boolean isKeyTopLeftPressed() {
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class ContainerManager {
|
||||
public void acceptKey() {
|
||||
|
||||
// Get hovered slot and goal slotIndex of pressed key (if pressed)
|
||||
Slot currentHoveredSlot = InputUtil.getSlotAtMousePosition(Util.client.currentScreen);
|
||||
Slot currentHoveredSlot = InputUtil.getSlotAtMousePosition(Util.client.screen);
|
||||
int slotIndex = specificKeyToSlotIndex();
|
||||
|
||||
// Handle accepted key
|
||||
@@ -61,7 +61,7 @@ public abstract class ContainerManager {
|
||||
!Util.isHoldingStack()) { // MOVE FROM SLOT
|
||||
|
||||
Logger.info("acceptKey()", "Key for index " + slotIndex + " pressed.");
|
||||
onSpecificKeyPressed(currentHoveredSlot.slotNumber, slotIndex);
|
||||
onSpecificKeyPressed(currentHoveredSlot.index, slotIndex);
|
||||
|
||||
|
||||
} else if (Util.isHoldingStack()) { // MOVE FROM HAND
|
||||
@@ -98,7 +98,7 @@ public abstract class ContainerManager {
|
||||
// Handles Interaction with items held
|
||||
// Stack up on hand if equal or small enough, else throw held stack away
|
||||
if (Util.isHoldingStack() && getItemStack(getInteractionSlotIndex()) != null && (
|
||||
!Util.getHeldStack().isItemEqual(getItemStack(getInteractionSlotIndex()))
|
||||
!Util.getHeldStack().sameItem(getItemStack(getInteractionSlotIndex()))
|
||||
|| Util.getHeldStack().getCount() + getItemStack(getInteractionSlotIndex()).getCount()
|
||||
> getItemStack(getInteractionSlotIndex()).getMaxStackSize())) {
|
||||
moveStackToInventory(-1);
|
||||
@@ -159,32 +159,32 @@ public abstract class ContainerManager {
|
||||
void handleNumKey(Slot currentHoveredSlot) {
|
||||
|
||||
// hotbar-slots are always the last 9 slots of the currently opened inventory
|
||||
int hotbarStartIndex = Util.client.player.openContainer.getInventory().size() - 9 - 1;
|
||||
int hotbarStartIndex = Util.client.player.containerMenu.getItems().size() - 9 - 1;
|
||||
|
||||
if (Util.client.currentScreen instanceof InventoryScreen) {
|
||||
if (Util.client.screen instanceof InventoryScreen) {
|
||||
hotbarStartIndex -= 1;
|
||||
}
|
||||
|
||||
int inputdelta;
|
||||
KeyBinding[] hotbar = Util.client.gameSettings.keyBindsHotbar;
|
||||
KeyBinding[] hotbar = Util.client.options.keyHotbarSlots;
|
||||
|
||||
if (Config.isKeyDown(hotbar[0].getKey().getKeyCode())) {
|
||||
if (Config.isKeyDown(hotbar[0].getKey().getValue())) {
|
||||
inputdelta = 1;
|
||||
} else if (Config.isKeyDown(hotbar[1].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[1].getKey().getValue())) {
|
||||
inputdelta = 2;
|
||||
} else if (Config.isKeyDown(hotbar[2].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[2].getKey().getValue())) {
|
||||
inputdelta = 3;
|
||||
} else if (Config.isKeyDown(hotbar[3].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[3].getKey().getValue())) {
|
||||
inputdelta = 4;
|
||||
} else if (Config.isKeyDown(hotbar[4].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[4].getKey().getValue())) {
|
||||
inputdelta = 5;
|
||||
} else if (Config.isKeyDown(hotbar[5].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[5].getKey().getValue())) {
|
||||
inputdelta = 6;
|
||||
} else if (Config.isKeyDown(hotbar[6].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[6].getKey().getValue())) {
|
||||
inputdelta = 7;
|
||||
} else if (Config.isKeyDown(hotbar[7].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[7].getKey().getValue())) {
|
||||
inputdelta = 8;
|
||||
} else if (Config.isKeyDown(hotbar[8].getKey().getKeyCode())) {
|
||||
} else if (Config.isKeyDown(hotbar[8].getKey().getValue())) {
|
||||
inputdelta = 9;
|
||||
} else {
|
||||
return;
|
||||
@@ -194,7 +194,7 @@ public abstract class ContainerManager {
|
||||
// if there could not be meant another stack at mouse position. cool logic!
|
||||
if (!Util.isHoldingStack()) {
|
||||
|
||||
if (currentHoveredSlot == null || !currentHoveredSlot.getHasStack()) {
|
||||
if (currentHoveredSlot == null || !currentHoveredSlot.hasItem()) {
|
||||
Logger.info("handleNumKey()", "Trying output to hotbar speedup.");
|
||||
onInteractionKeyPressed();
|
||||
}
|
||||
@@ -306,13 +306,13 @@ public abstract class ContainerManager {
|
||||
int movedAmount = Math.min(amount, sourceSize);
|
||||
|
||||
// Clear goal slot (May fail on full inventory!); only available if not holdling
|
||||
if (destination != null && !source.isItemEqual(destination) && srcIndex >= 0) {
|
||||
if (destination != null && !source.sameItem(destination) && srcIndex >= 0) {
|
||||
moveStackToInventory(destIndex);
|
||||
destination = getItemStack(destIndex);
|
||||
}
|
||||
|
||||
// Move some
|
||||
if (destination == null || source.isItemEqual(destination)) {
|
||||
if (destination == null || source.sameItem(destination)) {
|
||||
|
||||
if (srcIndex >= 0) {
|
||||
leftClick(srcIndex);
|
||||
@@ -342,14 +342,14 @@ public abstract class ContainerManager {
|
||||
*/
|
||||
ItemStack getItemStack(int index) {
|
||||
|
||||
if (index >= 0 && index < container.inventorySlots.size()) {
|
||||
if (index >= 0 && index < container.slots.size()) {
|
||||
|
||||
Slot slot = (Slot) (container.inventorySlots.get(index));
|
||||
Slot slot = (Slot) (container.slots.get(index));
|
||||
|
||||
// NEW_1_11 No Null-Stacks anymore. Empty Stacks with air...
|
||||
ItemStack returnStack = (slot == null) ? null : slot.getStack();
|
||||
ItemStack returnStack = (slot == null) ? null : slot.getItem();
|
||||
|
||||
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.getItemFromBlock(Blocks.AIR)) {
|
||||
if(returnStack.getCount() == 0 && returnStack.getItem() == Item.byBlock(Blocks.AIR)) {
|
||||
returnStack = null;
|
||||
}
|
||||
|
||||
@@ -425,12 +425,12 @@ public abstract class ContainerManager {
|
||||
private int calcInventoryDestination(ItemStack stackToMove) {
|
||||
|
||||
// First run: Try to find a nice stack to put items on additionally
|
||||
for (int i = getInventoryStartIndex(); i < container.inventorySlots.size(); i++) {
|
||||
for (int i = getInventoryStartIndex(); i < container.slots.size(); i++) {
|
||||
|
||||
ItemStack potentialGoalStack = getItemStack(i);
|
||||
|
||||
if (potentialGoalStack != null && stackToMove != null) {
|
||||
if (potentialGoalStack.isItemEqual(stackToMove)) {
|
||||
if (potentialGoalStack.sameItem(stackToMove)) {
|
||||
if (potentialGoalStack.getCount() + stackToMove.getCount() <= stackToMove.getMaxStackSize()) {
|
||||
return i;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ public abstract class ContainerManager {
|
||||
}
|
||||
|
||||
// Second run: Find a free slot
|
||||
for (int i = getInventoryStartIndex(); i < container.inventorySlots.size(); i++) {
|
||||
for (int i = getInventoryStartIndex(); i < container.slots.size(); i++) {
|
||||
if (getItemStack(i) == null) {
|
||||
return i;
|
||||
}
|
||||
@@ -493,7 +493,7 @@ public abstract class ContainerManager {
|
||||
|
||||
int rightClickData = (rightClick) ? 1 : 0;
|
||||
|
||||
CraftingKeys.proxy.sendSlotClick(Util.client.playerController, container.windowId, index,
|
||||
CraftingKeys.proxy.sendSlotClick(Util.client.gameMode, container.containerId, index,
|
||||
rightClickData, 0, Util.client.player);
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CraftingKeysProxy {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void sendSlotClick(PlayerController controller, int windowId, int slot, int rightClick, @SuppressWarnings("SameParameterValue") int action,
|
||||
PlayerEntity player) {
|
||||
controller.windowClick(windowId, slot, rightClick, ClickType.PICKUP, player);
|
||||
controller.handleInventoryMouseClick(windowId, slot, rightClick, ClickType.PICKUP, player);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,6 @@ public class LanguageLocalizer {
|
||||
* @return localized The localized String
|
||||
*/
|
||||
public static String localize(String unloc) {
|
||||
return I18n.format(unloc);
|
||||
return I18n.get(unloc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Util {
|
||||
* @return A item stack
|
||||
*/
|
||||
public static ItemStack getHeldStack() {
|
||||
return client.player.inventory.getItemStack();
|
||||
return client.player.inventory.getCarried();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,10 +49,10 @@ public class Util {
|
||||
* @return True, if this is the first tick
|
||||
*/
|
||||
public static boolean isFirstInWorldTick() {
|
||||
if (firstInWorldTick && client.world != null) {
|
||||
if (firstInWorldTick && client.level != null) {
|
||||
firstInWorldTick = false;
|
||||
return true;
|
||||
} else if (client.world == null) {
|
||||
} else if (client.level == null) {
|
||||
firstInWorldTick = true;
|
||||
}
|
||||
return false;
|
||||
@@ -64,8 +64,8 @@ public class Util {
|
||||
* @param lang_key key from lang-file
|
||||
*/
|
||||
public static void printMessage(String lang_key) {
|
||||
String translated = new TranslationTextComponent(lang_key).getUnformattedComponentText();
|
||||
client.player.sendChatMessage(translated);
|
||||
String translated = new TranslationTextComponent(lang_key).getContents();
|
||||
client.player.chat(translated);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user