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);
}
}
}
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);
}
}
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);
}
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);
}
}
}
}
}
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;
}
Aggregations