#anyone know how to make a throwable's cooldown shorter than the default?
1 messages · Page 1 of 1 (latest)
The shortest is 1 shot per tick (no cooldown), you can shoot 2 projectiles at the same time this would make the fire rate 2 per tick
20 ticks = 1 second
@dreamy cedar How do you shoot multiple projectiles?
You can use an event in player.json to add a component group with the minecraft:spawn_entity component, or you can use scripts too
"minecraft:spawn_entity": {
"entities": [
{
"spawn_entity": "minecraft:arrow",
"num_to_spawn": 2,
"min_wait_time": 0,
"max_wait_time": 0,
"single_use": true
}
]
}
where in the player.json do I put this?
Within a component group, you add this component group through an event
will the spawned projectiles travel in the same directrion and with the same force?
Yes, if the spawned entity has the minecraft:projectile component it is as if you were shooting the projectile
k ima try it
"description": {
"identifier": "minecraft:player",
"is_spawnable": false,
"is_summonable": false,
"is_experimental": false
},
"component_groups": {
"shoot_arrow": {
"minecraft:spawn_entity": {
"entities": [
{
"spawn_entity": "minecraft:arrow",
"num_to_spawn": 2,
"min_wait_time": 0,
"max_wait_time": 0,
"single_use": true
}
]
}
}
},
"events": {
"shoot:arrow": {
"add": {
"component_groups": [
"shoot_arrow"
]
}
}
}
does this have to go into the player.json to work or will it work on other entities
in any entity
k im a little stupido and don't know what im doing wrong, heres the code: {
"format_version": "1.16.0",
"minecraft:entity": {
"description": {
"identifier": "avatarelements:thrown_fire_breath",
"is_spawnable": false,
"is_summonable": true,
"is_experimental": false,
"runtime_identifier": "minecraft:snowball"
},
"components": {
"minecraft:collision_box": {
"width": 0.25,
"height": 0.25
},
"minecraft:projectile": {
"on_hit": {
"impact_damage": {
"damage": 9,
"knockback": true,
"power_multiplier": 5,
"destroy_on_hit": true
},
"particle_on_hit": {
"particle_type": "lava",
"num_particles": 3,
"on_entity_hit": true,
"on_other_hit": true
}
},
"catch_fire": true,
"anchor": 1,
"power": 5,
"gravity": 0.8,
"angle_offset": 0,
"offset": [
0,
-0.1,
0
],
"uncertainty_base": 35
},
"minecraft:physics": {},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
},
"minecraft:spawn_entity": {
"entities": {
"spawn_entity": "avatarelements:thrown_fire_breath",
"num_to_spawn": 4
}
}
}
}
}
You need to add this to the entity that should shoot the projectile and not to the projectile entity
ohhhh
And it must also be placed in a component group, and activated through a event
like this:
{
"format_version": "1.20.10",
"minecraft:entity": {
"description": {
"identifier": "avatarelements:thrown_fire_breath",
"is_spawnable": false,
"is_summonable": true,
"is_experimental": false,
"runtime_identifier": "minecraft:snowball"
},
"components": {
"minecraft:collision_box": {
"width": 0.25,
"height": 0.25
},
"minecraft:physics": {},
"minecraft:pushable": {
"is_pushable": true,
"is_pushable_by_piston": true
}
},
"component_groups": {
"shoot_projectile": {
"minecraft:spawn_entity": {
"entities": {
"spawn_entity": "avatarelements:thrown_fire_breath",
"num_to_spawn": 4,
"single_use": true
}
}
}
},
"events": {
"shoot:projectile": {
"add": {
"component_groups": [
"shoot_projectile"
]
}
}
}
}
}
Then you trigger this event in some way, for example by the /event command
OH WHAT HAVE I DONE!!!
@dreamy cedar I don't think this was supposed to happen
Oh I figured it out
I forgot to make it single use lol
@dreamy cedar now Is there a way I can trigger this event through the use of an item?
Yes, animation controllers in BP or scripts
like this animation controller, but in bp. Do you know how to add?
{
"format_version": "1.10.0",
"animation_controllers": {
"controller.animation.player_shoot": {
"initial_state": "default",
"states": {
"default": {
"transitions": [
{
"shoot": "query.is_item_name_any('slot.weapon.mainhand','item_identifier') && query.is_using_item"
}
]
},
"shoot": {
"transitions": [
{
"default": "query.is_alive"
}
],
"on_entry": [
"@s shoot:projectile"
]
}
}
}
}
}
yeah give me a sec, I think I might have just thought of another way
yeah nope, almost broke my world
tried to use On_Use in the item to play the event, I have no idea why this didn't work but, umm, dont try it.
ima go eat something, ill be back later
item events are deprecated and no longer work in new versions
You can do this easily with a script
import { world } from '@minecraft/server'
world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => {
if(itemStack.typeId === "minecraft:compass") {
player.triggerEvent('shoot:projectile')
}
});
so they're just removing pretty much all events then?
Yes, all events on items and blocks
that sucks, I have no Idea what im doing with javascript
They were replaced with custom components in scripts
the most I've done is make a menu with actionFormData
You can use this, it's ready to use. Just replace "minecraft:compass" with your item, the manifest file also needs to be correct
ty bro
@dreamy cedar hey a few more questions, if u don't mind, with the script, is there a way to make it run a command instead of an event(for another project) and how would you make it run that command after a block is placed
I think it would be like this, if it's wrong you can ask at #1067535382285135923
world.afterEvents.playerPlaceBlock.subscribe((data) {
const { player, block } = data;
if(block.permutation.matches("minecraft:stone")) {
player.runCommandAsync('say command 1')
}
});
@robust garnet
I edited it, I don't think it would have worked before
oh, tank ya
also for the Events, is there a way to make them useable for every entity or do I have to add the component group and event to everything I want to use it in?
Must add on each entity unless you shoot the projectile with scripts
how do I do that with scripts?
Which entities will fire the projectile and how?
yeah
I'm not sure if this is stable, but it should be like this
import { world } from '@minecraft/server'
world.afterEvents.itemUse.subscribe(({ source: player, itemStack }) => {
const head = player.getHeadLocation();
const viewVector = player.getViewDirection();
if(itemStack.typeId === "minecraft:compass") {
const ammo = "minecraft:snowball"
const direction = { x: head.x + viewVector.x, y: head.y + viewVector.y, z: head.z + viewVector.z };
const power = { x: viewVector.x*1.25, y: viewVector.y*1.25, z: viewVector.z*1.25 };
player.dimension.spawnEntity(ammo, direction).getComponent('minecraft:projectile').shoot(power, { owner: player });
}
});
so I can use this to make any entity able to shoot with the item?
I think this would only work on players
oh, all good
@dreamy cedar sorry im back, had to go do some stuff, will that script let me shoot multiple of the projectile like the Event let me do?
Also with that runCommandAsync for the block is there anyway to make that delayed like you could before with the queued_ticking component? and will that command work if the block is place using setblock/fill command?
queued_ticking was moved to scripts, now you use the custom component onTick which does the same thing.
No, it only shoots one per tick, to shoot more you need to double the line player.dimension.spawnEntity...
kk
If you have any other questions about scripts, please ask in #1067535382285135923 , There are people who can help you better with this.