Topic category: Help with Minecraft modding (Java Edition)
Hello,
I've been toying around with creating a simple shotgun-like ranged item and there is just one problem left for me to tackle:
The Item shoots 8 bullets per attack(1 though the ranged item settings itself and 7 via "on item used"-procedure)I want the item do do most damage at close distance, but any entity only recieves/registers one hit( =only the damage of a single bullet)
This is kind of frustrating because despite the useful bullet spread, common mobs are killed in two hits regardless of dsitance from the player.
Could this be resolved with changes to the ranged item itself, or would there have to be changes to the way any entity handles a damage event(per tick)? Unfortunately this is already beyond my comprehension.
Thank you for any advice
Not possible in Mcreator
Aw, waht a bummer. But I already suspected that.
Big thanks nontheless. That means I've got it working as best as I could.
Do zero damage projectiles, but make a procedure for when the projectile hits, and set their health to 1 less or something.
Hmm, that migh actually work.
Would you go about it by usind a command similar to this:
/damage @e[type=!player, distance=..2] 1 entity_attack entity @e[type=player, name="shotgun"]
?
I'll report back if this works as a simple solution
Ok. Jut tested it.
Sadly it does not overcome the initial problem. Even if the damage is applied via "projectile hits living entity" it still only applies it once, even if all 8 pellets hit at the same time. So the outcome is the same as before :/
Ok, so after all I tried the only solution is to make the projectiles do zero(0) damage and apply damage via the command.
But to scale damage according to distance you should instead define many individual if->do conditions of "does entity exist in cube of size x of type [player]" this way you can define damage dealt in relation to distance between player and target.
Just male sure to define a bunch for maybe diefferent cube-sizes in steps of 4 blocks until you have defined the maximum range that your "shotgun" should work.
I also set a block with a timer in the "on ranged item used" to despawn the bullets via command after x ticks to limit the range regardless of shoot power. This is optional of course
pls show procedure!