Posted January 23, 20196 yr Basicly just as the title describes i want to save multiple values in 1 Capability. i know i can do this with something like this in the Storage class: @Override public NBTBase writeNBT(Capability<IQuirk> capability, IQuirk instance, EnumFacing side) { NBTTagCompound tag = new NBTTagCompound(); tag.setString("name", instance.getName()); tag.setBoolean("activated", instance.getActivated()); tag.setBoolean("available",instance.getAvailable()); //Cooldown tag.setInteger("maxCooldown", instance.getMaxCooldown()); tag.setInteger("cooldown", instance.getCooldown()); //Activation Time tag.setInteger("maxAct", instance.getMaxActivatedTime()); tag.setInteger("act", instance.getAct()); //Quirk ID tag.setInteger("quirkid", instance.getQuirkID()); return tag; } @Override public void readNBT(Capability<IQuirk> capability, IQuirk instance, EnumFacing side, NBTBase nbt) { NBTTagCompound tag = (NBTTagCompound) nbt; tag.getBoolean("activated"); tag.getBoolean("aviable"); //Cooldown tag.getInteger("maxCooldown"); tag.getInteger("cooldown"); //Activation Time tag.getInteger("maxAct"); tag.getInteger("act"); //Quirk ID tag.getInteger("quirkid"); } But i ran into the problem with this that it saves to the Player... not on the world. (as Example: i join world A with "xp" capablity set to 12 and log out join world B and still have the same amount!) i AM using packets... so i dont know what i am doing wrong here.. thanks in advance
January 23, 20196 yr You need to explain what you are trying to achieve. Do you want the value to follow the player from world to world? When do you want the value go up and down? Is this a characteristic of the player, or the world?
January 23, 20196 yr Of course you "join world A" and then "join world B" won't carry a value with the player. They aren't the same player. It's the same player account, but World A and World B are two completely unrelated save files. Data does not carry over between them. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 27, 20196 yr Author okay sorry for the late reply, (had some school stuff to do) basicly i only want to save those values on the player but they save on the account and i dont know why till now my code is a BIG mess so its also very difficult to find the problem i set it up like this: in my OnPlayerJoin event (0 is the default value) a random "qurik" should be choosen (an ID between 1 and 2 till now) when it is 0... but the ID is NOT 0 when i joined a world before i join another if i restart the game the value is 0 again... If a Github Repository is prefered i would provide one (it will take some time because i am installing now a second OS on my pc) Edited January 27, 20196 yr by Oscarita25
January 27, 20196 yr 3 hours ago, Oscarita25 said: but they save on the account Capabilities are not set up to work this way. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 27, 20196 yr Author 1 minute ago, Draco18s said: Capabilities are not set up to work this way. i know that they are not made to work like this ... but i my code basicly does it.. and its not even wanted that it does this ...
January 27, 20196 yr Author ok, but First i am installing a OS ... (made a partition of my harddrive took long enough)
January 27, 20196 yr Author @diesieben07 here is the full code: https://github.com/Oscarita25/QuickRepo this is in my eventhandler: @SubscribeEvent public void onPlayerLoggedIn(PlayerLoggedInEvent event) { EntityPlayer player = event.player; //Sycronizing Capabilities ILevel level = player.getCapability(LevelProvider.LEVEL_CAP, null); IExp exp = player.getCapability(ExpProvider.EXP_CAP, null); INExp nexp = player.getCapability(NExpProvider.NEXP_CAP, null); IQuirk iquirk = player.getCapability(QuirkProvider.QUIRK_CAP, null); BNHA.NETWORK.sendTo(new MessageRequestLEVEL(), (EntityPlayerMP) player); BNHA.NETWORK.sendTo(new MessageRequestEXP(), (EntityPlayerMP) player); BNHA.NETWORK.sendTo(new MessageRequestNEXP(), (EntityPlayerMP) player); BNHA.NETWORK.sendTo(new MessageRequestQuirk(),(EntityPlayerMP) player); BNHA.NETWORK.sendToServer(new MessageLEVEL()); BNHA.NETWORK.sendToServer(new MessageEXP()); BNHA.NETWORK.sendToServer(new MessageNEXP()); BNHA.NETWORK.sendToServer(new MessageQuirk()); player.sendMessage(new TextComponentString("Your level is: " + level.getlvl())); player.sendMessage(new TextComponentString("Your exp is: " + exp.getexp())); player.sendMessage(new TextComponentString("Exp needed for the next level: " + (nexp.getnexp() - exp.getexp()))); } @SubscribeEvent public void onPlayerClone(PlayerEvent.Clone event) { //copy's capabilities EntityPlayer player = event.getEntityPlayer(); ILevel level = player.getCapability(LevelProvider.LEVEL_CAP, null); ILevel oldLevel = event.getOriginal().getCapability(LevelProvider.LEVEL_CAP, null); IExp exp = player.getCapability(ExpProvider.EXP_CAP, null); IExp oldExp = event.getOriginal().getCapability(ExpProvider.EXP_CAP, null); INExp nexp = player.getCapability(NExpProvider.NEXP_CAP, null); INExp oldNExp = event.getOriginal().getCapability(NExpProvider.NEXP_CAP, null); IQuirk cap = player.getCapability(QuirkProvider.QUIRK_CAP, null); IQuirk capold = event.getOriginal().getCapability(QuirkProvider.QUIRK_CAP, null); if(event.isWasDeath()) { cap.setMaxCooldown(capold.getMaxCooldown()); cap.setMaxActivatedTime(capold.getMaxActivatedTime()); cap.setCooldown(capold.getCooldown()); cap.setAct(capold.getAct()); cap.setActivated(capold.getActivated()); cap.setAvailable(capold.getAvailable()); cap.setQuirkID(capold.getQuirkID()); level.setlvl(oldLevel.getlvl()); exp.setexp(oldExp.getexp()); nexp.setnexp(oldNExp.getnexp()); BNHA.NETWORK.sendToServer(new MessageLEVEL()); BNHA.NETWORK.sendToServer(new MessageEXP()); BNHA.NETWORK.sendToServer(new MessageNEXP()); BNHA.NETWORK.sendToServer(new MessageQuirk()); BNHA.NETWORK.sendTo(new MessageRequestLEVEL(), (EntityPlayerMP) player); BNHA.NETWORK.sendTo(new MessageRequestEXP(), (EntityPlayerMP) player); BNHA.NETWORK.sendTo(new MessageRequestNEXP(), (EntityPlayerMP) player); BNHA.NETWORK.sendTo(new MessageRequestQuirk(),(EntityPlayerMP) player); } } @SubscribeEvent public void onPlayerTick(LivingUpdateEvent event) { //checking for level ups if (event.getEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntity(); IExp exp = player.getCapability(ExpProvider.EXP_CAP, null); INExp nexp = player.getCapability(NExpProvider.NEXP_CAP, null); ILevel level = player.getCapability(LevelProvider.LEVEL_CAP, null); IQuirk iquirk = player.getCapability(QuirkProvider.QUIRK_CAP, null); if (!player.world.isRemote) { //Random quirk choose Reference.RandomQuirkChoose(iquirk, player); if(exp.getexp() >= nexp.getnexp()) { level.setlvl(level.getlvl() + 1); BNHA.NETWORK.sendToServer(new MessageLEVEL()); nexp.setnexp(nexp.getnexp()*(level.getlvl() ^ 1)); BNHA.NETWORK.sendToServer(new MessageNEXP()); exp.setexp(0); BNHA.NETWORK.sendToServer(new MessageEXP()); player.sendMessage(new TextComponentString("You reached Level " + level.getlvl())); } }else return; } } in the on LivingUpdateEvent i put "Reference.RandomQuirkChoose(iquirk, player);" in my Reference class it looks like this (dont know if its relevant) public static void RandomQuirkChoose(IQuirk iquirk,EntityPlayer player) { if(iquirk.getQuirkID() == Reference.none) { int random = Reference.RandomIntChoose(); System.out.println(random + "Quirk NONE"); iquirk.setQuirkID(random); BNHA.NETWORK.sendToServer(new MessageQuirk()); if(iquirk.getQuirkID() == Reference.quirkless) { System.out.println(random + "Quirk QUIRKLESS"); iquirk.setName("Quirkless"); BNHA.NETWORK.sendToServer(new MessageQuirk()); }else if(iquirk.getQuirkID() == Reference.explosionquirk) { System.out.println(random + "Quirk EXPLOSION"); iquirk.setName("Explosion Quirk"); BNHA.NETWORK.sendToServer(new MessageQuirk()); } if(iquirk.getQuirkID() == Reference.quirkless) { player.sendMessage(new TextComponentString("You are " + iquirk.getName())); }else { player.sendMessage(new TextComponentString("Your Quirk is: " + iquirk.getName())); } } }
January 27, 20196 yr Author On 1/23/2019 at 4:29 AM, Daeruin said: You need to explain what you are trying to achieve. Do you want the value to follow the player from world to world? When do you want the value go up and down? Is this a characteristic of the player, or the world? also i did overlook this one ... i am only trying that it doesn't follow the player from world to world, I want to change the value when he has the default value, it is a capablitly attached to the player.
January 28, 20196 yr 2 hours ago, Oscarita25 said: also i did overlook this one ... i am only trying that it doesn't follow the player from world to world, I want to change the value when he has the default value, it is a capablitly attached to the player. The game does not do this. You need to save your data somewhere else, manually. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 28, 20196 yr Author 1 minute ago, Draco18s said: The game does not do this. You need to save your data somewhere else, manually. i am not sure if i am misunderstanding this ... but you mean i have to save it somewhere else ... not just with capablities?
January 28, 20196 yr 3 hours ago, diesieben07 said: As for what Draco said: The behavior you described does not just appear. It has to be caused by something in your code. It's not that you have to do something for it to stop, you have to stop doing something for it to stop. I think its behavior he doesn't have and wants. Not behavior that he has and doesn't want. But either way, in order to change it, it has to be custom code. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 28, 20196 yr Author 1 hour ago, Draco18s said: I think its behavior he doesn't have and wants. Not behavior that he has and doesn't want. But either way, in order to change it, it has to be custom code. nope its just exactly as the @diesieben07 said. for the unecissary package "overload" its just trying around ... if you read my previous posts you will propably notice that i had absolutly no clue how packages work ... so i am gotta fix that now. also thanks for all the pointers of what is complete nonsense of what i wrote there.
February 5, 20196 yr Author ironically i got back to just doing everything 1 capability for each ?♂️ worked out fine actually...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.