Jump to content

Recommended Posts

Posted

hello im trying to code my armor to turn water/lava in to an obsidian block that turns back into water/lava, but i dont want the blocks that where not the source block. this is what i have, i know its not pretty but this is me testing it. all the blocks of water/lava turn in to full blocks. the meltingObsidian turns in to lava, meltingObsidian0 turns in to air, meltingObsidian1 turns to water. the part thats not working is meltingObsidian0. It dose not detect the non source block. this code is the ruff draft(i will Be fixing it after this posts).

 

[embed=425,349]if (player.getCurrentArmor(0) != null &&player.getCurrentArmor(0).getItem().equals(DefineCraftMod.HellStoneBoots))

//if (itemStack.getItem().equals(DefineCraftMod.HellStoneBoots))

{

int x = (int) player.posX;

int y = (int) player.posY - 1;

int z = (int) player.posZ;

Block block0 = world.getBlock(x,y+2,z-1);

Block block = world.getBlock(x, y, z);

Block block1 = world.getBlock(x+1, y, z);

Block block2 = world.getBlock(x+2, y, z);

Block block3 = world.getBlock(x+3, y, z);

Block block4 = world.getBlock(x-1, y, z);

Block block5 = world.getBlock(x-2, y, z);

Block block6 = world.getBlock(x-3, y, z);

Block block7 = world.getBlock(x, y, z+1);

Block block8 = world.getBlock(x, y, z+2);

Block block9 = world.getBlock(x, y, z+3);

Block block10 = world.getBlock(x, y, z-1);

Block block11 = world.getBlock(x, y, z-2);

Block block12 = world.getBlock(x, y, z-3);

Block block13 = world.getBlock(x+1, y, z+1);

Block block14 = world.getBlock(x+2, y, z+1);

Block block15 = world.getBlock(x+1, y, z+2);

Block block16 = world.getBlock(x-1, y, z+1);

Block block17 = world.getBlock(x-1, y, z+2);

Block block18 = world.getBlock(x-2, y, z+1);

Block block19 = world.getBlock(x-1, y, z-1);

Block block20 = world.getBlock(x-1, y, z-2);

Block block21 = world.getBlock(x-2, y, z-1);

Block block22 = world.getBlock(x+1, y, z-1);

Block block23 = world.getBlock(x+1, y, z-2);

Block block24 = world.getBlock(x+2, y, z-1);

 

//water still

if(block == Blocks.water){

world.setBlock(x, y, z, DefineCraftMod.meltingObsidian1);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block1 == Blocks.water){

world.setBlock(x+1, y, z, DefineCraftMod.meltingObsidian1);

}

if(block2 == Blocks.water){

world.setBlock(x+2, y, z, DefineCraftMod.meltingObsidian1);

}

if(block3 == Blocks.water){

world.setBlock(x+3, y, z, DefineCraftMod.meltingObsidian1);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block4 == Blocks.water){

world.setBlock(x-1, y, z, DefineCraftMod.meltingObsidian1);

}

if(block5 == Blocks.water){

world.setBlock(x-2, y, z, DefineCraftMod.meltingObsidian1);

}

if(block6 == Blocks.water){

world.setBlock(x-3, y, z, DefineCraftMod.meltingObsidian1);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block7 == Blocks.water){

world.setBlock(x, y, z+1, DefineCraftMod.meltingObsidian1);

}

if(block8 == Blocks.water){

world.setBlock(x, y, z+2, DefineCraftMod.meltingObsidian1);

}

if(block9 == Blocks.water){

world.setBlock(x, y, z+3, DefineCraftMod.meltingObsidian1);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block10 == Blocks.water){

world.setBlock(x, y, z-1, DefineCraftMod.meltingObsidian1);

}

if(block11 == Blocks.water){

world.setBlock(x, y, z-2, DefineCraftMod.meltingObsidian1);

}

if(block12 == Blocks.water){

world.setBlock(x, y, z-3, DefineCraftMod.meltingObsidian1);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block13 == Blocks.water){

world.setBlock(x+1, y, z+1, DefineCraftMod.meltingObsidian1);

}

if(block14 == Blocks.water){

world.setBlock(x+2, y, z+1, DefineCraftMod.meltingObsidian1);

}

if(block15 == Blocks.water){

world.setBlock(x+1, y, z+2, DefineCraftMod.meltingObsidian1);

}

if(block16 == Blocks.water){

world.setBlock(x-1, y, z+1, DefineCraftMod.meltingObsidian1);

}

if(block17 == Blocks.water){

world.setBlock(x-1, y, z+2, DefineCraftMod.meltingObsidian1);

}

if(block18 == Blocks.water){

world.setBlock(x-2, y, z+1, DefineCraftMod.meltingObsidian1);

}

if(block19 == Blocks.water){

world.setBlock(x-1, y, z-1, DefineCraftMod.meltingObsidian1);

}

if(block20 == Blocks.water){

world.setBlock(x-1, y, z-2, DefineCraftMod.meltingObsidian1);

}

if(block21 == Blocks.water){

world.setBlock(x-2, y, z-1, DefineCraftMod.meltingObsidian1);

}

if(block22 == Blocks.water){

world.setBlock(x+1, y, z-1, DefineCraftMod.meltingObsidian1);

}

if(block23 == Blocks.water){

world.setBlock(x+1, y, z-2, DefineCraftMod.meltingObsidian1);

}

if(block24 == Blocks.water){

world.setBlock(x+2, y, z-1, DefineCraftMod.meltingObsidian1);

}

//Lava still

if(block == Blocks.lava){

world.setBlock(x, y, z, DefineCraftMod.meltingObsidian);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block1 == Blocks.lava){

world.setBlock(x+1, y, z, DefineCraftMod.meltingObsidian);

}

if(block2 == Blocks.lava){

world.setBlock(x+2, y, z, DefineCraftMod.meltingObsidian);

}

if(block3 == Blocks.lava){

world.setBlock(x+3, y, z, DefineCraftMod.meltingObsidian);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block4 == Blocks.lava){

world.setBlock(x-1, y, z, DefineCraftMod.meltingObsidian);

}

if(block5 == Blocks.lava){

world.setBlock(x-2, y, z, DefineCraftMod.meltingObsidian);

}

if(block6 == Blocks.lava){

world.setBlock(x-3, y, z, DefineCraftMod.meltingObsidian);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block7 == Blocks.lava){

world.setBlock(x, y, z+1, DefineCraftMod.meltingObsidian);

}

if(block8 == Blocks.lava){

world.setBlock(x, y, z+2, DefineCraftMod.meltingObsidian);

}

if(block9 == Blocks.lava){

world.setBlock(x, y, z+3, DefineCraftMod.meltingObsidian);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block10 == Blocks.lava){

world.setBlock(x, y, z-1, DefineCraftMod.meltingObsidian);

}

if(block11 == Blocks.lava){

world.setBlock(x, y, z-2, DefineCraftMod.meltingObsidian);

}

if(block12 == Blocks.lava){

world.setBlock(x, y, z-3, DefineCraftMod.meltingObsidian);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block13 == Blocks.lava){

world.setBlock(x+1, y, z+1, DefineCraftMod.meltingObsidian);

}

if(block14 == Blocks.lava){

world.setBlock(x+2, y, z+1, DefineCraftMod.meltingObsidian);

}

if(block15 == Blocks.lava){

world.setBlock(x+1, y, z+2, DefineCraftMod.meltingObsidian);

}

if(block16 == Blocks.lava){

world.setBlock(x-1, y, z+1, DefineCraftMod.meltingObsidian);

}

if(block17 == Blocks.lava){

world.setBlock(x-1, y, z+2, DefineCraftMod.meltingObsidian);

}

if(block18 == Blocks.lava){

world.setBlock(x-2, y, z+1, DefineCraftMod.meltingObsidian);

}

if(block19 == Blocks.lava){

world.setBlock(x-1, y, z-1, DefineCraftMod.meltingObsidian);

}

if(block20 == Blocks.lava){

world.setBlock(x-1, y, z-2, DefineCraftMod.meltingObsidian);

}

if(block21 == Blocks.lava){

world.setBlock(x-2, y, z-1, DefineCraftMod.meltingObsidian);

}

if(block22 == Blocks.lava){

world.setBlock(x+1, y, z-1, DefineCraftMod.meltingObsidian);

}

if(block23 == Blocks.lava){

world.setBlock(x+1, y, z-2, DefineCraftMod.meltingObsidian);

}

if(block24 == Blocks.lava){

world.setBlock(x+2, y, z-1, DefineCraftMod.meltingObsidian);

}

//Floowing lava/water

if(block == Blocks.flowing_water ||block == Blocks.flowing_lava){

world.setBlock(x, y, z, DefineCraftMod.meltingObsidian0);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block1 == Blocks.flowing_water ||block1 == Blocks.flowing_lava){

world.setBlock(x+1, y, z, DefineCraftMod.meltingObsidian0);

}

if(block2 == Blocks.flowing_water ||block2 == Blocks.flowing_lava){

world.setBlock(x+2, y, z, DefineCraftMod.meltingObsidian0);

}

if(block3 == Blocks.flowing_water ||block3 == Blocks.flowing_lava){

world.setBlock(x+3, y, z, DefineCraftMod.meltingObsidian0);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block4 == Blocks.flowing_water ||block4 == Blocks.flowing_lava){

world.setBlock(x-1, y, z, DefineCraftMod.meltingObsidian0);

}

if(block5 == Blocks.flowing_water ||block5 == Blocks.flowing_lava){

world.setBlock(x-2, y, z, DefineCraftMod.meltingObsidian0);

}

if(block6 == Blocks.flowing_water ||block6 == Blocks.flowing_lava){

world.setBlock(x-3, y, z, DefineCraftMod.meltingObsidian0);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block7 == Blocks.flowing_water ||block7 == Blocks.flowing_lava){

world.setBlock(x, y, z+1, DefineCraftMod.meltingObsidian0);

}

if(block8 == Blocks.flowing_water ||block8 == Blocks.flowing_lava){

world.setBlock(x, y, z+2, DefineCraftMod.meltingObsidian0);

}

if(block9 == Blocks.flowing_water ||block9 == Blocks.flowing_lava){

world.setBlock(x, y, z+3, DefineCraftMod.meltingObsidian0);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block10 == Blocks.flowing_water ||block10 == Blocks.flowing_lava){

world.setBlock(x, y, z-1, DefineCraftMod.meltingObsidian0);

}

if(block11 == Blocks.flowing_water ||block11 == Blocks.flowing_lava){

world.setBlock(x, y, z-2, DefineCraftMod.meltingObsidian0);

}

if(block12 == Blocks.flowing_water ||block12 == Blocks.flowing_lava){

world.setBlock(x, y, z-3, DefineCraftMod.meltingObsidian0);

world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);

}

