Started by
Duelnation
on
Topic category: Help with MCreator software
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.
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.
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;
}
Can you explain a little more. Like what procedure blocks to use.