Minecraft Data Packs / Game Mechanic

SwingThroughGrass [v2.1 (1.20.2+)]

  • check_circle Advancements
  • check_circle Functions
  • check_circle Predicates
  • 3,183 views, 10 today
  • 437 downloads, 2 today
  • 22
  • 14
  • 9
Kazii78's Avatar Kazii78
Level 19 : Journeyman System
14
🏆 - Credits
This data pack was inspired by the mod SwingThroughGrass by exidex, shout out to that guy, fabulous mod!

⚙️ - Functionality
Hit enemies behind grass!

When holding weapons (currently only counting swords and axes),
the grass in your line of sight will be removed.
This is improves visibility as well as adding the luxury of enchantments, crits and sweeps!

Once you move your camera away from your original location, all grass blocks that have been previously removed will appear back.
All blocks placed at the location of where the grass should've been will be broken and replaced with the grass when looking away.


In addition, there is a config where you can enable a setting to whether break grass when you hit an entity through it.
This is off by default.

This works for grass (short grass) and tall grass as of now.

📟 - Commands
/function swingthroughgrass:uninstall
Uninstalls the data pack.

/function swingthroughgrass:config
Opens the config to the data pack.

📜 - Information
swingthroughgrass:* is the public namespace, where all public commands are.
stg:* is the private namespace containing the system of the data pack.

Current data pack version: v2.1
Supported minecraft versions: 1.20.2+
Creditexidex
CompatibilityMinecraft 1.20
Tags

9 Update Logs

Config Addition [v2.1] : by Kazii78 02/28/2024 3:48:54 pmFeb 28th

- config added
- can change the breaking of grass when an entity is hit through it
- fixed and updated pack.mcmeta to proper format

(24w09a tested to be working with the removal of NBT and addition of components, predicate did need an update to work again though)
LOAD MORE LOGS

Create an account or sign in to comment.

1
02/21/2024 9:34 pm
Level 25 : Expert Goblin
Finnodile
Finnodile's Avatar
This is awesome! But i think it should permanently remove the grass when you swing the sword, to make building in plains easier :)
2
02/22/2024 3:58 am
Level 19 : Journeyman System
Kazii78
Kazii78's Avatar
I've had complaints about this so I've removed it. However, since people want it back, I'll implement a config to be able to change it!
1
02/22/2024 6:17 pm
Level 25 : Expert Goblin
Finnodile
Finnodile's Avatar
Great idea!
1
01/12/2024 7:34 pm
Level 69 : High Grandmaster Technomancer
GatKong
GatKong's Avatar
Great datapack, I gave you diamond. I like the way you test the server version using grass and short_grass.

Currently your datapack adds about 5ms to each tick on my very-high-speed system, but on lessor systems, that per-tick lag addition could be much more substantial, which on servers running a bunch of datapacks, adds up.

For example: Is it necessary to valid the system every tick?

Three suggestions to make it even more awesome than it already is:
1. Consider not using a per-tick mcfunction, which runs rather a player has swung into grass or not, but instead us an advancement to detect the player breaking grass etc. then running your code as a reward... so it only runs when necessary.
2. Rather than testing for every type of block to be affected, requiring you to run your check code nine times, use a custom block tag to identify relevant block types, then your code only has to run once. This streamlines your code, and helps address per-tick time as well.
3. Currently it doesn't take into account any enchantments on the mainhand weapon. It would be worth it to add that, IMO.

I hope you find this feedback useful.
1
01/14/2024 12:54 pmhistory
Level 19 : Journeyman System
Kazii78
Kazii78's Avatar
Reasonable feedback and arguments, I'll look into it and change some of the things within the data pack.

As for some parts of this, I can't use block tags sadly, there is no way for me to check a mined block in other ways (at least, not that I know of),

I really wish I could do so.

If you know how to, then please let me know.


I'll see what I can do to everything you've listed as of now,

I appreciate the compliment at the very start. I found it pretty neat that minecraft keeps functions with invalid /function commands valid.


It's how I made it work, I might do this for any future data packs as it doesn't require me to use another site where I have to upload multiple files and update multiple versions of a data pack.



Thanks for the feedback, I'll see if I can release something by the end of the week.
1
01/14/2024 5:42 pm
Level 69 : High Grandmaster Technomancer
GatKong
GatKong's Avatar
You said:
I can't use block tags sadly, there is no way for me to check a mined block in other ways (at least, not that I know of)

You are already using block tags :)
you have in your datapack these block tags: new.json & old.json

To test for blocks identified in your tag in a command would look like this:
execute if block ~ ~ ~ #kz.sg_swigra:affected_blocks/new run

in an advancement to test for breaking blocks it would be something like:
{
  "criteria": {
    "tall_grass": {
      "trigger": "minecraft:tick",
      "conditions": {
        "player": [
          {        
            "condition": "minecraft:entity_scores",
            "entity": "this",
            "scores": {
              "kz.sg_swigra.swing_through_grass.mined.tall_grass": {
                "min": 1
              }
            }
          }
        ]
      }
    },
    "grass": {
      "trigger": "minecraft:tick",
      "conditions": {
        "player": [
          {
            "condition": "minecraft:entity_scores",
            "entity": "this",
            "scores": {
              "kz.sg_swigra.swing_through_grass.mined.grass": {
                "min": 1
              }
            }
          }
         ]
        }
       }
  },
  "requirements": [
    [
      "grass",
      "tall_grass"
    ]
  ],
  "rewards": {
    "function": "namespace:function"
  }
}
1
02/18/2024 12:56 pm
Level 19 : Journeyman System
Kazii78
Kazii78's Avatar
"Thanks for the feedback, I'll see if I can release something by the end of the week."



That didn't go as planned, haha.
1
11/26/2023 4:49 am
Level 72 : Legendary Whale
A05n21
A05n21's Avatar
real?
1
11/26/2023 8:31 am
Level 19 : Journeyman System
Kazii78
Kazii78's Avatar
sure, why not
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome