Created
July 8, 2023 10:24
-
-
Save szdytom/b96028ba94375afe7716cf1930aa4ba3 to your computer and use it in GitHub Desktop.
[Minecraft] Shoot fireballs!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__on_player_uses_item(player, item_tuple, hand)->( | |
if(item_tuple:0 == 'fire_charge', | |
playerPos = query(player, 'pos') + l(0, 1, 0); // Set the position where the fireball will spawn | |
sound('entity.blaze.shoot', playerPos); // Play a sound | |
playerPitch = query(player, 'pitch'); // Detect where the player is looking | |
playerYaw = query(player, 'yaw') + 90; | |
v = query(player, 'look'); | |
fbv = v * 0.25; | |
fireball = spawn('fireball', playerPos + v*2, nbt(str('{ExplosionPower: 2b, power: [%fd,%fd,%fd]}', fbv:0, fbv:1, fbv:2))); | |
modify(fireball, 'nbt_merge', {'Owner' -> query(player, 'uuid')}); | |
gamemode = player ~ 'gamemode'; | |
if(gamemode == 'survival' || gamemode == 'adventure', // Remove a fire charge from the selected slot or offhand if the player is in survival mode | |
inventory_set(player, if(hand == 'offhand', -1, player ~ 'selected_slot'), (item_tuple: 1) - 1); | |
); | |
); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment