#How i can change bow pull speed time?

1 messages · Page 1 of 1 (latest)

bitter ravine
#

I try this code but seems this not working

package name.modid.mixin;

import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BowItem.class)
public class BowItemMixin {
  private static final float PULL_SPEED = 2.0f;

  @Inject(method = "getMaxUseTime", at = @At("RETURN"), cancellable = true)
  private void modifyMaxUseTime(ItemStack stack, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
    int original = cir.getReturnValue();
    cir.setReturnValue((int) (original / PULL_SPEED));
  }
}
night lion
#

getMaxUseTime is the maximum time you can hold the bow drawn, not how long it takes to reach full draw. This is measured in seconds, specifically, 72000 of them. (I was doing the same thing the other day and that was my first idea too).
Anyway, if I remember correctly, you need to mixin to getPullProgress. You should otherwise be able to do the same thing there as you tried here.

bitter ravine
#

Thank you, figured this out, all that's left is to synchronize animation speed

package name.modid.mixin;

import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(BowItem.class)
public class BowItemMixin {
  private static final float PULL_SPEED = 4.0f;

  @Inject(method = "getMaxUseTime", at = @At("RETURN"), cancellable = true)
  private void modifyMaxUseTime(ItemStack stack, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
    int original = cir.getReturnValue();
    cir.setReturnValue((int) (original / PULL_SPEED));
  }

  @Inject(method = "getPullProgress", at = @At("RETURN"), cancellable = true)
  private static void getPullProgress(int useTicks, CallbackInfoReturnable<Float> cir) {
    float f = useTicks / (20.0F / PULL_SPEED);
    f = (f * f + f * 2.0F) / 3.0F;
    if (f > 1.0F) {
      f = 1.0F;
    }
    cir.setReturnValue(f);
  }
}