- Supported Minecraft Versions
- 1.18
- 1.19
- 1.20
This resource allows you to create your own custom arrows easily within minutes.
Installation
Put the script file inside your scripts folder. Requires skript-reflect and SkBee.
Usage
1. Create a custom arrow and register it using the register function. Do not register 2 or more arrows with the same ID or they will be overwritten.
Code:
on load:
set {_arrow} to arrow named "My Awesome Arrow!"
registerCustomArrow("awesome", {_arrow}) # "awesome" is the ID
2. (Optional) Create a shoot listener for your custom arrow that will be triggered when an arrow is shot.
Code:
function arrow_awesome_shoot(shooter: player, projectile: entity, bow: item, event: event):
broadcast {_shooter}
We put awesome in the function name because that is the ID of the custom arrow.
{_shooter} is the player who shot the arrow.
{_projectile} is the arrow entity.
{_bow} is the bow/crossbow that was used to shoot the arrow.
{_event} is the raw event that can be used to run methods. If you don't know what this is you probably don't need it.
Keep in mind that you can name the variables whatever you want! You can also not include all of them. Example:
Code:
function arrow_awesome_shoot(shooter: player, projectile: entity, bow: item, event: event): # VALID
function arrow_awesome_shoot(shooter: player, projectile: entity, bow: item): # VALID
function arrow_awesome_shoot(shooter: player, bow: item, projectile: entity): # INVALID, the variables are not in order.
3. (Optional) Create a hit listener for your custom arrow that will be called whenever the arrow hits a block or an entity.
Code:
function arrow_awesome_hit(victim: entity, block: block, event: event):
broadcast {_victim}
{_block} is the block that was hit by the arrow. It may not always be set!!!
{_event} is the raw event that can be used to run methods.
4. Give yourself the arrow.
Code:
give player {custom.arrow::awesome}
Example Implementation
Code:
# Register the arrow
on load:
set {_arrow} to tipped arrow named "&6&lFire Arrow" with nbt (nbt from "{CustomPotionColor:16741120}") with all flags hidden
registerCustomArrow("fire", {_arrow})
function arrow_fire_shoot(shooter: player, projectile: entity, bow: item):
# Punish the player for using the wrong bow
if {_bow}'s name isn't "&6&lFire Bow":
ignite {_shooter} for 3 seconds
send "&cYou burnt yourself while shooting the fire arrow because you aren't using the fire bow." to {_shooter}
# Create particles until it hits the ground
while {_projectile} isn't on ground:
wait 1 tick
play flame at {_projectile}
# When it hits something, create an explosion
function arrow_fire_hit(victim: entity, block: block):
set {_location} to {_victim} ? {_block}
create an explosion with strength 10 at {_location} with fire