Posted June 29, 201510 yr I discovered that my problem was that I forgot to actually set iblockstate1 to equal the new value. The new code is this: package com.henrich.epicwasteoftime.blocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; public class ItemPillarBlock extends ItemBlock { public ItemPillarBlock(Block block) { super(block); if (!(block instanceof IMetaBlockName)) { throw new IllegalArgumentException(String.format("The given Block %s is not an instance of ISpecialBlockName!", block.getUnlocalizedName())); } this.setMaxDamage(0); } /** * Called when a Block is right-clicked with this Item * * @param pos The block being right-clicked * @param side The side being right-clicked */ public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { IBlockState iblockstate = worldIn.getBlockState(pos); Block block = iblockstate.getBlock(); if (!block.isReplaceable(worldIn, pos)) { pos = pos.offset(side); } if (stack.stackSize == 0) { return false; } else if (!playerIn.canPlayerEdit(pos, side, stack)) { return false; } else if (pos.getY() == 255 && this.block.getMaterial().isSolid()) { return false; } else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack)) { int i = this.getMetadata(stack.getMetadata()); IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn); switch(side) { case UP: case DOWN: iblockstate1=iblockstate1.withProperty(PillarBlock.ORIENTATION, PillarBlock.EnumOrientation.Y); break; case NORTH: case SOUTH: iblockstate1=iblockstate1.withProperty(PillarBlock.ORIENTATION, PillarBlock.EnumOrientation.Z); break; case EAST: case WEST: iblockstate1=iblockstate1.withProperty(PillarBlock.ORIENTATION, PillarBlock.EnumOrientation.X); break; default: break; } if (placeBlockAt(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ, iblockstate1)) { worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F); --stack.stackSize; } return true; } else { return false; } } @Override public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack); } } I should probably try to make a tutorial for this so that no one else has the same problem. I'm trying to make a pillar block that behaves like the existing log blocks. At the moment the only non-working thing seems to be the ItemBlock, because when I use /setblock nether_tree_wood <0, 1, 2> (where nether_tree_wood is the ID of the block and <0, 1, 2> are the possible metadatas) they get placed just fine with the proper rotations. This is the ItemBlock code I'm using: (code) If you think you need the rest of the code for this block, it's available on request. I just don't think it's necessary, though I could very well be wrong. I'll put something here when I have something of value I need to put at the end of every post. For now it's this mostly pointless text.
June 30, 201510 yr Question why are you handling the placing of the block in the itemblock? The easiest way to do this would just have the block extend BlockLog and look at what BlockOldLog or BlockNewLog do. It's a lot easier than an itemblock. Did you really need to know?
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.