use of net.minecraft.world.phys.HitResult.Type in project Cyclic by Lothrazar.
the class ItemEvents method onProjectileImpactEvent.
@SubscribeEvent
public void onProjectileImpactEvent(ProjectileImpactEvent event) {
Projectile arrow = event.getProjectile();
if (arrow == null || event.getRayTraceResult() == null) {
return;
}
Level world = arrow.level;
Type hit = event.getRayTraceResult().getType();
// getShooter
Entity shooter = arrow.getOwner();
if (shooter instanceof Player) {
Player ply = (Player) shooter;
// ply.isSprinting()
ItemStack find = CharmUtil.getIfEnabled(ply, ItemRegistry.QUIVER_DMG.get());
if (!find.isEmpty() && arrow instanceof AbstractArrow) {
// ModCyclic.LOGGER.info("before " + event.getArrow().getDamage());
AbstractArrow arroww = (AbstractArrow) arrow;
double boost = arroww.getBaseDamage() / 2;
arroww.setBaseDamage(arroww.getBaseDamage() + boost);
UtilItemStack.damageItem(ply, find);
}
find = CharmUtil.getIfEnabled(ply, ItemRegistry.QUIVER_LIT.get());
if (!find.isEmpty() && world.random.nextDouble() < 0.25) {
if (hit == HitResult.Type.ENTITY && ((EntityHitResult) event.getRayTraceResult()).getEntity() instanceof LivingEntity) {
LivingEntity target = (LivingEntity) ((EntityHitResult) event.getRayTraceResult()).getEntity();
target.setGlowingTag(true);
// ModCyclic.LOGGER.info(event.getEntity() + " eeeee" + event.getArrow().getDamage());
BlockPos p = target.blockPosition();
// lightning?
LightningBolt lightningboltentity = EntityType.LIGHTNING_BOLT.create(world);
lightningboltentity.moveTo(p.getX(), p.getY(), p.getZ());
world.addFreshEntity(lightningboltentity);
UtilItemStack.damageItem(ply, find);
}
}
}
}
Aggregations