Search in sources :

Example 91 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project artifality by PinkGoosik.

the class HandFanItem method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
    int tier = TiersUtils.getTier(user.getStackInHand(hand));
    user.getItemCooldownManager().set(this, (14 - 3 * tier) * 20);
    double radius = 6.0 + (2.0 * tier);
    int x1 = MathHelper.floor(user.getPos().x - radius);
    int y1 = MathHelper.floor(user.getPos().y - radius);
    int z1 = MathHelper.floor(user.getPos().z - radius);
    int x2 = MathHelper.floor(user.getPos().x + radius);
    int y2 = MathHelper.floor(user.getPos().y + radius);
    int z2 = MathHelper.floor(user.getPos().z + radius);
    List<Entity> list = world.getOtherEntities(user, new Box(x1, y1, z1, x2, y2, z2));
    Vec3d vec3d = new Vec3d(user.getPos().x, user.getPos().y, user.getPos().z);
    for (Entity entity : list) {
        double w = Math.sqrt(entity.squaredDistanceTo(vec3d)) / radius;
        if (w <= 1.0) {
            double x = entity.getX() - user.getPos().x;
            double y = (entity instanceof TntEntity ? entity.getY() : entity.getEyeY()) - user.getPos().y;
            double z = entity.getZ() - user.getPos().z;
            double aa = Math.sqrt(x * x + y * y + z * z);
            if (aa != 0.0) {
                x /= aa;
                y /= aa;
                z /= aa;
                double ab = Explosion.getExposure(vec3d, entity);
                double ac = (1.5 - w) * ab;
                entity.setVelocity(entity.getVelocity().add(x * ac, y * ac, z * ac));
            }
        }
    }
    user.fallDistance = 0.0F;
    Vec3d userVec = user.getVelocity();
    user.setVelocity(userVec.x, 1 + (0.25 * tier), userVec.z);
    user.addStatusEffect(new StatusEffectInstance(ArtifalityEffects.FALL_DAMAGE_IMMUNITY, 80 + (20 * tier), 0, false, false));
    return TypedActionResult.success(user.getStackInHand(hand));
}
Also used : TntEntity(net.minecraft.entity.TntEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) TntEntity(net.minecraft.entity.TntEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) Box(net.minecraft.util.math.Box) Vec3d(net.minecraft.util.math.Vec3d)

Example 92 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project artifality by PinkGoosik.

the class LunarWandItem method createCloudEffect.

public static void createCloudEffect(World world, LivingEntity entity, StatusEffect statusEffect, int durationInSec, float radius, int tier) {
    AreaEffectCloudEntity cloud = new AreaEffectCloudEntity(world, entity.getX(), entity.getY(), entity.getZ());
    cloud.setRadius(radius);
    cloud.setRadiusOnUse(-0.5F);
    cloud.setWaitTime(10);
    cloud.setRadiusGrowth(-cloud.getRadius() / (float) cloud.getDuration());
    int random = world.getRandom().nextInt(2);
    int amplifier = tier == 1 ? random : tier - 1;
    cloud.addEffect(new StatusEffectInstance(statusEffect, durationInSec * 20, amplifier));
    world.spawnEntity(cloud);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity)

Example 93 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Fabric-Course-118 by Kaupenjoe.

the class ModArmorItem method evaluateArmorEffects.

private void evaluateArmorEffects(PlayerEntity player) {
    for (Map.Entry<ArmorMaterial, StatusEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()) {
        ArmorMaterial mapArmorMaterial = entry.getKey();
        StatusEffectInstance mapStatusEffect = entry.getValue();
        if (hasCorrectArmorOn(mapArmorMaterial, player)) {
            addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect);
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ArmorMaterial(net.minecraft.item.ArmorMaterial) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 94 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Fabric-Course-118 by Kaupenjoe.

the class SpeedyBlock method onSteppedOn.

@Override
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
    if (!world.isClient()) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = ((LivingEntity) entity);
            livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 200));
        }
    }
    super.onSteppedOn(world, pos, state, entity);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 95 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Client by MatHax.

the class StatusEffectListSettingScreen method getPotionStack.

private ItemStack getPotionStack(StatusEffect effect) {
    ItemStack potion = Items.POTION.getDefaultStack();
    potion.getOrCreateNbt().putInt("CustomPotionColor", PotionUtil.getColor(new Potion(new StatusEffectInstance(effect))));
    return potion;
}
Also used : Potion(net.minecraft.potion.Potion) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ItemStack(net.minecraft.item.ItemStack)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)107 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 LivingEntity (net.minecraft.entity.LivingEntity)17 StatusEffect (net.minecraft.entity.effect.StatusEffect)14 ItemStack (net.minecraft.item.ItemStack)14 Inject (org.spongepowered.asm.mixin.injection.Inject)13 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)9 Sprite (net.minecraft.client.texture.Sprite)4 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)4 Entity (net.minecraft.entity.Entity)4 Box (net.minecraft.util.math.Box)4 List (java.util.List)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 EventHandler (mathax.client.eventbus.EventHandler)2 StatusEffectInstanceAccessor (mathax.client.mixin.StatusEffectInstanceAccessor)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ThirstManager (net.dehydration.thirst.ThirstManager)2