Jump to content

[1.8]generate blocks for custome extructure / magic block <SOLVED>


perromercenary00

Recommended Posts

well i have this block named way down

 

on rigth click it must dig an spiral lader goin down but how do to spawn a steeps lader whith the rigth orientation ?

 

picture for example.

it may looks like this

https://www.dropbox.com/s/87mm77vrcy4oq4j/waydown.png?dl=0

 

but looks like this

https://www.dropbox.com/s/6r1d32ccrokteqi/waydownWrong.png?dl=0

 

i dont know hot to control the facing of the steeps here in 1.8

 

in 1.7 i do that whit the metadata of the blocks

 

world.setBlock(xyz , Blocks.acacia_stairs , 0, 4 ); //north

world.setBlock(xyz , Blocks.acacia_stairs , 1, 4 ); //east

world.setBlock(xyz , Blocks.acacia_stairs , 2, 4 ); //west

world.setBlock(xyz , Blocks.acacia_stairs , 3, 4 ); //south

 

here goes the class

package mercenarymod.blocks.unatextura;

import java.util.Random;

import mercenarymod.Mercenary;
import mercenarymod.blocks.MercenaryModBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class waydown extends Block
{
    public static String name = "waydown";

    public waydown()
    {
    	super(Material.rock);
        setUnlocalizedName(Mercenary.MODID + "_" + name);
        GameRegistry.registerBlock(this, name);
        setCreativeTab(Mercenary.herramientas);
        //this.maxStackSize = 1;
    }

    
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
        return Item.getItemFromBlock(MercenaryModBlocks.waydown);
    }
    
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
    {
    	System.out.println("onBlockActivated()");
	int x=pos.getX(), y=pos.getY(), z=pos.getZ();
    	
	int xmin=x-2, xmax=x+2;  
	int zmin=z-2, zmax=z+2;

	BlockPos pos0 = pos;
	BlockPos pos1 = pos;

    	
    	Block blk0 = Blocks.planks;
    	IBlockState state0=blk0.getDefaultState();


    	Block blkstair = Blocks.acacia_stairs;
    	IBlockState state1=blkstair.getDefaultState();
    	
    	System.out.println("pos ="+pos);
    	
    	//escavar el agujero
    	   	
    	System.out.println("xmin="+xmin+" xmax="+xmax);
    	System.out.println("zmin="+zmin+" zmax="+zmax);
    	
    	for(int yd=y; yd > 10  ; yd-- ){
    	    	    	
    	for(int =xmin;  <= xmax  ; ++ ){
    	for(int zd=zmin; zd <= zmax  ; zd++ ){	
    	    		
    	pos0 = new BlockPos(,yd,zd);	
    	System.out.println(" "+pos0);
    	   	
    	//worldIn.setBlockToAir(pos);	
    	worldIn.destroyBlock(pos0, true);
    	
    	}}}
    	
    	//poner las escaleras
    	BlockPos pos2 = new BlockPos(xmin,y,zmin);
    	pos2.down();
    	
    	for(int yd=y ; yd > 10  ; yd-- ){
    		
    	for(int =xmin;  <= xmax  ; ++ ){	
    	
    	if (( == xmin)){
    	yd--;
    	pos2 = new BlockPos(,yd,zmin);	
    	worldIn.setBlockState(pos2,state0);
    	;
    	}else{
    	yd--;
        pos2 = new BlockPos(,yd,zmin);	
        worldIn.setBlockState(pos2,state1);	
    	}
    	}	
    		
    	
    	for(int zd=zmin; zd <= zmax  ; zd++ ){	
        	y=y+2;
    		
        	if ((zd == zmin)){
        	yd--;
        	pos2 = new BlockPos(xmax,yd,zd);	
        	worldIn.setBlockState(pos2,state0);
        	;
        	}else{
        	yd--;
            pos2 = new BlockPos(xmax,yd,zd);	
            worldIn.setBlockState(pos2,state1);	
        	}
        	}	
        	
    	for(int =xmax;  >= xmin  ; -- ){	
    		y=y+2;
    		
        	if (( == xmin)){
        	yd--;
        	pos2 = new BlockPos(,yd,zmax);	
        	worldIn.setBlockState(pos2,state0);
        	;
        	}else{
        	yd--;
            pos2 = new BlockPos(,yd,zmax);	
            worldIn.setBlockState(pos2,state1);	
        	}
        	}	
    	
    	
    	for(int zd=zmax; zd >= zmin  ; zd-- ){	
        	y=y+2;
    		
        	if ((zd == zmin)){
        	yd--;
        	pos2 = new BlockPos(xmin,yd,zd);	
        	worldIn.setBlockState(pos2,state0);
        	;
        	}else{
        	yd--;
            pos2 = new BlockPos(xmin,yd,zd);	
            worldIn.setBlockState(pos2,state1);	
        	}
        	}	
    	
    	}
    	return true;
    	
    }
    
    
    
    
}//fin de la classe

 

 

 

Link to comment
Share on other sites

it cost me to figure this.

 

first get load the default blockstate from the block i wanna use and then, this code creates four laders looking to four  diferents points

 

 

IBlockState acaciaLadder =  Blocks.acacia_stairs.getDefaultState();

worldIn.setBlockState(pos.north(), acaciaLadder.withProperty(FACING, EnumFacing.NORTH), 2);//por fin maldita sea

worldIn.setBlockState(pos.south(), acaciaLadder.withProperty(FACING, EnumFacing.SOUTH), 2);

worldIn.setBlockState(pos.east(), acaciaLadder.withProperty(FACING, EnumFacing.EAST), 2);

worldIn.setBlockState(pos.west(), acaciaLadder.withProperty(FACING, EnumFacing.WEST), 2);

 

 

logs work siglith diferent there arew no more blocks class but BlockRotatedPillar whicth in turn extends  block class, and i du not know how to call an acacia log  in the world.

 

 

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.