Skip to content

Commit

Permalink
chore[noci]: Improve island teleport, add client testmod
Browse files Browse the repository at this point in the history
  • Loading branch information
Awakened-Redstone committed Jul 7, 2024
1 parent 3d33da2 commit 7f1fae3
Show file tree
Hide file tree
Showing 29 changed files with 584 additions and 155 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
[//]: # (A skyblock mod with customizable islands, advanced island protection and support for expansion mods.)

[//]: # ()
[//]: # (NeoSkies provides it's own API and registries for other mods to add content and features and integrate with the island system.)

[//]: # ()
[//]: # (Each island have their own settings, those settings allow the owner to decide how other players can interact with the island, such as allowing interaction with doors, redstone, containers, etc.)

[//]: # ()
[//]: # (The mod uses the Common Economy API for currency, each island has it's account, that is shared between all island members.)

[//]: # ()
[//]: # (The mod is still in development and will change over time.)

[//]: # ()
[//]: # (This mod is a fork of Skylands, and the current island system and island templates are (mostly) from the original mod.)

[//]: # ()
[//]: # (Please provide feedback on the [discord server](https://discord.gg/MTqsjwMpN2), it helps a lot to continue developing the mod)

## About
<!-- modrinth_exclude.start -->
<img align="right" width="128" src="src/main/resources/assets/neoskies/icon.png">
Expand Down
85 changes: 66 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import java.io.File
import com.modrinth.minotaur.dependencies.ModDependency

//region Setup
plugins {
id("signing")
id("maven-publish")
id("fabric-loom") version "1.6-SNAPSHOT"
id("com.modrinth.minotaur") version "2.+"
}

val CHANGELOG: String =
if (file("CHANGELOG.md").exists()) {
file("CHANGELOG.md").readText()
} else {
"No changelog provided"
}
loom {
accessWidenerPath.set(file("src/main/resources/neoskies.accesswidener"))
splitEnvironmentSourceSets()

fun file(path: String): File {
return rootProject.file(path)
mods {
create("neoskies") {
sourceSet(sourceSets.main.get())
sourceSet(sourceSets.getByName("client"))
}
}
}

sourceSets {
Expand All @@ -30,37 +32,48 @@ sourceSets {
compileClasspath += sourceSets.main.get().compileClasspath
runtimeClasspath += sourceSets.main.get().runtimeClasspath
}

create("testmodClient") {
compileClasspath += main.get().compileClasspath
runtimeClasspath += main.get().runtimeClasspath

compileClasspath += sourceSets.getByName("client").compileClasspath
runtimeClasspath += sourceSets.getByName("client").runtimeClasspath

compileClasspath += sourceSets.getByName("testmod").compileClasspath
runtimeClasspath += sourceSets.getByName("testmod").runtimeClasspath
}
}

loom {
accessWidenerPath.set(file("src/main/resources/neoskies.accesswidener"))

runs {
create("datagenServer") {
server()
name = "Data Generation"
name("Data Generation")
vmArg("-Dfabric-api.datagen")
vmArg("-Dfabric-api.datagen.output-dir=${file("src/main/generated")}")
vmArg("-Dfabric-api.datagen.modid=neoskies")

//ideConfigGenerated = true
runDir = "build/datagen"
runDir("build/datagen")
ideConfigGenerated(true)
}

create("testmodServer") {
server()
name = "Testmod Server"
name("Testmod Server")
ideConfigGenerated(true)
source(sourceSets.getByName("testmod"))
}

create("testmodClient") {
client()
name = "Testmod Client"
name("Testmod Client")
runDir("run_client")
source(sourceSets.getByName("testmod"))
//TODO: Generate dev world
programArgs("--quickPlaySingleplayer \"world\"")
ideConfigGenerated(true)
source(sourceSets.getByName("testmodClient"))
}
}
}
//endregion

var archivesBaseName: String = property("archives_base_name").toString()
base {
Expand All @@ -76,6 +89,7 @@ repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.ladysnake.org/releases")
maven("https://maven.isxander.dev/releases")
maven("https://maven.deftu.dev/snapshots")
maven("https://jitpack.io")
maven {
name = "Modrinth"
Expand Down Expand Up @@ -122,11 +136,30 @@ dependencies {
include(api("blue.endless:jankson:${property("jankson_version")}") as Any)
//endregion

//region Client
"clientImplementation"("dev.deftu:dearimguimc-1.20.6-fabric:0.1.0") {
exclude(group = "net.fabricmc.fabric-api")
}
listOf(
"binding",
"lwjgl3",
"natives-windows",
"natives-linux",
"natives-macos"
).forEach { module ->
val version = "1.86.11"
implementation("io.github.spair:imgui-java-$module:$version") {
exclude(group = "org.lwjgl")
}
}
//endregion

// region Tests
"testmodImplementation"(sourceSets.main.get().output)
//endregion
}

//region Misc
tasks.processResources {
val map = mapOf(
"version" to version
Expand Down Expand Up @@ -156,7 +189,9 @@ tasks.jar {
rename { "${it}_${property("archivesBaseName")}" }
}
}
//endregion

//region Publishing
publishing {
repositories {
maven {
Expand All @@ -181,6 +216,17 @@ signing {
sign(publishing.publications["main"])
}

val CHANGELOG: String =
if (file("CHANGELOG.md").exists()) {
file("CHANGELOG.md").readText()
} else {
"No changelog provided"
}

fun file(path: String): File {
return rootProject.file(path)
}

modrinth {
val projectVersion: String = property("mod_version").toString()
val projectVersionNumber: List<String> = projectVersion.split(Regex("-"), 2)
Expand Down Expand Up @@ -212,3 +258,4 @@ modrinth {
ModDependency("placeholder-api", "embedded")
)
}
//endregion
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ mod_version=1.0.0-alpha.1
# Dependencies | Check these on https://fabricmc.net/develop
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
fabric_loader=0.15.10
fabric_loader=0.15.11

fabric_api=0.98.0+1.20.6
fabric_api=0.100.4+1.20.6

cardinal_components_api=6.0.0-beta.3

Expand Down
10 changes: 10 additions & 0 deletions src/client/java/com/awakenedredstone/neoskies/NeoSkiesClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.awakenedredstone.neoskies;

import net.fabricmc.api.ClientModInitializer;

public class NeoSkiesClient implements ClientModInitializer {
@Override
public void onInitializeClient() {

}
}
10 changes: 10 additions & 0 deletions src/client/resources/neoskies.client.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"required": true,
"package": "com.awakenedredstone.neoskies.mixin.client",
"compatibilityLevel": "JAVA_17",
"client": [
],
"injectors": {
"defaultRequire": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ private static void registerAdminCommands(CommandDispatcher<ServerCommandSource>
.putAny("current", integer)
.build()));
}, (timeTaken, scannedBlocks) -> {
Map.Entry<Identifier, Integer> i = scannedBlocks.entrySet().stream().findFirst().get();
source.sendMessage(Texts.of("Scanned %total% blocks in %time%", new MapBuilder.StringMap()
.putAny("total", UnitConvertions.readableNumber(scannedBlocks.values().stream().mapToInt(value -> value).sum()))
.putAny("time", UnitConvertions.formatTimings(timeTaken))
Expand All @@ -140,6 +139,7 @@ private static void registerAdminCommands(CommandDispatcher<ServerCommandSource>
})
)
).then(CommandManager.literal("list")
.requires(Permissions.require("neoskies.admin.island.list", 4))
.executes(context -> {
LinedStringBuilder builder = new LinedStringBuilder();
List<Island> islands = IslandLogic.getInstance().islands.stuck;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,38 @@
public class IslandDataCommand {
public static void init(CommandDispatcher<ServerCommandSource> dispatcher) {
registerAdmin(dispatcher, adminNode()
.then(literal("island-data")
.then(literal("find")
.requires(Permissions.require("neoskies.admin.island.data.find", 4))
.then(argument("player", StringArgumentType.word())
.suggests((context, builder) -> {
List<Island> islands = IslandLogic.getInstance().islands.stuck;
for (Island island : islands) {
builder.suggest(island.owner.name);
island.members.forEach(member -> {
builder.suggest(member.name);
});
}
return builder.buildFuture();
}).executes(context -> {
String playerName = StringArgumentType.getString(context, "player");
Optional<Island> islandOptional = NeoSkiesAPI.getIslandByPlayer(playerName);
return getIslandData(context.getSource(), islandOptional.orElse(null));
})
)
).then(literal("get")
.then(argument("id", StringArgumentType.word())
.suggests(CommandUtils.ISLAND_SUGGESTIONS)
.executes(context -> {
String islandId = StringArgumentType.getString(context, "id");
Optional<Island> islandOptional = NeoSkiesAPI.getIsland(UUID.fromString(islandId));
return getIslandData(context.getSource(), islandOptional.orElse(null));
})
)
)
.then(literal("island-data")
.requires(Permissions.require("neoskies.admin.island.data", 4))
.then(literal("find")
.requires(Permissions.require("neoskies.admin.island.data.find", 4))
.then(argument("player", StringArgumentType.word())
.suggests((context, builder) -> {
List<Island> islands = IslandLogic.getInstance().islands.stuck;
for (Island island : islands) {
builder.suggest(island.owner.name);
island.members.forEach(member -> {
builder.suggest(member.name);
});
}
return builder.buildFuture();
}).executes(context -> {
String playerName = StringArgumentType.getString(context, "player");
Optional<Island> islandOptional = NeoSkiesAPI.getIslandByPlayer(playerName);
return getIslandData(context.getSource(), islandOptional.orElse(null));
})
)
).then(literal("get")
.requires(Permissions.require("neoskies.admin.island.data.get", 4))
.then(argument("id", StringArgumentType.word())
.suggests(CommandUtils.ISLAND_SUGGESTIONS)
.executes(context -> {
String islandId = StringArgumentType.getString(context, "id");
Optional<Island> islandOptional = NeoSkiesAPI.getIsland(UUID.fromString(islandId));
return getIslandData(context.getSource(), islandOptional.orElse(null));
})
)
)
)
);
}

Expand All @@ -73,17 +75,17 @@ private static int getIslandData(ServerCommandSource source, @Nullable Island is
}

MapBuilder.StringMap map = new MapBuilder.StringMap()
.put("id", island.getIslandId().toString())
.put("owner", island.owner.name)
.put("members", members.toString())
.putAny("balance", island.getWallet().balance())
.putAny("has_nether", island.hasNether)
.putAny("has_end", island.hasEnd)
.putAny("spawn_pos", island.spawnPos)
.putAny("visit_pos", island.visitsPos)
.putAny("radius", island.radius)
.putAny("locked", island.locked)
.putAny("created", island.getCreated().toEpochMilli());
.put("id", island.getIslandId().toString())
.put("owner", island.owner.name)
.put("members", members.toString())
.putAny("balance", island.getWallet().balance())
.putAny("has_nether", island.hasNether)
.putAny("has_end", island.hasEnd)
.putAny("spawn_pos", island.spawnPos)
.putAny("visit_pos", island.visitsPos)
.putAny("radius", island.radius)
.putAny("locked", island.locked)
.putAny("created", island.getCreated().toEpochMilli());
source.sendFeedback(() -> Texts.of("message.neoskies.island_data", map.build()), false);
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.awakenedredstone.neoskies.command.island;

import com.awakenedredstone.neoskies.NeoSkies;
import com.awakenedredstone.neoskies.api.NeoSkiesAPI;
import com.awakenedredstone.neoskies.logic.Island;
import com.awakenedredstone.neoskies.logic.IslandLogic;
Expand Down Expand Up @@ -42,21 +41,4 @@ static void run(ServerPlayerEntity player) {
}
}, () -> player.sendMessage(Texts.prefixed("message.neoskies.home.no_island")));
}

static void run(ServerPlayerEntity visitor, String islandOwner) {
IslandLogic.getInstance().islands.getByPlayer(islandOwner).ifPresentOrElse(island -> {
if (visitor.getWorld().getRegistryKey().getValue().equals(NeoSkies.id(island.owner.uuid.toString())) && !IslandLogic.getConfig().allowVisitCurrentIsland) {
visitor.sendMessage(Texts.prefixed("message.neoskies.visit_home.fail", map -> map.put("owner", islandOwner)));
} else {
if (island.isMember(visitor)) {
visitor.sendMessage(Texts.prefixed("message.neoskies.visit_home.success", map -> map.put("owner", islandOwner)));
island.visitAsMember(visitor);
} else {
visitor.sendMessage(Texts.prefixed("message.neoskies.visit_home.not_member"));
}
}
}, () -> {
visitor.sendMessage(Texts.prefixed("message.neoskies.visit_home.no_island"));
});
}
}
Loading

0 comments on commit 7f1fae3

Please sign in to comment.