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.])
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).
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)
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
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.
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.
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.)
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.
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?
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;
}
}
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;
}
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?
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.
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.
0
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.])
0
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).
0
You can use the Random class to make it only have a chance to do so.
Edit: Beaten to the punch
0
0
And
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
you
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
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.
0
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.
0
1
If you can't figure it out, try this:
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.)
0
It constrcuts the WorldGenMinables, which place the ores.
0
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.
0
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?
0
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();
}
}
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);
}
to something like
You could add an instanceof check to make sure it is a mob, as well.
0
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?
0
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.
1
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.