
RealTheUnderTaker11
Members-
Posts
66 -
Joined
-
Last visited
Everything posted by RealTheUnderTaker11
-
I have spent a stupid amount of hours trying to figure out how to make a tile entity that will work with a GUI and show progress/Stored energy. There isn't a whole lot on this at all so I've been using https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe31_inventory_furnace as well as some things from MCjty's tutorials to try and create this machine block. The tutorial code is given using IInventory so I have had to fumble my way around this whole thing to get it to work with capabilities instead. Now that that's out of the way my problem is as the title says, it should be noted I know I changed the number of slots and the number of fires that would respond. I am planning to change the look of the texture later. Just know everything I put in place is working besides the fact shift click doesn't work, and nothing will update with how much power/ % progress. In fact it won't tell me the power at all, it always says it is 0. All related classes are below, I hope I don't miss one. Block class- http://pastebin.com/NUcDeyJ3 Tile Entity Class(And the one it extends right below it)- http://pastebin.com/buBHi2wy Container class-http://pastebin.com/yvijT51R Gui class- http://pastebin.com/Rc92LtFG GuiProxy class(A gui handler) Lastly the line of code I register the handler NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiProxy()); I am more than open to any suggestions about how to do things better or what I'm doing wrong besides the topic problem(Such as the shift click).
-
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
I FOUND OUT THE PROBLEM OH MY GOD I AM SO HAPPY. So I decided to look through all of the TileEntity class out of desperation, and I came upon that actual readFromNBT method. LITTLE DID I ****ING KNOW, they use x, y, and z int's saved to the NBT to get the location of the tile entity and do stuff with it... The more you know right? Lesson learned, kids, never use x, y, or z as NBT int keys or else it will screw up everything. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
How I said it or what is happening? Cause if its how I said it I could try and explain better. -
[1.11] Best way to make new config categories?
RealTheUnderTaker11 replied to boredherobrine13's topic in Modder Support
addCustomCategoryComment Its in the Configuration class. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
I THINK I JUST FIGURED OUT SOMETHING HUGE Okay so I talked with another programmer about this and he said that it might be making 2 instances of the tile entity. To test this, I put something that printed out the current energy every 5 seconds in the update() method. What I found out was that nothing happened until I interacted with the block. After that it seemed to make a new tile entity(Or something) and finally the current energy was printing every 5 seconds. So I had to go further before I made this post. I commented out all my onBlockActivated code and made the return to false again. On right clicking the block it made it start printing energy still. Then I left and came back and tried just placing a block next to it, and again that made it start printing the energy. My only conclusion is that it's not even making a tile entity until the block itself updates, and by then it doesn't even care about what the NBT data was the time before. I hope that helps, I'm going to keep fiddling around and changing things to try and get more info. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
Did you not see all the other console logs I showed that it was 0 outside of the read from NBT part, even serverside? the code that outputs the chat message is called serverside, but I use playerIn.addChatMessage() to send the result to the player in chat, so not everyone in chat will see when a player right clicks the block. [14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:186]: Tile Entity Energy: 0 [14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:187]: Class x: 0 [14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:186]: Tile Entity Energy: 0 [14:36:31] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:getEnergy:187]: Class x: 0 [14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:208]: Class Energy before actually writing: 0 [14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:209]: Class x before actually writing: 0 [14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:210]: Written to NBT [14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:217]: NBT Energy after actually writing: 0 [14:50:03] [server thread/INFO] [sTDOUT]: [com.theundertaker11.kitchensink.tileentity.KSTileEntityQuarryBlock:writeToNBT:218]: NBT x after actually writing: 0 All that is serverside, the few clientside ones in there just either say text or reflect what the serverside variable is. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
Well since you point that out now its weird. So when I put a printscreen here @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); System.out.println("NBT Energy: "+ compound.getInteger("Energy")); if (compound.hasKey("items")) { itemStackHandler.deserializeNBT((NBTTagCompound) compound.getTag("items")); } //this.replaceBlocks = compound.getBoolean("replaceBlocks"); this.Energy = compound.getInteger("Energy"); this.x = compound.getInteger("x"); this.y = compound.getInteger("y"); this.z = compound.getInteger("z"); System.out.println("Class Energy: "+ this.Energy); } Both come out with the number that should of been saved. But when I put a print screen here public int getEnergy() { System.out.println("Tile Entity Energy: "+ this.Energy); return this.Energy; } It comes out as 0. Spoiler below has the console logs of what was printed for each So the weirdest part is the write to NBT says everything comes out as 0, yet EVERY time I load the world, the read from NBT values stay at the 60 and -1891. NOTE: I haven't tried to add more energy since the initial 60 that it was, since I feel that would confuse things. But I can tell you from past trials it will set the energy to however much I put in, and dig until it runs out of that new energy. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
I thought the block code I put explained that well enough, but I'll type out the two reasons.(The second not being in the block code) Reason 1: When I right click the block after loading back the world, it told me there was 0 energy and it had reset the number that told the amount of blocks it needed to mine. Reason 2: If the quarry had mined some blocks before I saved and exited, after loading back in the world and giving the quarry more energy(Since it reset to 0), it will start back at the first block, meaning the X, Y, and Z int's are not saving. I could do screen prints but I really see no point given the information I have already. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
Yes it is calling both read and write to NBT. I put the print statement after the super() lines on both, shown below. -
[1.10.2] Tile Entity won't save data[Solved]
RealTheUnderTaker11 replied to RealTheUnderTaker11's topic in Modder Support
Bump, still no idea why it is not working. -
EDIT(SOLUTION): The problem was I used x, y, and z when I set my NBT data, and the TileEntity class uses those to get information about where the block is in the readFromNBT method. Moral of the story is always check the super to make sure you don't use variables they were already using... To be 100% safe just use your modID as a prefix to all your NBT keys, as said by Draco. So basically I had this problem before and fixed it, using the setDirty(). Now that I have added some more variables, it will not save at all, ever.(And by "save" I mean when I exit the world and come back the data persist) My TE class has a lot of stuff, but the read/write to NBT are both a few up from the very bottom. The reason there is so many setDirty()'s everywhere is because it was my last ditch attempt to try and get data to save. My TE class My Block class(Since this gives me some of the numbers I've been using it to check if they save) Any idea why nothing is being saved?
-
You know when you type that out it sounds a lot dumber than I thought it did... Probably should have asked "how to make a fake player" first. I fiddled around a bit after realizing how stupid that was, and came to this. private static GameProfile KitchenSinkProfile = new GameProfile(UUID.fromString("a7d50290-b3f6-4dd9-afa1-d1de51ce3355"),"[KitchenSink]"); private FakePlayer KitchenSinkPlayer = new FakePlayer(this.getWorld().getMinecraftServer().worldServerForDimension(0),KitchenSinkProfile); Am I doing it right, or am I supposed to use FakePlayerFactory somehow? And like I said google never came up with very much for me, so if you have a link that has the information I need I would be glad to use that. [EDIT] Completely forgot to mention this is in a Tile Entity class for a quarry block I am making. If there is a different place this should be I will move it.
-
Sorry if this or something very similar has been posted before, but I couldn't find it in all my searching. Title says it all, and I assume I just use this below to create a fake player? private static GameProfile KitchenSinkProfile = new GameProfile(UUID.fromString("a7d50290-b3f6-4dd9-afa1-d1de51ce3355"),"[KitchenSink]"); I know almost all mods now somehow use fake players to break their blocks, because it makes it work with permission add-ons on servers. I just need to know how I can break a block given the XYZ using that fakeplayer, and if that's not how I'm supposed to do it, tell me the best way for it to be done.