diff --git a/build.gradle b/build.gradle index 0f8011f9..da8706bd 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-0.6.4" +version = "1.7.10-0.6.5" group = "com.darkona.adventurebackpack" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "adventurebackpack" diff --git a/src/main/java/arg/ARG.java b/src/main/java/arg/ARG.java new file mode 100644 index 00000000..53f0c9ee --- /dev/null +++ b/src/main/java/arg/ARG.java @@ -0,0 +1,209 @@ +/** + * Copyright (C) 2013 Flow86 + * + * AdvancedRecipeGenerator is open-source. + * + * It is distributed under the terms of my Open Source License. + * It grants rights to read, modify, compile or run the code. + * It does *NOT* grant the right to redistribute this software or its + * modifications in any form, binary or source, except if expressively + * granted by the copyright holder. + */ + +package arg; + +import java.util.Map; +import java.util.logging.Logger; + +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.init.recipes.AbstractBackpackRecipe; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.RecipeFireworks; +import net.minecraft.item.crafting.RecipesArmorDyes; +import net.minecraft.item.crafting.RecipesMapCloning; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.common.MinecraftForge; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@Mod(modid = ARG.NAME, name = ARG.NAME, version = ARG.VERSION) +public class ARG +{ + public static final String NAME = "Advanced-Recipe-Generator"; + public static final String VERSION = "${version}"; + + @Instance("Advanced-Recipe-Generator") + public static ARG instance; + + public static Logger argLog = Logger.getLogger(NAME); + + public static int[] mapLoaded = {0, 0}; + public static boolean mapGenerated = false; + + @EventHandler + public void load(FMLInitializationEvent evt) + { + argLog.info("Starting " + NAME + " #${buildnumber} " + VERSION + " (Built for Minecraft/Forge ${mc_apiversion}"); + argLog.info("Copyright (c) Flow86, 2012-2014"); + + MinecraftForge.EVENT_BUS.register(this); + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @SubscribeEvent(priority = EventPriority.LOWEST) + @SideOnly(Side.CLIENT) + public void createRecipeImages(TextureStitchEvent.Post evt) + { + mapLoaded[evt.map.getTextureType()]++; + + if (mapLoaded[0] > 0 && mapLoaded[0] == mapLoaded[1]) + { + if (mapGenerated) + { + return; + } + mapGenerated = true; + + argLog.info("Generating Recipes ..."); + + TextureManager tm = Minecraft.getMinecraft().getTextureManager(); + + // save since we get a ConcurrentModificationException in TextureManager.func_110549_a otherwise + + Map mapTextureObjects = ObfuscationReflectionHelper.getPrivateValue(TextureManager.class, tm, "mapTextureObjects", "field_110585_a"); + + Map new_mapTextureObjects = Maps.newHashMap(); + new_mapTextureObjects.putAll(mapTextureObjects); + ObfuscationReflectionHelper.setPrivateValue(TextureManager.class, tm, new_mapTextureObjects, "mapTextureObjects", "field_110585_a"); + + for (Object orecipe : CraftingManager.getInstance().getRecipeList()) + { + IRecipe irecipe = (IRecipe) orecipe; + + if ((irecipe instanceof RecipesArmorDyes) || (irecipe instanceof RecipeFireworks) || (irecipe instanceof RecipesMapCloning)) + { + continue; + } + + if (irecipe.getRecipeOutput() == null) + { + System.out.println("Skip recipe without output: " + irecipe.getClass().getSimpleName()); + continue; + } + + if (irecipe instanceof AbstractBackpackRecipe) + { + AbstractBackpackRecipe abs = new AbstractBackpackRecipe(); + ItemStack b = new ItemStack(ModItems.adventureBackpack, 1); + b.setTagCompound(new NBTTagCompound()); + b.stackTagCompound.setString("colorName", "Standard"); + for (Map.Entry recipe : abs.recipes.entrySet()) + { + RenderRecipe render = new RenderRecipe(recipe.getKey()); + for (int i = 0; i < 9; i++) + { + if (i == 4) + { + render.getCraftingContainer().craftMatrix.setInventorySlotContents(i, b); + } else + { + render.getCraftingContainer().craftMatrix.setInventorySlotContents(i, recipe.getValue()[i]); + } + } + render.getCraftingContainer().craftResult.setInventorySlotContents(0, abs.getCraftingResult(render.getCraftingContainer().craftMatrix)); + render.draw("Adventure Backpack Colors"); + + } + } else + { + continue; + } + + + RenderRecipe render = new RenderRecipe(irecipe.getRecipeOutput().getDisplayName()); + + ItemStack[] recipeInput = null; + try + { + recipeInput = RecipeHelper.getRecipeArray(irecipe); + if (recipeInput == null) + { + continue; + } + } catch (Exception e) + { + e.printStackTrace(); + } + + // Determine mod of this recipe. + UniqueIdentifier identifier = null; + identifier = getUniqueIdentifier(irecipe.getRecipeOutput()); + int recipe = 0; + while (identifier == null && recipeInput != null && recipe < recipeInput.length) + { + ItemStack input = recipeInput[recipe]; + identifier = getUniqueIdentifier(input); + recipe++; + } + String subFolder = "vanilla"; + if (identifier != null) + { + subFolder = identifier.modId; + } + + try + { + for (int i = 0; i < recipeInput.length - 1; ++i) + render.getCraftingContainer().craftMatrix.setInventorySlotContents(i, recipeInput[i + 1]); + + render.getCraftingContainer().craftResult.setInventorySlotContents(0, recipeInput[0]); + render.draw(subFolder); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + // restore map since we get a ConcurrentModificationException in TextureManager.func_110549_a otherwise + ObfuscationReflectionHelper.setPrivateValue(TextureManager.class, tm, mapTextureObjects, "mapTextureObjects", "field_110585_a"); + + argLog.info("Finished Generation of Recipes in " + Minecraft.getMinecraft().mcDataDir + "/recipes/"); + } + } + + private UniqueIdentifier getUniqueIdentifier(ItemStack itemStack) + { + if (itemStack == null || itemStack.getItem() == null) + { + return null; + } + if (itemStack.getItem() instanceof ItemBlock) + { + Block block = Block.getBlockFromItem(((ItemBlock) itemStack.getItem())); + return GameRegistry.findUniqueIdentifierFor(block); + } else + { + return GameRegistry.findUniqueIdentifierFor(itemStack.getItem()); + } + } +} \ No newline at end of file diff --git a/src/main/java/arg/ContainerCraft.java b/src/main/java/arg/ContainerCraft.java new file mode 100644 index 00000000..502f5fe8 --- /dev/null +++ b/src/main/java/arg/ContainerCraft.java @@ -0,0 +1,50 @@ +/** + * Copyright (C) 2013 Flow86 + * + * AdvancedRecipeGenerator is open-source. + * + * It is distributed under the terms of my Open Source License. + * It grants rights to read, modify, compile or run the code. + * It does *NOT* grant the right to redistribute this software or its + * modifications in any form, binary or source, except if expressively + * granted by the copyright holder. + */ + +package arg; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCraftResult; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.inventory.SlotCrafting; + +public class ContainerCraft extends Container +{ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + public IInventory craftResult = new InventoryCraftResult(); + + public ContainerCraft() + { + this.addSlotToContainer(new SlotCrafting(null, this.craftMatrix, this.craftResult, 0, 124, 35)); + int l; + int i1; + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 3; ++i1) + { + this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); + } + } + + this.onCraftMatrixChanged(this.craftMatrix); + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/arg/RecipeHelper.java b/src/main/java/arg/RecipeHelper.java new file mode 100644 index 00000000..1b1089e4 --- /dev/null +++ b/src/main/java/arg/RecipeHelper.java @@ -0,0 +1,175 @@ +/** + * Copyright (C) 2013 Flow86 + * + * AdvancedRecipeGenerator is open-source. + * + * It is distributed under the terms of my Open Source License. + * It grants rights to read, modify, compile or run the code. + * It does *NOT* grant the right to redistribute this software or its + * modifications in any form, binary or source, except if expressively + * granted by the copyright holder. + */ + +package arg; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; + +public class RecipeHelper +{ + @SuppressWarnings("rawtypes") + public static ItemStack[] getRecipeArray(IRecipe irecipe) throws IllegalArgumentException, SecurityException, NoSuchFieldException + { + if (irecipe.getRecipeSize() > 9) + { + return null; + } + ItemStack[] recipeArray = new ItemStack[10]; + recipeArray[0] = irecipe.getRecipeOutput(); + + if ((irecipe instanceof ShapedRecipes)) + { + ShapedRecipes shapedRecipe = (ShapedRecipes) irecipe; + + ItemStack[] recipeInput = shapedRecipe.recipeItems; + + for (int slot = 0; slot < recipeInput.length; slot++) + { + ItemStack item = recipeInput[slot]; + + if ((item != null) && ((item.getItemDamage() == -1) || (item.getItemDamage() == 32767))) + { + item = item.copy(); + item.setItemDamage(0); + } + + int x = slot % shapedRecipe.recipeWidth; + int y = slot / shapedRecipe.recipeWidth; + recipeArray[(x + y * shapedRecipe.recipeWidth) + 1] = item; + } + + } else if ((irecipe instanceof ShapelessRecipes)) + { + ShapelessRecipes shapelessRecipe = (ShapelessRecipes) irecipe; + + List recipeInput = shapelessRecipe.recipeItems; + + for (int slot = 0; slot < recipeInput.size(); slot++) + { + ItemStack item = (ItemStack) recipeInput.get(slot); + + if ((item != null) && (item.getItemDamage() == -1)) + { + item = item.copy(); + item.setItemDamage(0); + } + + recipeArray[slot + 1] = item; + } + + } else if ((irecipe instanceof ShapedOreRecipe)) + { + ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) irecipe; + + Object[] recipeInput = shapedOreRecipe.getInput(); + + for (int slot = 0; slot < recipeInput.length; slot++) + { + Object recipeSlot = recipeInput[slot]; + + if (recipeSlot == null) + { + continue; + } + + if (recipeSlot instanceof ArrayList) + { + ArrayList list = (ArrayList) recipeSlot; + if (list.size() > 1) + { + System.out.println("ERROR: Slot-Array " + (slot + 1) + " has more then one item: " + list); + return null; + } + recipeSlot = list.get(0); + } + + if (recipeSlot instanceof ItemStack) + { + ItemStack item = (ItemStack) recipeSlot; + + if ((item != null) && (item.getItemDamage() == -1)) + { + item = item.copy(); + item.setItemDamage(0); + } + + recipeArray[slot + 1] = item; + + } else + { + System.out.println("Slot " + (slot + 1) + " is type " + recipeSlot.getClass().getSimpleName()); + return null; + } + } + + } else if ((irecipe instanceof ShapelessOreRecipe)) + { + ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) irecipe; + + List recipeInput = shapelessOreRecipe.getInput(); + + for (int slot = 0; slot < recipeInput.size(); slot++) + { + Object recipeSlot = recipeInput.get(slot); + + if (recipeSlot == null) + { + continue; + } + + if (recipeSlot instanceof ArrayList) + { + ArrayList list = (ArrayList) recipeSlot; + if (list.size() > 1) + { + System.out.println("ERROR: Slot-Array " + (slot + 1) + " has more then one item: " + list); + return null; + } + recipeSlot = list.get(0); + } + + if (recipeSlot instanceof ItemStack) + { + ItemStack item = (ItemStack) recipeSlot; + + if ((item != null) && (item.getItemDamage() == -1)) + { + item = item.copy(); + item.setItemDamage(0); + } + + recipeArray[slot + 1] = item; + + } else + { + System.out.println("Slot " + (slot + 1) + " is type " + recipeSlot.getClass().getSimpleName()); + return null; + } + } + + } else + { + System.out.println("Unknown Type: " + irecipe.getClass().getSimpleName()); + return null; + } + + return recipeArray; + } +} \ No newline at end of file diff --git a/src/main/java/arg/RenderRecipe.java b/src/main/java/arg/RenderRecipe.java new file mode 100644 index 00000000..ba6fb0e0 --- /dev/null +++ b/src/main/java/arg/RenderRecipe.java @@ -0,0 +1,314 @@ +/** + * Copyright (C) 2013 Flow86 + * + * AdvancedRecipeGenerator is open-source. + * + * It is distributed under the terms of my Open Source License. + * It grants rights to read, modify, compile or run the code. + * It does *NOT* grant the right to redistribute this software or its + * modifications in any form, binary or source, except if expressively + * granted by the copyright holder. + */ + +package arg; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +import javax.imageio.ImageIO; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.common.registry.LanguageRegistry; + +class RenderRecipe extends GuiContainer +{ + public String name; + private final HashMap incredientList = new HashMap(); + + @SuppressWarnings("rawtypes") + public RenderRecipe(String name) + { + super(new ContainerCraft()); + this.name = name; + mc = Minecraft.getMinecraft(); + fontRendererObj = mc.fontRenderer; + TileEntityRendererDispatcher tileEntityRendererDispatcher = TileEntityRendererDispatcher.instance; + TextureManager renderEngine = tileEntityRendererDispatcher.field_147553_e; + + if (renderEngine == null) + { + renderEngine = mc.renderEngine; + Iterator iterator = tileEntityRendererDispatcher.mapSpecialRenderers.values().iterator(); + + while (iterator.hasNext()) + { + TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer) iterator.next(); + tileentityspecialrenderer.func_147497_a(tileEntityRendererDispatcher); + } + } + + xSize = 176; + ySize = 155; + + width = xSize * 3; + height = ySize * 3; + } + + public ContainerCraft getCraftingContainer() + { + return (ContainerCraft) this.inventorySlots; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int k = this.guiLeft; + int l = this.guiTop; + this.drawGuiContainerBackgroundLayer(par3, par1, par2); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glPushMatrix(); + GL11.glTranslatef(k, l, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + short short1 = 240; + short short2 = 240; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, short1 / 1.0F, short2 / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + // crafting result + drawSlotInventory((Slot) inventorySlots.inventorySlots.get(0)); + + incredientList.clear(); + + for (int j1 = 1; j1 < inventorySlots.inventorySlots.size(); ++j1) + { + Slot slot = (Slot) inventorySlots.inventorySlots.get(j1); + drawSlotInventory(slot); + } + + this.drawGuiContainerForegroundLayer(par1, par2); + + GL11.glPopMatrix(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + } + + /** + * Draws an itemstack at a specific position + */ + protected void drawItemStackAtPosition(ItemStack itemstack, int x, int y) + { + if (itemstack == null) + { + return; + } + + this.zLevel = 100.0F; + itemRender.zLevel = 100.0F; + + String s = null; + if (itemstack.stackSize > 1) + { + s = "" + itemstack.stackSize; + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x, y); + itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, itemstack, x, y, s); + + itemRender.zLevel = 0.0F; + this.zLevel = 0.0F; + } + + /** + * Draws an inventory slot + */ + protected void drawSlotInventory(Slot slot) + { + ItemStack itemstack = slot.getStack(); + + if (itemstack == null) + { + return; + } + + itemstack.stackSize = 1; + + if (!incredientList.containsKey(itemstack.getDisplayName())) + { + incredientList.put(itemstack.getDisplayName(), itemstack); + } + + drawItemStackAtPosition(itemstack, slot.xDisplayPosition, slot.yDisplayPosition); + } + + protected int getCenteredOffset(String string, int xWidth) + { + return (xWidth - fontRendererObj.getStringWidth(string)) / 2; + } + + @Override + public void drawGuiContainerForegroundLayer(int i, int j) + { + super.drawGuiContainerForegroundLayer(i, j); + + String title = LanguageRegistry.instance().getStringLocalization(getCraftingContainer().craftResult.getStackInSlot(0).getDisplayName()); + fontRendererObj.drawString(title, getCenteredOffset(title, xSize), 5, 0x404040); + + float scale = 3 / 4F; + + // since we scale by 1/2, we have to start on *2 + int[] baseX = {(int) (10 * (1F / scale)), (int) (100 * (1F / scale))}; + int baseY = (int) (76 * (1F / scale)); + + GL11.glScalef(scale, scale, 1.0F); + + int item = 0; + int y = baseY; + for (Entry entry : incredientList.entrySet()) + { + + int x = baseX[incredientList.size() < 5 ? 0 : (item < incredientList.size() / 2 ? 0 : 1)]; + if (incredientList.size() < 5 ? false : (item == incredientList.size() / 2)) + { + y = baseY; + } + + String name = entry.getKey(); + if (incredientList.size() >= 5) + { + name = fontRendererObj.trimStringToWidth(name, (int) ((100 - 10 - 18) * (1F / scale))); + } + + fontRendererObj.drawString(name, x + 18, y + 4, 0x404040); + drawItemStackAtPosition(entry.getValue(), x, y); + y += 18; + item++; + } + GL11.glScalef(1F / scale, 1F / scale, 1.0F); + } + + @Override + public void drawBackground(int par1) + { + + } + + public void draw(String subFolder) + { + + File dir = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + subFolder.replace('|', '-')); + if (!dir.exists() && !dir.mkdirs()) + { + throw new RuntimeException("The recipes directory could not be created: " + dir); + } + + name = name.replace(" ", ""); + File file = new File(Minecraft.getMinecraft().mcDataDir, "recipes/" + subFolder + "/" + name + ".png"); + + if (file.exists()) + { + return; + } + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glPushClientAttrib(GL11.GL_ALL_CLIENT_ATTRIB_BITS); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glViewport(0, 0, width, height); + GL11.glOrtho(0.0D, xSize, ySize, 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + GL11.glLineWidth(1.0F); + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + + try + { + drawScreen(0, 0, 0); + } catch (Exception e) + { + e.printStackTrace(); + } + + ByteBuffer fb = ByteBuffer.allocateDirect(width * height * 3); + + GL11.glReadPixels(0, 0, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, fb); + GL11.glPopMatrix(); + GL11.glPopAttrib(); + GL11.glPopClientAttrib(); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + try + { + Display.swapBuffers(); + } catch (LWJGLException e1) + { + e1.printStackTrace(); + } + + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + + for (int x = 0; x < width; x++) + { + for (int y = 0; y < height; y++) + { + int i = (x + (width * y)) * 3; + int r = fb.get(i) & 0xFF; + int g = fb.get(i + 1) & 0xFF; + int b = fb.get(i + 2) & 0xFF; + image.setRGB(x, height - (y + 1), (0xFF << 24) | (r << 16) | (g << 8) | b); + } + } + + try + { + ImageIO.write(image, "png", file); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int i, int j) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + this.mc.renderEngine.bindTexture(new ResourceLocation("arg", "textures/gui/crafting.png")); + drawTexturedModalRect(0, 0, 0, 0, xSize, ySize); + // GL11.glDisable(GL11.GL_TEXTURE_2D); + } +} \ No newline at end of file diff --git a/src/main/java/com/darkona/adventurebackpack/common/AdvBackpackEProperty.java b/src/main/java/com/darkona/adventurebackpack/common/AdvBackpackEProperty.java new file mode 100644 index 00000000..d27d872a --- /dev/null +++ b/src/main/java/com/darkona/adventurebackpack/common/AdvBackpackEProperty.java @@ -0,0 +1,92 @@ +package com.darkona.adventurebackpack.common; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.IExtendedEntityProperties; + +/** + * Created on 24/10/2014 + * + * @author Darkona + */ +public class AdvBackpackEProperty implements IExtendedEntityProperties +{ + + public final static String PROPERTY_NAME = "AdvBackpackProperty"; + private final EntityPlayer player; + + private ItemStack backpack; + + public AdvBackpackEProperty(EntityPlayer player) + { + this.player = player; + backpack = null; + } + + public static final void register(EntityPlayer player) + { + player.registerExtendedProperties(PROPERTY_NAME, new AdvBackpackEProperty(player)); + } + + public static final AdvBackpackEProperty get(EntityPlayer player) + { + return (AdvBackpackEProperty) player.getExtendedProperties(PROPERTY_NAME); + } + + /** + * Called when the entity that this class is attached to is saved. + * Any custom entity data that needs saving should be saved here. + * + * @param compound The compound to save to. + */ + @Override + public void saveNBTData(NBTTagCompound compound) + { + NBTTagCompound stupidComplexThing = new NBTTagCompound(); + stupidComplexThing.setTag("adventureBackpack", backpack.writeToNBT(new NBTTagCompound())); + compound.setTag(PROPERTY_NAME, stupidComplexThing); + + } + + /** + * Called when the entity that this class is attached to is loaded. + * In order to hook into this, you will need to subscribe to the EntityConstructing event. + * Otherwise, you will need to initialize manually. + * + * @param compound The compound to load from. + */ + @Override + public void loadNBTData(NBTTagCompound compound) + { + backpack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("adventureBackpack")); + } + + /** + * Used to initialize the extended properties with the entity that this is attached to, as well + * as the world object. + * Called automatically if you register with the EntityConstructing event. + * May be called multiple times if the extended properties is moved over to a new entity. + * Such as when a player switches dimension {Minecraft re-creates the player entity} + * + * @param entity The entity that this extended properties is attached to + * @param world The world in which the entity exists + */ + @Override + public void init(Entity entity, World world) + { + + } + + public void setBackpack(ItemStack bp) + { + backpack = bp; + } + + public ItemStack getBackpack() + { + return backpack; + } +} diff --git a/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java b/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java index 93aa3399..8227dc19 100644 --- a/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java @@ -14,7 +14,7 @@ public class ConfigHandler { public static Configuration config; - public static boolean testValue = false; + public static boolean backpackSlot = false; public static int GUI_TANK_RENDER = 2; public static void init(File configFile) @@ -29,7 +29,7 @@ public static void init(File configFile) private static void loadConfiguration() { - testValue = config.getBoolean("testValue", config.CATEGORY_GENERAL, false, "This is a test configuration value"); + backpackSlot = config.getBoolean("testValue", config.CATEGORY_GENERAL, false, "Use backpacks in armor slot?"); GUI_TANK_RENDER = config.getInt("TankRenderType", config.CATEGORY_GENERAL, 3, 1, 3, "1,2,3 for different rendering of fluids in the Backpack GUI"); if (config.hasChanged()) { diff --git a/src/main/resources/assets/adventurebackpack/lang/es_ES.lang b/src/main/resources/assets/adventurebackpack/lang/es_ES.lang index ebc2dc7b..f286448e 100644 --- a/src/main/resources/assets/adventurebackpack/lang/es_ES.lang +++ b/src/main/resources/assets/adventurebackpack/lang/es_ES.lang @@ -10,14 +10,16 @@ item.adventurebackpack:backpackHose.name=Manquera de Mochila item.adventurebackpack:adventureSuit.name=Traje de Aventurero item.adventurebackpack:adventureHat.name=Fedora de Aventurero item.adventurebackpack:pistonBoots.name=Botas Pistón -item.adventurebackpack:hose.leftTank.suck.name=Manquera: Tanque Izq. / Modo Succión -item.adventurebackpack:hose.leftTank.spill=Manguera: Tanque Izq. / Modo Vertir -item.adventurebackpack:hose.leftTank.drink=Manguera: Tanque Izq. / Modo Beber -item.adventurebackpack:hose.rightTank.suck.name=Manguera: Tanque Der. / Modo Succión -item.adventurebackpack:hose.rightTank.spill.name=Manguera: Tanque Der. / Modo Vertir -item.adventurebackpack:hose.rightTank.drink.name=Manguera: Tanque Der. / Modo Beber +item.adventurebackpack:hose_leftTank_suck.name=Manquera: Tanque Izq. / Modo Succión +item.adventurebackpack:hose_leftTank_spill.name=Manguera: Tanque Izq. / Modo Vertir +item.adventurebackpack:hose_leftTank_drink.name=Manguera: Tanque Izq. / Modo Beber + + +item.adventurebackpack:hose_rightTank_suck.name=Manguera: Tanque Der. / Modo Succión +item.adventurebackpack:hose_rightTank_spill.name=Manguera: Tanque Der. / Modo Vertir +item.adventurebackpack:hose_rightTank_drink.name=Manguera: Tanque Der. / Modo Beber item.adventurebackpack:hoseUseless=Hose: Inútil / Sin Mochila diff --git a/src/main/resources/assets/adventurebackpack/lang/zh_CN.lang b/src/main/resources/assets/adventurebackpack/lang/zh_CN.lang index 5c969667..ca778484 100644 --- a/src/main/resources/assets/adventurebackpack/lang/zh_CN.lang +++ b/src/main/resources/assets/adventurebackpack/lang/zh_CN.lang @@ -10,14 +10,15 @@ item.adventurebackpack:backpackHose.name=背包软管 item.adventurebackpack:adventureSuit.name=探险者外套 item.adventurebackpack:adventureHat.name=探险者软呢帽 item.adventurebackpack:pistonBoots.name=活塞靴子 -item.adventurebackpack:hose.leftTank.suck.name=软管:左侧储水箱 / 吸取模式 -item.adventurebackpack:hose.leftTank.spill=软管:左侧储水箱 / 喷洒模式 -item.adventurebackpack:hose.leftTank.drink=软管:左侧储水箱 / 饮水模式 +item.adventurebackpack:hose_leftTank_suck.name=软管:左侧储水箱 / 吸取模式 +item.adventurebackpack:hose_leftTank_spill.name=软管:左侧储水箱 / 喷洒模式 +item.adventurebackpack:hose_leftTank_drink.name=软管:左侧储水箱 / 饮水模式 -item.adventurebackpack:hose.rightTank.suck.name=右侧储水箱 / 吸取模式 -item.adventurebackpack:hose.rightTank.spill.name=右侧储水箱 / 喷洒模式 -item.adventurebackpack:hose.rightTank.drink.name=右侧储水箱 / 饮水模式 + +item.adventurebackpack:hose_rightTank_suck.name=右侧储水箱 / 吸取模式 +item.adventurebackpack:hose_rightTank_spill.name=右侧储水箱 / 喷洒模式 +item.adventurebackpack:hose_rightTank_drink.name=右侧储水箱 / 饮水模式 item.adventurebackpack:hoseUseless=软管:无法使用 / 没有储水箱 diff --git a/src/main/resources/assets/arg/textures/gui/crafting.png b/src/main/resources/assets/arg/textures/gui/crafting.png new file mode 100644 index 00000000..ef1d0fb0 Binary files /dev/null and b/src/main/resources/assets/arg/textures/gui/crafting.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index bbbb7b30..bc867dc7 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "adventurebackpack", "name": "Adventure Backpack", "description": "Useful and pretty backpacks for Minecraft", - "version": "1.7.10-0.6.4", + "version": "1.7.10-0.6.5", "mcversion": "1.7.10", "url": "", "updateUrl": "",