Posted February 25, 20205 yr 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.
February 25, 20205 yr 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 February 26, 20205 yr by Peerius New knowledge
February 26, 20205 yr 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.