Hello to all and nice to meet you since this is my first post here
Ive read similar post about my question but since no two issues are alike im making this post hoping one of you can help me.
Im making my first mod and made a custom block that is 2 blocks tall
now i managed to get it render properly and place on the world.
the problem i have is this the lower block works just fine but i cant click on the second top block nor has any collation on it.
here is the code im using
package com.projects.tallblocksample.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import com.projects.tallblocksample.tallblocksample;
import com.projects.tallblocksample.tileentity.TileEntityTallBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class TallBlockBlock extends BlockContainer {
public TallBlockBlock() {
super(Material.wood);
this.setHardness(2.0F);
this.setResistance(5.0F);
this.setBlockBounds(0.05F, 0.05F, 0.05F, 0.95F, 2F, 0.95F);
this.setCreativeTab(tallblocksample.tabtallblocksample);
}
public int getRenderType() {
return -1;
}
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileEntityTallBlock();
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.blockIcon = iconRegister.registerIcon(tallblocksample.modid + ":" + this.getUnlocalizedName().substring(5));
}
public Item getItemDropped(int i, Random random, int j) {
return Item.getItemFromBlock(tallblocksample.blockTallBlock);
}
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
if(world.getBlockMetadata(x, y, z) == 0)
{
this.setDefaultDirection(world, x, y, z);
}
}
private void setDefaultDirection(World world, int x, int y, int z) {
if(!world.isRemote) {
Block b1 = world.getBlock(x, y, z - 1);
Block b2 = world.getBlock(x, y, z + 1);
Block b3 = world.getBlock(x - 1, y, z);
Block b4 = world.getBlock(x + 1, y, z);
byte b0 = 3;
if(b1.func_149730_j() && !b2.func_149730_j()) {
b0 = 3;
}
if(b2.func_149730_j() && !b1.func_149730_j()) {
b0 = 2;
}
if(b3.func_149730_j() && !b4.func_149730_j()) {
b0 = 5;
}
if(b4.func_149730_j() && !b3.func_149730_j()) {
b0 = 4;
}
world.setBlockMetadataWithNotify(x, y, x, b0, 2);
}
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack)
{
int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3;
if(l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 1);
}
if(l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 1);
}
if(l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 1, 1);
}
if(l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 1);
}
if(itemstack.hasDisplayName())
{
//TO DO
}
}
}
i realize this might be easy for some of you but please understand im new to MC modding (not new to coding)
thank you very much in advance
ps: sry English not my first language doing my best