-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
754 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions
77
Multiworld-Fabric-1.20.1/src/main/java/me/isaiah/multiworld/fabric/FabricWorldCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package me.isaiah.multiworld.fabric; | ||
|
||
import me.isaiah.multiworld.ICreator; | ||
import me.isaiah.multiworld.MultiworldMod; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.Difficulty; | ||
import net.minecraft.world.WorldProperties; | ||
import net.minecraft.world.dimension.DimensionType; | ||
import net.minecraft.world.dimension.DimensionTypes; | ||
import net.minecraft.world.gen.chunk.ChunkGenerator; | ||
import xyz.nucleoid.fantasy.Fantasy; | ||
import xyz.nucleoid.fantasy.RuntimeWorldConfig; | ||
import xyz.nucleoid.fantasy.RuntimeWorldHandle; | ||
|
||
public class FabricWorldCreator implements ICreator { | ||
|
||
public static void init() { | ||
MultiworldMod.setICreator(new FabricWorldCreator()); | ||
} | ||
|
||
public ServerWorld create_world(String id, Identifier dim, ChunkGenerator gen, Difficulty dif, long seed) { | ||
RuntimeWorldConfig config = new RuntimeWorldConfig() | ||
.setDimensionType(dim_of(dim)) | ||
.setGenerator(gen) | ||
.setDifficulty(Difficulty.NORMAL) | ||
.setSeed(seed) | ||
.setShouldTickTime(true) | ||
; | ||
|
||
Fantasy fantasy = Fantasy.get(MultiworldMod.mc); | ||
RuntimeWorldHandle worldHandle = fantasy.getOrOpenPersistentWorld(new Identifier(id), config); | ||
return worldHandle.asWorld(); | ||
} | ||
|
||
private static RegistryKey<DimensionType> dim_of(Identifier id) { | ||
return RegistryKey.of(RegistryKeys.DIMENSION_TYPE, id); | ||
} | ||
|
||
public void delete_world(String id) { | ||
Fantasy fantasy = Fantasy.get(MultiworldMod.mc); | ||
RuntimeWorldHandle worldHandle = fantasy.getOrOpenPersistentWorld(new Identifier(id), null); | ||
worldHandle.delete(); | ||
} | ||
|
||
@Override | ||
public Text colored_literal(String txt, Formatting color) { | ||
try { | ||
return Text.of(txt).copy().formatted(color); | ||
} catch (Exception | IncompatibleClassChangeError e) { | ||
// Fallback | ||
return Text.of(txt); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean is_the_end(ServerWorld world) { | ||
return world.getDimensionKey() == DimensionTypes.THE_END; | ||
} | ||
|
||
@Override | ||
public BlockPos get_pos(double x, double y, double z) { | ||
return BlockPos.ofFloored(x, y, z); | ||
} | ||
|
||
@Override | ||
public BlockPos get_spawn(ServerWorld world) { | ||
WorldProperties prop = world.getLevelProperties(); | ||
return new BlockPos(prop.getSpawnX(), prop.getSpawnY(), prop.getSpawnZ()); | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.