Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.