use of net.minecraft.entity.effect.StatusEffect 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);
}
use of net.minecraft.entity.effect.StatusEffect in project bewitchment by MoriyaShiine.
the class TheftStatusEffect method applyUpdateEffect.
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
if (!entity.world.isClient && entity.age % 20 == 0) {
entity.world.getEntitiesByClass(LivingEntity.class, entity.getBoundingBox().expand(3 * (amplifier + 1)), foundEntity -> foundEntity != entity).forEach(livingEntity -> {
List<StatusEffectInstance> statusEffects = livingEntity.getStatusEffects().stream().filter(instance -> instance.getEffectType().getCategory() == StatusEffectCategory.BENEFICIAL && !instance.isAmbient()).toList();
for (StatusEffectInstance statusEffect : statusEffects) {
entity.addStatusEffect(new StatusEffectInstance(statusEffect.getEffectType(), statusEffect.getDuration() / 2, statusEffect.getAmplifier()));
livingEntity.removeStatusEffect(statusEffect.getEffectType());
}
});
}
}
use of net.minecraft.entity.effect.StatusEffect in project bewitchment by MoriyaShiine.
the class CorruptionStatusEffect method applyUpdateEffect.
@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
if (!entity.world.isClient) {
Registry.STATUS_EFFECT.stream().forEach(effect -> {
if (effect.getCategory() == StatusEffectCategory.BENEFICIAL && entity.hasStatusEffect(effect) && !entity.getStatusEffect(effect).isAmbient()) {
StatusEffect inverse = INVERSE_EFFECTS.get(effect);
StatusEffectInstance inverseEffect = null;
if (inverse != null) {
StatusEffectInstance goodEffect = entity.getStatusEffect(effect);
inverseEffect = new StatusEffectInstance(inverse, goodEffect.getDuration(), goodEffect.getAmplifier(), goodEffect.isAmbient(), goodEffect.shouldShowParticles(), goodEffect.shouldShowIcon());
}
entity.removeStatusEffect(effect);
if (inverseEffect != null) {
entity.addStatusEffect(inverseEffect);
}
}
});
}
}
use of net.minecraft.entity.effect.StatusEffect in project meteor-client by MeteorDevelopment.
the class PotionSpoof method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
for (StatusEffect statusEffect : potions.get().keySet()) {
int level = potions.get().getInt(statusEffect);
if (level <= 0)
continue;
if (mc.player.hasStatusEffect(statusEffect)) {
StatusEffectInstance instance = mc.player.getStatusEffect(statusEffect);
((StatusEffectInstanceAccessor) instance).setAmplifier(level - 1);
if (instance.getDuration() < 20)
((StatusEffectInstanceAccessor) instance).setDuration(20);
} else {
mc.player.addStatusEffect(new StatusEffectInstance(statusEffect, 20, level - 1));
}
}
}
use of net.minecraft.entity.effect.StatusEffect in project meteor-client by MeteorDevelopment.
the class StatusEffectAmplifierMapSetting method parseImpl.
@Override
protected Object2IntMap<StatusEffect> parseImpl(String str) {
String[] values = str.split(",");
Object2IntMap<StatusEffect> effects = Utils.createStatusEffectMap();
try {
for (String value : values) {
String[] split = value.split(" ");
StatusEffect effect = parseId(Registry.STATUS_EFFECT, split[0]);
int level = Integer.parseInt(split[1]);
effects.put(effect, level);
}
} catch (Exception ignored) {
}
return effects;
}
Aggregations