use of cavern.magic.MagicBook in project Cavern2 by kegare.
the class MagicResultMessage method process.
@Override
public IMessage process(EntityPlayerMP player) {
MagicBook book = MagicBook.get(player);
Magic magic = book.getSpellingMagic();
if (magic != null) {
EnumActionResult type;
ITextComponent message;
if (clientResult == EnumActionResult.PASS) {
ActionResult<ITextComponent> result = magic.fireMagic();
type = result.getType();
message = result.getResult();
} else {
type = clientResult;
message = null;
}
if (type == EnumActionResult.SUCCESS) {
ItemStack stack = book.getSpellingMagicBook();
World world = player.getServerWorld();
int cost = 0;
SpecialMagic specialMagic = book.getSpecialMagic();
if (specialMagic != null && specialMagic != magic && specialMagic.hasSpecialCost(magic)) {
cost = specialMagic.getSpecialCost(magic);
} else {
cost = magic.getCost();
}
if (cost == 0) {
ItemMagicBook.setLastUseTime(stack, world.getTotalWorldTime());
} else {
if (ItemMagicBook.consumeMana(stack, cost) > 0) {
ItemMagicBook.setLastUseTime(stack, world.getTotalWorldTime());
} else {
player.setHeldItem(magic.getSpellingHand(), new ItemStack(Items.BOOK));
}
}
SoundEvent sound = magic.getSuccessSound();
if (sound != null) {
world.playSound(null, player.posX, player.posY + 0.25D, player.posZ, sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
}
if (magic.isOverload()) {
book.setSpecialMagic(null);
}
}
if (message != null) {
player.sendStatusMessage(message, true);
}
magic.onCloseBook();
}
book.setSpellingMagic(null);
return null;
}
use of cavern.magic.MagicBook in project Cavern2 by kegare.
the class SpecialMagicMessage method process.
@Override
public IMessage process(EntityPlayerMP player) {
MagicBook book = MagicBook.get(player);
SpecialMagic magic = book.getSpecialMagic();
if (magic != null) {
ITextComponent message = magic.finishMagic();
if (message != null) {
player.sendStatusMessage(message, true);
}
SoundEvent sound = magic.getFinishSound();
if (sound != null) {
player.world.playSound(null, player.posX, player.posY + 0.25D, player.posZ, sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
}
book.setSpecialMagic(null);
}
return null;
}
use of cavern.magic.MagicBook in project Cavern2 by kegare.
the class MagicInvisibleMessage method process.
@Override
public IMessage process(EntityPlayerMP player) {
MagicBook book = MagicBook.get(player);
Magic magic = book.getSpellingMagic();
if (magic != null) {
if (magic.getMana() < magic.getCost()) {
return new MagicCancelMessage();
}
player.setInvisible(true);
SoundEvent sound = magic.getSuccessSound();
if (sound != null) {
player.world.playSound(null, player.posX, player.posY + 0.25D, player.posZ, sound, SoundCategory.PLAYERS, 1.0F, 1.0F);
}
}
return null;
}
Aggregations