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

Hello,

 

I wanted to be able to put a flower created by me in a flower pot. After realising I have to add a new flower pot with my modded flower and change the onItemUse method I got some issues.

Here is my code of the new onItemUse method:

public ActionResultType onItemUse(ItemUseContext context) {
		ItemStack stack = context.getItem();
		World world = context.getWorld();
		if(stack.getItem()==ItemList.censored_flower) {
			BlockState state = world.getBlockState(context.getPos());
			if(state.getProperties().equals(Blocks.FLOWER_POT.getDefaultState().getProperties())) {
				world.setBlockState(context.getPos(), BlockList.censored_flower_pot.getDefaultState());
				stack.setCount(stack.getCount()-1);
				return ActionResultType.SUCCESS;
			}
			if(state.getBlock()==Blocks.GRASS_BLOCK||state.getBlock()==Blocks.DIRT) {
				BlockPos pos = new BlockPos(context.getHitVec());
				if(world.getBlockState(pos).getBlock()==Blocks.AIR) {
					world.setBlockState(pos, BlockList.censored_flower.getDefaultState());
					stack.setCount(stack.getCount()-1);
					return ActionResultType.SUCCESS;
				}
			}
		}
		logger.info("Fail.");
		return ActionResultType.FAIL;
	}

 

So my problem is that the method doesn't seem to register when I rightclick on an empty flower pot while holding my flower. I also tried it with state.getBlock()==Blocks.FLOWER_POT but that didn't work either. The placement on grass and dirt blocks works perfectly.

I believe the solution will be easy but I can't find it.

 

Thank you very much in advance.

  • Author

Okay thank you, that worked.

 

Now I have a new problem...

 

 

I obviously don't exactly know how to add a flower pot containing my flower. When the flower pot gets replaced there appears the "texture not available" texture. Here is the models json I used:

{
    "parent": "block/flower_pot_cross",
    "textures": {
        "plant": "censored_id:block/censored_flower"
    }
}

 

 

Thanks in advance again :) 

Edited by Peerius
New knowledge

  • Author

Yes.. Sorry for wasting your time, I forgot the "modid:" in the blockstates file.

 

 

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.