Hello everybody. I followed Iantheslimes tutorial on Instant structures. It did not work. I asked a question in the comments, but it never got answered. I hope you guys can help on thi.
my instant structure class
package com.example.dragonborn.blocks;
import java.util.Random;
import com.example.dragonborn.Main;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class CambrianBuilder extends Block
{
Blocks b;
public CambrianBuilder(Material material)
{
super(material);
}
public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
//Super
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z+1, Main.tonalite);
world.setBlock(x, y, z+2, Main.tonalite);
world.setBlock(x, y, z-1, Main.tonalite);
world.setBlock(x, y, z-2, Main.tonalite);
world.setBlock(x+1, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z-1, Main.FittedGlowstone);
world.setBlock(x+3, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+4, y, z, Main.tonalite);
world.setBlock(x+4, y, z+1, Main.tonalite);
world.setBlock(x+4, y, z+2, Main.tonalite);
world.setBlock(x+4, y, z-1, Main.tonalite);
world.setBlock(x+4, y, z-2, Main.tonalite);
world.setBlock(x+2, y, z-1, Main.tonalite);
world.setBlock(x+2, y, z, Main.tonalite);
world.setBlock(x+2, y, z+2, Main.tonalite);
world.setBlock(x+2, y, z+1, Main.tonalite);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
I don't understand what you're asking, what didn't work? DId it not set blocks? Did it not look how you wanted it to or did the block just disappear after placing it?
EDIT: I see a problem that might be the problem, Blocks b; is Null and it's just incorrect. To use the Blocks class, use it statically. For Example:
I don't understand what you're asking, what didn't work? DId it not set blocks? Did it not look how you wanted it to or did the block just disappear after placing it?
EDIT: I see a problem that might be the problem, Blocks b; is Null and it's just incorrect. To use the Blocks class, use it statically. For Example:
Change
world.setBlock(x, y, z, b.planks, 2, 2);
To
world.setBlock(x, y, z, Blocks.planks, 2, 2);
And remove the line
Blocks b;
Let me know if that helps!
no, that did not fix it. also, the problem is that when I plave it it does nothing. thanks for trying though.
What about, and this is just a suggestion, change it from onBlockPlacedBy(…) to onBlockActivated(…) that means, when it is right clicked, it's a lot more easier for the player using your mod and also it'll solve your problem! Let me know if that helps too!
No, I mean like change the whole method to the onBlockActivated one, like so:
Change this:
public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
//Super
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z+1, Main.tonalite);
world.setBlock(x, y, z+2, Main.tonalite);
world.setBlock(x, y, z-1, Main.tonalite);
world.setBlock(x, y, z-2, Main.tonalite);
world.setBlock(x+1, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z-1, Main.FittedGlowstone);
world.setBlock(x+3, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+4, y, z, Main.tonalite);
world.setBlock(x+4, y, z+1, Main.tonalite);
world.setBlock(x+4, y, z+2, Main.tonalite);
world.setBlock(x+4, y, z-1, Main.tonalite);
world.setBlock(x+4, y, z-2, Main.tonalite);
world.setBlock(x+2, y, z-1, Main.tonalite);
world.setBlock(x+2, y, z, Main.tonalite);
world.setBlock(x+2, y, z+2, Main.tonalite);
world.setBlock(x+2, y, z+1, Main.tonalite);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
To This:
public void onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float sideX, float sideY, float sideZ)
{
//Super
super.onBlockActivated(world, x, y, z, player, meta, sideX, sideY, sideZ);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z+1, Main.tonalite);
world.setBlock(x, y, z+2, Main.tonalite);
world.setBlock(x, y, z-1, Main.tonalite);
world.setBlock(x, y, z-2, Main.tonalite);
world.setBlock(x+1, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z-1, Main.FittedGlowstone);
world.setBlock(x+3, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+4, y, z, Main.tonalite);
world.setBlock(x+4, y, z+1, Main.tonalite);
world.setBlock(x+4, y, z+2, Main.tonalite);
world.setBlock(x+4, y, z-1, Main.tonalite);
world.setBlock(x+4, y, z-2, Main.tonalite);
world.setBlock(x+2, y, z-1, Main.tonalite);
world.setBlock(x+2, y, z, Main.tonalite);
world.setBlock(x+2, y, z+2, Main.tonalite);
world.setBlock(x+2, y, z+1, Main.tonalite);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
No, I mean like change the whole method to the onBlockActivated one, like so:
Change this:
public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
//Super
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z+1, Main.tonalite);
world.setBlock(x, y, z+2, Main.tonalite);
world.setBlock(x, y, z-1, Main.tonalite);
world.setBlock(x, y, z-2, Main.tonalite);
world.setBlock(x+1, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z-1, Main.FittedGlowstone);
world.setBlock(x+3, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+4, y, z, Main.tonalite);
world.setBlock(x+4, y, z+1, Main.tonalite);
world.setBlock(x+4, y, z+2, Main.tonalite);
world.setBlock(x+4, y, z-1, Main.tonalite);
world.setBlock(x+4, y, z-2, Main.tonalite);
world.setBlock(x+2, y, z-1, Main.tonalite);
world.setBlock(x+2, y, z, Main.tonalite);
world.setBlock(x+2, y, z+2, Main.tonalite);
world.setBlock(x+2, y, z+1, Main.tonalite);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
To This:
public void onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float sideX, float sideY, float sideZ)
{
//Super
super.onBlockActivated(world, x, y, z, player, meta, sideX, sideY, sideZ);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z+1, Main.tonalite);
world.setBlock(x, y, z+2, Main.tonalite);
world.setBlock(x, y, z-1, Main.tonalite);
world.setBlock(x, y, z-2, Main.tonalite);
world.setBlock(x+1, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z-1, Main.FittedGlowstone);
world.setBlock(x+3, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+4, y, z, Main.tonalite);
world.setBlock(x+4, y, z+1, Main.tonalite);
world.setBlock(x+4, y, z+2, Main.tonalite);
world.setBlock(x+4, y, z-1, Main.tonalite);
world.setBlock(x+4, y, z-2, Main.tonalite);
world.setBlock(x+2, y, z-1, Main.tonalite);
world.setBlock(x+2, y, z, Main.tonalite);
world.setBlock(x+2, y, z+2, Main.tonalite);
world.setBlock(x+2, y, z+1, Main.tonalite);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
}
}
I when I use this, I get an error under void. it wants me to change it to a Boolean, which is wrong.
I when I use this, I get an error under void. it wants me to change it to a Boolean, which is wrong.
Oh, Sorry! I forgot to change that, change the return type to boolean, Sorry it took so long to reply. Like So:
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float sideX, float sideY, float sideZ)
{
//Super
super.onBlockActivated(world, x, y, z, player, meta, sideX, sideY, sideZ);
//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlockToAir(x, y, z);
//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z, Main.tonalite);
world.setBlock(x, y, z+1, Main.tonalite);
world.setBlock(x, y, z+2, Main.tonalite);
world.setBlock(x, y, z-1, Main.tonalite);
world.setBlock(x, y, z-2, Main.tonalite);
world.setBlock(x+1, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z-1, Main.FittedGlowstone);
world.setBlock(x+3, y, z-1, Main.tonaliteHalfSlab);
world.setBlock(x+1, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+2, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+3, y, z + 1, Main.tonaliteHalfSlab);
world.setBlock(x+4, y, z, Main.tonalite);
world.setBlock(x+4, y, z+1, Main.tonalite);
world.setBlock(x+4, y, z+2, Main.tonalite);
world.setBlock(x+4, y, z-1, Main.tonalite);
world.setBlock(x+4, y, z-2, Main.tonalite);
world.setBlock(x+2, y, z-1, Main.tonalite);
world.setBlock(x+2, y, z, Main.tonalite);
world.setBlock(x+2, y, z+2, Main.tonalite);
world.setBlock(x+2, y, z+1, Main.tonalite);
//Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, b.planks, 2, 2); //This is for birch planks, if you want other planks, search 'Minecraft Block Metadata' in google or find it on the MinecraftWiki
return true;
}
my instant structure class
EDIT: I see a problem that might be the problem, Blocks b; is Null and it's just incorrect. To use the Blocks class, use it statically. For Example:
To
And remove the line
Let me know if that helps!
Hello!
no, that did not fix it. also, the problem is that when I plave it it does nothing. thanks for trying though.
Hello!
Hello!
I when I use this, I get an error under void. it wants me to change it to a Boolean, which is wrong.
Oh, Sorry! I forgot to change that, change the return type to boolean, Sorry it took so long to reply. Like So:
Hello!