Jump to content

[1.9] [Solved, solution inside] A very weird set of issues with GUI


Recommended Posts

Posted

Code:

TestBlock: http://pastebin.com/nub56uNM

GuiContainerTileEntityTestBlock: http://pastebin.com/ueL72uSc

GuiMessage: http://pastebin.com/2idHgLsk

GuiHandler: http://pastebin.com/pYC8pr4X

ContainerTileEntityTestBlock: http://pastebin.com/a3GB6rNC

GuiMessageHandler: http://pastebin.com/qzZEbKfP

TileEntityTestBlock: http://pastebin.com/Aj4gCkJa

 

Alright, I can't describe this problem very well, so here is exactly what I do:

 

1. Create a new world, place my block

Special Occurrences: Nothing

Log entry:

 

[21:02:46] [server thread/INFO]: [Player865: Set own game mode to Survival Mode]

[21:02:46] [Client thread/INFO]: [CHAT] Your game mode has been updated to Survival Mode

[21:02:53] [server thread/INFO]: [Player865: Given [Test Block] * 1 to Player865]

[21:02:53] [Client thread/INFO]: [CHAT] Given [Test Block] * 1 to Player865

entered onBlockPlacedBy

 

 

2. Place an energy source next to block and right click the block

Special occurrences: I see the RF filling up (in the form of text)

Log entry:

 

 

entered onBlockPlacedBy[21:05:47] [server thread/INFO] [sTDOUT]: [greatblitz.testmod.blocks.TestBlock:onBlockActivated:69]: Hello!

[21:05:47] [server thread/INFO] [sTDOUT]: [greatblitz.testmod.blocks.TestBlock:onBlockActivated:70]: Energy: 140/32000

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 140

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 140

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 140

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 160

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 160

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 160

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 180

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 180

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 180

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 200

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 200

[21:05:47] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

 

and so on

 

 

3. Break the block, place it elsewhere

Special occurrences: The block gets placed as normal.

Log entry:

 

entered onBlockPlacedBy[21:26:33] [Client thread/FATAL]: Error executing task

java.util.concurrent.ExecutionException: java.lang.NullPointerException

at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_101]

at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1109) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:404) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]

at GradleStart.main(GradleStart.java:26) [start/:?]

Caused by: java.lang.NullPointerException

at net.minecraft.client.network.NetHandlerPlayClient.handleUpdateTileEntity(NetHandlerPlayClient.java:1303) ~[NetHandlerPlayClient.class:?]

at net.minecraft.network.play.server.SPacketUpdateTileEntity.processPacket(SPacketUpdateTileEntity.java:55) ~[sPacketUpdateTileEntity.class:?]

at net.minecraft.network.play.server.SPacketUpdateTileEntity.processPacket(SPacketUpdateTileEntity.java:12) ~[sPacketUpdateTileEntity.class:?]

at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_101]

at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_101]

at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?]

... 15 more

 

 

Note about the log: Where is this NPE coming from?

 

4. Right-click the block

Special occurrences: RF appears as 0.

Log entry:

 

[21:29:04] [server thread/INFO] [sTDOUT]: [greatblitz.testmod.blocks.TestBlock:onBlockActivated:69]: Hello!

[21:29:04] [server thread/INFO] [sTDOUT]: [greatblitz.testmod.blocks.TestBlock:onBlockActivated:70]: Energy: 3460/32000

[21:29:04] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:04] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:29:05] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

 

 

Note about the log: It's weird, that the block shows that there is RF, but the GUI itself and the GUI prints display as 0.

 

5. Exit, re-enter world, right click block

Special occurrences: RF is still 0.

Log entry:

 

[21:32:42] [server thread/INFO] [sTDOUT]: [greatblitz.testmod.blocks.TestBlock:onBlockActivated:69]: Hello!

[21:32:42] [server thread/INFO] [sTDOUT]: [greatblitz.testmod.blocks.TestBlock:onBlockActivated:70]: Energy: 0/32000

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:45]: printing from drawscreen

false

[21:32:42] [Client thread/INFO] [sTDOUT]: [greatblitz.testmod.client.gui.GuiContainerTileEntityTestBlock:drawScreen:47]: rf: 0

 

Note about the log: It's even weirder, that although the GUI prints continue to display RF as 0, this time the block itself displays RF as 0 (didn't happen in step 5, read note).

 

Tell me if you need more files/logs.

 

Appreciate all the help I can get.

 

Regards,

GreatBlitz.

Posted

Hi

 

Although I don't really understand what problems you're having, the general symptoms make me think you are probably messing up the client-server synchronisation.

 

If you need an example of working containers and/or tile entity synchronisation, this tutorial project might help

https://github.com/TheGreyGhost/MinecraftByExample

(mbe20, mbe30, mbe31 in particular)

 

-TGG

 

But if you look at my tile entity (TileEntityTestBlock: http://pastebin.com/Aj4gCkJa), my getUpdatePacket(), getUpdateTag(), onDataPacket(), handleUpdateTag(), readFromNBT(), writeToNBT() methods seem fine...?

Posted

then the problem most likely isn't your tile entity. your tile entity looks really fine.

 

i'm going to read trough the classes now.

 

look 1: you most likely would want to do world.notifyblock as well when you are placing the block

-2 most certainly after calling the readNbt to copy over the itemstack data.

also, why are you reading the entire itemstack data ? I might be wrong here, but wouldn't it be better to append a tag to the stack tag so you write your entire TE to a nbttagcompound that you append to the stack tag compound ?

if other mods, or even vanilla?, write data to the itemstack, stuff might get funky.

 

short conclusion : you will want to call world.blocknotify whenever you make a change to the TE. you will want to do this server side.

-when placing a block next to it

-when changing RF by use of items

-when sending a packet to the server

 

(most of these are already done. just verify)

 

the biggest problem about breaking block and re-placing it is most likely reading the nbt from the stack, and writing it to the stack. double check on those.

 

do not know where the NPE is comming from, but you can trace it down with a break point on NPE exceptions (yes, that does exist). it is most likely comming from a packet error and something that has to do with threads ?

"java.util.concurrent.ExecutionException,

handleUpdateTileEntity,

SPacketUpdateTileEntity.processPacket"

 

 

unrelated :

-you might want to rename some of your classes.

Gui's start with the Gui prefix, so GuiMessageHandler would be inapropriate.

PacketSyncServerTestBlock and PacketSyncServertestBlockHandler would be more appropriate.

-BlockPos can be written to long, which can be written by ByteBufers, and BlockPos.fromLong(long) is also a thing. no need to explicetly write the coords out to the packet.

Posted

Marking as solved. The helpful people at IRC told me to use BlockEntityTag instead, this is what my code in getDrops becomes, for anyone curious:

List<ItemStack> drops = Lists.newArrayList();
TileEntityTestBlock te = (TileEntityTestBlock) world.getTileEntity(pos);
if (te != null && te instanceof TileEntityTestBlock) {
     	ItemStack i = new ItemStack(ModBlocks.testblock);
       	NBTTagCompound compound = new NBTTagCompound();
       	te.writeToNBT(compound);
       	compound.removeTag("x");
       	compound.removeTag("y");
       	compound.removeTag("z");
       	NBTTagCompound stackTag = new NBTTagCompound();
        stackTag.setTag("BlockEntityTag", compound);
        i.setTagCompound(stackTag);drops.add(i);
   }

   return drops;
}

 

Then I removed the onBlockPlacedBy method, as BlockEntityTag loads it on its own.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.