Jump to content

[1.19.2] how do I add the light level property on a double plant block


Recommended Posts

Posted (edited)

I have been making a double plant block that needs the light level property but I get the error

Caused by: java.lang.IllegalArgumentException: Cannot set property EnumProperty{name=half, clazz=class net.minecraft.world.level.block.state.properties.DoubleBlockHalf, values=[upper, lower]} as it does not exist in Block{minecraft:air}

and I don't how to fix it.

code for the block registry:

 public static final RegistryObject<Block> TALL_INVERTED_END_FERN = registerBlock("tall_inverted_end_fern",
            () -> new ModTallInvertedEndFern(BlockBehaviour.Properties.of(Material.REPLACEABLE_PLANT).instabreak()
                    .noCollission().sound(SoundType.GRASS).lightLevel(state -> state.getValue(ModTallInvertedEndFern.LIT) ? 15 : 0)), ModCreativeModeTab.ECHOING_VOID_TAB);

code for the block class:

package net.XO.echoing_void.blocks.custom;

import net.XO.echoing_void.blocks.ModBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DoublePlantBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;

public class ModTallInvertedEndFern extends DoublePlantBlock {
    public ModTallInvertedEndFern(Properties pProperties) {
        super(pProperties);
    }
    @Override
    protected boolean mayPlaceOn(BlockState p_55920_, BlockGetter p_55921_, BlockPos p_55922_) {
        return p_55920_.is(ModBlocks.INVERTED_END_STONE_GRASS_BLOCK.get()) ||
                p_55920_.is(ModBlocks.INVERTED_GREEN_END_STONE_GRASS_BLOCK.get()) ||
                p_55920_.is(ModBlocks.INVERTED_END_DIRT_GRASS_BLOCK.get()) || super.mayPlaceOn(p_55920_, p_55921_, p_55922_);
    }
    public static final BooleanProperty LIT = BooleanProperty.create("lit");

    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        builder.add(LIT);
    }
}

 

Edited by XsistOrder
new issue with the block
  • XsistOrder changed the title to [1.19.2] how do I add the light level property on a double plant block
Posted

when you override a method, you usually want to call the inherited code with your own being an addition.

separate issue, why "lit"? that's a furnace on/off property. don't you want an integer property?

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.