Search in sources :

Example 1 with VampirismVampireSword

use of de.teamlapen.vampirism.items.VampirismVampireSword in project Vampirism by TeamLapen.

the class SetSwordChargedCommand method setSwordCharged.

private static int setSwordCharged(CommandSource commandSource, Collection<ServerPlayerEntity> players, float charge) {
    for (ServerPlayerEntity player : players) {
        ItemStack held = player.getMainHandItem();
        if (held.getItem() instanceof VampirismVampireSword) {
            ((VampirismVampireSword) held.getItem()).setCharged(held, charge);
            player.setItemInHand(Hand.MAIN_HAND, held);
        } else {
            commandSource.sendSuccess(new TranslationTextComponent("command.vampirism.test.swordcharged.nosword"), false);
        }
    }
    return 0;
}
Also used : VampirismVampireSword(de.teamlapen.vampirism.items.VampirismVampireSword) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack)

Example 2 with VampirismVampireSword

use of de.teamlapen.vampirism.items.VampirismVampireSword in project Vampirism by TeamLapen.

the class CNameItemPacket method handle.

static void handle(CNameItemPacket msg, Supplier<NetworkEvent.Context> contextSupplier) {
    final NetworkEvent.Context ctx = contextSupplier.get();
    ServerPlayerEntity player = ctx.getSender();
    Validate.notNull(player);
    ctx.enqueueWork(() -> {
        if (VampirismVampireSword.DO_NOT_NAME_STRING.equals(msg.name)) {
            ItemStack stack = player.getMainHandItem();
            if (stack.getItem() instanceof VampirismVampireSword) {
                ((VampirismVampireSword) stack.getItem()).doNotName(stack);
            }
        } else if (!org.apache.commons.lang3.StringUtils.isBlank(msg.name)) {
            ItemStack stack = player.getMainHandItem();
            stack.setHoverName(new StringTextComponent(msg.name).withStyle(TextFormatting.AQUA));
        }
    });
    ctx.setPacketHandled(true);
}
Also used : VampirismVampireSword(de.teamlapen.vampirism.items.VampirismVampireSword) NetworkEvent(net.minecraftforge.fml.network.NetworkEvent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) StringTextComponent(net.minecraft.util.text.StringTextComponent) ItemStack(net.minecraft.item.ItemStack)

Example 3 with VampirismVampireSword

use of de.teamlapen.vampirism.items.VampirismVampireSword in project Vampirism by TeamLapen.

the class SetSwordTrainedCommand method setSwordCharged.

private static int setSwordCharged(CommandSource commandSource, Collection<ServerPlayerEntity> players, float train) {
    for (ServerPlayerEntity player : players) {
        ItemStack held = player.getMainHandItem();
        if (held.getItem() instanceof VampirismVampireSword) {
            ((VampirismVampireSword) held.getItem()).setTrained(held, player, train);
            player.setItemInHand(Hand.MAIN_HAND, held);
        } else {
            commandSource.sendSuccess(new TranslationTextComponent("command.vampirism.test.swordtrained.nosword"), false);
        }
    }
    return 0;
}
Also used : VampirismVampireSword(de.teamlapen.vampirism.items.VampirismVampireSword) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

VampirismVampireSword (de.teamlapen.vampirism.items.VampirismVampireSword)3 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)3 ItemStack (net.minecraft.item.ItemStack)3 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 StringTextComponent (net.minecraft.util.text.StringTextComponent)1 NetworkEvent (net.minecraftforge.fml.network.NetworkEvent)1