Hello! I recently added the propertyDirection tag to my block "Drill". No errors are shown in the console or FML log, but the block for some reason doesn't follow the direction it should be placed in. (Minecraft Forge 1.10.2 in Eclipse)
Block (BlockDrill.java)
package archieab.andustry.blocks;
import java.util.List;
import archieab.andustry.Reference;
import archieab.andustry.blocks.item.IMetaBlockName;
import archieab.andustry.handlers.EnumHandler.MacTypes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class BlockDrill extends Block implements IMetaBlockName {
public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class);
public static final PropertyDirection FACING = PropertyDirection.create("facing");
public BlockDrill(String unlocalizedName) {
super(Material.IRON);
this.setUnlocalizedName(unlocalizedName);
this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName));
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH));
}
@Override
protected BlockStateContainer createBlockState() {
return new BlockStateContainer(this, new IProperty[] {TYPE,FACING});
}
@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
int meta, EntityLivingBase placer) {
return super.onBlockPlaced(worldIn, pos, BlockPistonBase.getFacingFromEntity(pos, placer), hitX, hitY, hitZ, meta, placer);
}
@Override
public int getMetaFromState(IBlockState state) {
MacTypes type = (MacTypes) state.getValue(TYPE);
return type.getID();
}
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState().withProperty(TYPE, MacTypes.values()[meta]);
}
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) {
for(int i = 0; i < MacTypes.values().length; i++) {
list.add(new ItemStack(itemIn, 1, i));
}
}
@Override
public String getSpecialName(ItemStack stack) {
return MacTypes.values()[stack.getItemDamage()].getName();
}
@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,
EntityPlayer player) {
return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
}
@Override
public int damageDropped(IBlockState state) {
return getMetaFromState(state);
}
}
Blockstate json (drill.json)
Basic drill model (block_drill_basic.json)
Advanced drill model (block_drill_advanced.json)
Basic drill item model (block_drill_basic.json)
Advanced drill item model (block_drill_advanced.json)
Any help would be greatly appreciated.