#anyone know how to make a throwable's cooldown shorter than the default?

1 messages · Page 1 of 1 (latest)

robust garnet
#

when making an item I know you can use the "minecraft:cooldown" component to make the cooldown longer but how do you make it shorter? I want like a rapid fire machine gun style of shooting

dreamy cedar
#

20 ticks = 1 second

robust garnet
#

@dreamy cedar How do you shoot multiple projectiles?

dreamy cedar
#
"minecraft:spawn_entity": {
  "entities": [
    {
      "spawn_entity": "minecraft:arrow",
      "num_to_spawn": 2,
      "min_wait_time": 0,
      "max_wait_time": 0,
      "single_use": true
    }
  ]
}
robust garnet
#

where in the player.json do I put this?

dreamy cedar
#

Within a component group, you add this component group through an event

robust garnet
#

will the spawned projectiles travel in the same directrion and with the same force?

dreamy cedar
#

Yes, if the spawned entity has the minecraft:projectile component it is as if you were shooting the projectile

robust garnet
#

k ima try it

dreamy cedar
#
  "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"
        ]
      }
    }
  }
robust garnet
#

does this have to go into the player.json to work or will it work on other entities

dreamy cedar
#

in any entity

robust garnet
#

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
}
}
}
}
}

dreamy cedar
#

You need to add this to the entity that should shoot the projectile and not to the projectile entity

robust garnet
#

ohhhh

dreamy cedar
#

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

robust garnet
#

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?

dreamy cedar
#

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"
          ]
        }
      }
    }
  }
}
robust garnet
#

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

dreamy cedar
#

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')
    }
});
robust garnet
#

so they're just removing pretty much all events then?

dreamy cedar
#

Yes, all events on items and blocks

robust garnet
#

that sucks, I have no Idea what im doing with javascript

dreamy cedar
#

They were replaced with custom components in scripts

robust garnet
#

the most I've done is make a menu with actionFormData

dreamy cedar
robust garnet
#

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

dreamy cedar
robust garnet
#

I love you no homo

#

you have litterally just solved every problem I was having

dreamy cedar
robust garnet
#

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?

dreamy cedar
#

Must add on each entity unless you shoot the projectile with scripts

robust garnet
#

how do I do that with scripts?

dreamy cedar
#

Which entities will fire the projectile and how?

robust garnet
#

yeah

dreamy cedar
#

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 });
    }
});
robust garnet
#

so I can use this to make any entity able to shoot with the item?

dreamy cedar
#

I think this would only work on players

robust garnet
#

oh, all good

robust garnet
#

@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?

dreamy cedar
dreamy cedar
robust garnet
#

kk

dreamy cedar
#

If you have any other questions about scripts, please ask in #1067535382285135923 , There are people who can help you better with this.