-
Notifications
You must be signed in to change notification settings - Fork 27
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
41 changed files
with
2,106 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
plugins { | ||
id "java-library" | ||
id "maven-publish" | ||
id "com.github.johnrengelman.shadow" version "7.1.1" | ||
id "architectury-plugin" version "3.4-SNAPSHOT" | ||
id "dev.architectury.loom" version "1.6-SNAPSHOT" | ||
} | ||
|
||
architectury { | ||
platformSetupLoomIde() | ||
forge() | ||
} | ||
|
||
// archivesBaseName = rootProject.archives_base_name | ||
|
||
base { | ||
archivesBaseName = "Multiworld-Forge" | ||
version = "1.18.2" | ||
group = "me.isaiah.mods" | ||
} | ||
|
||
loom { | ||
forge { | ||
getMixinConfigs().empty() | ||
mixinConfig "dim.mixins.json" | ||
mixinConfig "fantasy.mixins.json" | ||
} | ||
} | ||
|
||
configurations { | ||
extraLibs | ||
common | ||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. | ||
compileClasspath.extendsFrom common | ||
runtimeClasspath.extendsFrom common | ||
developmentForge.extendsFrom common | ||
} | ||
|
||
dependencies { | ||
minecraft "com.mojang:minecraft:1.18.2" | ||
forge "net.minecraftforge:forge:${rootProject.forge_version_1_18_2}" | ||
mappings "net.fabricmc:yarn:1.18.2+build.2:v2" | ||
|
||
annotationProcessor 'com.pkware.jabel:jabel-javac-plugin:1.0.1-1' | ||
compileOnly 'com.pkware.jabel:jabel-javac-plugin:1.0.1-1' | ||
|
||
// Note: | ||
// Forge port of CyberPermissions currently not on maven. | ||
// | ||
common fileTree(dir: 'lib', include: 'permissions-forge-dev.jar') | ||
|
||
// modImplementation("me.lucko:fabric-permissions-api:0.2-SNAPSHOT") | ||
// modImplementation("net.fabricmc:fabric-loader:0.14.18") | ||
|
||
common(project(path: ":Multiworld-Common", configuration: "namedElements")) { transitive false } | ||
shadowCommon(project(path: ":Multiworld-Common", configuration: "transformProductionForge")) { transitive = false } | ||
|
||
// fantasy api | ||
//common(project(path: ":fantasy-forge", configuration: "namedElements")) { transitive false } | ||
//shadowCommon(project(path: ":fantasy-forge", configuration: "transformProductionForge")) { transitive = false } | ||
|
||
// common( project(path: ":fantasy-forge") ) | ||
// shadowCommon( project(path: ":fantasy-forge") ) | ||
} | ||
|
||
configure([tasks.compileJava]) { | ||
sourceCompatibility = 21 // for the IDE support | ||
options.release = 16 | ||
|
||
javaCompiler = javaToolchains.compilerFor { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
|
||
jar { | ||
sourceSets { | ||
main { | ||
java { | ||
exclude '**/fabric/*.java' | ||
exclude '**/fabric/*.class' | ||
} | ||
resources { | ||
exclude '**/fabric/*.java' | ||
exclude '**/fabric/*.class' | ||
} | ||
} | ||
} | ||
} | ||
|
||
processResources { | ||
inputs.property "version", project.version | ||
|
||
filesMatching("META-INF/mods.toml") { | ||
expand "version": project.version | ||
} | ||
|
||
exclude '**/fabric/*.class' | ||
exclude '**/fabric/*.java' | ||
} | ||
|
||
shadowJar { | ||
sourceSets { | ||
main { | ||
java { | ||
exclude '**/fabric/*.java' | ||
exclude '**/fabric/*.class' | ||
} | ||
} | ||
} | ||
|
||
exclude "fabric.mod.json" | ||
exclude '**/fabric/*.java' | ||
exclude '**/fabric/*.class' | ||
|
||
configurations = [project.configurations.shadowCommon] | ||
// classifier "dev-shadow" | ||
} | ||
|
||
remapJar { | ||
input.set shadowJar.archiveFile | ||
dependsOn shadowJar | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
exclude '**/fabric/*.java' | ||
exclude '**/fabric/*.class' | ||
} | ||
} | ||
} | ||
//lassifier null | ||
} | ||
|
||
tasks.named("build") { finalizedBy("copyReport2") } | ||
tasks.named("build") { finalizedBy("copyReport2") } | ||
|
||
tasks.register('copyReport2', Copy) { | ||
from remapJar | ||
into "${project.rootDir}/output" | ||
} | ||
|
||
/* | ||
sourcesJar { | ||
// def commonSources = project(":Multiworld-Common").sourcesJar | ||
// dependsOn commonSources | ||
// from commonSources.archiveFile.map { zipTree(it) } | ||
} | ||
*/ | ||
|
||
components.java { | ||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { | ||
skip() | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenForge(MavenPublication) { | ||
artifactId = rootProject.archives_base_name + "-" + project.name | ||
from components.java | ||
} | ||
} | ||
|
||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. | ||
repositories { | ||
// Add repositories to publish to here. | ||
} | ||
} |
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 @@ | ||
loom.platform=forge |
Binary file not shown.
17 changes: 17 additions & 0 deletions
17
Multiworld-Forge-1.18.2/src/main/java/me/isaiah/multiworld/forge/CyberHandler.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,17 @@ | ||
package me.isaiah.multiworld.forge; | ||
|
||
import cyber.permissions.v1.CyberPermissions; | ||
import cyber.permissions.v1.Permission; | ||
import cyber.permissions.v1.PermissionDefaults; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
|
||
/** | ||
*/ | ||
public class CyberHandler { | ||
|
||
public static boolean hasPermission(ServerPlayerEntity plr, String perm) { | ||
Permission p = new Permission(perm, "A permission for Multiworld", PermissionDefaults.OPERATOR); | ||
return plr.hasPermissionLevel(2) || CyberPermissions.getPlayerPermissible(plr).hasPermission(p); | ||
} | ||
|
||
} |
106 changes: 106 additions & 0 deletions
106
Multiworld-Forge-1.18.2/src/main/java/me/isaiah/multiworld/forge/ForgeWorldCreator.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,106 @@ | ||
package me.isaiah.multiworld.forge; | ||
|
||
import java.util.HashMap; | ||
|
||
import dimapi.FabricDimensionInternals; | ||
import me.isaiah.multiworld.ICreator; | ||
import me.isaiah.multiworld.MultiworldMod; | ||
|
||
import net.minecraft.server.network.ServerPlayerEntity; | ||
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.util.math.Vec3d; | ||
import net.minecraft.util.registry.Registry; | ||
import net.minecraft.util.registry.RegistryKey; | ||
import net.minecraft.world.Difficulty; | ||
import net.minecraft.world.TeleportTarget; | ||
import net.minecraft.world.WorldProperties; | ||
import net.minecraft.world.dimension.DimensionType; | ||
|
||
import net.minecraft.world.gen.chunk.ChunkGenerator; | ||
import xyz.nucleoid.fantasy.Fantasy; | ||
import xyz.nucleoid.fantasy.RuntimeWorldConfig; | ||
import xyz.nucleoid.fantasy.RuntimeWorldHandle; | ||
|
||
public class ForgeWorldCreator implements ICreator { | ||
|
||
public HashMap<String, RuntimeWorldConfig> worldConfigs; | ||
|
||
public ForgeWorldCreator() { | ||
this.worldConfigs = new HashMap<>(); | ||
} | ||
|
||
public static void init() { | ||
MultiworldMod.setICreator(new ForgeWorldCreator()); | ||
} | ||
|
||
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(dif) | ||
.setSeed(seed) | ||
.setShouldTickTime(true) | ||
; | ||
|
||
Fantasy fantasy = Fantasy.get(MultiworldMod.mc); | ||
RuntimeWorldHandle worldHandle = fantasy.getOrOpenPersistentWorld(new Identifier(id), config); | ||
this.worldConfigs.put(id, config); | ||
return worldHandle.asWorld(); | ||
} | ||
|
||
@Override | ||
public void set_difficulty(String id, Difficulty dif) { | ||
this.worldConfigs.get(id).setDifficulty(dif); | ||
} | ||
|
||
private static RegistryKey<DimensionType> dim_of(Identifier id) { | ||
return RegistryKey.of(Registry.DIMENSION_TYPE_KEY, 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) { | ||
if (!world.getDimension().isBedWorking() && !world.getDimension().hasCeiling()) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public BlockPos get_pos(double x, double y, double z) { | ||
return new BlockPos(x, y, z); | ||
} | ||
|
||
@Override | ||
public BlockPos get_spawn(ServerWorld world) { | ||
WorldProperties prop = world.getLevelProperties(); | ||
return new BlockPos(prop.getSpawnX(), prop.getSpawnY(), prop.getSpawnZ()); | ||
} | ||
|
||
@Override | ||
public void teleleport(ServerPlayerEntity player, ServerWorld world, double x, double y, double z) { | ||
TeleportTarget target = new TeleportTarget(new Vec3d(x, y, z), new Vec3d(1, 1, 1), 0f, 0f); | ||
FabricDimensionInternals.changeDimension(player, world, target); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
Multiworld-Forge-1.18.2/src/main/java/me/isaiah/multiworld/forge/MultiworldModForge.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,40 @@ | ||
/** | ||
* Multiworld Mod | ||
*/ | ||
package me.isaiah.multiworld.forge; | ||
|
||
import me.isaiah.multiworld.MultiworldMod; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.event.RegisterCommandsEvent; | ||
import net.minecraftforge.event.server.ServerStartingEvent; | ||
import net.minecraftforge.eventbus.api.SubscribeEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; | ||
|
||
@Mod(MultiworldMod.MOD_ID) | ||
public class MultiworldModForge { | ||
|
||
public MultiworldModForge() { | ||
// Register ourselves for server and other game events we are interested in | ||
MinecraftForge.EVENT_BUS.register(this); | ||
new xyz.nucleoid.fantasy.FantasyInitializer(); | ||
ForgeWorldCreator.init(); | ||
PermForge.init(); | ||
MultiworldMod.init(); | ||
} | ||
|
||
@SubscribeEvent | ||
public void commonSetup(FMLCommonSetupEvent event) { | ||
} | ||
|
||
@SubscribeEvent | ||
public void onServerStarting(ServerStartingEvent event) { | ||
MultiworldMod.on_server_started(event.getServer()); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onCommandsRegister(RegisterCommandsEvent event) { | ||
MultiworldMod.register_commands(event.getDispatcher()); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
Multiworld-Forge-1.18.2/src/main/java/me/isaiah/multiworld/forge/PermForge.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,26 @@ | ||
package me.isaiah.multiworld.forge; | ||
|
||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import me.isaiah.multiworld.perm.Perm; | ||
import net.minecraftforge.fml.OptionalMod; | ||
|
||
public class PermForge extends Perm { | ||
|
||
public static void init() { | ||
Perm.setPerm(new PermForge()); | ||
} | ||
|
||
@Override | ||
public boolean has_impl(ServerPlayerEntity plr, String perm) { | ||
boolean cyber = OptionalMod.of("cyberpermissions").isPresent(); | ||
|
||
boolean res = plr.hasPermissionLevel(2); | ||
|
||
if (cyber) { | ||
if (CyberHandler.hasPermission(plr, perm)) res = true; | ||
} | ||
|
||
return res; | ||
} | ||
|
||
} |
Oops, something went wrong.