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 created a TileEntity block that places like a normal block. Now I wanted to make it rotate-able like the dispenser so I looked into the dispenser code and created this.

Spoiler

public class CaskBlock extends Block {

    public static final DirectionProperty FACING = DirectionalBlock.FACING;

    public CaskBlock(Block.Properties properties) {
        super(properties);
        this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.UP));
    }

    @Override
    public BlockRenderLayer getRenderLayer() {
        return BlockRenderLayer.CUTOUT;
    }

    @Nullable
    @Override
    public BlockState getStateForPlacement(BlockItemUseContext context) {
        return this.getDefaultState().with(FACING, context.getNearestLookingDirection().getOpposite());
    }

    @Override
    public BlockState rotate(BlockState state, IWorld world, BlockPos pos, Rotation direction) {
        return state.with(FACING, direction.rotate(state.get(FACING)));
    }

    @Override
    public BlockState mirror(BlockState state, Mirror mirrorIn) {
        return state.rotate(mirrorIn.toRotation(state.get(FACING)));
    }

    @Override
    public boolean hasTileEntity(BlockState state) {
        return true;
    }

    @Nullable
    @Override
    public TileEntity createTileEntity(BlockState state, IBlockReader world) {
        return ModTileEntityTypes.CASK.create();
    }

    @Override
    public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {

        if (worldIn.isRemote) return true;
        if (!(worldIn.getTileEntity(pos) instanceof CaskTileEntity)) return false;

        LazyOptional<IFluidHandler> handler = worldIn.getTileEntity(pos).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, hit.getFace());
        handler.ifPresent(tank -> {
            FluidUtil.interactWithFluidHandler(player, handIn, worldIn, pos, hit.getFace());
        });

        return true;
    }
}

 

When I try to load the game I get the following error:

Spoiler

java.lang.IllegalArgumentException: Cannot set property DirectionProperty{name=facing, clazz=class net.minecraft.util.Direction, values=[north, east, south, west, up, down]} as it does not exist in Block{null}
	at net.minecraft.state.StateHolder.with(StateHolder.java:105)
	at mod.tieso2001.boneappletea.block.CaskBlock.<init>(CaskBlock.java:31)
	at mod.tieso2001.boneappletea.ModEventSubscriber.onRegisterBlocks(ModEventSubscriber.java:36)
	at net.minecraftforge.eventbus.ASMEventHandler_1_ModEventSubscriber_onRegisterBlocks_Register.invoke(.dynamic)
	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)
	at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258)
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.fireEvent(FMLModContainer.java:106)
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
	at net.minecraftforge.fml.ModContainer.transitionState(ModContainer.java:112)
	at net.minecraftforge.fml.ModList.lambda$dispatchSynchronousEvent$5(ModList.java:124)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at net.minecraftforge.fml.ModList.dispatchSynchronousEvent(ModList.java:124)
	at net.minecraftforge.fml.ModList.lambda$static$1(ModList.java:95)
	at net.minecraftforge.fml.LifecycleEventProvider.dispatch(LifecycleEventProvider.java:71)
	at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:194)
	at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$24(ModLoader.java:186)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:969)
	at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:186)
	at net.minecraftforge.fml.client.ClientModLoader.lambda$begin$2(ClientModLoader.java:79)
	at net.minecraftforge.fml.client.ClientModLoader.lambda$createRunnableWithCatch$5(ClientModLoader.java:95)
	at net.minecraftforge.fml.client.ClientModLoader.begin(ClientModLoader.java:79)
	at net.minecraft.client.Minecraft.init(Minecraft.java:456)
	at net.minecraft.client.Minecraft.run(Minecraft.java:365)
	at net.minecraft.client.main.Main.main(Main.java:128)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55)
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:50)
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:68)
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:80)
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65)
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101)

 

I understand that "java.lang.IllegalArgumentException: Cannot set property DirectionProperty{name=facing, clazz=class net.minecraft.util.Direction, values=[north, east, south, west, up, down]} as it does not exist in Block{null}" this says what is wrong and that it cannot set the property because it doesn't exist, but I don't know how to fix this. Help would be appreciated.

Edited by Tieso2001

You haven't set up the state container.

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/block/WindvaneBlock.java#L33-L36

Also, show where you create and register your blocks

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.

  • Author
48 minutes ago, Draco18s said:

Thanks, now it works.

 

51 minutes ago, Draco18s said:

Also, show where you create and register your blocks

Here:

Spoiler

@ObjectHolder(BoneAppleTea.MOD_ID)
public class ModBlocks {

    public static final Block BARLEY = Null();
    public static final Block QUERN = Null();

    public static final Block OAK_CASK = Null();
    public static final Block SPRUCE_CASK = Null();
    public static final Block BIRCH_CASK = Null();
    public static final Block JUNGLE_CASK = Null();
    public static final Block ACACIA_CASK = Null();
    public static final Block DARK_OAK_CASK = Null();
}

 

Spoiler

@SubscribeEvent
    public static void onRegisterBlocks(final RegistryEvent.Register<Block> event) {
        event.getRegistry().registerAll(
                setup(new BarleyBlock(Block.Properties.create(Material.PLANTS).doesNotBlockMovement().tickRandomly().hardnessAndResistance(0.0F).sound(SoundType.CROP)), "barley"),
                setup(new QuernBlock(Block.Properties.create(Material.ROCK).hardnessAndResistance(2.0F).sound(SoundType.STONE).harvestTool(ToolType.PICKAXE).harvestLevel(1)), "quern"),

                setup(new CaskBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE).harvestLevel(0)), "oak_cask"),
                setup(new CaskBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE).harvestLevel(0)), "spruce_cask"),
                setup(new CaskBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE).harvestLevel(0)), "birch_cask"),
                setup(new CaskBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE).harvestLevel(0)), "jungle_cask"),
                setup(new CaskBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE).harvestLevel(0)), "acacia_cask"),
                setup(new CaskBlock(Block.Properties.create(Material.WOOD).hardnessAndResistance(2.0F).sound(SoundType.WOOD).harvestTool(ToolType.AXE).harvestLevel(0)), "dark_oak_cask")
        );
    }

 

 

5 minutes ago, Tieso2001 said:

Here:

Looks good. Just wanted to make sure there wasn't anything there that might've been a problem too.

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.

  • Author
1 minute ago, Draco18s said:

Looks good. Just wanted to make sure there wasn't anything there that might've been a problem too.

Okay thanks for checking.

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.