Is there a way to give ranged weapons a cooldown?

Started by Duelnation on Sat, 07/20/2019 - 18:24

Topic category: Help with MCreator's application

Last seen on 22:16, 14. Aug 2019
Joined Nov 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Is there a way to give ranged weapons a cooldown?
Sat, 07/20/2019 - 18:24

Since the ranged weapons in mcreator  have no cooldown, they're too OP. So I need to know how to give the weapons a cooldown for whenever you use them so that you can't rapid-fire and take things down in a second. I don't mind having to code it in, just let me know where the code goes so I can easily plug it in. I feel like a lot of people would like to know how to do this too.

Last seen on 17:49, 4. Aug 2019
Joined Nov 2018
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Use NBT data for the…
Mon, 07/22/2019 - 08:04

Use NBT data for the cooldown on the player make it increase when the item is used. Change the "if flag = true"(or whatever statement) to getting the specified ticks on the nbt data.

Last seen on 22:16, 14. Aug 2019
Joined Nov 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
I couldn't find something…
Wed, 07/24/2019 - 18:54

I couldn't find something that resembeled a true or false thing that had to do with the "flag". Here's every instance of flag in the code.

 

if (flag || slotID != -1) {
                    float f = 1F;
                    EntityArrowCustom entityarrow = new EntityArrowCustom(world, entity);
                    entityarrow.shoot(entity.getLookVec().x, entity.getLookVec().y, entity.getLookVec().z, f * 2.0F, 0);
                    entityarrow.setIsCritical(false);
                    entityarrow.setDamage(5);
                    entityarrow.setKnockbackStrength(5);
                    itemstack.damageItem(1, entity);
                    int x = (int) entity.posX;
                    int y = (int) entity.posY;
                    int z = (int) entity.posZ;
                    world.playSound((EntityPlayer) null, (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D,
                            (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
                                    ("entity.arrow.shoot"))), SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

 

        if (flag) {
                        entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
                    } else {
                        if (new ItemStack(Items.DYE, (int) (1), 4).isItemStackDamageable()) {
                            ItemStack stack = entity.inventory.getStackInSlot(slotID);
                            if (stack.attemptDamageItem(1, new Random(), entity)) {
                                stack.shrink(1);
                                stack.setItemDamage(0);
                            }
                        } else {
                            entity.inventory.clearMatchingItems(new ItemStack(Items.DYE, (int) (1), 4).getItem(), -1, 1, null);
                        }

 

boolean flag = entity.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, itemstack) > 0;
                int slotID = entity.inventory.getSlotFor(new ItemStack(Items.DYE, (int) (1), 4));

 

 

 

Though I did find this.

@Override
        public EnumAction getItemUseAction(ItemStack itemstack) {
            return EnumAction.BOW;
        }