• 0

    posted a message on Lightning New Portal, not working..
    Is mod_TropicalDimension.TropicPortal of type BlockTropicPortal?
    I assume you have something like Block TropicPortal = new BlockTropicPortal(STUFF).setName(ETC).STUFF?
    Try casting it to BlockTropicPortal, like so:
    BlockTropicPortal TropicPortal = (BlockTropicPortal)new BlockTropicPortal(STUFF).setName(ETC).STUFF?
    It would help to see your mod_TropicalDimension file, as well as the actual error. (Try hitting alt+enter over it, that's how to see the true error in NetBeans, I'm not sure about Eclipse, or whatever IDE that is.
    [Edit: It looks like CTRL+1 shows the tooltip in Eclipse.])
    Posted in: Modification Development
  • 0

    posted a message on How do I print the value of a float?
    Add the float to a string, like this
    float f = 0.3f;
    String toDisplay = ""+f;

    and then display toDisplay.

    You can add basically anything to a string, as every object in Java has a toString() method that is called when you add an object to a string. And all of the primitives (int, char, byte, long, double, float, short) have object equivalents (Integer, Character, Byte, Long, Double, Float, Short).
    Posted in: Modification Development
  • 0

    posted a message on Is it possible to create a custom sword which spawns mobs?
    In your swords hitEntity Method, add the following code
    EntityOcelot entity= new EntityEntityOcelot (par3EntityLiving.worldObj);
    			 entity.setLocationAndAngles(par3EntityLiving.posX, par3EntityLiving.posY, par3EntityLiving.posZ, par3EntityLiving.rotationYaw, 0.0F);
    			 par3EntityLiving.worldObj.spawnEntityInWorld(entity);

    You can use the Random class to make it only have a chance to do so.
    Edit: Beaten to the punch :P
    Posted in: Modification Development
  • 0

    posted a message on Save the world!
    You need to be more specific with your questions. It seems as though you are asking us to make you a GUI and a save function. There are plenty of GUI files to look at, and you can look at World.quickSaveWorld(0)
    Posted in: Modification Development
  • 0

    posted a message on [solved]throwables more spread out?
    In the EntityPlayer class, there is the method

    public EntityItem dropOneItem()
        {
            return dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);
        }

    And
        public EntityItem dropPlayerItemWithRandomChoice(ItemStack par1ItemStack, boolean par2)
        {
    	    if (par1ItemStack == null)
    	    {
    		    return null;
    	    }
    	    EntityItem entityitem = new EntityItem(worldObj, posX, (posY - 0.30000001192092896D) + (double)getEyeHeight(), posZ, par1ItemStack);
    	    entityitem.delayBeforeCanPickup = 40;
    	    float f = 0.1F;	    if (par2)
    	    {
    		    float f2 = rand.nextFloat() * 0.5F;
    		    float f4 = rand.nextFloat() * (float)Math.PI * 2.0F;
    		    entityitem.motionX = -MathHelper.sin(f4) * f2;
    		    entityitem.motionZ = MathHelper.cos(f4) * f2;
    		    entityitem.motionY = 0.20000000298023224D;
    	    }
    	    else
    	    {
    		    float f1 = 0.3F;
    		    entityitem.motionX = -MathHelper.sin((rotationYaw / 180F) * (float)Math.PI) * MathHelper.cos((rotationPitch / 180F) * (float)Math.PI) * f1;
    		    entityitem.motionZ = MathHelper.cos((rotationYaw / 180F) * (float)Math.PI) * MathHelper.cos((rotationPitch / 180F) * (float)Math.PI) * f1;
    		    entityitem.motionY = -MathHelper.sin((rotationPitch / 180F) * (float)Math.PI) * f1 + 0.1F;
    		    f1 = 0.02F;
    		    float f3 = rand.nextFloat() * (float)Math.PI * 2.0F;
    		    f1 *= rand.nextFloat();
    		    entityitem.motionX += Math.cos(f3) * (double)f1;
    		    entityitem.motionY += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
    		    entityitem.motionZ += Math.sin(f3) * (double)f1;
    	    }
    	    joinEntityItemWithWorld(entityitem);
    	    addStat(StatList.dropStat, 1);
    	    return entityitem;
        }

    In the dropOneItem method, you could check if inventory.currentItem is the item you want to be thrown 3 times, and if it is, then instead of
    return dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);

    you
    return dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 3), false);

    And you could also tweak the dropPlayerItemWithRandomChoice method to throw items more randomly, or make your own that you call instead that throws items more randomly.
    The code that controls throwing power in dropPlayerItemWithRandomChoice is
    	    if (par2)
    	    {
    		    float f2 = rand.nextFloat() * 0.5F;
    		    float f4 = rand.nextFloat() * (float)Math.PI * 2.0F;
    		    entityitem.motionX = -MathHelper.sin(f4) * f2;
    		    entityitem.motionZ = MathHelper.cos(f4) * f2;
    		    entityitem.motionY = 0.20000000298023224D;
    	    }

    All of the entityitem.motionX/Y/Z's control how hard it is thrown, and you can mess with the things being multiplied to rand.nextFloat() to make it more random.
    Posted in: Modification Development
  • 0

    posted a message on when i run this happens in the console
    It appears you gave an item an index that is way too high.....

    After each "at net.WORDSHERE (WORDS:A NUMBER HERE)" look at the A NUMBER HERE, and find that line in your code.
    So, at net.minecraft.src.Item.<clinit>(Item.java:13) means go to Item.java, and find the 13th line of code, because there is a potential error in it.
    Posted in: Modification Development
  • 0

    posted a message on Custom Armor unable to equip help please.
    What do those errors say? And could you also post your current code?
    Posted in: Modification Development
  • 1

    posted a message on Custom Armor unable to equip help please.
    You need to pass the correct arguments to your constructor, meaning it needs to match up.

    If you can't figure it out, try this:
    	super(par1,par2EnumArmorMaterial, par3, par4);
    You see, super(STUFF) just calls the constructor of whatever class you are extending.

    So If I have a class, A, that extends B:
    B's constructor could be B(int i)
    A's constructor could call super(3), which would invoke B's constructor, but if A called super("f") it would not, as B's constructor wants an integer, not a string.

    Edit: The first quickfix isn't fully wrong, it's just that it passes null instead of an armor type, which would cause a NullPointerException. (Basically, an error that occurs when you try doing something that doesn't exist. null is nothing. You can't tell null to do anything, it will always cause an exception. You can check if something is null, however.)
    Posted in: Modification Development
  • 0

    posted a message on Ore generation class?
    Take a look at BiomeDecorator.java
    It constrcuts the WorldGenMinables, which place the ores.
    Posted in: Modification Development
  • 0

    posted a message on MCP help!
    The class for the block is a part of BlockOre.java
    The Item is part of Item.java

    In the future, you can use a program like Notepad++ which has a "find in files" feature that lets you search a bunch of files for a keyword, so you can more easily find the java file containing what you want to edit.
    Posted in: Modification Development
  • 0

    posted a message on errors?
    Quote from Decman1717

    Let me make a real life analogy.
    Lets say I have no idea how to drive. I have never seen a car before, and I have no idea what anything does inside of a car. If you just put me in the car and say go forward, I wouldn't know what to do. If you put me in the car and say go forward, and then explain where and what the gas pedal does, then I have learned this. In this case, the car is the code. You are putting functional code. He has no experience in java programming, and has no idea what anything does. But if you say "This part is wrong: *insert code here* to fix it you do *insert fix here*, here's why: *insert reason here*" Then he can learn what he is doing and learn to improve on his mistakes.

    I suggest you find a better analogy, as many people watch others drive before getting behind the wheel themselves. In your analogy, you are saying that you have never seen a car before. Yet that does not carry over, as ryakra probably has seen some code before. Many people learn in different ways, there is absolutely no use in arguing over this, neither one of us benefits from this, and it isn't constructive.
    Edit: Every programming book I have ever seen is loaded with code examples, because that is how some people learn. Others jump to the back of the chapter and just do all of the exercises (like, write a 3D tic tac toe program that is a command-line game). We all learn differently, I simply posted what I did encase he was still lost after Princeofmar5's post, OK?
    Posted in: Modification Development
  • 0

    posted a message on [Solved]How to make items bounce when thrown?
    This is EntityItems onupdate method

    public void onUpdate()
    {
    super.onUpdate();

    if (delayBeforeCanPickup > 0)
    {
    delayBeforeCanPickup--;
    }

    prevPosX = posX;
    prevPosY = posY;
    prevPosZ = posZ;
    motionY -= 0.039999999105930328D;

    if (worldObj.getBlockMaterial(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)) == Material.lava)
    {
    motionY = 0.20000000298023224D;
    motionX = (rand.nextFloat() - rand.nextFloat()) * 0.2F;
    motionZ = (rand.nextFloat() - rand.nextFloat()) * 0.2F;
    worldObj.playSoundAtEntity(this, "random.fizz", 0.4F, 2.0F + rand.nextFloat() * 0.4F);
    }

    pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2D, posZ);
    moveEntity(motionX, motionY, motionZ);
    float f = 0.98F;

    if (onGround)
    {
    f = 0.5880001F;
    int i = worldObj.getBlockId(MathHelper.floor_double(posX), MathHelper.floor_double(boundingBox.minY) - 1, MathHelper.floor_double(posZ));

    if (i > 0)
    {
    f = Block.blocksList[i].slipperiness * 0.98F;
    }
    }

    motionX *= f;
    motionY *= 0.98000001907348633D;
    motionZ *= f;

    if (onGround)
    {
    motionY *= -0.5D;
    }

    age++;

    if (age >= 6000)
    {
    setDead();
    }
    }
    The part we want is
    if (onGround)
    {
    motionY *= -0.5D;
    }

    Change the value before the D as you wish, do NOT make it lower than negative one, or it will bounce forever, and make sure it is negative, or it will either fall to the ground immediately, or bounce forever.

    I'm not sure about with other entities (such as mobs), but you might want to look at overriding

    public void applyEntityCollision(Entity par1Entity)
    {
    if (par1Entity.riddenByEntity == this || par1Entity.ridingEntity == this)
    {
    return;
    }

    double d = par1Entity.posX - posX;
    double d1 = par1Entity.posZ - posZ;
    double d2 = MathHelper.abs_max(d, d1);

    if (d2 >= 0.0099999997764825821D)
    {
    d2 = MathHelper.sqrt_double(d2);
    d /= d2;
    d1 /= d2;
    double d3 = 1.0D / d2;

    if (d3 > 1.0D)
    {
    d3 = 1.0D;
    }

    d *= d3;
    d1 *= d3;
    d *= 0.05000000074505806D;
    d1 *= 0.05000000074505806D;
    d *= 1.0F - entityCollisionReduction;
    d1 *= 1.0F - entityCollisionReduction;
    addVelocity(-d, 0.0D, -d1);
    par1Entity.addVelocity(d, 0.0D, d1);
    }
    And changing the third to last line
    addVelocity(-d, 0.0D, -d1);
    to something like
    addVelocity(-2*d, 0.0D, -2*d1);

    You could add an instanceof check to make sure it is a mob, as well.
    Posted in: Modification Development
  • 0

    posted a message on errors?
    Quote from Decman1717

    Here's the thing. You knew what it was, then got example code. He doesn't know what he is doing and got code. NOTHING was explained in the code, so he cannot learn. I started making mods in the same way. Didn't know what I was doing. Then I learned some java by watching online tutorials and I finally got what I was doing. The code finally made sense after I learned java.

    ryakra seemed to have trouble with knowing when to place semicolons, and seeing as Priceofmar5's post contained no semicolons, I did not see how that would help. We clearly have different opinions about how to learn a programming language, so why don't we just agree to disagree?
    Posted in: Modification Development
  • 0

    posted a message on errors?
    Quote from Princeofmar5

    So much for guiding him so he learns.

    Some times you need to see real code to know what your doing wrong.

    When I was younger, I did not understand inheritance. I knew WHAT it meant, but whenever I tried extending classes, it wouldn't work. So I found an example of code using inheritance, and found that I was just messing up the constructor. From then on, I knew what to do.
    Posted in: Modification Development
  • 1

    posted a message on How to get nearest entity pos
    In which case, this should work, make this your items OnItemRightClick method

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
    float closest = Float.MAX_VALUE;
    Entity thisOne=null;
    for (int i = 0; i < par2World.loadedEntityList.size(); i++)
    {
    if (((Entity)par2World.loadedEntityList.get(i)).getDistanceToEntity(par3EntityPlayer)<closest)
    {
    if (par2World.loadedEntityList.get(i) instanceof EntityMob) //if it is a mob...
    {
    closest = ((Entity)par2World.loadedEntityList.get(i)).getDistanceToEntity(par3EntityPlayer);
    thisOne = ((Entity)par2World.loadedEntityList.get(i));
    }
    }
    }
    if (thisOne!=null)
    {
    par2World.addWeatherEffect(new EntityLightningBolt(par2World,thisOne.posX,thisOne.posY, thisOne.posZ));
    }
    return par1ItemStack;
    }


    Edit 1: Fixed possible NULLPOINTEREXCEPTION.
    Edit like 200something: I couldn't figure out why it was striking random locations... then it hit me! It's mobs, strictly relating to hostile mobs. Anyways, I suggest you cap the distance it effects (which you can do by tweaking the initial value of closest.
    Posted in: Modification Development
  • To post a comment, please .