Update to latest Crafting Tweaks API and fix the buttons to always align to the correct slot. (#1192)
Set keyHandled = true in GuiGrid to prevent the KeyboardInput.Post event from firing.
This commit is contained in:
@@ -591,6 +591,7 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
||||
updateJEI();
|
||||
|
||||
sortItems();
|
||||
keyHandled = true;
|
||||
} else if (searchField.isFocused() && (keyCode == Keyboard.KEY_UP || keyCode == Keyboard.KEY_DOWN || keyCode == Keyboard.KEY_RETURN)) {
|
||||
if (keyCode == Keyboard.KEY_UP) {
|
||||
updateSearchHistory(-1);
|
||||
@@ -603,10 +604,12 @@ public class GuiGrid extends GuiBase implements IGridDisplay {
|
||||
searchField.setFocused(false);
|
||||
}
|
||||
}
|
||||
keyHandled = true;
|
||||
} else if (keyCode == RSKeyBindings.FOCUS_SEARCH_BAR.getKeyCode() && (grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_NORMAL || grid.getSearchBoxMode() == NetworkNodeGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED)) {
|
||||
searchField.setFocused(!searchField.isFocused());
|
||||
|
||||
saveHistory();
|
||||
keyHandled = true;
|
||||
} else {
|
||||
super.keyTyped(character, keyCode);
|
||||
}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.integration.craftingtweaks;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.raoulvdberge.refinedstorage.block.GridType;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotGridCrafting;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
@@ -18,17 +20,29 @@ public final class IntegrationCraftingTweaks {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setString("ContainerClass", ContainerGrid.class.getName());
|
||||
tag.setString("ContainerCallback", ContainerCallback.class.getName());
|
||||
tag.setInteger("GridSlotNumber", 36);
|
||||
tag.setString("ValidContainerPredicate", ValidContainerPredicate.class.getName());
|
||||
tag.setString("GetGridStartFunction", GetGridStartFunction.class.getName());
|
||||
tag.setString("AlignToGrid", "left");
|
||||
|
||||
FMLInterModComms.sendMessage(ID, "RegisterProviderV2", tag);
|
||||
FMLInterModComms.sendMessage(ID, "RegisterProviderV3", tag);
|
||||
}
|
||||
|
||||
public static class ContainerCallback implements Function<ContainerGrid, Boolean> {
|
||||
public static class ValidContainerPredicate implements Predicate<ContainerGrid> {
|
||||
@Override
|
||||
public Boolean apply(ContainerGrid containerGrid) {
|
||||
public boolean apply(ContainerGrid containerGrid) {
|
||||
return containerGrid.getGrid().getType() == GridType.CRAFTING;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GetGridStartFunction implements Function<ContainerGrid, Integer> {
|
||||
@Override
|
||||
public Integer apply(ContainerGrid containerGrid) {
|
||||
for(int i = 0; i < containerGrid.inventorySlots.size(); i++) {
|
||||
if(containerGrid.inventorySlots.get(i) instanceof SlotGridCrafting) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user