
Thornack
Members-
Posts
629 -
Joined
-
Last visited
Everything posted by Thornack
-
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
I do understand it and I already have an IEEP class that adds a stamina bar already and that is persistent and the NBT saves and I am actually using that as a gude to try and get this working. What I am trying to do is waaaay more complicated than a simple stamina bar and hence why I am debugging rather than going backwards. I made my player server side like you suggested and I pass the player in. I put the client and server side player in my debug message to see what the differences were and if you read my last post you can see them. I put what the consol outprints when I try the client player and I also put what it outprints when I try the passed in player (This is the server player I believe that is obtained using the getThrower method inside my class that extends EntityThrowable) I will try the outprints inside the save and load NBT that you suggested and see what I get. -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Ya I saw that and fixed it but the NBt data still isnt persistent not sure why. I also tried passing in the player as a parameter [but doing this presented a problem] when I pass the player as a Parameter I get Null for all slots of my party. Below is my tryToAddMobToParty method with the player passed in as a parameter and my getPartyMember method that is located inside the IEEP class. I tried to outprint both the Minecraft.getMinecraft.thePlayer and the passed in player and I get the following outprints to consol. What is werid is that if I use Minecraft.getMinecraft.thePlayer the slots are not null when the getPartyMember(); method is called and they contain the NBT data of each unique instance of my entity. if |I used the passed in player the getPartyMember(); outprints null for all slots. Player is EntityPlayerMP['Player845'/247, l='New World', x=1109.00, y=4.00, z=392.58] Minecraft.getMinecraft.thePlayer is EntityClientPlayerMP['Player845'/247, l='MpServer', x=1109.00, y=5.62, z=392.58] public void tryToAddMobToParty(EntityPlayer player){ System.out.println("Player is " + player); System.out.println("Minecraft.getMinecraft.thePlayer is " + Minecraft.getMinecraft.thePlayer); PlayerParty pp = PlayerParty.get(player);// instead of PlayerParty pp = PlayerParty.get(Minecraft.getMinecraft.thePlayer); System.out.println("free slot? " + pp.hasFreeSlot()); if(pp.hasFreeSlot() == true){ pp.setPartyMember(pp.getNextFreeSlot(), this.hitEntity); System.out.println(this.hitEntity + " saved to slot " + pp.getNextFreeSlot()); }else{ this.displayChatMessage(EnumChatFormatting.RED + "Your Party Is Currently Full!"); System.out.println("next free slot " + pp.getNextFreeSlot());//should return -1 at this point because party is full [works] pp.getPartyMember(0); System.out.println("first in party " + pp.getPartyMember(0)); pp.getPartyMember(1); System.out.println("second in party " + pp.getPartyMember(1)); pp.getPartyMember(2); System.out.println("thirdt in party " + pp.getPartyMember(2)); pp.getPartyMember(3); System.out.println("fourth in party " + pp.getPartyMember(3)); pp.getPartyMember(4); System.out.println("fifth in party " + pp.getPartyMember(4)); pp.getPartyMember(5); System.out.println("sixth in party " + pp.getPartyMember(5)); } } Whats weird is if the party is full and if i pass in the player rather than using Minecraft.getMinecraft.thePlayer then the getPartyMember method doesnt return null and then immediately the next tick it is null again... but what is weird also is that if i try to add another party member the NBT data is still there I know this because the UUID's that get printed dont change... get member in slot0null get member in slot1null get member in slot2null get member in slot3null get member in slot4null get member in slot5null next free slot -1 first mob in party {DropChances:[... second mob in party {DropChances:[... thirdt mob in party {DropChances:[... fourth mob in party {DropChances:[... sixth mob in party {DropChances:[... get member in slot1null get member in slot2null get member in slot3null get member in slot4null get member in slot5null public NBTTagCompound getPartyMember(int slot){ System.out.println("get member in slot" + slot + partyNbt[slot]); return partyNbt[slot]; } I get Null for all slots all the time if I pass in the player but if I use Minecraft.getMinecraft then all is fine and dandy -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
The reason why I need the entity tied to both the itemstack and upon item pick up the entity gets tied to the player and the itemstack NBT is cleaned up is because the eggs can be stolen by other players. if an egg is stolen then this initiates a quest that is unique to the player that originally caught the entity. In order to get my quest to work properly, in the way that I want it to, I have to know how to tie the entity to both the player and the itemstack. The design I want is clear, all I had issues with is getting the entity to save to the player persistently. I mean currently it does "save" as long as the player doesnt log off or die haha but i am trying out a few things to fix this issue, thanks a lot for the suggestions, ill post if and when i get a solution or if i run into more issues. -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
pokemon nah but you can think of it as similar to pokeball thrown at a pokemon in an attempt to catch it i guess if that clarifies the end goal. im trying to get that sort of functionality kinda but with a twist, the twist is my holder entity and what it does and the custom animation based on my calculation and you get an egg afterwards rather than a pokeball. ill switch over from using stuff liek EntityCustom and ImpactEntity to EntityPokemon and EntityPokeball if that helps clarify my code? -atm I am saving to both the itemstack and the player just to see if I can and how to do it, eventually I want it to save first to itemstack and when itemstack is picked up by the player then the entity that is inside the itemstack is saved to players party. (think of the itemstack as a spawn egg or if it helps visualize what I want to achieve think of it as a pokeball or whatever youd like to imagine it as Im looking for that kind of functionality roughly) -the caught entity will always be of the same type (of type EntityPartyMember) and is my custom entity, I plan to eliminate all vanilla entities from my mod and dont plan to make my mod compatible with others as that would be a pain to code -EntityPartyMember is the class that I made all of my entities inherit from, it extends EntityAnimal implements IEntityAdditionalSpawnData, I implement my stats system for EntityPartyMember among other stuff. so EntityEachCustomEntityInMyMod->EntityPartyMember->EntityAnimal->EntityAgeable->EntityCreature->EntityLiving->EntityLivingBase->Entity ok ya i thought i would have to pass arguments it wont be an easy fix but ill give it a go and you are correct I could access it faster but I dont want to, I want it accessed in order i think (unless ill suffer performance issues due to my order or some technical impossible wall I cannot get over or around that prevents me from achieving my goal) but i dont think that should be the case. next time im modding I may give you a should over skype -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Also, I have a bit of a problem I think. I need to call this method on server but I need to have the client player. I am not sure how to get the client player while also calling the method on the server without doing PlayerParty pp = PlayerParty.get(Minecraft.getMinecraft().thePlayer); - I think this may be causing the weird problems where I need packets. public void tryToAddMobToParty(){ PlayerParty pp = PlayerParty.get(Minecraft.getMinecraft().thePlayer); System.out.println("free slot? " + pp.hasFreeSlot()); if(pp.hasFreeSlot() == true){ pp.setPartyMember(pp.getNextFreeSlot(), this.hitEntity); System.out.println(this.hitEntity + " saved to slot " + pp.getNextFreeSlot()); }else{ this.displayChatMessage(EnumChatFormatting.RED + "Your Party Is Currently Full!"); System.out.println("next free slot " + pp.getNextFreeSlot());//should return -1 at this point because party is full [works] pp.getPartyMember(0); System.out.println("first in party " + pp.getPartyMember(0)); pp.getPartyMember(1); System.out.println("second in party " + pp.getPartyMember(1)); pp.getPartyMember(2); System.out.println("thirdt in party " + pp.getPartyMember(2)); pp.getPartyMember(3); System.out.println("fourth in party " + pp.getPartyMember(3)); pp.getPartyMember(4); System.out.println("fifth in party " + pp.getPartyMember(4)); pp.getPartyMember(5); System.out.println("sixth in party " + pp.getPartyMember(5)); } } -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Also, The reason why I cannot simply just save a reference to my entity is because the entity only exists inside my itemstack and does not exist in the world. So I need to be able to save the entity NBT to the players extended properties in order to get its data. -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Is it because when I get the instance of my party class I am passing in the client player using PlayernParty ppp = PlayerParty.get(Minecraft.getMinecraft().thePlayer); but I am calling my setPartyMember code server side and as such only the client player is updated and not the server player? is that what is going on and does the saveNBTData method work only from server player? public void setPartyMember(int slot, EntityPartyMember partyMember){ NBTTagCompound compound = new NBTTagCompound(); partyMember.writeToNBT(compound); partyNbt[slot] = compound; test = 100; System.out.println("setting test to" + test); System.out.println("partyMember added to party " + partyNbt[slot]); } -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Im not really seeing the problem can you elaborate, I am printing out test 6 times and it is 0 all 6 times -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
So basically, my method setPartyMember gets called server side, at which point the variable test is set to be 100. I do not call any other method to reset test to 0 but for some reason it is 0 when saveNBTData is called... I have no idea why... *Note to force the saveNBTData method to be called hit the escape key to bring up the log off menu -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Ok so I found something really weird If I add a variable called test that is an int to my class public class PlayerParty implements IExtendedEntityProperties { protected EntityPlayer entityPlayer; public int test = 0; public static final int NUM_SLOTS = 6; //.....the rest of the class } then inside my setParty Member Method I do test = 100 as seen in the method below and outprint the value of test when the method is called I get [server thread/INFO] [sTDOUT]: [custommod.player.properties.PlayerParty:setPartyMember:28]: setting test to100 //this is as expected public void setPartyMember(int slot, EntityPartyMember partyMember){ NBTTagCompound compound = new NBTTagCompound(); partyMember.writeToNBT(compound); partyNbt[slot] = compound; test = 100; System.out.println("setting test to" + test); System.out.println("partyMember added to party " + partyNbt[slot]); } then if I put a system.outprint line to get the value of test when NBT data gets saved I get the following [server thread/INFO] [sTDOUT]: [custommod.player.properties.PlayerParty:saveNBTData:80]: test equals 0 //this is the problem...why would it be 0? when I just set it to be 100! @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); for(int i=0; i < NUM_SLOTS; i++){ System.out.println("test equals " + test); if(partyNbt[i] != null){ compound.setTag("Slot"+i, partyNbt[i]); } } compound.setTag(EXTENDED_ENTITY_PROPERTIES_TAGNAME, properties); } Does anyone know why? -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
To get entity from uuid, loop through world entities and check uuid match... isnt looping through the entire world entities list very messy and intensive? wouldn't that cause lag? I need a fairly clean solution, some way to give the player access to my custom entities and all of their data easily since my spawn/despawn/spawn again / despawn again ...etc process will happen frequently and I need to be able to have the data each time it happens and it needs to be persistent. My entities will have stats that change over time and the player will be able to become each entity in his/her party and in order for that to work I need to be able to get the entities in a robust and not very intensive way so that the process doesnt cause crazy lag cause if this is occurring in a multiplayer, it probably isnt good to have several players looping through the entire entities list every time they want to change whomever they are in their party. Especially because the player holds the entity they want in the form of an item... where that itemstack contains all of the desired entities NBT data -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
BTW I know how to get the UUID I dont know how to get the entity from the UUID - basically not sure how to say the following in code "Hey server I want to get this entity from UUID ashfjws23857tiodjswufy847390ri and all associated properties including health, position, extra stats ive given my entity etc etc.." [NOTE] - the UUID's are different and unpredictable depending on which entity the player captures and the player will be able to swap out party members for different ones so the solution im looking for needs to be able to account for that hence why I thought the NBT approach I posted above would work. -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Yes I know all of that but my party involves entities not players... hence my problem, to note, The entities in my party get impacted by an entity that is thrown by the player whereupon they get saved to NBT and set to dead in the world and their NBT data is transferred to the impact entity and then to a holder entity that allows animations to play and then if animations are successful the NBT is transferred to an itemstack and the holder entity is set to dead and the itemstack then acts like a spawn/despawn egg. The UUID's persist throughout this process oh and the itemstack can spawn another impact entity to get the "tamed" entity to spawn/despawn it at the will of a player. I want the entity that is captured to join the players party at the first time it is caught and to remain in teh party throughout any subsequent spawn/despawns. This is why I tried to create a party where the slots are NBT Tag Compounds that are saved to the player to give him easy access to the party members so that the player can switch places with the party members easily. But I guess that is not proper, so I am looking for a solution to achieve this result. I got it figured out to the point where I can get the switching to work but the party doesnt persist through player death or log off -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Does anyone know of a way to save a stable reference to the entity so that it is easy to get the entity at a later date whenever i want? i tried getEntityById but the id changes since it is not a UUID. Im not sure how to get the entity from the UUID, and am not aware of any other good references to entities. -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Hmm ya i see your point, Im just not sure what a good way would be to store the reference to my entity rather than the entity itself. I know my entities have persistent UUID's and persistent stats -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
I guess my problem is that I need an array of "slots" that can store entity data, where each slot stores all of the information about the entity that was assigned to the slot. -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
To which are you referring to im sorry I dont quite understand your comment -
Hi everyone, So I have a class that implements IExtendedEntityProperties which I use to give the player a party of entities. I want the party members to be selectable at a later time so that the player can select whichever party member he chooses. Currently my entities get saved to the party slot but when the player dies or logs off and then logs back on the party member data doesnt persist. Im not sure what the problem is. This is my class. If you have any questions let me know, and any help is appreciated. My PlayerParty class I use this method elsewhere to get the party members (it works)
-
in Client Proxy public void registerKeyBindings() { MinecraftForge.EVENT_BUS.register(this); KeyZoomIn key2 = new KeyZoomIn(); ClientRegistry.registerKeyBinding(key2); FMLCommonHandler.instance().bus().register(key2); } in common proxy /* Overriden in ClientProxy*/ public void registerKeyBindings() {} /*preInit() is called from PokeWorlds.java, and is responsible for registering all * Items and Entities. You should register the following here: creative tabs, items, * entities, blocks, tile entities, and mobs. * */ public void preInit(){ registerKeyBindings(); }
-
This is the class with the imports - it works as is for me i use Eclipse as an IDE and my forge version is forge\1.7.10-10.13.2.1230\forgeSrc-1.7.10-10.13.2.1230.jar import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.input.Keyboard; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; public class KeyZoomIn extends KeyBinding { public KeyZoomIn() { super("key.keyZoomIn", Keyboard.KEY_Z, "key.categories.custommod"); } Minecraft mc; double zoom; @SubscribeEvent public void keyDown(InputEvent.KeyInputEvent event) { Keyboard.enableRepeatEvents(true); if(Keyboard.isRepeatEvent()){ if (isPressed()) { double currentZoom = zoom += 0.005; this.cameraZoom(currentZoom); System.out.println(currentZoom); }} else if (!isPressed() && zoom !=1) { zoom = 1; this.cameraZoom(zoom); } } public void cameraZoom(double zoomValue){ EntityRenderer entRenderer = Minecraft.getMinecraft().entityRenderer; try { entRenderer.getClass().getDeclaredField("cameraZoom").set(entRenderer, zoomValue); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } } } [code]
-
Haha nope the code works as posted you need to register the keybinding using in client proxy public void registerKeyBindings() { MinecraftForge.EVENT_BUS.register(this); KeyZoomIn key1 = new KeyZoomIn(); ClientRegistry.registerKeyBinding(key1); FMLCommonHandler.instance().bus().register(key1); } and overright that same method in common proxy and correctly pass it to your main mod file but other than that it works just fine. Not sure why like I said it was my first attempt using reflections
-
[1.7.10] Player hitbox and hit mechanics - how to change stuff
Thornack replied to Thornack's topic in Modder Support
Ya Ive seen that reach code before, havent played around with his solution yet though. I wish the players hitbox/camera/reach n hit mechanics were more easily accessible using a forge hook or something like that. Ill try out some stuff before reposting, so far all I have figured out is how to change the camera zoom (but not its x y z position) not sure how to change the actual camera x y z position but I have been starting there. Once I figure that out then Im moving on to the reach, and the player hitbox. but all three are necessary to what I need to do. Otherwise, if the player uses a large model like a model giant third person is broken n useless and first person looks weird to other players since it looks like the hits come from my giants knees. -
[1.7.10] Player hitbox and hit mechanics - how to change stuff
Thornack replied to Thornack's topic in Modder Support
I know how to zoom the camera but I need the position of the punch box to be changed and was wondering if anyone knows how -
Images of what I want to achieve Hi everyone, hopefully the image above clearly demonstrates what I need to do I need to change the way the players hit mechanics work. specifically to change the position of the players punching box (when you hit F3 + B) it would be the small white cube inside the players large hitbox (at least I believe this small hitbox represents the players arm and is used for actual collision calculations?). The diagram above hopefully clearly shows what I need to do so that the players reach is calculated from a different position. Also I also need to resize the players hitbox to be smaller or larger (when you hit F3 +B) the large hitbox that appears I would need to scale that. The reason being is I have a very large model that the player can become. However, this model will only permit the player to play in 3rd person view. To make it look and work properly I need to have the position of the + cursor to be farther away from the model and represent the players reach distance. When you are my large model your reach distance should be a lot greater, but due to its size you should have movement penalty n not be able to fit into all places. hence why I need to change the players hit mechanics and the players hitbox size. I think some people have kinda dabbled into this a little bit, my goal is to get a fully working solution to this. I do know it is a tough problem though hence any input is appreciated.