Skip to content

Instantly share code, notes, and snippets.

@szdytom
Created July 8, 2023 10:24
Show Gist options
  • Save szdytom/b96028ba94375afe7716cf1930aa4ba3 to your computer and use it in GitHub Desktop.
Save szdytom/b96028ba94375afe7716cf1930aa4ba3 to your computer and use it in GitHub Desktop.
[Minecraft] Shoot fireballs!
__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