
StrangeOne101
Members-
Posts
48 -
Joined
-
Last visited
Everything posted by StrangeOne101
-
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Ok. Now to change my data, what do I do? I actually don't have a clue. Sorry. -
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Ok, but in "setItemData", it looks like I'm setting kind of the same string, just ones in the class. This is very confusing. Thanks for your help, though. -
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Can you possibly elaborate on that or give an example? I have my new class, extending WorldSavedData and with the data I want to keep in the NBT tag read/write methods. What now? Sorry, I'm not very advanced with modding. -
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
I've done a lot of googling and searching but all I can find is tutorials for Tile Entities. It would work, but it's not what I want considering that there will be no way of tracking where it is. So to elaborate, a TileEntity would be good but it uses coords, not a global variable. -
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Actually, I would prefer if it if the date was tested when the player logs into a world. Just thought I'd add that. -
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
I just want to check if the date (within month) is equal to a value, so then I can run some code, and only allow it to be repeated the year after. Kind of like a one day a year thing. To do that, I need it to record if the event has been run and stuff. Do I need to elaborate more? -
Item Not Doing what it should [Unsolved]
StrangeOne101 replied to StrangeOne101's topic in Modder Support
I'll have a look at the code soon. And I've checked the TileEntity for chests. I've got the calender stuff all working, I just need a method to keep checking it with. -
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par2World.isRemote) { EntityItem item = new EntityItem(par2World, x, y z, new ItemStack(yourmod.youritem.itemID, 1)); par2World.spawnEntityInWorld(item); } return par1ItemStack; }
-
I have two main things I want to get done today, but I need help with them. I have changed the question, too. Edit: Scroll down to the bottom of the page. I have a problem with my item. As I've said before, I'm new to forge. So I have no idea. Thanks
-
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Thanks. Kinda funny when you think about it. Lol. -
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
It's just the same error. I think it doesn't like my code returning a random. Which is stupid, considering that the random returns an int. I have no idea how to fix this. -
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
I've redone the way it chooses the random item now, through the config file's list of ids. By default, I've put only vanilla IDs in. But you are right. I do need to post my code if I ever want this fixed. [spoiler=ItemEasterEgg] package so101.eastersurprise.eggs; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; import cpw.mods.fml.relauncher.*; import so101.eastersurprise.Main; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; public class ItemEasterEgg extends Item { protected Icon[] icon = new Icon[5]; private Random random; private int randItem; protected int[] items; public ItemEasterEgg(int par1) { super(par1); setCreativeTab(CreativeTabs.tabMaterials); setMaxStackSize(1); setHasSubtypes(true); } /**Adds the texture from the directory stated**/ @Override public void updateIcons(IconRegister ir) { icon[0] = ir.registerIcon("EasterSurpriseMod:blue"); icon[1] = ir.registerIcon("EasterSurpriseMod:yellow"); icon[2] = ir.registerIcon("EasterSurpriseMod:green 2"); icon[3] = ir.registerIcon("EasterSurpriseMod:pink"); icon[4] = ir.registerIcon("EasterSurpriseMod:purple"); //icon[5] = ir.registerIcon("EasterSurpriseMod:purple"); } @SideOnly(Side.CLIENT) public Icon getIconFromDamage(int i) { //return icon[i*2+random.nextInt(1)]; return icon[i]; } public int getRandomItemByRarity() { this.items[0] = 43; this.items[1] = 24; this.items[2] = 20; return items[random.nextInt(3)]; } public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if (par1ItemStack.getItemDamage()==4) { par2EntityPlayer.addStat(Main.EasterEggRareAch, 1); } par2EntityPlayer.addExperience(15); par2EntityPlayer.addScore(3+(this.getMetadata(this.itemID)*2)); RandomItemSelect ris = new RandomItemSelect(); ItemStack item = new ItemStack(ris.getItemFromRarity(par1ItemStack.getItemDamage()), 1, 0); par1ItemStack.stackSize--; par3World.spawnEntityInWorld(new EntityItem(par3World, par4, par5, par6, item)); return true; } @SideOnly(Side.CLIENT) public void getSubItems(int itemID, CreativeTabs tab, List itemList) { for(int i=0;i<5;i++) { itemList.add(new ItemStack(itemID,1,i)); } } } [spoiler=RandomItemSelect] package so101.eastersurprise.eggs; import java.util.Random; import so101.eastersurprise.Main; import so101.eastersurprise.client.ConfigEasterSurprise; public class RandomItemSelect { private int i; private Random rand; private ConfigEasterSurprise cc = Main.cc; private int[] commonIDs; private int commonIDLength; private int[] uncommonIDs; private int uncommonIDLength; private int[] rareIDs; private int rareIDLength; public RandomItemSelect() { commonIDLength = cc.toStringArray.length; uncommonIDLength = cc.toStringArray2.length; rareIDLength = cc.toStringArray3.length; commonIDs = cc.commonIDs; uncommonIDs = cc.commonIDs; rareIDs = cc.commonIDs; } protected int getCommonID() { return commonIDs[rand.nextInt(commonIDLength)]; } protected int getUncommonID() { return uncommonIDs[rand.nextInt(uncommonIDLength)]; } protected int getRareID() { return rareIDs[rand.nextInt(rareIDLength)]; } public int getItemFromRarity(int rarity) { switch(rarity) { case 0: return getCommonID(); case 1: return getCommonID(); case 2: return getUncommonID(); case 3: return getUncommonID(); case 4: return getRareID(); } return getCommonID(); } } [spoiler=ConfigEasterEggs] package so101.eastersurprise.client; import java.awt.List; import java.lang.reflect.Array; import net.minecraft.block.Block; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Property; import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class ConfigEasterSurprise { public static int easterEggID; public static String[] toStringArray; public static String[] toStringArray2; public static String[] toStringArray3; public static int[] commonIDs; public static int[] uncommonIDs; public static int[] rareIDs; public static void loadConfig(FMLPreInitializationEvent e) { Configuration config = new Configuration(e.getSuggestedConfigurationFile()); //Gets the file config.load(); //Loads it /** Items **/ Property easteregg; //This is a property, see below easteregg = config.getItem("Easter Egg ID", 28600); //This gets the property easteregg.comment = "Deafult ID for the Easter Eggs."; //This adds a comment easterEggID = easteregg.getInt(); //This gets the value String easterEggCommonIDs; easterEggCommonIDs = config.get(Configuration.CATEGORY_GENERAL, "Common IDs", "1,2,3,4,5,6,12,13,17,18,20,23,24,25,27,28,29,31,33,37,38,39,40,43,44,45,47,48,50,53,54,55,61,65,66,67,69,70,72,76,77,80,81,82,84,85,86,87,88,89,91,96,97,98,99,100,101,102,103,105,107,105,109,111,112,113,114,123,125,126,125,134,135,136,139,143,145,146,147,148,151,155,157,158,259,260,261,262,263,268,269,270,271,272,273,274,275,280,281,282,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,318,319,320,321,323,324,325,326,328,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,384,385,386,388,389,390,391,392,393,394,395,396,397,398,399,400,401,404,405,406,407,408,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,264,265,266,267").getString(); config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, "All the item IDs that the easter eggs can give you. DO NOT leave spaces in the ID list or it won't work."); toStringArray = easterEggCommonIDs.split(","); commonIDs = new int[toStringArray.length]; for(int i = 0; i < toStringArray.length; i++) { try { commonIDs[i] = Integer.parseInt(toStringArray[i]); } catch(NumberFormatException numberFormatException) { numberFormatException.printStackTrace(); } } String easterEggUnCommonIDs; easterEggUnCommonIDs = config.get(Configuration.CATEGORY_GENERAL, "Uncommon IDs", "2,14,15,16,19,30,41,42,46,47,48,49,79,84,89,97,110,111,121,122,129,130,133,145,152,153,256,257,258,267,283,284,285,286,293,302,303,304,305,306,307,308,309,314,315,316,317,322,327,345,347,354,368,378,369,379,381,384,407").getString(); //config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, "All the item IDs that uncommon easter eggs can give you."); toStringArray2 = easterEggCommonIDs.split(","); uncommonIDs = new int[toStringArray.length]; for(int i = 0; i < toStringArray.length; i++) { try { uncommonIDs[i] = Integer.parseInt(toStringArray[i]); } catch(NumberFormatException numberFormatException) { numberFormatException.printStackTrace(); } } String easterEggRareIDs; easterEggRareIDs = config.get(Configuration.CATEGORY_GENERAL, "Rare IDs", "52,57,116,122,130,133,138,145,152,276,277,278,279,310,311,312,313,322,329,399").getString(); //config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, "All the item IDs that common easter eggs can give you."); toStringArray3 = easterEggCommonIDs.split(","); rareIDs = new int[toStringArray.length]; for(int i = 0; i < toStringArray.length; i++) { try { rareIDs[i] = Integer.parseInt(toStringArray[i]); } catch(NumberFormatException numberFormatException) { numberFormatException.printStackTrace(); } } //General config.save(); } } Ask if you don't understand some parts. -
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Is there another way around using the random variable instead? I've seen in the vanilla code things like "a ? b : c" but have no idea how it works. -
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Yes. It can return a normal int, but any form of random will make it crash. I can't think of any other way into making this happen. Damn shame, since I was going to try and release this for Easter. Thanks for your help though. -
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
At the moment, getRandomItemByRarity() only returns "random.nextInt(256)+1". I will actually add the ids I need later but I want to get this working first. -
Item returning random item when used? - Solved
StrangeOne101 replied to StrangeOne101's topic in Modder Support
Same error. Thanks for your input, though. -
I'm making an item that returns or just adds a random item from a list of ids to the players inventory. Everytime I use the item, the game crashes. So far, I've tried... public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ItemStack item = new ItemStack(this.randItem, 1, 0); return item; } and... public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { ItemStack item = new ItemStack(this.getRandomItemfromList(), 1, 0); par1ItemStack.stackSize--; par2EntityPlayer.inventory.addItemStackToInventory(item); return true; } Both end in a crash. Could someone please help me? Thanks.
-
"this.potionDuration * 20" It's in ticks. Every second in minecraft is equal to 20 ticks. That's why there's the "* 20" bit.
-
Meta data items registering with the same name
StrangeOne101 replied to jordan30001's topic in Modder Support
public String getItemDisplayName(ItemStack is) { switch (is.getItemDamage()) { case 0: return "Topaz"; case 1: return "Smoked Topaz"; case 2: return "Ruby"; case 3: return "Pad Paradsha"; //Etc Etc. I know they aren't in the right order, but oh well. You get the point. } return "Unknown Gem Item"; } -
Thanks. Sorry for the confusion.
-
I may be new to the forums, but I am not thick. I've googled it lots of times, and searched it on the forums. I'm wanting something like this in the config file: blockToInterect: { -19 -4 -52 } something where the users can add to the list if they wish.
-
I'd like my config file to contain a list of block ids that my entities can interact with. I have no idea how to do it. I've played around with it but still haven't got a way. Anyone know an easy way of doing this? Thanks.