use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class LevelUpMagic method process.
@Override
public void process(EntityPlayer player, Side side) {
int firstEmptySlot = -1;
boolean hasMagicInSlot = false;
for (int i = 0; i < InventorySpells.INV_SIZE; i++) {
if (!ItemStack.areItemStacksEqual(player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i), ItemStack.EMPTY)) {
if (player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().getStackInSlot(i).getItem() == player.getHeldItem(EnumHand.MAIN_HAND).getItem()) {
hasMagicInSlot = true;
}
} else {
firstEmptySlot = i;
break;
}
}
if (!hasMagicInSlot) {
player.getCapability(ModCapabilities.MAGIC_STATE, null).getInventorySpells().setStackInSlot(firstEmptySlot, player.getHeldItem(EnumHand.MAIN_HAND));
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
TextComponentTranslation learnMessage = new TextComponentTranslation(Strings.Chat_Magic_Learn, new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic))));
learnMessage.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(learnMessage);
} else {
if (player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic) < Constants.MAX_MAGIC_LEVEL) {
player.getCapability(ModCapabilities.MAGIC_STATE, null).setMagicLevel(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic) + 1);
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
TextComponentTranslation levelupMessage = new TextComponentTranslation(Strings.Chat_Magic_Levelup, new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic) - 1)), new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic))));
levelupMessage.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(levelupMessage);
} else {
TextComponentTranslation errorMessage = new TextComponentTranslation(Strings.Chat_Magic_Error, new TextComponentTranslation(Constants.getMagicName(magic, player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(magic))));
errorMessage.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(errorMessage);
}
}
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncMagicInventory(player.getCapability(ModCapabilities.MAGIC_STATE, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class MagicAero method process.
@Override
public void process(EntityPlayer player, Side side) {
if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
player.getCapability(ModCapabilities.PLAYER_STATS, null).remMP(Constants.getCost(Strings.Spell_Aero));
World world = player.world;
if (!world.isRemote) {
switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Aero)) {
case 1:
world.spawnEntity(new EntityAero(world, player, player.posX, player.posY, player.posZ));
PacketDispatcher.sendToAllAround(new SpawnAeroParticles(player, 1), player, 64.0D);
break;
case 2:
world.spawnEntity(new EntityAerora(world, player, player.posX, player.posY, player.posZ));
PacketDispatcher.sendToAllAround(new SpawnAeroParticles(player, 2), player, 64.0D);
break;
case 3:
world.spawnEntity(new EntityAeroga(world, player, player.posX, player.posY, player.posZ));
PacketDispatcher.sendToAllAround(new SpawnAeroParticles(player, 3), player, 64.0D);
break;
}
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class MagicBlizzard method process.
@Override
public void process(EntityPlayer player, Side side) {
if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
player.getCapability(ModCapabilities.PLAYER_STATS, null).remMP(Constants.getCost(Strings.Spell_Blizzard));
World world = player.world;
switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Blizzard)) {
case 1:
EntityBlizzard entityBlizzard = new EntityBlizzard(world, player);
world.spawnEntity(entityBlizzard);
entityBlizzard.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
// PacketDispatcher.sendToAllAround(new SpawnBlizzardParticles(new EntityBlizzard(world), 1), player, 64.0D);
break;
case 2:
EntityBlizzara entityBlizzara = new EntityBlizzara(world, player);
world.spawnEntity(entityBlizzara);
entityBlizzara.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 2, 0);
// PacketDispatcher.sendToAllAround(new SpawnBlizzardParticles(new EntityBlizzara(world), 2), player, 64.0D);
break;
case 3:
EntityBlizzaga entityBlizzaga = new EntityBlizzaga(world, player);
world.spawnEntity(entityBlizzaga);
entityBlizzaga.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 3, 0);
// PacketDispatcher.sendToAllAround(new SpawnBlizzardParticles(new EntityBlizzaga(world), 3), player, 64.0D);
break;
}
world.playSound(player.posX, player.posY, player.posZ, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.PLAYERS, 1, 1, false);
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class MagicCure method process.
@Override
public void process(EntityPlayer player, Side side) {
if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
player.getCapability(ModCapabilities.PLAYER_STATS, null).setMP(0);
World world = player.world;
player.extinguish();
switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Cure)) {
case 1:
if (player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3 + player.getHealth() > player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP())
player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() - player.getHealth());
else
player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3);
world.spawnEntity(new EntityCure(world, player, player.posX, player.posY, player.posZ));
break;
case 2:
if (player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3 * 2 + player.getHealth() > player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP())
player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() - player.getHealth());
else
player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() / 3 * 2);
world.spawnEntity(new EntityCura(world, player, player.posX, player.posY, player.posZ));
break;
case 3:
player.heal(player.getCapability(ModCapabilities.PLAYER_STATS, null).getHP() - player.getHealth());
world.spawnEntity(new EntityCuraga(world, player, player.posX, player.posY, player.posZ));
break;
}
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncMagicData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class MagicKH1Fire method process.
@Override
public void process(EntityPlayer player, Side side) {
if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode())
player.getCapability(ModCapabilities.PLAYER_STATS, null).remMP(Constants.getCost(Strings.Spell_Fire));
World world = player.world;
switch(player.getCapability(ModCapabilities.MAGIC_STATE, null).getMagicLevel(Strings.Spell_Fire)) {
case 1:
EntityKH1Fire entityKH1Fire = new EntityKH1Fire(world, player);
world.spawnEntity(entityKH1Fire);
entityKH1Fire.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
PacketDispatcher.sendToAllAround(new SpawnKH1FireParticles(new EntityKH1Fire(world), 1), player, 64.0D);
break;
case 2:
EntityKH1Fira entityKH1Fira = new EntityKH1Fira(world, player);
world.spawnEntity(entityKH1Fira);
entityKH1Fira.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
PacketDispatcher.sendToAllAround(new SpawnKH1FireParticles(new EntityKH1Fira(world), 1), player, 64.0D);
break;
case 3:
EntityKH1Firaga entityKH1Firaga = new EntityKH1Firaga(world, player);
world.spawnEntity(entityKH1Firaga);
entityKH1Firaga.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0, 1, 0);
PacketDispatcher.sendToAllAround(new SpawnKH1FireParticles(new EntityKH1Firaga(world), 1), player, 64.0D);
break;
}
PacketDispatcher.sendTo(new SyncMagicData(player.getCapability(ModCapabilities.MAGIC_STATE, null), player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
Aggregations