use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class PoisonCloudShotEnchantmentMixin method onPoisonCloudShotEnchantmentEntityHit.
@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onPoisonCloudShotEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
return;
}
PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
Entity target = entityHitResult.getEntity();
LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
ItemStack mainHandStack = null;
if (shooter != null) {
mainHandStack = shooter.getMainHandStack();
}
if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.POISON_CLOUD, mainHandStack) >= 1)) {
int level = EnchantmentHelper.getLevel(EnchantsRegistry.POISON_CLOUD, mainHandStack);
float poisonCloudShotRand = shooter.getRandom().nextFloat();
if (poisonCloudShotRand <= 0.2F) {
if (target instanceof LivingEntity) {
AOECloudHelper.spawnPoisonCloud(shooter, (LivingEntity) target, level - 1);
}
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class McdwLongBow method onStoppedUsing.
@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
super.onStoppedUsing(stack, world, user, remainingUseTicks);
if (user instanceof PlayerEntity) {
PlayerEntity playerEntity = (PlayerEntity) user;
boolean bl = playerEntity.abilities.creativeMode || EnchantmentHelper.getLevel(Enchantments.INFINITY, stack) > 0;
ItemStack itemStack = playerEntity.getArrowType(stack);
if (!itemStack.isEmpty() || bl) {
if (itemStack.isEmpty()) {
itemStack = new ItemStack(Items.ARROW);
}
int i = this.getMaxUseTime(stack) - remainingUseTicks;
float f = getPullProgress(i);
if ((double) f >= 0.1D) {
boolean bl2 = bl && itemStack.getItem() == Items.ARROW;
if (!world.isClient) {
ArrowItem arrowItem = ((ArrowItem) (itemStack.getItem() instanceof ArrowItem ? itemStack.getItem() : Items.ARROW));
PersistentProjectileEntity persistentProjectileEntity = arrowItem.createArrow(world, itemStack, playerEntity);
persistentProjectileEntity.setProperties(playerEntity, playerEntity.pitch, playerEntity.yaw, 0.0F, f * maxBowRange, 1.0F);
if (f == 1.0F) {
persistentProjectileEntity.setCritical(true);
}
// POWER ENCHANTMENT
int j = EnchantmentHelper.getLevel(Enchantments.POWER, stack);
if (j > 0) {
persistentProjectileEntity.setDamage(persistentProjectileEntity.getDamage() + (double) j * 0.5D + 0.5D);
}
// PUNCH ENCHANTMENT
int k = EnchantmentHelper.getLevel(Enchantments.PUNCH, stack);
if (k > 0) {
persistentProjectileEntity.setPunch(k);
}
// FLAME ENCHANTMENT
if (EnchantmentHelper.getLevel(Enchantments.FLAME, stack) > 0) {
persistentProjectileEntity.setOnFireFor(100);
}
}
}
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class McdwShortBow method onStoppedUsing.
@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) {
super.onStoppedUsing(stack, world, user, remainingUseTicks);
if (user instanceof PlayerEntity) {
PlayerEntity playerEntity = (PlayerEntity) user;
boolean bl = playerEntity.abilities.creativeMode || EnchantmentHelper.getLevel(Enchantments.INFINITY, stack) > 0;
ItemStack itemStack = playerEntity.getArrowType(stack);
if (!itemStack.isEmpty() || bl) {
if (itemStack.isEmpty()) {
itemStack = new ItemStack(Items.ARROW);
}
int i = this.getMaxUseTime(stack) - remainingUseTicks;
float f = getPullProgress(i);
if ((double) f >= 0.1D) {
boolean bl2 = bl && itemStack.getItem() == Items.ARROW;
if (!world.isClient) {
ArrowItem arrowItem = ((ArrowItem) (itemStack.getItem() instanceof ArrowItem ? itemStack.getItem() : Items.ARROW));
PersistentProjectileEntity persistentProjectileEntity = arrowItem.createArrow(world, itemStack, playerEntity);
persistentProjectileEntity.setProperties(playerEntity, playerEntity.pitch, playerEntity.yaw, 0.0F, f * maxBowRange, 1.0F);
if (f >= 0.4F) {
persistentProjectileEntity.setCritical(true);
}
// POWER ENCHANTMENT
int j = EnchantmentHelper.getLevel(Enchantments.POWER, stack);
if (j > 0) {
persistentProjectileEntity.setDamage(persistentProjectileEntity.getDamage() + (double) j * 0.5D + 0.5D);
}
// PUNCH ENCHANTMENT
int k = EnchantmentHelper.getLevel(Enchantments.PUNCH, stack);
if (k > 0) {
persistentProjectileEntity.setPunch(k);
}
// FLAME ENCHANTMENT
if (EnchantmentHelper.getLevel(Enchantments.FLAME, stack) > 0) {
persistentProjectileEntity.setOnFireFor(100);
}
}
}
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class GrowingEnchantmentMixin method onGrowingEnchantmentEntityHit.
@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onGrowingEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
return;
}
PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
Entity target = entityHitResult.getEntity();
LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
ItemStack mainHandStack = null;
if (shooter != null) {
mainHandStack = shooter.getMainHandStack();
}
if (McdwEnchantsConfig.getValue("growing")) {
if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.GROWING, mainHandStack) >= 1)) {
int level = EnchantmentHelper.getLevel(EnchantsRegistry.GROWING, mainHandStack);
double originalDamage = persistentProjectileEntity.getDamage();
double damageModifier = 0;
if (level == 1)
damageModifier = 1.25D;
if (level == 2)
damageModifier = 1.5D;
if (level == 3)
damageModifier = 1.75D;
double squareDistanceTo = shooter.distanceTo(target);
double distance = Math.sqrt(squareDistanceTo);
double distanceTraveledModifier = distance * 0.1;
persistentProjectileEntity.setDamage(originalDamage * Math.min(distanceTraveledModifier, damageModifier));
}
}
}
use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.
the class RadianceShotEnchantmentMixin method onRadianceShotEnchantmentEntityHit.
@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onRadianceShotEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
return;
}
PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
Entity target = entityHitResult.getEntity();
LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
ItemStack mainHandStack = null;
if (shooter != null) {
mainHandStack = shooter.getMainHandStack();
}
if (McdwEnchantsConfig.getValue("radiance_shot")) {
if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.RADIANCE_SHOT, mainHandStack) >= 1)) {
int level = EnchantmentHelper.getLevel(EnchantsRegistry.RADIANCE_SHOT, mainHandStack);
float radianceShotRand = shooter.getRandom().nextFloat();
if (radianceShotRand <= 0.2F) {
if (target instanceof LivingEntity) {
AOECloudHelper.spawnRegenCloudAtPos(shooter, true, target.getBlockPos(), level - 1);
}
}
}
}
}
Aggregations