Search in sources :

Example 1 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDoom by AzureDoom.

the class ClientPlayNetworkHandlerMixin method onEntitySpawn.

@Inject(method = "onEntitySpawn", at = @At("TAIL"))
private void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo callbackInfo) {
    EntityType<?> type = packet.getEntityTypeId();
    double x = packet.getX();
    double y = packet.getY();
    double z = packet.getZ();
    PersistentProjectileEntity entity = null;
    if (type == ProjectilesEntityRegister.MEATHOOOK_ENTITY)
        entity = new MeatHookEntity(world, x, y, z);
    if (entity != null) {
        Entity owner = world.getEntityById(packet.getEntityData());
        if (owner != null)
            entity.setOwner(owner);
        int id = packet.getId();
        entity.updateTrackedPosition(x, y, z);
        entity.refreshPositionAfterTeleport(x, y, z);
        entity.setPitch((float) (packet.getPitch() * 360) / 256f);
        entity.setYaw((float) (packet.getYaw() * 360) / 256f);
        entity.setId(id);
        entity.setUuid(packet.getUuid());
        world.addEntity(id, entity);
    }
}
Also used : Entity(net.minecraft.entity.Entity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) MeatHookEntity(mod.azure.doom.entity.projectiles.MeatHookEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) MeatHookEntity(mod.azure.doom.entity.projectiles.MeatHookEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.

the class AnimaConduitShotEnchantmentMixin method onAnimaConduitShotEnchantmentEntityHit.

@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onAnimaConduitShotEnchantmentEntityHit(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("anima")) {
        if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.ANIMA_CONDUIT, mainHandStack) >= 1)) {
            int level = EnchantmentHelper.getLevel(EnchantsRegistry.ANIMA_CONDUIT, mainHandStack);
            float healthRegained;
            // ANIMA CONDUIT AS PER KILL
            if (shooter.getHealth() < shooter.getMaxHealth()) {
                healthRegained = (float) (getCurrentExperience((PlayerEntity) shooter) * (0.2 * level));
                shooter.heal(healthRegained);
                ((PlayerEntity) shooter).addExperienceLevels(-999999999);
            // this.world.sendEntityStatus(this,(byte)35);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) ItemStack(net.minecraft.item.ItemStack) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.

the class ChainReactionEnchantmentMixin method onChainReactionEnchantmentEntityHit.

@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onChainReactionEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
    if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
        return;
    }
    PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
    LivingEntity target = (LivingEntity) entityHitResult.getEntity();
    LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
    ItemStack mainHandStack = null;
    if (shooter != null) {
        mainHandStack = shooter.getMainHandStack();
    }
    if (McdwEnchantsConfig.getValue("chain_reaction")) {
        if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, mainHandStack) >= 1)) {
            int level = EnchantmentHelper.getLevel(EnchantsRegistry.CHAIN_REACTION, mainHandStack);
            if (target == null)
                return;
            if (level > 0) {
                float chainReactionChance = 0;
                if (level == 1)
                    chainReactionChance = 0.1F;
                if (level == 2)
                    chainReactionChance = 0.2F;
                if (level == 3)
                    chainReactionChance = 0.3F;
                float chainReactionRand = shooter.getRandom().nextFloat();
                if (chainReactionRand <= chainReactionChance) {
                    ProjectileEffectHelper.fireChainReactionProjectiles(target.getEntityWorld(), target, shooter, 3.15F, 1.0F, persistentProjectileEntity);
                }
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.

the class GravityShotEnchantmentMixin method onGravityShotEnchantmentEntityHit.

@Inject(method = "onEntityHit", at = @At("TAIL"))
private void onGravityShotEnchantmentEntityHit(EntityHitResult entityHitResult, CallbackInfo ci) {
    if (!(entityHitResult.getEntity() instanceof LivingEntity)) {
        return;
    }
    PersistentProjectileEntity persistentProjectileEntity = (PersistentProjectileEntity) (Object) this;
    LivingEntity target = (LivingEntity) entityHitResult.getEntity();
    LivingEntity shooter = (LivingEntity) persistentProjectileEntity.getOwner();
    ItemStack mainHandStack = null;
    if (shooter != null) {
        mainHandStack = shooter.getMainHandStack();
    }
    if (McdwEnchantsConfig.getValue("gravity")) {
        if (mainHandStack != null && (EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, mainHandStack) >= 1)) {
            int level = EnchantmentHelper.getLevel(EnchantsRegistry.GRAVITY, mainHandStack);
            float gravityShotRand = shooter.getRandom().nextFloat();
            if (gravityShotRand <= 0.2F) {
                AOEHelper.pullInNearbyEntities(shooter, target, (level + 1) * 3);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with PersistentProjectileEntity

use of net.minecraft.entity.projectile.PersistentProjectileEntity in project MCDungeonsWeapons by chronosacaria.

the class MultiShotEnchantmentMixin method createMultiShotArrows.

// Bow Multi Shot
@Inject(method = "onStoppedUsing", at = @At("HEAD"))
private void createMultiShotArrows(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfo ci) {
    LivingEntity target = user.getAttacking();
    boolean uniqueWeaponFlag = stack.getItem() == ItemRegistry.getItem("bow_lost_souls").asItem();
    if (McdwEnchantsConfig.getValue("multi_shot")) {
        if (uniqueWeaponFlag) {
            ArrowItem arrowitem = (ArrowItem) (stack.getItem() instanceof ArrowItem ? stack.getItem() : Items.ARROW);
            PersistentProjectileEntity persistentProjectileEntity = arrowitem.createArrow(world, stack, user);
            if (!(target == null)) {
                // \/\/ Taken from AbstractSkeletonEntity
                double d = target.getX() - user.getX();
                double e = target.getBodyY(0.3333333333333333D) - persistentProjectileEntity.getY();
                double f = target.getZ() - user.getZ();
                double g = MathHelper.sqrt((float) (d * d + f * f));
                persistentProjectileEntity.setVelocity(d, e + g * 0.20000000298023224D, f, 1.6F, (float) (14 - user.world.getDifficulty().getId() * 4));
                persistentProjectileEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY;
                world.spawnEntity(persistentProjectileEntity);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)20 LivingEntity (net.minecraft.entity.LivingEntity)10 ItemStack (net.minecraft.item.ItemStack)10 Inject (org.spongepowered.asm.mixin.injection.Inject)10 Entity (net.minecraft.entity.Entity)7 PlayerEntity (net.minecraft.entity.player.PlayerEntity)7 List (java.util.List)3 Vector3f (net.minecraft.client.util.math.Vector3f)3 SnowballEntity (net.minecraft.entity.projectile.thrown.SnowballEntity)3 Quaternion (net.minecraft.util.math.Quaternion)3 Vec3d (net.minecraft.util.math.Vec3d)3 MeleeRangedEnchantmentList (chronosacaria.mcdw.enchants.lists.MeleeRangedEnchantmentList)2 Comparator (java.util.Comparator)2 Random (java.util.Random)2 Set (java.util.Set)2 EnchantmentHelper (net.minecraft.enchantment.EnchantmentHelper)2 ArrowEntity (net.minecraft.entity.projectile.ArrowEntity)2 ProjectileEntity (net.minecraft.entity.projectile.ProjectileEntity)2 net.minecraft.item (net.minecraft.item)2 SoundEvents (net.minecraft.sound.SoundEvents)2