Jump to content

Boxtop5000

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Boxtop5000

  1. I've been working, off and on, a mod that adds Diablo-style random loot to the game (I know DiabloDrops exists but it's Bukkit only). I've gotten to the point where I can generate standard items with random lore, names, loot tiers, enchantments, and even the item's durability (by default). I'm currently reorganizing the code so I can add more control over generation. To add a bit more randomness to loot generation, I wanted to have the armor and tools generated to be randomly colored (preferably with one of Minecraft's default 16 colors). I'm sure I can use Minecraft's leather armor coloring code to change the color of my custom armor drops, so I'm not too worried about that, but I'm at a loss as to how to change the color of an item. I've looked around the 'Net to find out how to do this, and have found some tutorials here and there--including the Custom 2D inventory item renderer tutorial and a few on how LWJGL and OpenGL itself handles blending and transparency--yet I'm still unsure of a few things. I'm also not looking for someone to write the code for me; I just need a little direction. 1. I know I need to make a separate renderer for the item, but I'm not quite sure on how to go about building it. Do I need to load the item's texture, set the blend mode/blend function, then color the item and display the colored texture? Do I need to have separate renderers for inventory view and first person mode? I read the Custom 2D Inventory Item tutorial, but that only talked about drawing something on top of the icon in the inventory. 2. How exactly does Minecraft format the color codes for leather armor (i.e., the data stored in the armor's color NBT tag)? Is it a hex value? All RGBA values as one number? I'm asking this because, from the code in ItemArmor, it appears that Minecraft gets the RGB color values through bit manipulation. Discovering that kinda threw me for a loop. Thanks for the help.
  2. Hello, everyone. I originally posted this question on Minecraft's official forums but didn't get a response. What I'm trying to do is create a mod that adds random loot to the game. I've been successful in some regards, but I've run into another problem that's been driving me nuts for days. Specifically, how to give each instance of a tool (in this case, a sword) a separate icon, as well as separate stats, without overriding any previously generated tool with the new tool's data. I've created a chat command (a copy of CommandGive that makes the player drop a random sword generated by the CreateTestTool function below, instead of whatever item the user asks for) as a debug command, but when I generate more than one piece of loot, the icons of the previous pieces of loot change to the icon of the one that was just generated. Likewise, the stats of the previous piece of loot are overwritten with the stats of the new piece of loot. I've been trying to wrap my head around why this happens for almost four days and I still can't figure it out. I can't use damage values to change the icons because these are tools, not items, and I've tried using NBTTags but I must be loading them in wrong because nothing really changes. This is a relatively simple task, so there has to be something key I'm missing. My code is below. First is the function that generates the tool: public ItemStack CreateTestTool() { String name = mod_epicloot.Namer.GenerateFullName(); int damage = LootGenHandler.GenerateDamageValue(); int uses = LootGenHandler.GenerateMaxUses(); int imgid = LootGenHandler.getRandomSwordImgID(); ItemStack is = null; String[] loreText = {mod_epicloot.Namer.GenerateLore(), "", "§r§7 *** DPS: §b" + Integer.toString(((damage + 4))) + " §7(§b" + Double.toString((((damage + 4)/2))) + "§7 hearts)", "§r§7 *** Base Durability: §b" + Integer.toString(uses)}; ItemRandomSword irs = (ItemRandomSword)mod_epicloot.irs; EnumToolMaterial newMat = LootGenHandler.GenToolMaterialEnum(damage, uses); is = new ItemStack(irs, 1); is = LootGenHandler.setIconIndex(is, LootGenHandler.getRandomSwordImgID()); is.getItem().setIconIndex(LootGenHandler.getIconIndex(is)); is = mod_epicloot.Namer.setDisplayName(is, name); is = mod_epicloot.Namer.setLore(is, loreText); return is; } Next, is the ItemRandomSword class. I extended it from Item because I thought that would make things work but it's not much of a change. I'll probably just have it extend from ItemSword again. http://pastebin.com/hYzTJGb8 And, finally, my LootGenHandler class, for reference. Everything is static because I'm stupid and thought that Java class functions had to be static in order to use them (which is only the case if you don't make an instance of the class first). http://pastebin.com/EDBXzRTb Any help would be appreciated. I think after I get over this hurdle, the rest of the mod would be relatively simple. EDIT 11/30/12: Here's my main mod file, if it helps at all: http://pastebin.com/HMbnxRDE And, finally, the code for the debug command I use: package com.boxtop.epicloot; import net.minecraft.src.*; public class CommandGiveRand extends CommandBase { public String getCommandName() { return "gr"; } /** * Return the required permission level for this command. */ public int getRequiredPermissionLevel() { return 0; } public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) { EntityPlayerMP var3 = getCommandSenderAsPlayer(par1ICommandSender); var3.dropPlayerItem(LootGenHandler.CreateTestTool()); par1ICommandSender.sendChatToPlayer("[DEBUG] Gave you a random weapon."); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.