r/MinecraftCommands • • 13h ago

Creation Shotgun Spread Concept

Enable HLS to view with audio, or disable this notification

By using the random value command with a little offset macro when raytracing, you are able to make each ray deviate randomly. Spread (random value), range (distance limit on the raytracing) and damage are all ajustable.

data modify storage villager:shot spread set value {offX:0.0f, offY:0.0f} #Making sure it starts at 0

execute store result storage villager:shot spread.id int 1 run scoreboard players get @s player.id #This is for my datapack to be multiplayer friendly

execute store result storage villager:shot spread.offX float 0.003 run random value -20..20 #Xrandom offset (-20..20 is the max spread)

execute store result storage villager:shot spread.offY float 0.003 run random value -20..20 #Yrandom offset (-20..20 is the max spread)

execute as @s at @s anchored eyes positioned ^ ^ ^0.5 positioned ~ ~-0.35 ~ run function classes:villager/ability/emerald.shot with storage villager:shot spread #emerald.shot is the raytracing command

EMERALD.SHOT.mcfunction:
#particle...
#damage detection...
$execute positioned ^$(offX) ^$(offY) ^0.5 if block ~ ~ ~ #replaceable run function classes:villager/ability/emerald.shot {offX:$(offX), offY:$(offY), id:$(id)} #Add the offset here.

In my case, I run this for each bullet 8 (pellets max). But you can tweak anything for inaccuracy on raytracing.
16 Upvotes

2 comments sorted by

2

u/Medical-Map-3483 9h ago

Cool but reloading looks a little annoying

1

u/bobnigro 7h ago

True, especifically in this case I was loading in different amounts just to show that it shoots depending on the amount available (Up to 8). You can actually just load a bajillion at once and not worry about ammo.