[TUTOTIAL] TreeCapitator / Veinminer | Few custom code | Using loot table | 2024.2 | NeoForge 1.20.4

Started by doomsday_fire on

Topic category: User side tutorials

Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTOTIAL] TreeCapitator / Veinminer | Few custom code | Using loot table | 2024.2 | NeoForge 1.20.4
Fri, 10/04/2024 - 16:41 (edited)

Procedure brakes any log/wood block placed close to each other (up to 64 blocks - configurable).

If you use custom wood in your mod, you should include blocks in common wood tags.

NeoForge 1.20.4, 2024.2, but should work in future versions too.

IF ANY LINKS OR IMAGES ARE BROKEN IN THIS GUIDE, CONTACT ME IN DISCORD - @doomsdayfire

Features:

  • Universal to use with any blocks - you don't need to check for each block material manually
  • Breaks only wood tagged as minecraft:log (configurable)
  • Supports enchantments (If you creates ones that affect wood loot table drop)
  • Beautiful chain-like animations (delay between braking blocks)
  • Tool breaking prevention
  • Can implement Veinminer behavior (break full ore cluster) - small changes in original procedure

Step 1. Creating tool - axe

There you choose your preferred properties: tier, efficiency, durability.

You have to create 2 triggers: When block destroyed with tool and When entity swings item (any left click with tool)

Step 2. Procedure import
Open it and import Axe_guide.ptpl file for When block destroyed with tool (Procedure file):

There you don't need any local variables, since Wait for X ticks function doesn't work with them, so we use NBT tags to store information

Open it and import SwingItemMaxBlocks.ptpl file for When block destroyed with tool 

There you don't need any local variables as well

Step 3. Work explanation

Breaking the block makes procedure to check 3x3x3 area, where middle block is originally breaking one. If any of surrounding blocks is valid (wood type), we recall same procedure again (AxeGuideBlockDestroyedWithTool or whatever you named it) with respective coordinates. Otherwise procedure looks for another direction automatically (kind of sculk spreading).

Step 4. Procedure overview

For better matrix calculation method check other tutorial (Step 4)

If tool have 1 durability, whole process stops and cooldown for 3 seconds (60 ticks) is applied
Process also stops if you drop tool while chain-breaking is active

Custom code snippet part:

(BuiltInRegistries.BLOCK.getKey((world.getBlockState(BlockPos.containing

(itemstack.getOrDefault(DataComponents.CUSTOM_DATA, 

CustomData.EMPTY).copyTag().getDouble("local_x"),
itemstack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag().getDouble("local_y"),
itemstack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag().getDouble("local_z")))).

getBlock()).toString().split(":")[1])


[Full procedure overview]


Ingame examples
- Unbreaking enchantment works (24 durability lost for 64 blocks - Unbreaking III)

Breaks all type of trees: even complex big oak tree. Leaves falling fast due to random_tick_speed set to 300 manually

Veinminer variant. Assign procedures to pickaxe
Set needed tag (c:ores for example)
Don't forget to change Recall procedure component as well (for pickaxe's When block destroyed with tool -> VeinMinerPickaxe in my case)



If you have any questions or suggestions, feel free to ask in comments or discord (@doomsdayfire).

1st Procedure link and 2nd Procedure link 

Edited by doomsday_fire on Fri, 10/04/2024 - 16:41
Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
One of the detailed…
Fri, 10/04/2024 - 16:51

One of the detailed tutorials I ever seen!