Search in sources :

Example 1 with PlayerEntityAccess

use of com.frostwizard4.Neutrino.PlayerEntityAccess in project Neutrino by FrostWizard4.

the class SoulHealerArtifact method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
    if (((PlayerEntityAccess) playerEntity).neutrino$getPowerCount() >= 150) {
        // Play Healer Sound
        playerEntity.playSound(SoundRegister.SOUL_HEALER_ACTIVATE, 1.0F, 1.0F);
        // Heal
        world.getClosestPlayer(playerEntity, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 200, 2));
        ((PlayerEntityAccess) playerEntity).neutrino$setPowerCount(0);
    } else {
        if (world.isClient()) {
            MinecraftClient.getInstance().inGameHud.addChatMessage(MessageType.GAME_INFO, Text.of("Not enough souls!"), UUID.randomUUID());
        }
    }
    return TypedActionResult.success(playerEntity.getStackInHand(hand));
}
Also used : PlayerEntityAccess(com.frostwizard4.Neutrino.PlayerEntityAccess) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 2 with PlayerEntityAccess

use of com.frostwizard4.Neutrino.PlayerEntityAccess in project Neutrino by FrostWizard4.

the class CommandRegistry method init.

public static void init() {
    CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
        dispatcher.register(literal("soullevel").requires(source -> source.hasPermissionLevel(2)).then(argument("amount", IntegerArgumentType.integer(0, 3000)).executes(ctx -> {
            ServerPlayerEntity source = ctx.getSource().getPlayer();
            ((PlayerEntityAccess) source).neutrino$setPowerCount(IntegerArgumentType.getInteger(ctx, "amount") * 10);
            source.sendMessage(Text.of("§l§9Soul level§r§7 is set to " + (IntegerArgumentType.getInteger(ctx, "amount")) + "!"), false);
            return 1;
        })));
    });
}
Also used : PlayerEntityAccess(com.frostwizard4.Neutrino.PlayerEntityAccess) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Aggregations

PlayerEntityAccess (com.frostwizard4.Neutrino.PlayerEntityAccess)2 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1