Jump to content

[1.11.2] BlockSnapshot serialization not posible


Recommended Posts

In Forge Build


Was introdused BlockSnapshot


This commit also includes a new utility class called BlockSnapshot which is serializable. This new class is used in conjunction with both PlaceEvent and MultiPlaceEvent in order to record a snapshot of block space before it is altered. This allows us to restore the block(s) if an event is cancelled. The class also provides the ability to restore a snapshot to any location using the restoreToLocation method. This should be helpful to many mods that are looking to be able to capture block data then restore it to back to any location required.

(BlockSnapshot contained blockID, Meta, BlockPosition(int: x, y, z), etc.
But later at Forge Build
Build 1.8-


Some notes: Almost all int x, int y, int z parameters have been changed to BlockPos class

all of the x,y,z values was replaced by BlockPos
(Now BlockSnapshot contains BlockID(string),Meta, BlockPosition(BlockPos), etc.
This change (int: x, y, z, -> BlockPos) renders Serialization not posible, due to BlockPos not a serializable class.

BlockSnapshot still implements io.Serializable interface, but it cant be serialized


[Server thread/INFO]: [STDERR]: java.io.NotSerializableException: net.minecraft.util.math.BlockPos


Idk this is a bug or feature, but still cost me a hour to realise a problem source.


code example:

BlockSnapshot BA1 = new BlockSnapshot(plr.world,cap1.getBlockPos(0),plr.world.getBlockState(cap1.getBlockPos(0)));
                      try {
                          File directory = new File(System.getProperty("user.dir")+"/"+arg2+"/"+arg3+"/");
                            if (! directory.exists()){
                          FileOutputStream fileOut =
                          new FileOutputStream(System.getProperty("user.dir")+"/"+arg2+"/"+arg3+"/"+arg4+".zba");
                          ObjectOutputStream out = new ObjectOutputStream(fileOut);
                          System.out.printf("Serialized data is saved in :"+System.getProperty("user.dir")+"/"+arg2+"/"+arg3+"/"+arg4+".zba");
                       }catch(IOException i) {




Edited by Zergod
Link to comment
Share on other sites

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.

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.

  • Create New...

Important Information

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