1

The method is undefined for the type

archieab's Avatar archieab1/27/18 5:40 pm
1 emeralds 275
Hello! For some reason, my EnumFacing.getDirectionFromEntityLiving is throwing the error, "The method getDirectionFromEntityLiving(BlockPos, EntityLivingBase) is undefined for the type EnumFacing". Additionally, my block will always place with the facing tag "=up" for some odd reason. Any help would be appreciated!

Here is my block's java and my EnumHandler java:

Spoiler - click to reveal
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.EnumHand;
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 getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,
float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer))
.withProperty(TYPE, getStateFromMeta(meta * EnumFacing.values().length).getValue(TYPE));
}

@Override
public int getMetaFromState(IBlockState state) {
MacTypes type = (MacTypes) state.getValue(TYPE);
EnumFacing facing = (EnumFacing) state.getValue(FACING);
int meta = type.getID() * EnumFacing.values().length + facing.ordinal();
return meta;
}

@Override
public IBlockState getStateFromMeta(int meta) {
MacTypes type = MacTypes.values()[(int)(meta / EnumFacing.values().length) % MacTypes.values().length];
EnumFacing facing = EnumFacing.values()[meta % EnumFacing.values().length];
return this.getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing);
}

@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);
}

}
Spoiler - click to reveal
package archieab.andustry.handlers;

import net.minecraft.util.IStringSerializable;

public class EnumHandler {

public static enum MacTypes implements IStringSerializable {
BASIC("basic", 0),
ADVANCED("advanced", 1);

private int ID;
private String name;

private MacTypes(String name, int ID) {
this.ID = ID;
this.name = name;
}

@Override
public String getName() {
return this.name;
}

public int getID() {
return ID;
}

@Override
public String toString() {
return getName();
}

}

}
Posted by archieab's Avatar
archieab
Level 1 : New Crafter
0

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome