• 0

    posted a message on Item ID Problem
    Please supply code? but it seems you are using the same ID as something else.
    Posted in: Mods Discussion
  • 0

    posted a message on [solved]How to detect if it is raining using code?
    The world can be raining, but you may not even see it because it only rains in specific spots, sometimes if you move far enough you can still hear it, but the rain is not visible. If you could find a way to detect if rain is falling on that specific block, instead of anywhere in the world then it would be even better.
    Posted in: Mods Discussion
  • 0

    posted a message on [Help] Custom Block/Item ID
    You can look up BufferedReader in java, as well as BufferedWriter, then before making the ids read the files and parse the integer from the file.

    Integer.parseInt(string)
    Posted in: Mods Discussion
  • 0

    posted a message on Update an item on Tick
    for(ItemStack itemstack : player.getInventory()){
        if(itemstack.getItem() instanceof YourItem){
            ((YourItem)itemstack.getItem()).onUpdate();
        }
    }


    However I realized that it will give you a nnew instance of that item in the slot, so it's a little more advanced. Instead of having the method in your class, what you would do is every 100 ticks you'd cycle through the inventory and for each item of your type heal it.

    for(ItemStack itemstack : player.getInventory()){
        if(itemstack.getItem() instanceof YourItem){
            itemstack.damageItem(-1, null);//you may want to heal more than 1 however
            //healing one use every 100 ticks is REALLY slow, it would take over 100,000 for diamond (for example)
        }
    }
    Posted in: Modification Development
  • 1

    posted a message on Update an item on Tick
    That makes perfect sense, there are several ways to accomplish this, and probably some that people don't even know yet. Good luck.

    Here is another suggestion, In you're tool class make a method called onTick(), then with the ModLoader onTickInGame() in your main class or somewhere, cycle through the inventory every 100 ticks and if the item is instanceof YourItemClass, cast to that class and call its onTick() method. cause you can use the onTickInGame() other ways, however you may not get the best results if it's only affecting the class, you would want to use it on all the instances of the item.
    Posted in: Modification Development
  • 0

    posted a message on Update an item on Tick
    Quote from Builder4Free

    Create a for loop to increase the damage +1/-1 every tick, this is easier than finding a way to implement time in it.

    NEVER do that! While looping it will just freeze the entire game until the loop is done.


    Quote from Dreagar

    Could you give me an example of this, I'm not that good at for loops. :/


    A better way, although harder, but more reliable, if to edit Item.java to have a method called updateTick() and a void called onUpdate(), in which it does nothing. then hijack the updateTick() from any existing block that uses it and call Item.onUpdate(), in onUpdate() in the Item class you should call the updateTick method for each item stored in Item.java. Old Items will not be affected, as it will just run the updateTick() it gets from it's superclass, which does nothing. However, on your Item, override the updateTick() method and add 1 to a variable until you get to 100 and do something.
    Posted in: Modification Development
  • 0

    posted a message on how do i take away a whole itemstack?
    well, what you should do is cycle through the inventory to find the logs, when you find a log itemstack get its value, if it is less than then find how much more is needed to reach 64 logs.

    Set the itemstack to null:

    itemstack=null;


    and then cycle through to find the next log stack in the inventory, 4 possibilities:

    1 : There is none left, just exit, no use doing anything, they have no logs.
    2 : you find a stack with less then the needed number of logs, in which case you repeat the first step for this itemstack.
    3 : you find a stack with exactly what you need and you set it to null and exit.
    4 : you find one with more than the needed amount and you subtract the needed amount from the current amount.

    int needed = 64;
    for(ItemStack itemstack : player.getInventory())
    {
    	if(needed <= 0)
    	{
    		return;
    	}
    	if(itemstack.itemId() == Block.log)
    	{
    		if(itemstack.stackSize == needed)
    		{
    			itemstack = null;
    			needed = 0;	
    		}
    		else if(itemstack.stackSize < needed)
    		{
    			needed -= itemstack.stackSize;
    			itemstack = null;
    		}
    		else
    		{
    			itemstack.stackSize -= needed;
    			needed = 0;
    		}	
    	}
    }
    Posted in: Modification Development
  • 0

    posted a message on No errors, but doesn't work
    The way you have it setup, the recipe requires a stick and a sapling right below the stick. AddRecipe is shaped, the first two arguments in your new Object[]{} are telling it that the first layer contains R and the second contains W, the next ones tell what item each character should be, so the pattern you've created is:

    :|:
    :Sap:

    If you use that in a crafting table it should work. it you're looking to do something like this:

    :|: :: ::
    :: :: ::
    :: :Sap: ::

    then you should use AddShapelessRecipe.
    Posted in: Modification Development
  • 0

    posted a message on Get Closed Block to RGB Values
    EDIT! Never-mind, it was the simplest possible problem I've ever dealt with, and it was caused by inadequate sleep to the point where I forgot how new ItemStack() works. I was trying to place the damage values however I was putting the damage value in the slot for the quantity, so all wools were white, the coding is actually working quite well now.




    I am making a simple mod for personal use, I don't really need to do into too much detail of what it is, I have everything working great besides it's returning wrong blocks.

    I am passing 2 values, R G and B values through a method on a class I made, the class compares the RGB values of that with the preset RGB values I put for each possible block that can be chosen.

    the preset block closest to the color is returned as an item stack (to maintain damage value for wools) where it is used in the world.setBlockAndMetaData(Block b, int i).

    Here is the code(s) I am using, if someone can point out what is wrong, for example, incorrect RGB values, inverted RGB values. I was also not sure if RGB values from BufferedImage are stored 0.0 - 1.0 or 0-255 so I tried both, 0-255 gave better results, 0.0-1.0 gave only black and white, and the colors were inverted.


    package net.minecraft.src;
    
    public class RGBlockDecision
    {
    	public static ItemStack getBlock(int[] rgb)
    	{
    		float dif = -1;//Define the defaul difference as -1 so we can scan for initalization.
    		int index = 0;//define the return index default at 0.
    		
    		for(int[] rgbi : values)//For each of the block rgb values do the following.
    		{
    			float[] nrgb = new float[]{(float)rgbi[0], (float)rgbi[1], (float)rgbi[2]};
    			nrgb[0] /= 255.0F;//
    			nrgb[1] /= 255.0F;//  I tried to use 0.0 - 1.0, but it made it even worse.
    			nrgb[2] /= 255.0F;//
                
    			float i1 = a(nrgb[0] - rgb[0]);//i1 = absolute value of the difference between the two r values.
    			float i2 = a(nrgb[1] - rgb[1]);//i2 = absolute value of the difference between the two g values.
    			float i3 = a(nrgb[2] - rgb[2]);//i3 = absolute value of the difference between the two b values.
    			
    			float difference = i1 + i2 + i3;//Add them up, this number shows how far of close the rgb value is
    			//to being the same color.
    			
    			if(dif==-1F)//if -1 (initalization stage) set to first number.
    			{
    				dif = difference;
    				index = rgbi[3];
    			}
    			//if the difference between the RGB is less than the stored one (closer to color)
    			//use this diffecence instead and replace the return index with the new one.
    			else if(difference < dif)
    			{
    				dif = difference;
    				index = rgbi[3];
    			}
    		}
    		//Return the correct block corresponding to the closest color.
    		return valves[index];
    	}
    	public static int a(int i)
    	{
    		return i < 0 ? -i : i;
    	}
        public static float a(float i)
    	{
    		return i < 0 ? -i : i;
    	}
        public static double a(double i)
    	{
    		return i < 0 ? -i : i;
    	}
    	
        //Presets contain R G B and an Index value
        //
        //The RGB is the color
        //The index [3] is the index of the valves array (tells which ItemStack relates to the preset)
        
    	private static int[] STONE        = new int[]{ 145 , 145 , 145 , 0 };
    	private static int[] WOOL_GREY    = new int[]{ 99  , 99  , 99  , 1 };
    	private static int[] WOOL_L_GREY  = new int[]{ 145 , 145 , 145 , 2 };
    	private static int[] WOOL_BLACK   = new int[]{  0  ,  0  ,  0  , 3 };
    	private static int[] WOOL_ORANGE  = new int[]{ 255 , 128 ,  0  , 4 };
    	private static int[] WOOL_MAGENTA = new int[]{ 255 ,  0  , 255 , 5 };
    	private static int[] WOOL_L_BLUE  = new int[]{  0  , 155 , 255 , 6 };
    	private static int[] WOOL_YELLOW  = new int[]{ 175 , 175 ,  0  , 7 };
    	private static int[] WOOL_LIME    = new int[]{ 75  , 255 ,  0  , 8 };
    	private static int[] WOOL_PINK    = new int[]{ 255 , 125 , 180 , 9 };
    	private static int[] WOOL_CYAN    = new int[]{  0  , 150 , 255 , 10 };
    	private static int[] WOOL_PURPLE  = new int[]{ 150 ,  0  , 150 , 11 };
    	private static int[] WOOL_BLUE    = new int[]{  0  ,  0  , 255 , 12 };
    	private static int[] WOOL_BROWN   = new int[]{ 130 , 75  ,  0  , 13 };
    	private static int[] WOOL_GREEN   = new int[]{  0  , 255 ,  0  , 14 };
    	private static int[] WOOL_RED     = new int[]{ 255 ,  0  ,  0  , 15 };
    	private static int[] WOOL_WHITE   = new int[]{ 180 , 180 , 180 , 16 };
    	private static int[] SANDSTONE    = new int[]{ 255 , 175 , 135 , 17 };
    	private static int[] IRON         = new int[]{ 215 , 215 , 215 , 18 };
    	private static int[] DIAMOND      = new int[]{  0  , 255 , 255 , 19 };
    	private static int[] GOLD         = new int[]{ 255 , 255 ,  0  , 20 };
    	private static int[] SNOW         = new int[]{ 255 , 255 , 255 , 21 };
    	private static int[] GRAVEL       = new int[]{ 140 , 135 , 155 , 22 };
    	
    	static Block _wool           =   Block.cloth;
    	static ItemStack o_wool      =   new ItemStack(_wool, 1);
    	static ItemStack m_wool      =   new ItemStack(_wool, 2);
    	static ItemStack lb_wool     =   new ItemStack(_wool, 3);
    	static ItemStack y_wool      =   new ItemStack(_wool, 4);
    	static ItemStack l_wool      =   new ItemStack(_wool, 5);
    	static ItemStack pi_wool     =   new ItemStack(_wool, 6);
    	static ItemStack dg_wool     =   new ItemStack(_wool, 7);
    	static ItemStack lg_wool     =   new ItemStack(_wool, 8);
    	static ItemStack c_wool      =   new ItemStack(_wool, 9);
    	static ItemStack pu_wool     =   new ItemStack(_wool, 10);
    	static ItemStack bl_wool     =   new ItemStack(_wool, 11);
    	static ItemStack br_wool     =   new ItemStack(_wool, 12);
    	static ItemStack g_wool      =   new ItemStack(_wool, 13);
    	static ItemStack r_wool      =   new ItemStack(_wool, 14);
    	static ItemStack b_wool      =   new ItemStack(_wool, 15);
    	static ItemStack wool        =   new ItemStack(_wool, 0);
    	
    	static ItemStack stone       =   new ItemStack(Block.stone, 0);
    	static ItemStack sandStone   =   new ItemStack(Block.sandStone, 0);
    	static ItemStack blockSteel  =   new ItemStack(Block.blockSteel, 0);
    	static ItemStack blockDiamond=   new ItemStack(Block.blockDiamond, 0);
    	static ItemStack blockGold   =   new ItemStack(Block.blockGold, 0);
    	static ItemStack snow        =   new ItemStack(Block.snow, 0);
    	static ItemStack gravel      =   new ItemStack(Block.gravel, 0);
    	
    	private static int[][] values = new int[][]{STONE, WOOL_GREY, WOOL_L_GREY, WOOL_BLACK, WOOL_ORANGE, WOOL_MAGENTA,
    			WOOL_L_BLUE, WOOL_YELLOW, WOOL_LIME, WOOL_PINK, WOOL_CYAN, WOOL_PURPLE, WOOL_BLUE, WOOL_BROWN,
    			WOOL_GREEN, WOOL_RED, WOOL_WHITE, SANDSTONE, IRON, DIAMOND, GOLD, SNOW, GRAVEL
    	};
    	
    	public static ItemStack[] valves = new ItemStack[]{stone, dg_wool, lg_wool, b_wool, o_wool,
    			m_wool, lb_wool, y_wool, l_wool, pi_wool, c_wool, pu_wool,
    			bl_wool, br_wool, g_wool, r_wool, wool, sandStone, blockSteel,
    			blockDiamond, blockGold, snow, gravel
    	};
    }


    int colors = img.getRGB(c-x-1, r-y-1);
    
    int RGB[] = new int[]
    {
    	(colors >> 16 )&0xff,//R
    	(colors >>  8 )&0xff,//G
    	(colors       )&0xff //B
    };
    				
    ItemStack is = RGBlockDecision.getBlock(RGB);
    
    w.setBlockAndMetadata(x, y, z, is.itemID, is.getItemDamage());


    Any help would be appreciated.
    Posted in: Modification Development
  • 0

    posted a message on [1.6.X] Portal Gun - Reconstructed [v1] - Rewritten... again.
    Quote from a531

    have you tried using the default texture pack yet? I've had issues with texture packs and items displaying incorrectly.are you using hdpatcher or optfine?


    I have been using the default textures, no texture pack. I am not using HD-Patcher or Optifine either, only mods I have are:

    • SPC(w/ WEdit)
    • TMI
    • Zombe Modpack
    • ModLoader(SP and MP)
    • And Portal Mod
    Posted in: Minecraft Mods
  • 0

    posted a message on [1.6.X] Portal Gun - Reconstructed [v1] - Rewritten... again.
    Quote from a531

    ir your running Forge API, make sure you aren't running itemSprite API with it.

    I'm not. I put the correct files in the mod folder. I have ModLoader and ModloaderMP, the audio one is optional and is not really needed to test the map. But the textures are just not working at all. It's trying to use the set index in the terrain.png instead of the specified image, the addOverride on ModLoader is not working correctly somehow, I have a few ModLoader mods and this is the only one having problems with.

    I do not even have Forge API.


    Quote from Cystern

    My portals disappear when I try to fire another of a different kind or when I get close to them.All of the other guns work but the main one does not.Edit : One more Gun has Broken, Now its Chells Gun and Atlas's gunEdit : And another The Bacon Gun has broken. Thats 3/4.Edit : And thats it. None of the guns work anynmore. They all just disappear when I fire another portal or get near it.Edit : And somehow I fixed it by restarting minecraft. Weird.
    I had the same problem, it sometimes happens, idk y. but yeah, restarting minecraft should always fix it. it not discard all guns and remake them then reload before using them.
    Quote from Mr_ONI_man

    minecraft crashed when i tried to close a portal spawner with the R key. Please help me!!
    Here is the crash report...

    --snip--


    That's not the crash report, that's the ModLoader log, it will help sometimes, but in this case it holds no useful info, as it is saying everything is working correctly. If minecraft gets the black screen make sure you deleted META-INF, if you have and it wouldn't load, then you should get a screen with a lot of text, copy and paste that, that's the crash report.
    Posted in: Minecraft Mods
  • 0

    posted a message on [1.8.1][Nov 19] Lahwran's mods - WorldeditCUI
    WorldEdit CUI not working at all for me. It's not showing anything. No outlines, no nothing. the Modloader.txt says it was successfully loaded, and checking my mod list it's enabled.
    Posted in: Minecraft Mods
  • 0

    posted a message on [1.6.X] Portal Gun - Reconstructed [v1] - Rewritten... again.
    Can anyone tell me why there are no working textures? Everything is just pink squares and the portal gun is a completely invisible object minus two little L shaped pieces in two of the corners.
    Posted in: Minecraft Mods
  • 0

    posted a message on [1.6.X] Portal Gun - Reconstructed [v1] - Rewritten... again.
    I get the achievement, meaning it was installed correctly, however, there are not textures, even though the modloader.txt says it added the override.
    Posted in: Minecraft Mods
  • 0

    posted a message on [1.6.X] Portal Gun - Reconstructed [v1] - Rewritten... again.
    Wow... this must have taken a while. epic.
    Posted in: Minecraft Mods
  • To post a comment, please .