Jump to content

[1.7.2]Create Instant Structures?[Solved]


KaptainWiz

Recommended Posts

I want to add instant structures to my mod but the code just won't work:

package com.kaptainwiz.mykindmod.blocks;

import java.util.Random;
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 BlockInstantStructure extends Block
{
Blocks block;

public BlockInstantStructure(Material material)
{
super(material);
}

public void onBlockPlacedBy(World world, Random random, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack)
{
super.onBlockPlacedBy(world, x, y, z, entity, itemstack);//Super

world.setBlockToAir(x, y, z);//Sets the block to air on the x, y, and z coords from where you placed the block
world.setBlock(x, y, z, block.cobblestone);//Sets the block on the x, y, and z coords starting from where you placed the block
world.setBlock(x, y+1, z, block.planks, 2, 2); //Sets the block(with set metadata) on the x, y, and z coords from where you placed the block
world.setBlock(x+1, y, z+1, block.planks, 2, 2); 
world.setBlock(x+2, y, z+2, block.planks, 2, 2); 
world.setBlock(x+3, y, z+3, block.planks, 2, 2); 
world.setBlock(x+4, y, z+4, block.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
}
}






Here's the registry:







public static Block blockInstantStructure;


blockInstantStructure = new BlockInstantStructure(Material.anvil).setCreativeTab(SampleTab).setBlockName("Instant").setBlockTextureName("sample:SampleInstant");

    	GameRegistry.registerBlock(blockInstantStructure, "instant");

 

This doesn't seem to work when I place the block down.. What now

Link to comment
Share on other sites

wrong function its

 

@Override

public void onBlockPlacedBy(World world,int x,int y,int z,EntityLivingBase entity, ItemStack itemstack){

//code

}

 

Also you should do @Override before your functions, because if the function is incorrect, you get an error.

The proud(ish) developer of Ancients

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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