Search in sources :

Example 6 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class LivingEntityMixin method tryUseTotem.

@Inject(method = "tryUseTotem", at = @At(value = "HEAD"), cancellable = true)
private void tryUseTotem(DamageSource source, CallbackInfoReturnable<Boolean> ci) {
    LivingEntity livingEntity = (LivingEntity) (Object) this;
    if (source.isOutOfWorld()) {
        ci.setReturnValue(false);
    } else {
        ItemStack stack = TrinketsApi.getTrinketComponent(livingEntity).map(component -> {
            List<Pair<SlotReference, ItemStack>> res = component.getEquipped(DoomItems.SOULCUBE);
            return res.size() > 0 ? res.get(0).getRight() : ItemStack.EMPTY;
        }).orElse(ItemStack.EMPTY);
        if (!stack.isEmpty()) {
            stack.damage(1, livingEntity, p -> p.sendToolBreakStatus(livingEntity.getActiveHand()));
            livingEntity.setHealth(20.0F);
            livingEntity.clearStatusEffects();
            livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 100, 4));
            livingEntity.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 100, 4));
            livingEntity.world.sendEntityStatus(livingEntity, (byte) 95);
            ci.setReturnValue(true);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) TrinketsApi(dev.emi.trinkets.api.TrinketsApi) Pair(net.minecraft.util.Pair) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) Inject(org.spongepowered.asm.mixin.injection.Inject) LivingEntity(net.minecraft.entity.LivingEntity) StatusEffects(net.minecraft.entity.effect.StatusEffects) DamageSource(net.minecraft.entity.damage.DamageSource) DoomItems(mod.azure.doom.util.registry.DoomItems) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) SlotReference(dev.emi.trinkets.api.SlotReference) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) Mixin(org.spongepowered.asm.mixin.Mixin) At(org.spongepowered.asm.mixin.injection.At) SlotReference(dev.emi.trinkets.api.SlotReference) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 7 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class SentinelHammerItem method doDamage.

private void doDamage(LivingEntity user, Entity target) {
    if (target instanceof LivingEntity) {
        target.timeUntilRegen = 0;
        ((LivingEntity) target).addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 1000, 2));
        target.damage(DamageSource.player((PlayerEntity) user), 25F);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 8 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Rug by RubixDev.

the class MaxEffectCommand method register.

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
    LiteralArgumentBuilder<ServerCommandSource> command = literal("maxeffect").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandMaxEffect)).then(argument("effect", StatusEffectArgumentType.statusEffect()).executes(context -> {
        ServerCommandSource source = context.getSource();
        ServerPlayerEntity player = source.getPlayer();
        StatusEffect effect = StatusEffectArgumentType.getStatusEffect(context, "effect");
        boolean success = false;
        if (player instanceof LivingEntity) {
            StatusEffectInstance statusEffectInstance = new StatusEffectInstance(effect, effect.isInstant() ? 999999 : (999999 * 20), 255, false, false);
            success = (player).addStatusEffect(statusEffectInstance, source.getEntity());
        }
        if (!success) {
            throw new SimpleCommandExceptionType(new TranslatableText("commands.effect.give.failed")).create();
        }
        source.sendFeedback(new TranslatableText("commands.effect.give.success.single", effect.getName(), player.getDisplayName(), 999999), true);
        return 1;
    }));
    dispatcher.register(command);
}
Also used : StatusEffectArgumentType(net.minecraft.command.argument.StatusEffectArgumentType) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LivingEntity(net.minecraft.entity.LivingEntity) SettingsManager(carpet.settings.SettingsManager) TranslatableText(net.minecraft.text.TranslatableText) RugSettings(de.rubixdev.rug.RugSettings) CommandManager.literal(net.minecraft.server.command.CommandManager.literal) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandManager.argument(net.minecraft.server.command.CommandManager.argument) StatusEffect(net.minecraft.entity.effect.StatusEffect) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) TranslatableText(net.minecraft.text.TranslatableText) StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

Example 9 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class WednesdayRitualFunction method tick.

@Override
public void tick(World world, BlockPos glyphPos, BlockPos effectivePos, boolean catFamiliar) {
    if (!world.isClient) {
        if (world.getTime() % 20 == 0) {
            for (int i = 0; i < world.random.nextInt(4) + (catFamiliar ? 3 : 1); i++) {
                ToadEntity entity = BWEntityTypes.TOAD.create(world);
                if (entity != null) {
                    entity.initialize((ServerWorldAccess) world, world.getLocalDifficulty(effectivePos), SpawnReason.EVENT, null, null);
                    entity.getDataTracker().set(BWTameableEntity.VARIANT, 0);
                    entity.updatePositionAndAngles(effectivePos.getX() + 0.5 + MathHelper.nextDouble(world.random, -3, 3), effectivePos.getY() + 3, effectivePos.getZ() + 0.5 + MathHelper.nextDouble(world.random, -3, 3), world.random.nextFloat() * 360, 0);
                    entity.addStatusEffect(new StatusEffectInstance(BWStatusEffects.WEDNESDAY, world.random.nextInt(100)));
                    entity.isFromWednesdayRitual = true;
                    world.spawnEntity(entity);
                }
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ToadEntity(moriyashiine.bewitchment.common.entity.living.ToadEntity)

Example 10 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project bewitchment by MoriyaShiine.

the class MendingSigil method use.

@Override
public ActionResult use(World world, BlockPos pos, LivingEntity user, Hand hand) {
    ActionResult result = super.use(world, pos, user, hand);
    boolean flag = true;
    if (world.getBlockState(pos).getBlock() instanceof PressurePlateBlock) {
        flag = user.age % 20 == 0;
    }
    if (flag) {
        StatusEffectInstance regeneration = new StatusEffectInstance(StatusEffects.REGENERATION, 200);
        if (user.canHaveStatusEffect(regeneration)) {
            if (!world.isClient) {
                user.addStatusEffect(regeneration);
            }
            result = ActionResult.SUCCESS;
        }
        StatusEffectInstance resistance = new StatusEffectInstance(StatusEffects.RESISTANCE, 200);
        if (user.canHaveStatusEffect(resistance)) {
            if (!world.isClient) {
                user.addStatusEffect(resistance);
            }
            result = ActionResult.SUCCESS;
        }
    }
    return result;
}
Also used : ActionResult(net.minecraft.util.ActionResult) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PressurePlateBlock(net.minecraft.block.PressurePlateBlock)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)128 LivingEntity (net.minecraft.entity.LivingEntity)25 PlayerEntity (net.minecraft.entity.player.PlayerEntity)20 StatusEffect (net.minecraft.entity.effect.StatusEffect)16 ItemStack (net.minecraft.item.ItemStack)15 Inject (org.spongepowered.asm.mixin.injection.Inject)13 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)10 TypedActionResult (net.minecraft.util.TypedActionResult)7 Sprite (net.minecraft.client.texture.Sprite)4 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)4 Entity (net.minecraft.entity.Entity)4 MobEntity (net.minecraft.entity.mob.MobEntity)4 Box (net.minecraft.util.math.Box)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 List (java.util.List)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ThirstManager (net.dehydration.thirst.ThirstManager)2