• Posts

    • 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; }  
    • 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?
    • Don't create the containmentField in setPos. Initialize it on demand in tick.
    • 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.    
  • Topics

  • Who's Online (See full list)