Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Cannot set property PropertyDirection


Oen44
 Share

Recommended Posts

[19:17:40] [Client thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.RegistryEvent$Register@9f3d1b9:
java.lang.IllegalArgumentException: Cannot set property PropertyDirection{name=facing, clazz=class net.minecraft.util.EnumFacing, values=[north, south, west, east]} as it does not exist in BlockStateContainer{block=minecraft:air, properties=[]}
	at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:221) ~[BlockStateContainer$StateImplementation.class:?]
	at eu.includespark.rpgmod.blocks.NoticeBoardBlock.<init>(NoticeBoardBlock.java:22) ~[NoticeBoardBlock.class:?]
	at eu.includespark.rpgmod.blocks.ModBlocks.registerBlocks(ModBlocks.java:26) ~[ModBlocks.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_ModBlocks_registerBlocks_Register.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) ~[EventBus$1.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:847) [GameData.class:?]
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:514) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:422) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_181]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]

 

public class NoticeBoardBlock extends BlockHorizontal {
    private final AxisAlignedBB BOUNDING_BOX;

    public NoticeBoardBlock(String name, Material material, AxisAlignedBB bb) {
        super(material);
        BOUNDING_BOX = bb;
        setUnlocalizedName(name);
        setRegistryName(name);
        setDefaultState(getBlockState().getBaseState().withProperty(FACING, EnumFacing.NORTH));
    }

    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    public boolean isFullCube(IBlockState state) {
        return false;
    }

    @Override
    public boolean isFullBlock(IBlockState state) {
        return false;
    }

    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
        return BOUNDING_BOX;
    }

    @Override
    public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos) {
        return BOUNDING_BOX;
    }

    @Override
    public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
        return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }
}

 

@Mod.EventBusSubscriber(modid=RPGMod.MODID)
public class ModBlocks {

    private static Block nbLeft;
    private static Block nbMiddle;
    private static Block nbRight;
    private static Block nbLeg;

    @SubscribeEvent
    public static void registerBlocks(RegistryEvent.Register<Block> event) {
        nbLeft = new NoticeBoardBlock("notice_board_left", Material.WOOD, new AxisAlignedBB(0f, 0f, 0.375f, 1f, 1f, 0.625f)).setCreativeTab(RPGMod.creativeTab);
        nbLeft.setHarvestLevel("axe", 1);
        nbMiddle = new NoticeBoardBlock("notice_board_mid", Material.WOOD, new AxisAlignedBB(0f, 0f, 0.375f, 1f, 1f, 0.625f)).setCreativeTab(RPGMod.creativeTab);
        nbMiddle.setHarvestLevel("axe", 1);
        nbRight = new NoticeBoardBlock("notice_board_right", Material.WOOD, new AxisAlignedBB(0f, 0f, 0.375f, 1f, 1f, 0.625f)).setCreativeTab(RPGMod.creativeTab);
        nbRight.setHarvestLevel("axe", 1);
        nbLeg = new BlockBase("notice_board_leg", Material.WOOD, new AxisAlignedBB(0.375f, 0f, 0.375f, 0.625f, 1f, 0.625f)).setCreativeTab(RPGMod.creativeTab);
        nbLeg.setHarvestLevel("axe", 1);
        event.getRegistry().registerAll(nbLeft);
        event.getRegistry().registerAll(nbMiddle);
        event.getRegistry().registerAll(nbRight);
        event.getRegistry().registerAll(nbLeg);
    }

    @SubscribeEvent
    public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
        event.getRegistry().registerAll(new ItemBlock(nbLeft).setRegistryName(nbLeft.getRegistryName()));
        event.getRegistry().registerAll(new ItemBlock(nbMiddle).setRegistryName(nbMiddle.getRegistryName()));
        event.getRegistry().registerAll(new ItemBlock(nbRight).setRegistryName(nbRight.getRegistryName()));
        event.getRegistry().registerAll(new ItemBlock(nbLeg).setRegistryName(nbLeg.getRegistryName()));
    }

    @SubscribeEvent
    public static void registerRenders(ModelRegistryEvent event) {
        registerRender(Item.getItemFromBlock(nbLeft));
        registerRender(Item.getItemFromBlock(nbMiddle));
        registerRender(Item.getItemFromBlock(nbRight));
        registerRender(Item.getItemFromBlock(nbLeg));
    }

    public static void registerRender(Item item) {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory"));
    }
}

 

Crash happens on initialization. This line is the issue

setDefaultState(getBlockState().getBaseState().withProperty(FACING, EnumFacing.NORTH));

 

Example blockstate registry JSON

{
    "variants": {
        "normal": { "model": "rpgmod:notice_board_mid_model" },
        "facing=north": {"model": "rpgmod:notice_board_mid_model"},
        "facing=south": {"model": "rpgmod:notice_board_mid_model"},
        "facing=west": {"model": "rpgmod:notice_board_mid_model"},
        "facing=east": {"model": "rpgmod:notice_board_mid_model"}
    }
}

 

I'm trying to make custom block face the player when placed.

Link to comment
Share on other sites

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

34 minutes ago, Draco18s said:

Great, added few more methods from your code, had to edit few parts but now it works.

 

#Edit

Actually there is one more thing. Looks like whenever I'm rejoining the world, blocks are facing different direction, like its not saving.

Edited by Oen44
More issues
Link to comment
Share on other sites

You still have to convert from state to meta and back.

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/farming/block/BlockTanner.java#L70-L78

(Note that the &1 will not be relevant for you, that is because that block only has 2 effective rotations).

Edited by Draco18s
  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.