Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Bumpay

Members
  • Joined

  • Last visited

Everything posted by Bumpay

  1. 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?
  2. 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; } ?
  3. 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?
  4. 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?
  5. 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?
  6. 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?
  7. 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?
  8. How can I set a directory where the .nbt file wil be saved?
  9. 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]
  10. Yeah I do know that, I ´just thought you had an option for the gradle runServer command
  11. Then could you also tell me how to do that?
  12. Well now I do get this message. I guess that has something to do with the answer ow this Post.
  13. They replaced it with the getOrCreate function, right?
  14. 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; }
  15. 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?
  16. 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.
  17. 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?
  18. error: cannot find symbol PortWorldSavedData instance = (PortWorldSavedData) data.getOrCreate(PortWorldSavedData, NAME); ^
  19. 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
  20. So I could run runServer and runClient on the same time?
  21. 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.
  22. 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?
  23. 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:?]

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.