use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class CommandDriveLevel method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (sender.getCommandSenderEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) sender.getCommandSenderEntity();
if (args.length == 0 || args.length > 3)
TextHelper.sendFormattedChatMessage("Invalid arguments, usage: " + getUsage(sender), TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
else if (args.length >= 2 && args.length <= 3) {
if (args.length == 3) {
if (getPlayerFromUsername(args[2]) != null) {
player = getPlayerFromUsername(args[2]);
}
}
int level = 1;
try {
// Parse the given level
if (Integer.parseInt(args[1]) < 1 || Integer.parseInt(args[1]) > 7) {
TextHelper.sendFormattedChatMessage("Invalid level, it must be a number between 1 - 7", TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
return;
} else
level = Integer.parseInt(args[1]);
} catch (Exception e) {
TextHelper.sendFormattedChatMessage("Invalid level, it must be a number between 1 - 7", TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
return;
}
IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
String form = null;
int oldLevel = DRIVE.getDriveLevel("form." + args[0].toLowerCase());
int newLevel = Integer.parseInt(args[1].toString());
switch(args[0].toLowerCase()) {
case "valor":
DRIVE.setDriveLevel(Strings.Form_Valor, newLevel);
form = Utils.translateToLocal(Strings.Form_Valor);
break;
case "wisdom":
DRIVE.setDriveLevel(Strings.Form_Wisdom, Integer.parseInt(args[1].toString()));
form = Utils.translateToLocal(Strings.Form_Wisdom);
break;
case "limit":
DRIVE.setDriveLevel(Strings.Form_Limit, Integer.parseInt(args[1].toString()));
form = Utils.translateToLocal(Strings.Form_Limit);
break;
case "master":
DRIVE.setDriveLevel(Strings.Form_Master, Integer.parseInt(args[1].toString()));
form = Utils.translateToLocal(Strings.Form_Master);
break;
case "final":
DRIVE.setDriveLevel(Strings.Form_Final, Integer.parseInt(args[1].toString()));
form = Utils.translateToLocal(Strings.Form_Final);
break;
}
DRIVE.displayLevelUpMessage(player, "form." + args[0].toLowerCase());
if (oldLevel != 7 && newLevel == 7) {
// Increase
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
} else if (oldLevel == 7 && newLevel != 7) {
// Decrease
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() - 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
}
if (form != null) {
if (args.length == 3)
TextHelper.sendFormattedChatMessage("Succesfully leveled up " + form + " to level " + args[1] + " for player " + args[2], TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
else
TextHelper.sendFormattedChatMessage("Succesfully leveled up " + form + " to level " + args[1], TextFormatting.YELLOW, (EntityPlayer) sender.getCommandSenderEntity());
} else {
TextHelper.sendFormattedChatMessage("Unknown form " + args[0], TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
}
} else {
TextHelper.sendFormattedChatMessage("Invalid arguments, usage: " + getUsage(sender), TextFormatting.RED, (EntityPlayer) sender.getCommandSenderEntity());
}
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class DriveOrbPickup method process.
@Override
public void process(EntityPlayer player, Side side) {
toRemove.setCount(toRemove.getCount() - 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).addDP(toRemove.getTagCompound().getInteger("amount"));
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class LevelUpDrive method process.
@Override
public void process(EntityPlayer player, Side side) {
int hasDriveInSlot = -1, nullSlot = -1;
if (levels == 7) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
TextComponentTranslation driMessage = new TextComponentTranslation(Strings.Chat_DriveBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel()));
driMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(driMessage);
}
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveLevel(form, levels);
for (int i = 0; i < InventoryDriveForms.INV_SIZE; i++) {
if (!ItemStack.areItemStacksEqual(player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getStackInSlot(i), ItemStack.EMPTY)) {
if (ItemStack.areItemStacksEqual(player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().getStackInSlot(i), player.getHeldItem(EnumHand.MAIN_HAND))) {
hasDriveInSlot = i;
}
} else {
nullSlot = i;
break;
}
}
if (hasDriveInSlot == -1) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).getInventoryDriveForms().setStackInSlot(nullSlot, player.getHeldItem(EnumHand.MAIN_HAND));
System.out.println(player.getHeldItemMainhand());
if (player.getHeldItemMainhand().getItem() instanceof ItemDriveForm) {
String form = ((ItemDriveForm) player.getHeldItemMainhand().getItem()).getDriveFormName();
// System.out.println(form+"\n"+player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveLevel(form));
if (player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveLevel(form) == 0) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveLevel(form, 1);
}
}
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
TextComponentTranslation learnMessage = new TextComponentTranslation(Strings.Chat_Drive_Learn, new TextComponentTranslation(this.form));
learnMessage.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(learnMessage);
} else {
TextComponentTranslation errorMessage = new TextComponentTranslation(Strings.Chat_Drive_Error, new TextComponentTranslation(this.form));
errorMessage.getStyle().setColor(TextFormatting.YELLOW);
player.sendMessage(errorMessage);
}
PacketDispatcher.sendTo(new SyncDriveInventory(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class RemoveItemInSlot method process.
@Override
public void process(EntityPlayer player, Side side) {
switch(inv) {
case "keychain":
keychain = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain();
keychain.setStackInSlot(slot, ItemStack.EMPTY);
break;
case Strings.DefenseBoost:
if (!player.capabilities.isCreativeMode)
player.inventory.removeStackFromSlot(player.inventory.currentItem);
player.getCapability(ModCapabilities.PLAYER_STATS, null).addDefense(1);
TextComponentTranslation strMessage = new TextComponentTranslation(Strings.Chat_DefenseBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.PLAYER_STATS, null).getDefense()));
strMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(strMessage);
break;
case Strings.MagicBoost:
if (!player.capabilities.isCreativeMode)
player.inventory.removeStackFromSlot(player.inventory.currentItem);
player.getCapability(ModCapabilities.PLAYER_STATS, null).addMagic(1);
TextComponentTranslation magMessage = new TextComponentTranslation(Strings.Chat_MagicBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.PLAYER_STATS, null).getMagic()));
magMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(magMessage);
break;
case Strings.PowerBoost:
if (!player.capabilities.isCreativeMode)
player.inventory.removeStackFromSlot(player.inventory.currentItem);
player.getCapability(ModCapabilities.PLAYER_STATS, null).addStrength(1);
TextComponentTranslation powMessage = new TextComponentTranslation(Strings.Chat_PowerBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.PLAYER_STATS, null).getStrength()));
powMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(powMessage);
break;
case Strings.Potion:
potions = player.getCapability(ModCapabilities.PLAYER_STATS, null).getInventoryPotionsMenu();
potions.setStackInSlot(slot, ItemStack.EMPTY);
if (sound)
player.world.playSound(null, player.getPosition(), ModSounds.potion, SoundCategory.MASTER, 0.5f, 1);
break;
case Strings.DriveBoost:
if (!player.capabilities.isCreativeMode)
player.inventory.removeStackFromSlot(player.inventory.currentItem);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
TextComponentTranslation driMessage = new TextComponentTranslation(Strings.Chat_DriveBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel()));
driMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(driMessage);
break;
}
PacketDispatcher.sendTo(new SyncLevelData(player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class EntityEvents method onLivingDeathEvent.
@SubscribeEvent
public void onLivingDeathEvent(LivingDeathEvent event) {
if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
SummonKeybladeCapability.ISummonKeyblade SUMMON = player.getCapability(ModCapabilities.SUMMON_KEYBLADE, null);
IOrganizationXIII ORG = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null);
if (SUMMON.getIsKeybladeSummoned(EnumHand.MAIN_HAND)) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
PacketDispatcher.sendToServer(new DeSummonKeyblade());
PacketDispatcher.sendTo(new SyncKeybladeData(SUMMON), (EntityPlayerMP) player);
} else {
SUMMON.setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if (event.getEntity().world.getGameRules().getBoolean("keepInventory")) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (!ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(i), ItemStack.EMPTY)) {
if (player.inventory.getStackInSlot(i).getItem() instanceof ItemRealKeyblade) {
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}
}
}
} else if (ORG.summonedWeapon(EnumHand.MAIN_HAND)) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
PacketDispatcher.sendToServer(new DeSummonOrgWeapon());
PacketDispatcher.sendTo(new SyncOrgXIIIData(ORG), (EntityPlayerMP) player);
} else {
SUMMON.setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if (event.getEntity().world.getGameRules().getBoolean("keepInventory")) {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
if (!ItemStack.areItemStacksEqual(player.inventory.getStackInSlot(i), ItemStack.EMPTY)) {
if (player.inventory.getStackInSlot(i).getItem() instanceof IOrgWeapon) {
player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}
}
}
}
}
if (event.getEntity() instanceof EntityDragon) {
WorldSavedDataKingdomKeys.get(DimensionManager.getWorld(DimensionType.OVERWORLD.getId())).setSpawnHeartless(true);
}
if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityMob)
if (event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
EntityMob mob = (EntityMob) event.getEntity();
player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, (int) (mob.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getAttributeValue() / 2));
if (!player.getCapability(ModCapabilities.PLAYER_STATS, null).enderDragonDefeated()) {
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDriveGaugeLevel(player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel() + 1);
player.getCapability(ModCapabilities.DRIVE_STATE, null).setDP(player.getCapability(ModCapabilities.DRIVE_STATE, null).getMaxDP());
PacketDispatcher.sendTo(new SyncDriveData(player.getCapability(ModCapabilities.DRIVE_STATE, null)), (EntityPlayerMP) player);
TextComponentTranslation driMessage = new TextComponentTranslation(Strings.Chat_DriveBoost, new TextComponentTranslation("" + player.getCapability(ModCapabilities.DRIVE_STATE, null).getDriveGaugeLevel()));
driMessage.getStyle().setColor(TextFormatting.GREEN);
player.sendMessage(driMessage);
player.getCapability(ModCapabilities.PLAYER_STATS, null).setEnderDragonDefeated(true);
}
if (event.getEntity() instanceof EntityDragon) {
player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, 2000);
}
if (event.getEntity() instanceof EntityWither) {
player.getCapability(ModCapabilities.PLAYER_STATS, null).addExperience(player, 1500);
}
PacketDispatcher.sendTo(new SyncLevelData(player.getCapability(ModCapabilities.PLAYER_STATS, null)), (EntityPlayerMP) player);
}
}
Aggregations