but please learn how to google simple things like this all i did was
google "java generate random number between 1 and 10"
and it was the first one on the list.
k i believe i have figured this out, the only problem is that its giving me a "missing return statement" error near the bottom:
package net.minecraft.src;
import java.util.Random;
public class BlockJump extends Block
{
public BlockJump(int blockID)
{
// Call our inherited's class telling it
// we want to use the jukebox texture and
// have wood like properties
super(blockID, 74, Material.wood);
// Need to create the item that will be dropped
Item.itemsList[blockID] = new ItemBlock(blockID-256);
// Sets the recipe be two planks horizontal to each other
this.setResistance(2.0F).setHardness(10F).setStepSound(soundClothFootstep);
}
public int getBlockTextureFromSide(int side)
{
Random r = new Random();
side = 1;
int status = -1;
if (side==1)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 2;
status = -1;
if (side==2)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 3;
status = -1;
if (side==3)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 4;
status = -1;
if (side==4)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 5;
status = -1;
if (side==5)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 6;
status = -1;
if (side==6)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
} //<-----***HERE*** (and the bracket)
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
// Add to the entities upward velocity to send them up into the air
entity.motionY += 2.0;
}
}
could someone help resolve this?
(btw this is trying to take the jumpblock mod and making the game choose a random texture from a 9x9 block on terrain.png for each side)
Rollback Post to RevisionRollBack
Remeber: that little green plus sign is a great way to say thank you!
k i believe i have figured this out, the only problem is that its giving me a "missing return statement" error near the bottom:
package net.minecraft.src;
import java.util.Random;
public class BlockJump extends Block
{
public BlockJump(int blockID)
{
// Call our inherited's class telling it
// we want to use the jukebox texture and
// have wood like properties
super(blockID, 74, Material.wood);
// Need to create the item that will be dropped
Item.itemsList[blockID] = new ItemBlock(blockID-256);
// Sets the recipe be two planks horizontal to each other
this.setResistance(2.0F).setHardness(10F).setStepSound(soundClothFootstep);
}
public int getBlockTextureFromSide(int side)
{
Random r = new Random();
side = 1;
int status = -1;
if (side==1)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 2;
status = -1;
if (side==2)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 3;
status = -1;
if (side==3)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 4;
status = -1;
if (side==4)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 5;
status = -1;
if (side==5)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
side = 6;
status = -1;
if (side==6)
{
int n = r.nextInt(9);
if (n == 0){
status = 1;
} else if (n == 1){
status = 2;
} else if (n == 2){
status = 3;
} else if (n == 3){
status = 4;
} else if (n == 4){
status = 5;
} else if (n == 5){
status = 6;
} else if (n == 6){
status = 7;
} else if (n == 7){
status = 8;
} else {
status = 9;
}
switch (status) {
case 1:
return 136;
case 2:
return 137;
case 3:
return 138;
case 4:
return 152;
case 5:
return 153;
case 6:
return 154;
case 7:
return 168;
case 8:
return 169;
default:
return 170;
}
}
} //<-----***HERE*** (and the bracket)
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
// Add to the entities upward velocity to send them up into the air
entity.motionY += 2.0;
}
}
could someone help resolve this?
(btw this is trying to take the jumpblock mod and making the game choose a random texture from a 9x9 block on terrain.png for each side)
Add a return statement there, before that final brace. If that line will never be reached, then it doesn't matter what value that return statement returns.
thanks for the tip with condensing! I just recently made an attempt to start learning java and this is the first thing I worked on :smile.gif:
and actually it worked exactly how I wanted it to! it works because it only looks for if(side == 1) immediately after i tell it that side = 1 and then after that loop closes THEN i tell it the side = 2 then make it look for if(side == 2) and so on
however, the only problem i've been seeing is that once the block is placed, it tends to keep changing textures quickly for a bit then slowing down (my point being that the texture continues to change even after it is placed) how do I make it only select te textures once? this isnt a necessary fix seeing as how the effect is actually pretty cool
if anyone wants my terrain.png where I put the textures (really just white squares with numbers 1-9) that show up on the block and all the classes (3) for the mod just ask!
Rollback Post to RevisionRollBack
Remeber: that little green plus sign is a great way to say thank you!
You should really work on your Googling skills. Java will literally give you hundreds of problems like those two in your career as a java programming hobbiest. Forum members are going to hate you if you ask for help for every one of them.
yes i noticed, I was able to figure out most of them on my own by trial and error, and these two i was having special trouble with (because I just started with java) i tried googling them, but I couldnt figure out how to translate the answers given on google to my actual code, and I figured out how to fix them on my own anyways (posted prematurely lol) turns out for the first one, my only problem was that I had set up my PATH variable wrong so it didnt know where to look when I told it to import java.util.Random. and the second one i figured out about 10 seconds before the guy answered :tongue.gif: it just didnt occur to me to try that because i thought it had something to do with the bracket, not that it was missing something
Rollback Post to RevisionRollBack
Remeber: that little green plus sign is a great way to say thank you!
import java.util.Random;
public class RandomNumberJava
{
public static void main(String[] args)
{
System.out.println("Java generating random number in range 1 to 10 : ");
int numStart = 1;
int numEnd = 10;
Random rd = new Random();
for(int a = 1; a <= 10; ++a)
{
findRandom(numStart, numEnd, rd);
}
}
private static void findRandom(int numBegin, int numStop, Random rand)
{
if(numBegin > numStop)
{
throw new IllegalArgumentException("Begin should not be more than Stop!!");
}
// java random range
long range = (long)numStop - (long)numBegin + 1;
long num = (long)(range * rand.nextDouble());
int randomNumber = (int)(num + numBegin);
System.out.print(" " + randomNumber);
}
}
help
please?
but please learn how to google simple things like this all i did was
google "java generate random number between 1 and 10"
and it was the first one on the list.
could someone help resolve this?
(btw this is trying to take the jumpblock mod and making the game choose a random texture from a 9x9 block on terrain.png for each side)
Add a return statement there, before that final brace. If that line will never be reached, then it doesn't matter what value that return statement returns.
Builder Mobs 0.53
My Other Mods Here
that fixed it :smile.gif:
and actually it worked exactly how I wanted it to! it works because it only looks for if(side == 1) immediately after i tell it that side = 1 and then after that loop closes THEN i tell it the side = 2 then make it look for if(side == 2) and so on
however, the only problem i've been seeing is that once the block is placed, it tends to keep changing textures quickly for a bit then slowing down (my point being that the texture continues to change even after it is placed) how do I make it only select te textures once? this isnt a necessary fix seeing as how the effect is actually pretty cool
if anyone wants my terrain.png where I put the textures (really just white squares with numbers 1-9) that show up on the block and all the classes (3) for the mod just ask!
Well, here's code
For more on random numbers refer this resource.