Everything posted by Draco18s
-
[1.7.10] Recipe remover mod
Config files support arrays already. config.get(String category, String key, String[] defaultValues)
-
[1.7.10] List-boxes - scrolling
You're almost certainly going to have to code it yourself. List boxes aren't commonly used in Minecraft.
-
[1.7.10] Recipe remover mod
package com.draco18s.hardlib; import java.util.ArrayList; import java.util.Map; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; public class RecipesUtil { public static void RemoveRecipe(Item resultItem, int stacksize, int meta, String modID) { ItemStack resultStack = new ItemStack(resultItem, stacksize, meta); ItemStack recipeResult = null; ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList(); for (int scan = 0; scan < recipes.size(); scan++) { IRecipe tmpRecipe = (IRecipe) recipes.get(scan); if (tmpRecipe instanceof ShapedRecipes) { ShapedRecipes recipe = (ShapedRecipes)tmpRecipe; recipeResult = recipe.getRecipeOutput(); } if (tmpRecipe instanceof ShapelessRecipes) { ShapelessRecipes recipe = (ShapelessRecipes)tmpRecipe; recipeResult = recipe.getRecipeOutput(); } if (ItemStack.areItemStacksEqual(resultStack, recipeResult)) { System.out.println(modID + " Removed Recipe: " + recipes.get(scan) + " -> " + recipeResult); recipes.remove(scan); } } } public static void RemoveSmelting(Item resultItem, int stacksize, int meta, String modID) { ItemStack resultStack = new ItemStack(resultItem, stacksize, meta); ItemStack recipeResult = null; Map recipes = FurnaceRecipes.smelting().getSmeltingList(); for (int scan = 0; scan < recipes.size(); scan++) { ItemStack tmpRecipe = (ItemStack) recipes.get(scan); if (ItemStack.areItemStacksEqual(resultStack, recipeResult)) { System.out.println(modID + " Removed Smelting: " + recipes.get(scan) + " -> " + recipeResult); recipes.remove(scan); } } } } Removes a crafting or smelting recipe that has a result of the given item, stacksize, and metadata.
-
[1.7.10] How to include and reference text file?
Likely because we don't know the wheel exists.
-
[1.7.10] How to include and reference text file?
Here's a class I use to unpack some custom COG files, which is based off how COG unpacks its config files (COG is also open source). package com.draco18s.hardlib; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import cpw.mods.fml.common.Loader; public class CogConfig { private static List<String> extraModules = new ArrayList<String>(); public static void addCogModule(String name) { extraModules.add(name); } public static void unpackConfigs() { File configPath = getConfigDir(); File defaultModulesDir = new File(modulesDir, "custom"); //TODO change this if you don't need a sub-folder or want a different name if (!defaultModulesDir.exists()) { defaultModulesDir.mkdir(); } for (String module : extraModules) { File writeFile = new File(defaultModulesDir, module); if(!writeFile.exists()) { unpackConfigFile(module, writeFile); } } } private static boolean unpackConfigFile(String configName, File destination) { String resourceName = "cog_config/" + configName; //TODO: change this to point to your resource location, which is inside "src/main/resources", eg. this currently points to "src/main/resources/cog_config" try { InputStream ex = HardLib.class.getClassLoader().getResourceAsStream(resourceName); BufferedOutputStream streamOut = new BufferedOutputStream(new FileOutputStream(destination)); byte[] buffer = new byte[1024]; boolean len = false; int len1; while ((len1 = ex.read(buffer)) >= 0) { streamOut.write(buffer, 0, len1); } ex.close(); streamOut.close(); return true; } catch (Exception var6) { throw new RuntimeException("Failed to unpack resource \'" + resourceName + "\'", var6); } } private static File getConfigDir() { return new File(Loader.instance().getConfigDir(), "CustomOreGen");//TODO: change this to point to you desired config location } } It's flexible enough that you should be able to alter it to handle whatever file or files you want.
-
Block with composite texture
For a 1.6.4 micromod that I've since misplaced the code for (no really, I was syncing everything to dropbox and somewhere along the way I deleted the folders for everything pre-1.6.4). Sure. 1.6.4.? Nein, 1.5.1. and 1.6.2 It's one I do want to remake for 1.7 though, it's very useful. I'd drop the slope support though, it was slightly buggy (the custom rail required air below it, so if you tried to connect a slope to a vanilla rail that was on the ground, it would work....until that rail received a block update).
-
Block with composite texture
And even then you'll fuck it up once in a while. Doing this correctly took me like four hours even with a properly labeled drawing of which faces face which direction and have to be constructed in what order.
-
[SOLVED][1.7.10] ItemStack not saving NBT data
oops, you're right. The badly named variable names were making me see it as "var1.stackTagCompound == null; var1.stackTagCompound.setTag(...)"
-
[SOLVED][1.7.10] ItemStack not saving NBT data
if (var1.stackTagCompound == null) { var1.setTagCompound(varData); //this will crash } else { //do nothing }
- .
-
running my mod
Congratulations, it's running! Unless you made a coding error, your recipe works!
-
Different texture in inventory?
Or you can give it whatever texture you want, then tell shouldSideRender() to return false all the time.
-
Walkthrough blocks?
Primarily you need: @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { return null; }
-
[1.8] Q. can I get the actual world and the actual EntityPlayer from other class
That code will always get the local player. However, that code will crash a server.
-
[1.8] Q. can I get the actual world and the actual EntityPlayer from other class
These gears have no meaning unless you're trying to use keybinds to affect an object in the world. If that's the case, you need packets. If you're doing something entirely client side, you don't need a world and player reference at all and should be looking into playing client-side-only sounds.
-
Making a custom mob
Sheep, cows, pigs, and chickens can't be tamed. They just are. "Tame" is an aspect of hostile mobs, such as the wolf, ocelot, and iron golem.
-
[1.8] Adding shapeless recipes <NOT SOLVED>
Items.dye (meta 15) http://minecraft.gamepedia.com/Bonemeal (look at the panel on the right)
-
[1.8] Q. can I get the actual world and the actual EntityPlayer from other class
This code literally makes no sense. Where is mgear() called from? Why does it return a string and play a sound? Why not pass it a world and player parameter when its called?
-
[1.7.x] addShapedRecipe with item stacks
Recipes don't work that way.
-
New modder getting started - looking for some guidance
Aside from some method renaming and a annotation renaming, 1.6.4 guides are 98% identical to 1.7 code. It's really really easy. I thought there were big changes I had to pay attention to, but as it turned out it was pretty much same-ol same-ol.
-
[Solved]Importing .obj into Minecraft and Handle it as a Placeable Block
*Cough* Client proxy. *Cough*
-
New modder getting started - looking for some guidance
You mean http://www.minecraftforge.net/wiki/ ? The wiki has all kinds of things http://www.minecraftforge.net/forum/index.php/board,120.0.html ? This board has tutorials, though dominated by 1.8 things, but there's still 1.7 stuff in the archives http://www.minecraftforge.net/forum/index.php/board,118.0.html ? This board has everything to do with Forge Gradle, the "replacement" to MCP
-
[Solved]Importing .obj into Minecraft and Handle it as a Placeable Block
This is basic stuff dude. The block and the renderer are separate and distinct classes. To register the renderer, you need to do this (from my own project): TileEntitySpecialRenderer render = new TESRWindvane(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWindvane.class, render); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(OresBase.blockvane), new ItemModelRenderer(render, new TileEntityWindvane()));
-
[SOLVED] [1.7.10] Chunkloading Block
I noticed something: ticket.getModData().setInteger("coreX",xCoord);//set X to X ticket.getModData().setInteger("coreX",yCoord);//set X to Y ticket.getModData().setInteger("coreX",zCoord);//set X to Z Uh?
-
[1.7.10] Getting Block Coordinates
Also, your TileEntity's constructor MUST take NO parameters or things will go weird, fast.
IPS spam blocked by CleanTalk.