Started add an CraftingManager for anvils and added some generators to GuiConfig.

This commit is contained in:
tosta3000
2015-11-05 11:32:10 +01:00
parent d03dab36dd
commit fbb8211f8f
3 changed files with 135 additions and 24 deletions
@@ -20,10 +20,7 @@ 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.GuiEnchantment;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiMerchant;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.inventory.*;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
@@ -113,7 +110,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!
}
}
@@ -176,6 +173,10 @@ public class CraftingKeys {
((GuiEnchantment) currentScreen).inventorySlots);
con.acceptKey();
} else if (currentScreen instanceof GuiRepair){
ContainerManager con = AnvilManager.getInstance(
((GuiRepair) currentScreen).inventorySlots);
con.acceptKey();
}
}
@@ -20,8 +20,8 @@ public class GuiConfig extends GuiScreen {
//TODO:Give all buttons the name you think are good for the eventhandling
private int buttonSaveID = 901;
private int buttonAbortID = 902;
private int buttonSpaceID = 903;
private int buttonShiftID = 904;
private int buttonDropID = 903;
private int buttonStackID = 904;
private int buttonCraftingID = 301;
private int buttonBrewingstandID = 302;
@@ -84,17 +84,18 @@ public class GuiConfig extends GuiScreen {
}else if(guiType == GuiType.BREWINGSTAND){
genBrewingStandInfo();
}else if(guiType == GuiType.DISPENSER){
genDispenserInfo();
}else if(guiType == GuiType.ENCHANTMENT){
genEnchantmentInfo();
}else if(guiType == GuiType.INVENTORY){
genInventoryInfo();
}else if(guiType == GuiType.VILAGER){
genVillagerInfo();
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
//TODO: Set here the buttons with the function
@Override
public void actionPerformed(GuiButton button) {
@@ -107,18 +108,22 @@ public class GuiConfig extends GuiScreen {
addCraftingButtons();
}else if(button.id == buttonInventoryID) {
guiType = GuiType.INVENTORY;
addInventoryButtons();
}else if(button.id == buttonEnchantmentID){
guiType = GuiType.ENCHANTMENT;
addEnchantmentButtons();
}else if(button.id == buttonBrewingstandID){
guiType = GuiType.BREWINGSTAND;
addBrewingStandButtons();
}else if(button.id == buttonDispenserID){
guiType = GuiType.DISPENSER;
addDispenserButtons();
}else if(button.id == buttonFurnaceID){
guiType = GuiType.FURNACE;
addFurnaceButtons();
}else if(button.id == buttonVillagerID){
guiType = GuiType.VILAGER;
addVillagerButtons();
}
}
@@ -130,8 +135,10 @@ public class GuiConfig extends GuiScreen {
*/
private void genCraftingInfo(){
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/crafting_table.png"));
drawTexturedModalRect(guiBasePosition - 86, height / 2 - 100, 1, 0, 174, 80);
drawString(fontRendererObj, "Crafting Table", guiBasePosition - 33, height / 2 - 100 + 3, lightGray.getRGB());
}
private void addCraftingButtons(){
@@ -149,11 +156,13 @@ public class GuiConfig extends GuiScreen {
addStandardButtons();
}
private void genFurnaceInfo() {
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/furnace.png"));
drawTexturedModalRect(guiBasePosition - 86, height / 2 - 100, 1, 0, 174, 80);
drawString(fontRendererObj, "Furnace", guiBasePosition - 15, height / 2 - 100 + 3, lightGray.getRGB());
/*drawString(fontRendererObj, "Furnace", xBase + 5, yBase + 5, lightGray.getRGB());
drawCenteredString(fontRendererObj, "W", xBase + 63, yBase + 21, highlight.getRGB());
drawCenteredString(fontRendererObj, "S", xBase + 63, yBase + 57, highlight.getRGB());
@@ -162,36 +171,85 @@ public class GuiConfig extends GuiScreen {
private void addFurnaceButtons(){
buttonList.clear();
addStandardButtons();
}
private void genBrewingStandInfo() {
GL11.glColor4f(1F, 1F, 1F, 1.0F);
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/brewing_stand.png"));
drawTexturedModalRect(guiBasePosition - 86, height / 2 - 100, 1, 0, 174, 80);
/*drawString(fontRendererObj, "Brewing Stand", guiBasePosition + 5, height / 2 - 100 + 5, lightGray.getRGB());
drawCenteredString(fontRendererObj, "W", guiBasePosition + 86, height / 2 - 100 + 21, highlight.getRGB());
drawString(fontRendererObj, "Brewing Stand", guiBasePosition - 33, height / 2 - 100 + 3, lightGray.getRGB());
/*drawCenteredString(fontRendererObj, "W", guiBasePosition + 86, height / 2 - 100 + 21, highlight.getRGB());
drawCenteredString(fontRendererObj, "S", guiBasePosition + 86, height / 2 - 100 + 58, highlight.getRGB());
drawCenteredString(fontRendererObj, "A", guiBasePosition + 63, height / 2 - 100 + 50, highlight.getRGB());
drawCenteredString(fontRendererObj, "D", guiBasePosition + 109, height / 2 - 100 + 50, highlight.getRGB());*/
}
public void addBrewingStandButtons(){
private void addBrewingStandButtons(){
buttonList.clear();
addStandardButtons();
}
private void genEnchantmentInfo(){
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/enchanting_table.png"));
drawTexturedModalRect(guiBasePosition - 86, height / 2 - 100, 1, 0, 174, 80);
drawString(fontRendererObj, "Enchanting", guiBasePosition - 20, height / 2 - 100 + 3, lightGray.getRGB());
}
private void addEnchantmentButtons(){
buttonList.clear();
addStandardButtons();
}
private void genVillagerInfo(){
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/villager.png"));
drawTexturedModalRect(guiBasePosition - 86, height / 2 - 100, 1, 0, 174, 80);
drawString(fontRendererObj, "Villager", guiBasePosition - 17, height / 2 - 100 + 5, lightGray.getRGB());
}
private void addVillagerButtons(){
buttonList.clear();
addStandardButtons();
}
private void genInventoryInfo(){
GL11.glColor4f(1F, 1F, 1F, 1F);
}
private void addInventoryButtons(){
buttonList.clear();
addStandardButtons();
}
private void genDispenserInfo(){
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(new ResourceLocation("textures/gui/container/dispenser.png"));
drawTexturedModalRect(guiBasePosition - 86, height / 2 - 100, 1, 0, 174, 80);
drawString(fontRendererObj, "Dispenser", guiBasePosition - 23, height / 2 - 100 + 5, lightGray.getRGB());
}
private void addDispenserButtons(){
buttonList.clear();
addStandardButtons();
}
private void addStandardButtons(){
// Add control buttons
buttonList.add((new GuiButton(buttonAbortID, width - 53, 3, 50, 20, "Abort")));
buttonList.add((new GuiButton(buttonSaveID, width - 53, 26, 50, 20, "Save")));
//I don't know if you need to change those for every gui
buttonList.add((new GuiButton(buttonShiftID, guiBasePosition + 105, height / 2 - 84, 50, 20, "Shift")));
buttonList.add((new GuiButton(buttonSpaceID, guiBasePosition + 105, height / 2 - 46, 50, 20, "Space")));
//I don't know if you want to change those for every gui
buttonList.add((new GuiButton(buttonStackID, guiBasePosition + 105, height / 2 - 84, 50, 20, "Shift")));
buttonList.add((new GuiButton(buttonDropID, guiBasePosition + 105, height / 2 - 46, 50, 20, "Space")));
//Add Switch Buttons
buttonList.add((new GuiButton(buttonCraftingID, 15, height / 2 + 40, 70, 20, "Crafting")));
buttonList.add((new GuiButton(buttonInventoryID, 15 + 70 + 5, height / 2 + 40, 70, 20, "Inventory")));
@@ -199,9 +257,9 @@ public class GuiConfig extends GuiScreen {
buttonList.add((new GuiButton(buttonBrewingstandID, 15 + 3*70 + 3*5, height / 2 + 40, 90, 20, "Brewing Stand")));
buttonList.add((new GuiButton(buttonDispenserID, 15 + 4*70 + 20 + 4*5, height / 2 + 40, 70, 20, "Dispenser")));
buttonList.add((new GuiButton(buttonVillagerID, 15, height / 2 + 40 + 20 + 4, 70, 20, "Villager")));
buttonList.add((new GuiButton(buttonEnchantmentID, 15 + 70 + 5, height / 2 + 40 + 20 + 4, 70, 20, "Enchantment")));
buttonList.add((new GuiButton(buttonEnchantmentID, 15 + 70 + 5, height / 2 + 40 + 20 + 4, 70, 20, "Enchanting")));
}
//TODO:Get strings from language file(Localizer)...
//TODO:Add things that make this GUI to an Config ... :P
}
@@ -0,0 +1,52 @@
package de.skate702.craftingkeys.manager;
import de.skate702.craftingkeys.util.Logger;
import net.minecraft.inventory.Container;
public class AnvilManager extends ContainerManager {
//TODO:Get it to work...It's just a copy of the brewingManager
private static AnvilManager instance = null;
private AnvilManager(Container container) {
super(container);
}
public static AnvilManager getInstance(Container container) {
if (instance == null) {
instance = new AnvilManager(container);
} else {
instance.container = container;
}
return instance;
}
@Override
protected int specificKeyToSlotIndex() {
return mapKeyToSlot(-1, 3, -1, 0, 1, 2, -1, -1, -1);
}
@Override
protected int getInventoryStartIndex() {
return 4;
}
@Override
protected int getInteractionSlotIndex() {
return -1;
}
@Override
protected void onInteractionKeyPressed() {
Logger.info("onInteractionKeyPressed()", "Brewing stands have no interaction!");
}
@Override
protected int[] getDropSlots() {
return new int[]{0, 1, 2, 3};
}
@Override
protected void interact() {
}
}