CraftingKeys
CraftingKeys copied to clipboard
Mod support.
Is there anyway that mod support could be added? I looked at the code, all the crafting managers seem like they should be able to be created dynamically easy enough using the slot numbers. So maybe some sort of config / way to display the slot numbers that the mods are using?
Yes, sould be possible. I don't know enough about mods supporting each other, but a public interface or some thing with configs should do the job!
~~I am not shure but wouldn't it be possible to just add another Manager Like Class with specific config in it? (Of course at this point the Gui would not be updated) Also I am not shure how to do that and say that CraftingKeys is not an Dependency~~
An Gui API can be found here (pull request when ready and discussed): https://github.com/MTRNord/CraftingKeys/tree/ModApi Api Example here: http://pastebin.com/EhQvu0eJ
Please not there are still bugs and it is an very early (not completly tested) version!
Edit: Fix Link to correct Branch. Pushed to wrong branch.
Some Ideas on the API itself. Would using an abstract class make sense so you would do something like this:
package de.skate702.craftingkeys.api;
import de.skate702.craftingkeys.CraftingKeys;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
/**
* Created by Marcel on 15.12.2016.
*/
public class APITest extends Api {
private static APITest instance = null;
/**
* Creates a new ContainerManager with the given container.
*
* @param container
*/
private APITest(Container container) {
super(container, "ApiTestGui");
}
@Override
public void initGui() {
Gui gui = Gui.getInstance();
gui.glColor4f(0.5F, 0.5F, 0.5F, 1F);
gui.bindTexture(new ResourceLocation("textures/gui/container/inventory.png"));
gui.drawTexturedModalRect(gui.guiShowBasePosX - 86, gui.guiShowBasePosY, 1, 0, 174, 80);
gui.glColor4f(1F, 1F, 1F, 1F);
gui.bindTexture(new ResourceLocation(CraftingKeys.MODID, "textures/gui/symbols.png"));
gui.drawTexturedModalRect(gui.guiShowBasePosX + 105, gui.guiShowBasePosY + 17, 0, 0, 50, 50);
gui.drawInfoString(1, 105, 22); //W
gui.drawInfoString(2, 123, 22); //E
gui.drawInfoString(4, 105, 40); //S
gui.drawInfoString(5, 123, 40); //D
gui.drawInfoString(9, 164, 32); //LCTRL
}
/**
* Returns a Inventory Manager Instance operating on the given container
*
* @param container A container from a GUI
* @return manager-singleton
*/
public static APITest getInstance(Container container) {
if (instance == null) {
instance = new APITest(container);
} else {
instance.container = container;
}
return instance;
}
@Override
protected int specificKeyToSlotIndex() {
return mapKeyToSlot(-1, 1, 2, 45, 3, 4, 45, -1, -1);
// NEW_1_9 return mapKeyToSlot(-1, 1, 2, 45, 3, 4, 45, -1, -1);
}
@Override
protected int getInventoryStartIndex() {
return 9;
}
@Override
protected int getInteractionSlotIndex() {
return 0;
}
@Override
protected int[] getDropSlots() {
return new int[]{1, 2, 3, 4};
}
@Override
protected void interact() {
clickOnCraftingOutput();
}
/**
* Sends a click on the crafting output
*/
private void clickOnCraftingOutput() {
Logger.info("clickOnCraftingOutput()", "Clicked on Crafing Output.");
leftClick(0);
}
}
Maybe that would be easier if it provides an Wrapper around the hole Api.
PS: The Example will I from now on show in this file: https://github.com/MTRNord/CraftingKeys/blob/ModApi/ModdingApiExample.java PPS: Currently the Manager that you see there is not yet registered. WIP