use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class InputHandler method antiFormCheck.
public boolean antiFormCheck() {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
World world = mc.world;
double random = Math.random();
int ap = player.getCapability(ModCapabilities.DRIVE_STATE, null).getAntiPoints();
int prob = 0;
if (ap > 0 && ap <= 4)
prob = 0;
else if (ap > 4 && ap <= 9)
prob = 10;
else if (ap >= 10)
prob = 25;
if (random * 100 < prob) {
PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Anti));
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
PacketDispatcher.sendToServer(new AntiPoints(-4));
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
return true;
} else
return false;
}
use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class InputHandler method commandEnter.
public void commandEnter() {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
World world = mc.world;
PlayerStatsCapability.IPlayerStats STATS = player.getCapability(ModCapabilities.PLAYER_STATS, null);
IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
loadLists();
switch(GuiCommandMenu.selected) {
case GuiCommandMenu.ATTACK:
player.swingArm(EnumHand.MAIN_HAND);
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
// Submenu of the portals
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (!this.portalCommands.isEmpty() && !STATS.getRecharge()) {
GuiCommandMenu.submenu = GuiCommandMenu.SUB_PORTALS;
GuiCommandMenu.portalSelected = 0;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
} else {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
}
return;
}
}
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Wisdom)) {
PacketDispatcher.sendToServer(new MagicWisdomShot());
}
break;
case GuiCommandMenu.MAGIC:
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (!STATS.getRecharge() && (!this.magicCommands.isEmpty() && !DRIVE.getActiveDriveName().equals(Strings.Form_Valor))) {
GuiCommandMenu.magicselected = 0;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAGIC;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
return;
} else {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
break;
case GuiCommandMenu.ITEMS:
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (!this.itemsCommands.isEmpty()) {
GuiCommandMenu.submenu = GuiCommandMenu.SUB_ITEMS;
GuiCommandMenu.potionselected = 0;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
} else {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
}
return;
}
break;
case GuiCommandMenu.DRIVE:
if (GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAIN) {
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
// TODO Use Limit
player.sendMessage(new TextComponentString("Limits are not available yet"));
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
} else {
if (DRIVE.getInDrive()) {
// Revert
if (DRIVE.getActiveDriveName().equals(Strings.Form_Anti) && !player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
player.sendMessage(new TextComponentTranslation("Cannot revert while in Anti form"));
} else {
PacketDispatcher.sendToServer(new DriveFormPacket(DRIVE.getActiveDriveName(), true));
if (DriveFormRegistry.isDriveFormRegistered(DRIVE.getActiveDriveName()))
DriveFormRegistry.get(DRIVE.getActiveDriveName()).endDrive(player);
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
} else if (this.driveCommands.isEmpty() || DRIVE.getDP() <= 0) {
world.playSound(player, player.getPosition(), ModSounds.error, SoundCategory.MASTER, 1.0f, 1.0f);
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
} else {
GuiCommandMenu.driveselected = 0;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_DRIVE;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
return;
}
}
}
break;
}
// Portal Submenu
if (GuiCommandMenu.selected == GuiCommandMenu.ATTACK && GuiCommandMenu.submenu == GuiCommandMenu.SUB_PORTALS) {
if (this.portalCommands.isEmpty()) {
} else {
// ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
if (!player.getCapability(ModCapabilities.PLAYER_STATS, null).getRecharge()) {
PortalCoords coords = this.portalCommands.get((byte) GuiCommandMenu.portalSelected);
if (coords.getX() != 0 && coords.getY() != 0 && coords.getZ() != 0) {
// ValidPortal
summonPortal(player, coords);
} else {
player.sendMessage(new TextComponentString(TextFormatting.RED + "You don't have any portal destination"));
}
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
}
// Magic Submenu
if (GuiCommandMenu.selected == GuiCommandMenu.MAGIC && GuiCommandMenu.submenu == GuiCommandMenu.SUB_MAGIC) {
if (this.magicCommands.isEmpty()) {
} else if (!STATS.getRecharge() || Constants.getCost((String) this.magicCommands.get(GuiCommandMenu.magicselected)) == -1 && STATS.getMP() > 0) {
Magic.getMagic(player, world, (String) this.magicCommands.get(GuiCommandMenu.magicselected));
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
if (GuiCommandMenu.selected == GuiCommandMenu.ITEMS && GuiCommandMenu.submenu == GuiCommandMenu.SUB_ITEMS) {
if (this.itemsCommands.isEmpty()) {
} else if (!this.itemsCommands.isEmpty()) {
ItemKKPotion.getItem(player, world, (String) this.itemsCommands.get(GuiCommandMenu.potionselected), GuiCommandMenu.potionselected);
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
if (GuiCommandMenu.selected == GuiCommandMenu.DRIVE && GuiCommandMenu.submenu == GuiCommandMenu.SUB_DRIVE) {
if (this.driveCommands.isEmpty()) {
} else if ((DRIVE.getDP() >= Constants.getCost((String) this.driveCommands.get(GuiCommandMenu.driveselected)))) {
if (this.driveCommands.get(GuiCommandMenu.driveselected).equals(Strings.Form_Final)) {
ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
} else {
if (!antiFormCheck()) {
ModDriveForms.getDriveForm(player, world, (String) this.driveCommands.get(GuiCommandMenu.driveselected));
}
}
GuiCommandMenu.selected = GuiCommandMenu.ATTACK;
GuiCommandMenu.submenu = GuiCommandMenu.SUB_MAIN;
world.playSound(player, player.getPosition(), ModSounds.select, SoundCategory.MASTER, 1.0f, 1.0f);
}
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class DriveFormAnti method update.
@Override
public void update(EntityPlayer player) {
if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() > 0) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).remFP(0.1);
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() < 0) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).setFP(0);
endDrive(player);
if (player.world.isRemote) {
PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
}
}
} else {
System.out.println(FMLCommonHandler.instance().getEffectiveSide());
endDrive(player);
}
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ModDriveForms method getDriveForm.
public static void getDriveForm(EntityPlayer player, World world, String drive) {
switch(drive) {
case Strings.Form_Valor:
PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Valor));
PacketDispatcher.sendToServer(new AntiPoints(1));
break;
case Strings.Form_Wisdom:
PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Wisdom));
PacketDispatcher.sendToServer(new AntiPoints(1));
break;
case Strings.Form_Limit:
PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Limit));
PacketDispatcher.sendToServer(new AntiPoints(1));
break;
case Strings.Form_Master:
PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Master));
PacketDispatcher.sendToServer(new AntiPoints(1));
break;
case Strings.Form_Final:
PacketDispatcher.sendToServer(new DriveFormPacket(Strings.Form_Final));
PacketDispatcher.sendToServer(new AntiPoints(-10));
break;
default:
break;
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.server.DriveFormPacket in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class DriveForm method update.
public void update(EntityPlayer player) {
if (player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot() == -1) {
player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setActiveSlot(player.inventory.currentItem);
}
if (player.world.isRemote) {
GuiScreen currScreen = Minecraft.getMinecraft().currentScreen;
if (currScreen instanceof GuiContainer) {
Minecraft.getMinecraft().displayGuiScreen(null);
player.sendMessage(new TextComponentTranslation("Cannot open containers while drive form is active"));
}
}
if (player.inventory.currentItem != player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot())
player.inventory.currentItem = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot();
if (ItemStack.areItemStacksEqual(player.inventory.getItemStack(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()))) {
player.inventory.setItemStack(ItemStack.EMPTY);
player.inventory.setInventorySlotContents(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()));
}
if (hasOffHand() && ItemStack.areItemStacksEqual(player.inventory.getItemStack(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(getKeychainSlot()).getItem()).getKeyblade()))) {
player.inventory.setItemStack(ItemStack.EMPTY);
player.inventory.offHandInventory.set(0, new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(1).getItem()).getKeyblade()));
}
if (ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot()), ItemStack.EMPTY)) {
player.inventory.setInventorySlotContents(player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).activeSlot(), new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0).getItem()).getKeyblade()));
}
if (hasOffHand() && ItemStack.areItemStacksEqual(player.inventory.offHandInventory.get(0), ItemStack.EMPTY)) {
player.inventory.offHandInventory.set(0, new ItemStack(((ItemKeychain) player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(1).getItem()).getKeyblade()));
}
if (!player.getCapability(ModCapabilities.CHEAT_MODE, null).getCheatMode()) {
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() > 0) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).remFP(0.1);
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getFP() < 0) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).setFP(0);
endDrive(player);
if (player.world.isRemote) {
PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
}
}
} else {
endDrive(player);
if (player.world.isRemote) {
PacketDispatcher.sendToServer(new DriveFormPacket(getName(), true));
}
/*Utils.summonWeapon(player, EnumHand.MAIN_HAND, 0);
if(hasOffHand())
Utils.summonWeapon(player, EnumHand.OFF_HAND, getKeychainSlot());
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
player.inventory.offHandInventory.set(0, ItemStack.EMPTY);*/
}
}
}
Aggregations