if(block13 == Blocks.flowing_water ||block13 == Blocks.flowing_lava){

world.setBlock(x+1, y, z+1, DefineCraftMod.meltingObsidian0);

}

if(block14 == Blocks.flowing_water ||block14 == Blocks.flowing_lava){

world.setBlock(x+2, y, z+1, DefineCraftMod.meltingObsidian0);

}

if(block15 == Blocks.flowing_water ||block15 == Blocks.flowing_lava){

world.setBlock(x+1, y, z+2, DefineCraftMod.meltingObsidian0);

}

if(block16 == Blocks.flowing_water ||block16 == Blocks.flowing_lava){

world.setBlock(x-1, y, z+1, DefineCraftMod.meltingObsidian0);

}

if(block17 == Blocks.flowing_water ||block17 == Blocks.flowing_lava){

world.setBlock(x-1, y, z+2, DefineCraftMod.meltingObsidian0);

}

if(block18 == Blocks.flowing_water ||block18 == Blocks.flowing_lava){

world.setBlock(x-2, y, z+1, DefineCraftMod.meltingObsidian0);

}

if(block19 == Blocks.flowing_water ||block19 == Blocks.flowing_lava){

world.setBlock(x-1, y, z-1, DefineCraftMod.meltingObsidian0);

}

if(block20 == Blocks.flowing_water ||block20 == Blocks.flowing_lava){

world.setBlock(x-1, y, z-2, DefineCraftMod.meltingObsidian0);

}

if(block21 == Blocks.flowing_water ||block21 == Blocks.flowing_lava){

world.setBlock(x-2, y, z-1, DefineCraftMod.meltingObsidian0);

}

if(block22 == Blocks.flowing_water ||block22 == Blocks.flowing_lava){

world.setBlock(x+1, y, z-1, DefineCraftMod.meltingObsidian0);

}

if(block23 == Blocks.flowing_water ||block23 == Blocks.flowing_lava){

world.setBlock(x+1, y, z-2, DefineCraftMod.meltingObsidian0);

}

if(block24 == Blocks.flowing_water ||block24 == Blocks.flowing_lava){

world.setBlock(x+2, y, z-1, DefineCraftMod.meltingObsidian0);

}[/embed]

Posted

Jesus H Chris on a Stick.

Use a freaking for loop.

 

for(int _x = -3; _x <= 3; _x++) {
    for(int _z = -3; _z <= 3; _z++) {
        if(Math.abs(_x) + Math.abs(_z) <= 3) {
            Block block = world.getBlock(x+_x, y, z+_z);
            //check and replace.
        }
    }
}

 

As for detecting source / not source:

its all in the metadata.

 

(Also, update to 1.9)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.