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