Progress with loading custom dimensions

It begins loading but complains about having the same UUID (it's using the same conversion stuff)
This commit is contained in:
Norbi Peti 2020-09-08 22:30:09 +02:00
parent 14867a4b6d
commit 2d5b6e4492
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 49 additions and 8 deletions

View file

@ -32,6 +32,12 @@
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version> <version>1.16.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -11,10 +11,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.objenesis.Objenesis;
import org.objenesis.ObjenesisStd;
import org.spigotmc.SpigotWorldConfig;
import org.spigotmc.TickLimiter;
import java.util.*; import java.util.*;
@ -69,13 +65,13 @@ public class CustomDimensions extends JavaPlugin implements Listener {
if (resourcekey != WorldDimension.OVERWORLD) { if (resourcekey != WorldDimension.OVERWORLD) {
ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.L, resourcekey.a()); ResourceKey<World> resourcekey1 = ResourceKey.a(IRegistry.L, resourcekey.a());
DimensionManager dimensionmanager1 = entry.getValue().b(); DimensionManager dimensionmanager1 = entry.getValue().b();
ChunkGenerator chunkgenerator = entry.getValue().c(); ChunkGenerator chunkgenerator = entry.getValue().c(); //TODO: Shade
SecondaryWorldData secondaryworlddata = new SecondaryWorldData(saveData, iworlddataserver); var data = DimensionWorldData.create((WorldDataServer) iworlddataserver, "dream_dimension", EnumGamemode.CREATIVE);
WorldServer worldserver1 = new WorldServer(console, console.executorService, console.convertable, WorldServer worldserver1 = new WorldServer(console, console.executorService, console.convertable,
secondaryworlddata, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator, data, resourcekey1, dimensionmanager1, worldloadlistener, chunkgenerator,
false, //isDebugWorld false, //isDebugWorld
BiomeManager.a(mainWorld.getSeed()), //Biome seed BiomeManager.a(mainWorld.getSeed()), //Biome seed
ImmutableList.of(), false, org.bukkit.World.Environment.NORMAL, null, secondaryworlddata.getName()); ImmutableList.of(), false, org.bukkit.World.Environment.NORMAL, null);
((CraftWorld) mainWorld).getHandle().getWorldBorder().a(new IWorldBorderListener.a(worldserver1.getWorldBorder())); ((CraftWorld) mainWorld).getHandle().getWorldBorder().a(new IWorldBorderListener.a(worldserver1.getWorldBorder()));
console.worldServer.put(resourcekey1, worldserver1); console.worldServer.put(resourcekey1, worldserver1);

View file

@ -0,0 +1,39 @@
package buttondevteam.customdimensions;
import com.mojang.serialization.Lifecycle;
import net.minecraft.server.v1_16_R2.*;
import org.mockito.Answers;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
public class DimensionWorldData extends WorldDataServer {
public DimensionWorldData(WorldSettings worldsettings, GeneratorSettings generatorsettings, Lifecycle lifecycle) {
super(worldsettings, generatorsettings, lifecycle);
}
private String name;
private EnumGamemode gamemode;
@Override
public String getName() {
return name;
}
@Override
public EnumGamemode getGameType() {
return gamemode;
}
public static DimensionWorldData create(WorldDataServer data, String name, EnumGamemode gamemode) {
var mock = Mockito.mock(DimensionWorldData.class, invocation -> {
if (invocation.getMethod().getDeclaringClass() == DimensionWorldData.class)
return invocation.callRealMethod();
return invocation.getMethod().invoke(data, invocation.getArguments());
});
mock.name = name;
mock.gamemode = gamemode; //There are a couple things that come from SaveData, but that's the same
mock.b = data.b;
return mock;
}
}