use of team.cqr.cqrepoured.entity.projectiles.ProjectileBullet in project ChocolateQuestRepoured by TeamChocoQuest.
the class ItemRevolver method shoot.
public void shoot(ItemStack stack, World worldIn, PlayerEntity player) {
boolean flag = player.abilities.instabuild;
ItemStack itemstack = this.findAmmo(player);
if (!itemstack.isEmpty() || flag) {
if (!worldIn.isClientSide) {
if (flag && itemstack.isEmpty()) {
ProjectileBullet bulletE = new ProjectileBullet(player, worldIn, EBulletType.IRON);
// ProjectileBullet bulletE = CQREntityTypes.PROJECTILE_BULLET.get().create(worldIn);
// bulletE.setBulletType(1);
bulletE.shootFromRotation(player, player.xRot, player.yRot, 0.0F, 3.5F, 5F);
player.getCooldowns().addCooldown(stack.getItem(), 10);
worldIn.addFreshEntity(bulletE);
} else {
// ProjectileBullet bulletE = CQREntityTypes.PROJECTILE_BULLET.get().create(worldIn); //, player, this.getBulletType(itemstack));
// bulletE.setBulletType(this.getBulletType(itemstack));
ProjectileBullet bulletE = new ProjectileBullet(player, worldIn, this.getBulletType(itemstack));
bulletE.shootFromRotation(player, player.xRot, player.yRot, 0.0F, 3.5F, 5F);
player.getCooldowns().addCooldown(stack.getItem(), 10);
worldIn.addFreshEntity(bulletE);
stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(player.getUsedItemHand()));
}
}
worldIn.playLocalSound(player.position().x, player.position().y + player.getEyeHeight(), player.position().z, this.getShootSound(), SoundCategory.MASTER, 1.0F, 0.9F + random.nextFloat() * 0.2F, false);
player.xRot -= worldIn.random.nextFloat() * this.getRecoil();
if (!flag) {
itemstack.shrink(1);
if (itemstack.isEmpty()) {
player.inventory.removeItem(itemstack);
}
}
}
}
use of team.cqr.cqrepoured.entity.projectiles.ProjectileBullet in project ChocolateQuestRepoured by TeamChocoQuest.
the class ItemRevolver method shoot.
@Override
public void shoot(World worldIn, LivingEntity shooter, Entity target, Hand handIn) {
if (!worldIn.isClientSide) {
ItemStack bulletStack = new ItemStack(CQRItems.BULLET_IRON.get(), 1);
if (shooter instanceof AbstractEntityCQR) {
AbstractEntityCQR cqrEnt = (AbstractEntityCQR) shooter;
ItemStack bullet = cqrEnt.getItemStackFromExtraSlot(EntityEquipmentExtraSlot.ARROW);
if (bullet != null && !bullet.isEmpty() && (bullet.getItem() instanceof ItemBullet)) {
bulletStack = bullet;
bullet.shrink(1);
}
}
ProjectileBullet bulletE = new ProjectileBullet(shooter, worldIn, this.getBulletType(bulletStack));
Vector3d v = target.position().subtract(shooter.position());
v = v.normalize();
v = v.scale(3.5D);
// bulletE.setVelocity(v.x, v.y, v.z);
bulletE.setDeltaMovement(v);
// bulletE.motionX = v.x;
// bulletE.motionY = v.y;
// bulletE.motionZ = v.z;
// bulletE.velocityChanged = true;
worldIn.addFreshEntity(bulletE);
}
}
use of team.cqr.cqrepoured.entity.projectiles.ProjectileBullet in project ChocolateQuestRepoured by TeamChocoQuest.
the class ItemMusket method shoot.
@Override
public void shoot(ItemStack stack, World worldIn, PlayerEntity player) {
boolean flag = player.abilities.instabuild;
ItemStack itemstack = this.findAmmo(player);
if (!itemstack.isEmpty() || flag) {
if (!worldIn.isClientSide) {
if (flag && itemstack.isEmpty()) {
ProjectileBullet bulletE = new ProjectileBullet(player, worldIn, EBulletType.IRON);
bulletE.shootFromRotation(player, player.xRot, player.yRot, 0.0F, 3.5F, 2F);
player.getCooldowns().addCooldown(stack.getItem(), 30);
worldIn.addFreshEntity(bulletE);
} else {
ProjectileBullet bulletE = new ProjectileBullet(player, worldIn, this.getBulletType(itemstack));
bulletE.shootFromRotation(player, player.xRot, player.yRot, 0.0F, 3.5F, 2F);
player.getCooldowns().addCooldown(stack.getItem(), 30);
worldIn.addFreshEntity(bulletE);
stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(p.getUsedItemHand()));
}
}
worldIn.playLocalSound(player.position().x, player.position().y + player.getEyeHeight(), player.position().z, this.getShootSound(), SoundCategory.MASTER, 1.0F, 0.9F + random.nextFloat() * 0.2F, false);
player.xRot -= worldIn.random.nextFloat() * 10;
if (!flag) {
itemstack.shrink(1);
if (itemstack.isEmpty()) {
player.inventory.removeItem(itemstack);
}
}
}
}
Aggregations