Everything posted by Bumpay
-
Save a list of objects as .json on server side
So if I now run the write function, the data will be saved in the Server directory. And for the read function I just need to do the sam vice versa?
-
Save a list of objects as .json on server side
So more like this: @Override public CompoundNBT write(CompoundNBT compound) { //NBT_Compound ListNBT portsListNBT = new ListNBT(); compound.put("ports", portsListNBT); //-NBT_List "ports" for (Port p:portList){ CompoundNBT portNBT = new CompoundNBT(); //--NBT_Compound "a single port" portNBT.putLong("uuidL", p.getOwner().getUniqueID().getLeastSignificantBits()); //---NBT_Long "uuidL" portNBT.putLong("uuidM", p.getOwner().getUniqueID().getMostSignificantBits()); //---NBT_Long "uuidM" portNBT.putBoolean("isOpen", p.isOpen()); //---NBT_Bool "isOpen" portNBT.putString("name", p.getName()); //---NBT_String "name" portNBT.putInt("x", p.getXCoordinate()); //---NBT_Int "x" portNBT.putInt("y", p.getZCoordinate()); //---NBT_Int "y" ListNBT docksListNBT = new ListNBT(); portNBT.put("docks", docksListNBT); //---NBT_List "docks" for (Dock d:p.getDocks()) { CompoundNBT dockNBT = new CompoundNBT(); //----NBT_Compound "a single dock" dockNBT.putBoolean("isHomeDock", d.isHomeDock); //----NBT_Bool "isHomeDock" dockNBT.putBoolean("isUsed", d.isUsed); //----NBT_Bool "isUsed" dockNBT.putIntArray("dockArea", d.getDockArea().toNBTTagIntArray().getIntArray()); //----NBT_Int[] "dockArea" docksListNBT.add(dockNBT); } portsListNBT.add(portNBT); } return compound; } ?
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
So how do I do it if I run the server with the gradle command? Do I have a server config in my workspace folder?
-
Save a list of objects as .json on server side
Alright thanks. I've done it as follows: @Override public CompoundNBT write(CompoundNBT compound) { ListNBT portsListNBT = new ListNBT(); CompoundNBT portNBT = new CompoundNBT(); int i = 0; for (Port p:portList){ portNBT.putLong("uuidL", p.getOwner().getUniqueID().getLeastSignificantBits()); portNBT.putLong("uuidM", p.getOwner().getUniqueID().getMostSignificantBits()); portNBT.putBoolean("isOpen", p.isOpen()); portNBT.putString("name", p.getName()); portNBT.putInt("x", p.getXCoordinate()); portNBT.putInt("y", p.getZCoordinate()); ListNBT docksListNBT = new ListNBT(); CompoundNBT dockNBT = new CompoundNBT(); for (Dock d:p.getDocks()) { dockNBT.putBoolean("isHomeDock", d.isHomeDock); dockNBT.putBoolean("isUsed", d.isUsed); dockNBT.putIntArray("dockArea", d.getDockArea().toNBTTagIntArray().getIntArray()); docksListNBT.add(dockNBT); } portsListNBT.add(portNBT); } return compound; } Now how do I get a ListNBT into a compound, or do I now need to save a ListNBT and not the compound?
-
Save a list of objects as .json on server side
My Port.class structure looks like this: public class Port { private ServerPlayerEntity owner; private boolean isOpen = false; private String name; private int xCoordinate; private int zCoordinate; private List<Dock> docks; } And my thoughts brang me to this: @Override public CompoundNBT write(CompoundNBT compound) { for (Port p:portList) { compound.putLong("uuidL", p.getOwner().getDisplayNameAndUUID()); compound.putBoolean("isOpen", p.isOpen()); compound.putString("name", p.getName()); compound.putInt("x", p.getXCoordinate()); compound.putInt("y", p.getZCoordinate()); //list of Docks } return compound; } Is this right? And how do I get the UUID of a player? Also my Port has a List of Docks, how do I write this in the compound? Another foreach?
-
Save a list of objects as .json on server side
Sorry if I take long to get what you are trying me to do, but it is my first time working on minecraft or forge. So to safe my List<Port> I have to write what? in the WorldSavedData#write function?
-
Save a list of objects as .json on server side
And how do I create the structure in code? I saw something like the CompoundNBT class, is this the one? And if, is it done by declaring a CompoundNBT object in my WorldSavedData class and simply so compund.put... for every attribute that my object has? Can you maybe give an example on a very simple Object so I can relate?
-
Save a list of objects as .json on server side
How can I set a directory where the .nbt file wil be saved?
-
Save a list of objects as .json on server side
So now I can save my list of objects with the WorldSavedData#write command? Do I need to have a structure like this for my nbt? Data [NBT_Compound] Ports [NBT_List] A single Port [NBT_Compound] Name [NBT_String] Owner [NBT_List] A single player [NBT_Compound] L [NBT_Long] M [NBT_Long] Docks [NBT_List] A single dock [NBT_Compound] isUsed [NBT_Byte] isHome [NBT_Byte] x1 [NBT_Double] y1 [NBT_Double] z1 [NBT_Double] x2 [NBT_Double] y2 [NBT_Double] z2 [NBT_Double] X [NBT_Double] Z [NBT_Double]
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
Yeah I do know that, I ´just thought you had an option for the gradle runServer command
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
Then could you also tell me how to do that?
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
Thanks man, that helped alot 😀
-
Save a list of objects as .json on server side
They replaced it with the getOrCreate function, right?
-
Save a list of objects as .json on server side
Is this the right way of doing it? public static PortWorldSavedData get(ServerWorld world) { DimensionSavedDataManager data = world.getSavedData(); PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(() -> {return new PortWorldSavedData();}, NAME); if(instance == null) { instance = new PortWorldSavedData(); } return instance; }
-
Save a list of objects as .json on server side
This is how it looks now: package com.bumpay.travelsimplified.trasim.port; import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.DimensionSavedDataManager; import net.minecraft.world.storage.WorldSavedData; import java.util.function.Supplier; public class PortWorldSavedData extends WorldSavedData { private static final String NAME = "TraSim_PortData"; public PortWorldSavedData() { super(NAME); } public PortWorldSavedData(String name) { super(name); } @Override public void read(CompoundNBT nbt) { } @Override public CompoundNBT write(CompoundNBT compound) { return null; } public static PortWorldSavedData get(ServerWorld world) { DimensionSavedDataManager data = world.getSavedData(); PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(() -> {return null;}, NAME); if(instance == null) { instance = new PortWorldSavedData(); } return instance; } } But as described in the Docs, I guess I shouldn't just pass a null pointer in the getOrCreate function. I also tried PortWorldSavedData.class there like in the Docs but it sais it is a Supplier<T> needed. public static PortWorldSavedData get(ServerWorld world) { DimensionSavedDataManager data = world.getSavedData(); PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(PortWorldSavedData.class, NAME); if(instance == null) { instance = new PortWorldSavedData(); } return instance; } So I also tried new Supplier<PortWorldSavedData> which added the abstract method within the parameter-section public static PortWorldSavedData get(ServerWorld world) { DimensionSavedDataManager data = world.getSavedData(); PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(new Supplier<PortWorldSavedData>() { @Override public PortWorldSavedData get() { return null; } }, NAME); if(instance == null) { instance = new PortWorldSavedData(); } return instance; } And even though I don't actually know, if this is the right way to do it scince Forge updated but didn't update the Docs. Can someone confirm that I am not complete off the track?
-
Save a list of objects as .json on server side
I do know coding in Java. The only things I am struggeling with are the classes from minecraft as I don't know which are there and how to use them. Yeah I changed it, I did not recognize, that I tried something different there and forgot to type it back.
-
Save a list of objects as .json on server side
Can I just set the suplier to null, because it will create it then with the getOrCreate method? Or is this not how to use it?
-
Save a list of objects as .json on server side
error: cannot find symbol PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(PortWorldSavedData, NAME); ^
-
Save a list of objects as .json on server side
package com.bumpay.travelsimplified.trasim.port; import net.minecraft.nbt.CompoundNBT; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.DimensionSavedDataManager; import net.minecraft.world.storage.WorldSavedData; public class PortWorldSavedData extends WorldSavedData { private static final String NAME = "TraSim_PortData"; public PortWorldSavedData() { super(NAME); } public PortWorldSavedData(String name) { super(name); } @Override public void read(CompoundNBT nbt) { } @Override public CompoundNBT write(CompoundNBT compound) { return null; } public static PortWorldSavedData get(ServerWorld world) { DimensionSavedDataManager data = world.getSavedData(); PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(PortWorldSavedData), NAME); } } And I do get an error on PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(PortWorldSavedData), NAME); I tried to do it like in the Decumentations of Forge
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
So I could run runServer and runClient on the same time?
-
Save a list of objects as .json on server side
I want to store a list of Objects on the serverside. Basically what I am trying to do is to store all created Shipports as a List on the Serverside. But it should be able to add/delete and get ports from/to the list. You showed me the WorldSavedData method but I couldn't find any goo example of how to use it so I searched for different methods. I am not bad at programming but it is hard to figure out how minecraft work with different things.
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
To join my server I do need the mod right? And do I need to Export my mod first or is it already saved somewhere?
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
Working now! Found it.
-
Launch Minecraft Server within IntelliJ with the runServer Command not working
Found it, but it takes forever to upload somehow. So i checked it and found the line: [30Sep2020 20:34:06.226] [main/FATAL] [net.minecraft.server.MinecraftServer/]: Failed to start the minecraft server joptsimple.UnrecognizedOptionException: username is not a recognized option at joptsimple.OptionException.unrecognizedOption(OptionException.java:108) ~[jopt-simple-5.0.4.jar:?] at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510) ~[jopt-simple-5.0.4.jar:?] at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56) ~[jopt-simple-5.0.4.jar:?] at joptsimple.OptionParser.parse(OptionParser.java:396) ~[jopt-simple-5.0.4.jar:?] at net.minecraft.server.MinecraftServer.main(MinecraftServer.java:945) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_261] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_261] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_261] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_261] at net.minecraftforge.userdev.FMLUserdevServerLaunchProvider.lambda$launchService$0(FMLUserdevServerLaunchProvider.java:54) ~[forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?] at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.2.jar:?] at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.2.jar:?] at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.2.0_mapped_snapshot_20200514-1.15.1-recomp.jar:?]
IPS spam blocked by CleanTalk.