Posted January 18, 201312 yr So I am developing my first (well 2nd really) mod. I am adding slabs (of wool) and I got it all to work, except for the part that the slabs, the first 8 in the id are laid on the ground, and the other 8 are on the top. I have no clue what is going wrong... package us.xvicario.minecraft.EssentialStuff.common; import java.util.List; import us.xvicario.minecraft.EssentialStuff.common.mod_EssentialStuff; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockWoolSlab extends Block { private final boolean isDoubleSlab; public BlockWoolSlab(int id, boolean par2) { super(id, Material.cloth); this.isDoubleSlab = par2; setBlockName("woolSlab"); Block added = setCreativeTab(CreativeTabs.tabBlock); System.out.println(added.toString()); if (par2) { opaqueCubeLookup[id] = true; } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setLightOpacity(255); } public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { boolean var5 = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0; if (var5) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } public void setBlockBoundsForItemRender() { if (this.isDoubleSlab) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } public boolean isOpaqueCube() { return this.isDoubleSlab; } public int func_85104_a(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9) { return this.isDoubleSlab ? par9 : (par5 != 0 && (par5 == 1 || (double)par7 <= 0.5D) ? par9 : par9 | ; } @Override public int damageDropped(int par1) { return par1; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return this.isDoubleSlab; } public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { if (this.isDoubleSlab) { return super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); } else if (par5 != 1 && par5 != 0 && !super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5)) { return false; } else { int var6 = par2 + Facing.offsetsXForSide[Facing.faceToSide[par5]]; int var7 = par3 + Facing.offsetsYForSide[Facing.faceToSide[par5]]; int var8 = par4 + Facing.offsetsZForSide[Facing.faceToSide[par5]]; boolean var9 = (par1IBlockAccess.getBlockMetadata(var6, var7, var8) & != 0; return var9 ? (par5 == 0 ? true : (par5 == 1 && super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1IBlockAccess.getBlockId(par2, par3, par4)) || (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & == 0)) : (par5 == 1 ? true : (par5 == 0 && super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5) ? true : !isBlockSingleSlab(par1IBlockAccess.getBlockId(par2, par3, par4)) || (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0)); } } @SideOnly(Side.CLIENT) /** * Takes a block ID, returns true if it's the same as the ID for a stone or wooden single slab. */ private static boolean isBlockSingleSlab(int par0) { return par0 == mod_EssentialStuff.woolSingleSlab.blockID; } /** * Returns the slab block name with step type. */ //public abstract String getFullSlabName(int var1); /** * Get the block's damage value (for use with pick block). */ public int getDamageValue(World par1World, int par2, int par3, int par4) { return super.getDamageValue(par1World, par2, par3, par4) & 7; } @SideOnly(Side.CLIENT) public int idPicked(World par1World, int par2, int par3, int par4) { return isBlockSingleSlab(this.blockID) ? this.blockID : (this.blockID == mod_EssentialStuff.woolDoubleSlab.blockID ? Block.stoneSingleSlab.blockID : (this.blockID == Block.woodDoubleSlab.blockID ? Block.woodSingleSlab.blockID : Block.stoneSingleSlab.blockID)); } @Override public int getBlockTextureFromSideAndMetadata(int side, int metadata) { if (metadata == 0) { return 64; } else { metadata = ~(metadata & 15); return 113 + ((metadata & >> 3) + (metadata & 7) * 16; } } @SideOnly(Side.CLIENT) public void getSubBlocks(int unknown, CreativeTabs tab, List subItems) { for (int ix = 0; ix < 16; ix++) { subItems.add(new ItemStack(this, 1, ix)); } } } If you need any more information, please just ask. edit: I fixed it, but I dont understand the part of the code that determines what the slab is on, If someone can explain it to me. else { boolean var5 = (par1IBlockAccess.getBlockMetadata(par2, par3, par4) & != 0; if (var5) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } }
January 20, 201312 yr It's because the minecraft uses metadata to checking if it's on bottom or on top. You can only use the first 8 metadata because the last 8 metadata is the top one. You will need two block for wool,one for the first 8 ,one for the last 8.
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.