@Override public void initGui(GuiContainer guiContainer, List buttonList) { buttonList.add( CraftingTweaksAPI.createRotateButton( 0, guiContainer.width / 2 - 18, guiContainer.height / 2 - 48)); buttonList.add( CraftingTweaksAPI.createClearButton( 0, guiContainer.width / 2 + 2, guiContainer.height / 2 - 48)); }
@Override @SideOnly(Side.CLIENT) public void initGui(GuiContainer guiContainer, List buttonList) { final int paddingTop = 73; buttonList.add( CraftingTweaksAPI.createRotateButton( 0, guiContainer.guiLeft + 19, guiContainer.guiTop + paddingTop)); buttonList.add( CraftingTweaksAPI.createClearButton( 0, guiContainer.guiLeft + 37, guiContainer.guiTop + paddingTop)); }
public class TinkersConstructTweakProvider implements TweakProvider { private final DefaultProvider defaultProvider = CraftingTweaksAPI.createDefaultProvider(); private Field craftMatrixField; @Override public boolean load() { try { Class clazz = Class.forName("tconstruct.tools.inventory.CraftingStationContainer"); craftMatrixField = clazz.getField("craftMatrix"); return true; } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return false; } @Override public ItemStack transferIntoGrid( EntityPlayer entityPlayer, Container container, int id, ItemStack itemStack) { try { IInventory craftMatrix = (IInventory) craftMatrixField.get(container); return defaultProvider.transferIntoGrid(entityPlayer, container, craftMatrix, itemStack); } catch (IllegalAccessException e) { e.printStackTrace(); return itemStack; } } @Override public ItemStack putIntoGrid( EntityPlayer entityPlayer, Container container, int id, ItemStack itemStack, int index) { try { IInventory craftMatrix = (IInventory) craftMatrixField.get(container); return defaultProvider.putIntoGrid(entityPlayer, container, craftMatrix, itemStack, index); } catch (IllegalAccessException e) { e.printStackTrace(); return itemStack; } } @Override public IInventory getCraftMatrix(EntityPlayer entityPlayer, Container container, int id) { try { return (IInventory) craftMatrixField.get(container); } catch (IllegalAccessException e) { e.printStackTrace(); return null; } } @Override public void clearGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) craftMatrixField.get(container); defaultProvider.clearGrid(entityPlayer, container, craftMatrix); } catch (IllegalAccessException e) { e.printStackTrace(); } } @Override public void rotateGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) craftMatrixField.get(container); defaultProvider.rotateGrid(entityPlayer, container, craftMatrix); } catch (IllegalAccessException e) { e.printStackTrace(); } } @Override public void balanceGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) craftMatrixField.get(container); defaultProvider.balanceGrid(entityPlayer, container, craftMatrix); } catch (IllegalAccessException e) { e.printStackTrace(); } } @Override @SideOnly(Side.CLIENT) public void initGui(GuiContainer guiContainer, List buttonList) { final int paddingTop = 16; buttonList.add( CraftingTweaksAPI.createRotateButton( 0, guiContainer.guiLeft - 16, guiContainer.guiTop + paddingTop)); buttonList.add( CraftingTweaksAPI.createBalanceButton( 0, guiContainer.guiLeft - 16, guiContainer.guiTop + paddingTop + 18)); buttonList.add( CraftingTweaksAPI.createClearButton( 0, guiContainer.guiLeft - 16, guiContainer.guiTop + paddingTop + 36)); } @Override @SideOnly(Side.CLIENT) public boolean areHotkeysEnabled(EntityPlayer entityPlayer, Container container) { return true; } @Override public String getModId() { return "TConstruct"; } }
public class MineFactoryReloadedTweakProvider implements TweakProvider { private final DefaultProvider defaultProvider = CraftingTweaksAPI.createDefaultProvider(); private Field crafterField; @Override public boolean load() { try { Class clazz = Class.forName("powercrystals.minefactoryreloaded.gui.container.ContainerLiquiCrafter"); crafterField = clazz.getDeclaredField("_crafter"); crafterField.setAccessible(true); return true; } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } return false; } @Override public void clearGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) crafterField.get(container); for (int i = 0; i < 9; i++) { craftMatrix.setInventorySlotContents(i, null); } container.detectAndSendChanges(); } catch (IllegalAccessException e) { e.printStackTrace(); } } @Override public void rotateGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) crafterField.get(container); defaultProvider.rotateGrid( entityPlayer, container, craftMatrix, 0, 9, defaultProvider.getRotationHandler()); } catch (IllegalAccessException e) { e.printStackTrace(); } } @Override public void balanceGrid(EntityPlayer entityPlayer, Container container, int id) { return; } @Override public void initGui(GuiContainer guiContainer, List buttonList) { buttonList.add( CraftingTweaksAPI.createRotateButton( 0, guiContainer.width / 2 - 18, guiContainer.height / 2 - 48)); buttonList.add( CraftingTweaksAPI.createClearButton( 0, guiContainer.width / 2 + 2, guiContainer.height / 2 - 48)); } @Override public boolean areHotkeysEnabled(EntityPlayer entityPlayer, Container container) { return true; } @Override public String getModId() { return "MineFactoryReloaded"; } }
public class ForestryCarpenterOldTweakProvider implements TweakProvider { private final DefaultProvider defaultProvider = CraftingTweaksAPI.createDefaultProvider(); private Field tileEntityField; private Method getCraftingInventory; @Override public boolean load() { try { Class containerClass = Class.forName("forestry.core.gui.ContainerTile"); tileEntityField = containerClass.getDeclaredField("tile"); tileEntityField.setAccessible(true); Class tileClass = Class.forName("forestry.factory.gadgets.MachineCarpenter"); getCraftingInventory = tileClass.getMethod("getCraftingInventory"); return true; } catch (ClassNotFoundException ignored) { } catch (NoSuchFieldException ignored) { } catch (NoSuchMethodException ignored) { } return false; } @Override public ItemStack transferIntoGrid( EntityPlayer entityPlayer, Container container, int id, ItemStack itemStack) { try { IInventory craftMatrix = (IInventory) getCraftingInventory.invoke(tileEntityField.get(container)); return defaultProvider.transferIntoGrid(entityPlayer, container, craftMatrix, itemStack); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return itemStack; } @Override public ItemStack putIntoGrid( EntityPlayer entityPlayer, Container container, int id, ItemStack itemStack, int index) { try { IInventory craftMatrix = (IInventory) getCraftingInventory.invoke(tileEntityField.get(container)); return defaultProvider.putIntoGrid(entityPlayer, container, craftMatrix, itemStack, index); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return itemStack; } @Override public IInventory getCraftMatrix(EntityPlayer entityPlayer, Container container, int id) { try { return (IInventory) getCraftingInventory.invoke(tileEntityField.get(container)); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; } @Override public void clearGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) getCraftingInventory.invoke(tileEntityField.get(container)); for (int i = 0; i < 9; i++) { craftMatrix.setInventorySlotContents(i, null); } container.detectAndSendChanges(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } @Override public void rotateGrid(EntityPlayer entityPlayer, Container container, int id) { try { IInventory craftMatrix = (IInventory) getCraftingInventory.invoke(tileEntityField.get(container)); defaultProvider.rotateGrid( entityPlayer, container, craftMatrix, 0, 9, defaultProvider.getRotationHandler()); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } @Override public void balanceGrid(EntityPlayer entityPlayer, Container container, int id) {} @Override @SideOnly(Side.CLIENT) public void initGui(GuiContainer guiContainer, List buttonList) { final int paddingTop = 73; buttonList.add( CraftingTweaksAPI.createRotateButton( 0, guiContainer.guiLeft + 19, guiContainer.guiTop + paddingTop)); buttonList.add( CraftingTweaksAPI.createClearButton( 0, guiContainer.guiLeft + 37, guiContainer.guiTop + paddingTop)); } @Override @SideOnly(Side.CLIENT) public boolean areHotkeysEnabled(EntityPlayer entityPlayer, Container container) { return true; } @Override public String getModId() { return "Forestry"; } }