How to make logs unbreakable by hand?

Started by GrayEtc on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make logs unbreakable by hand?

I’m planning on making the starting stages of the game more difficult, similar to RLCraft. How would I make wood unbreakable with just your hand, to where only wood or above could break it?

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
make 2 versions of it and…
Sat, 06/06/2020 - 04:51

make 2 versions of it and use trigger and procedures to change it to a breakable version of this block.

Note:hardness should more than or equal to 10,000 but do not check "is block unbreakable?"

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I am so fired up right now…
Sat, 06/06/2020 - 04:54

I am so fired up right now with this mod idea! I have been wanting to do a mod like this for so long. My plans would be limiting the player inventory to 3 slots (main hand, offhand, inventory). Also, I would do similar things to this request. I almost want to join in on this project of yours!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

To cut to the chase, this is an event I came up with off the spot;

    @SubscribeEvent
    public void harvestCheck(PlayerEvent.BreakSpeed event)
    {
        BlockState block = event.getState();
        if (block.getBlock() instanceof LogBlock)
        {
            PlayerEntity player = event.getPlayer();
            ItemStack item = player.getItemStackFromSlot(EquipmentSlotType.MAINHAND);
            if (!(item.getItem() instanceof AxeItem))
            {
                event.setCanceled(true);
            }
        }
    }

 

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Don't be mad if I do a…
Sat, 06/06/2020 - 04:54

Don't be mad if I do a similar mod on my own! Good luck to you!

Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Haha, the mod I’m working on…
Sat, 06/06/2020 - 05:47

Haha, the mod I’m working on will just have this in it and I won’t be going as far as you do most likely with it, but Thank you for the code! I’m quite inexperienced with it though, so how I would I go about implementing this string?

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You just chuck that tang…
Sat, 06/06/2020 - 05:50

You just chuck that tang right in 'er!

 

But actually, you can just put that snippet in any class as long as it is registered using;

		MinecraftForge.EVENT_BUS.register(new AnyDangClass());

You should probably just create a procedure, lock it, and put it in.

If you need more information or help. Post code, preferably in a pastebin/git. Or add me on discord!

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
its a couple years late, but…
Sat, 08/19/2023 - 15:37

its a couple years late, but this is the (simple) solution i found in case anybody new wants to see. works perfectly:

basically, it checks if the block is wood, then checks if the player is holding an axe of any type. (this works with both modded woods and axes.)

only if both are true, it cancels the event that triggered it, stopping the left click. because the player is holding click, they continue to punch, but it does zero damage to the block itself. this essentially is exactly how the bedrock block works.

you can also do this with stone and pickaxes, dirt and shovels, pretty much anything. all you need is more procedures