Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Posts posted by jonaskohl

  1. I want to add a recipe to my mod that has a block (let's say wooden planks) and a vanilla tool (let's say an axe) and I want the axe to loose durability when used in crafting. This is what I got so far (inside of ModRecipeProvider#registerRecipes):

    Ingredient axeIngredients = Ingredient.fromItems(
        () -> Items.WOODEN_AXE,
        () -> Items.STONE_AXE,
        () -> Items.GOLDEN_AXE,
        () -> Items.IRON_AXE,
        () -> Items.DIAMOND_AXE,
        () -> Items.NETHERITE_AXE
        .addCriterion("has_plank", hasItem(Blocks.OAK_PLANKS))

    However, this will consume the axe completely when crafted. How can I make the axe stay inside of the crafting grid and lose one point of durability?

    (Forge 1.16)

  2. I am using the following snippet inside of an onBlockClicked event listener to strip a custom log.

    public static void onBlockClicked(PlayerInteractEvent.RightClickBlock event) {
        final int FLAG_BLOCK_UPDATE = 1;
        final int FLAG_SEND_TO_CLIENTS = 2;
        final int FLAG_FORCE_RERENDER_MAIN_THREAD = 8;
        if (event.getItemStack().getItem() instanceof AxeItem) {
            World world = event.getWorld();
            BlockPos blockpos = event.getPos();
            BlockState blockstate = world.getBlockState(blockpos);
            Block block = BLOCK_STRIPPING_MAP.get(blockstate.getBlock());
            if (block != null) {
                PlayerEntity playerentity = event.getPlayer();
                world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
                if (!world.isRemote) {
                    world.setBlockState(blockpos, block.getDefaultState()
                    if (playerentity != null) {
                        event.getItemStack().damageItem(1, playerentity, (entityIn) -> {


    Everything works as expected, except the axe doesn't "swing" as it does with vanilla blocks. It just does nothing. I tried using


    but that does absolutely nothing. How can I achieve a swinging tool?

  3. In my mod I have several custom flower types (instances of FlowerBlock), which I register using the DeferredRegister. Now I want to add them to the composter's registry of compostable items. I know I need to add them to ComposterBlock.CHANCES, but I don't know when exactly I need to do this. When I call ComposterBlock.CHANCES.put() in my mod's main class's constructor, I get a NullPointerException with the message 'Registry Object not present: my_mod:my_flower', even though I created the flower objects before I tried to register them. I suspect I need to call this at a later time, but I couldn't find any information about this anywhere.

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.