Posted April 19, 20178 yr In Forge Build 1.7.10-10.13.1.1219: Was introdused BlockSnapshot Quote 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-11.14.0.1296: Quote 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 Quote [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()){ directory.mkdirs(); } FileOutputStream fileOut = new FileOutputStream(System.getProperty("user.dir")+"/"+arg2+"/"+arg3+"/"+arg4+".zba"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(BA1); out.close(); fileOut.close(); System.out.printf("Serialized data is saved in :"+System.getProperty("user.dir")+"/"+arg2+"/"+arg3+"/"+arg4+".zba"); }catch(IOException i) { i.printStackTrace(); } https://takahikokawasaki.github.io/minecraft-resources/javadoc/forge/1.8-11.14.1.1320/serialized-form.html#net.minecraftforge.common.util.BlockSnapshot http://takahikokawasaki.github.io/minecraft-resources/javadoc/forge/1.7.10-10.13.2.1291//index.html?net/minecraftforge/common/util/BlockSnapshot.html http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.11.2-13.20.0.2282/forge-1.11.2-13.20.0.2282-changelog.txt Edited April 19, 20178 yr by Zergod
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.