use of net.minecraft.item.RangedWeaponItem in project BleachHack by BleachDrinker420.
the class BowBot method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (!(mc.player.getMainHandStack().getItem() instanceof RangedWeaponItem) || !mc.player.isUsingItem())
return;
if (getSetting(0).asToggle().getState()) {
if (mc.player.getMainHandStack().getItem() == Items.CROSSBOW && (float) mc.player.getItemUseTime() / (float) CrossbowItem.getPullTime(mc.player.getMainHandStack()) >= 1f) {
mc.player.stopUsingItem();
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.UP));
mc.interactionManager.interactItem(mc.player, mc.world, Hand.MAIN_HAND);
} else if (mc.player.getMainHandStack().getItem() == Items.BOW && BowItem.getPullProgress(mc.player.getItemUseTime()) >= getSetting(0).asToggle().getChild(0).asSlider().getValueFloat()) {
mc.player.stopUsingItem();
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.UP));
}
}
// Credit: https://github.com/Wurst-Imperium/Wurst7/blob/master/src/main/java/net/wurstclient/hacks/BowAimbotHack.java
SettingToggle aimToggle = getSetting(1).asToggle();
if (aimToggle.getState()) {
LivingEntity target = Streams.stream(mc.world.getEntities()).filter(e -> EntityUtils.isAttackable(e, true) && (!aimToggle.getChild(3).asToggle().getState() || mc.player.canSee(e))).filter(e -> (aimToggle.getChild(0).asToggle().getState() && EntityUtils.isPlayer(e)) || (aimToggle.getChild(1).asToggle().getState() && EntityUtils.isMob(e)) || (aimToggle.getChild(2).asToggle().getState() && EntityUtils.isAnimal(e))).sorted(Comparator.comparing(mc.player::distanceTo)).map(e -> (LivingEntity) e).findFirst().orElse(null);
if (target == null)
return;
// set velocity
float velocity = (72000 - mc.player.getItemUseTimeLeft()) / 20F;
velocity = Math.min(1f, (velocity * velocity + velocity * 2) / 3);
// set position to aim at
Vec3d newTargetVec = target.getPos().add(target.getVelocity());
double d = mc.player.getEyePos().distanceTo(target.getBoundingBox().offset(target.getVelocity()).getCenter());
double x = newTargetVec.x + (newTargetVec.x - target.getX()) * d - mc.player.getX();
double y = newTargetVec.y + (newTargetVec.y - target.getY()) * d + target.getHeight() * 0.5 - mc.player.getY() - mc.player.getEyeHeight(mc.player.getPose());
double z = newTargetVec.z + (newTargetVec.z - target.getZ()) * d - mc.player.getZ();
// set yaw
mc.player.setYaw((float) Math.toDegrees(Math.atan2(z, x)) - 90);
// calculate needed pitch
double hDistance = Math.sqrt(x * x + z * z);
double hDistanceSq = hDistance * hDistance;
float g = 0.006F;
float velocitySq = velocity * velocity;
float velocityPow4 = velocitySq * velocitySq;
float neededPitch = (float) -Math.toDegrees(Math.atan((velocitySq - Math.sqrt(velocityPow4 - g * (g * hDistanceSq + 2 * y * velocitySq))) / (g * hDistance)));
// set pitch
if (Float.isNaN(neededPitch)) {
WorldUtils.facePos(target.getX(), target.getY() + target.getHeight() / 2, target.getZ());
} else {
mc.player.setPitch(neededPitch);
}
}
}
use of net.minecraft.item.RangedWeaponItem in project Biome-Makeover by Lemonszz.
the class StoneGolemEntity method getArrowType.
public ItemStack getArrowType(ItemStack stack) {
if (stack.getItem() instanceof RangedWeaponItem) {
Predicate<ItemStack> predicate = ((RangedWeaponItem) stack.getItem()).getHeldProjectiles();
ItemStack itemStack = RangedWeaponItem.getHeldProjectile(this, predicate);
return itemStack.isEmpty() ? new ItemStack(Items.ARROW) : itemStack;
} else {
return ItemStack.EMPTY;
}
}
Aggregations