-
Notifications
You must be signed in to change notification settings - Fork 1
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
30 changed files
with
971 additions
and
9 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,137 @@ | ||
plugins { | ||
alias quilt.plugins.quilt.loom | ||
} | ||
|
||
project.configurations.runtimeClasspath { | ||
exclude(group: "loom_mappings_1_20_4_layered_hash_919249853_v2.net.fabricmc", module: "fabric-loader") | ||
} | ||
|
||
dependencies { | ||
minecraft libs.minecraft | ||
mappings(loom.layered { | ||
it.parchment("${libs.parchment.mappings.get()}@zip") | ||
it.officialMojangMappings() | ||
}) | ||
|
||
modImplementation fabric.fabric.loader | ||
modImplementation (fabric.fabric.api) { | ||
exclude group: "net.fabricmc", module: "fabric-loader" | ||
} | ||
|
||
compileOnly project(":Common") | ||
|
||
testmodImplementation sourceSets.main.output | ||
testmodCompileOnly project(path: ":Common", configuration: "testmod") | ||
|
||
modImplementation (libs.resourcefulconfig.fabric) { | ||
transitive = false | ||
} | ||
|
||
implementation libs.appdirs | ||
include libs.appdirs | ||
|
||
modCompileOnly ("${libs.emi.fabric.get()}:api") { | ||
transitive = false | ||
} | ||
modLocalRuntime (libs.emi.fabric) { | ||
transitive = false | ||
} | ||
|
||
modCompileOnly (fabric.modmenu) { | ||
transitive = false | ||
} | ||
modLocalRuntime (fabric.modmenu) { | ||
transitive = false | ||
} | ||
} | ||
|
||
loom { | ||
mods { | ||
"${mod_id}" { | ||
// Tell Loom about each source set used by your mod here. This ensures that your mod's classes are properly transformed by Loader. | ||
sourceSet("main") | ||
} | ||
|
||
"${mod_id}_testmod" { | ||
sourceSet("testmod") | ||
} | ||
} | ||
if (project(":Common").file("src/main/resources/${mod_id}.accesswidener").exists()) { | ||
accessWidenerPath.set(project(":Common").file("src/main/resources/${mod_id}.accesswidener")) | ||
} | ||
mixin { | ||
defaultRefmapName.set("${mod_id}.refmap.json") | ||
} | ||
|
||
runs { | ||
client { | ||
client() | ||
setConfigName("Fabric Client") | ||
ideConfigGenerated(true) | ||
runDir("run") | ||
|
||
if (project.hasProperty('mc_uuid')) { | ||
programArg("--uuid=${project.findProperty('mc_uuid')}") | ||
} | ||
|
||
if (project.hasProperty('mc_username')) { | ||
programArg("--username=${project.findProperty('mc_username')}") | ||
} | ||
|
||
if (project.hasProperty('mc_java_agent_path')) { | ||
vmArg("-javaagent:${project.findProperty('mc_java_agent_path')}") | ||
} | ||
} | ||
|
||
testmodClient { | ||
client() | ||
setConfigName("Fabric Testmod Client") | ||
ideConfigGenerated(true) | ||
runDir("run/testmod") | ||
source(sourceSets.testmod) | ||
|
||
if (project.hasProperty('mc_uuid')) { | ||
programArg("--uuid=${project.findProperty('mc_uuid')}") | ||
} | ||
|
||
if (project.hasProperty('mc_username')) { | ||
programArg("--username=${project.findProperty('mc_username')}") | ||
} | ||
|
||
if (project.hasProperty('mc_java_agent_path')) { | ||
vmArg("-javaagent:${project.findProperty('mc_java_agent_path')}") | ||
} | ||
} | ||
|
||
server { | ||
server() | ||
setConfigName("Fabric Server") | ||
ideConfigGenerated(true) | ||
runDir("run/server") | ||
} | ||
} | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
source(project(":Common").sourceSets.main.allJava) | ||
} | ||
|
||
tasks.named("compileTestmodJava", JavaCompile).configure { | ||
source(project(":Common").sourceSets.testmod.allJava) | ||
} | ||
|
||
tasks.named("javadoc", Javadoc).configure { | ||
source(project(":Common").sourceSets.main.allJava) | ||
} | ||
|
||
tasks.named("sourcesJar", Jar) { | ||
from(project(":Common").sourceSets.main.allSource) | ||
} | ||
|
||
processResources { | ||
from project(":Common").sourceSets.main.resources | ||
} | ||
|
||
processTestmodResources { | ||
from project(":Common").sourceSets.testmod.resources | ||
} |
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 @@ | ||
[versions] | ||
# The latest versions are available at https://fabricmc.net/develop | ||
|
||
fabric_loader = "0.15.11" | ||
fabric_api = "0.97.0+1.20.4" | ||
|
||
modmenu = "9.2.0-beta.2" | ||
|
||
[libraries] | ||
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" } | ||
|
||
fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_api" } | ||
|
||
modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" } | ||
|
||
# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". | ||
#[bundles] |
40 changes: 40 additions & 0 deletions
40
Fabric/src/main/java/dev/upcraft/sparkweave/fabric/client/command/ClientRootCommand.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 @@ | ||
package dev.upcraft.sparkweave.fabric.client.command; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import dev.upcraft.sparkweave.fabric.client.consent.ConsentScreen; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.List; | ||
|
||
public class ClientRootCommand { | ||
|
||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) { | ||
var root = ClientCommandManager.literal("sparkweave"); | ||
DebugMonitorCommand.register(root); | ||
|
||
//TODO remove debug | ||
root.then(ClientCommandManager.literal("test") | ||
.executes(ClientRootCommand::openConsentScreen)); | ||
|
||
dispatcher.register(root); | ||
} | ||
|
||
private static int openConsentScreen(CommandContext<FabricClientCommandSource> ctx) { | ||
List<ResourceLocation> permissions = List.of( | ||
new ResourceLocation("sparkweave", "test1"), | ||
new ResourceLocation("sparkweave", "test2"), | ||
new ResourceLocation("sparkweave", "test3"), | ||
new ResourceLocation("sparkweave", "test4"), | ||
new ResourceLocation("sparkweave", "test5") | ||
); | ||
System.out.println("opening screen"); | ||
ctx.getSource().getClient().setScreen(new ConsentScreen(permissions, true)); | ||
|
||
return Command.SINGLE_SUCCESS; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
Fabric/src/main/java/dev/upcraft/sparkweave/fabric/client/command/DebugMonitorCommand.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,14 @@ | ||
package dev.upcraft.sparkweave.fabric.client.command; | ||
|
||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; | ||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
|
||
public class DebugMonitorCommand { | ||
|
||
public static void register(LiteralArgumentBuilder<FabricClientCommandSource> root) { | ||
root.then(ClientCommandManager.literal("debug").then(ClientCommandManager.literal("monitor").executes(context -> { | ||
return 0; | ||
}))); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Fabric/src/main/java/dev/upcraft/sparkweave/fabric/client/consent/ConsentScreen.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 @@ | ||
package dev.upcraft.sparkweave.fabric.client.consent; | ||
|
||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.screens.Screen; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
import java.util.List; | ||
|
||
public class ConsentScreen extends Screen { | ||
|
||
private static final Component TITLE = Component.translatable("screen.sparkweave.consent.title"); | ||
private final List<ResourceLocation> permissions; | ||
private final boolean explicit; | ||
|
||
public ConsentScreen(List<ResourceLocation> permissions, boolean explicit) { | ||
super(TITLE); | ||
this.permissions = permissions; | ||
this.explicit = explicit; | ||
System.out.println("screen constructor"); | ||
} | ||
|
||
@Override | ||
protected void init() { | ||
super.init(); | ||
System.out.println("initializing screen"); | ||
} | ||
|
||
@Override | ||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) { | ||
this.renderBackground(guiGraphics, mouseX, mouseY, delta); | ||
super.render(guiGraphics, mouseX, mouseY, delta); | ||
System.out.println("rendering screen"); | ||
} | ||
|
||
@Override | ||
public boolean shouldCloseOnEsc() { | ||
return false; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/Client.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,70 @@ | ||
package dev.upcraft.sparkweave.fabric.entrypoint; | ||
|
||
import dev.upcraft.sparkweave.SparkweaveMod; | ||
import dev.upcraft.sparkweave.api.annotation.CalledByReflection; | ||
import dev.upcraft.sparkweave.api.client.event.*; | ||
import dev.upcraft.sparkweave.api.client.render.DebugRenderer; | ||
import dev.upcraft.sparkweave.api.entrypoint.ClientEntryPoint; | ||
import dev.upcraft.sparkweave.client.event.RegisterItemPropertiesEventImpl; | ||
import dev.upcraft.sparkweave.entrypoint.EntrypointHelper; | ||
import dev.upcraft.sparkweave.fabric.client.command.ClientRootCommand; | ||
import dev.upcraft.sparkweave.fabric.impl.registry.RegisterBlockEntityRenderersEventImpl; | ||
import dev.upcraft.sparkweave.fabric.impl.registry.RegisterEntityRenderersEventImpl; | ||
import dev.upcraft.sparkweave.fabric.impl.registry.RegisterMenuScreensEventImpl; | ||
import dev.upcraft.sparkweave.fabric.impl.registry.RegisterParticleFactoriesEventImpl; | ||
import dev.upcraft.sparkweave.validation.TranslationChecker; | ||
import net.fabricmc.api.ClientModInitializer; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; | ||
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; | ||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper; | ||
import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys; | ||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.PackType; | ||
import net.minecraft.server.packs.resources.ResourceManager; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
@Environment(EnvType.CLIENT) | ||
@CalledByReflection | ||
public class Client implements ClientModInitializer { | ||
@Override | ||
public void onInitializeClient() { | ||
WorldRenderEvents.AFTER_ENTITIES.register((context) -> DebugRenderer.render(context.matrixStack(), context.consumers(), context.camera())); | ||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, buildContext) -> { | ||
if(Minecraft.getInstance().hasSingleplayerServer()) { | ||
ClientRootCommand.register(dispatcher); | ||
} | ||
}); | ||
|
||
ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { | ||
private final ResourceLocation ID = new ResourceLocation(SparkweaveMod.MODID, "translation_checker"); | ||
@Override | ||
public ResourceLocation getFabricId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public void onResourceManagerReload(ResourceManager resourceManager) { | ||
TranslationChecker.validate(); | ||
} | ||
|
||
@Override | ||
public Collection<ResourceLocation> getFabricDependencies() { | ||
return Set.of(ResourceReloadListenerKeys.LANGUAGES); | ||
} | ||
}); | ||
|
||
EntrypointHelper.fireEntrypoints(ClientEntryPoint.class, ClientEntryPoint::onInitializeClient); | ||
|
||
RegisterBlockEntityRenderersEvent.EVENT.invoker().registerBlockEntityRenderers(new RegisterBlockEntityRenderersEventImpl()); | ||
RegisterEntityRenderersEvent.EVENT.invoker().registerEntityRenderers(new RegisterEntityRenderersEventImpl()); | ||
RegisterItemPropertiesEvent.EVENT.invoker().registerItemProperties(new RegisterItemPropertiesEventImpl()); | ||
RegisterMenuScreensEvent.EVENT.invoker().registerMenuScreens(new RegisterMenuScreensEventImpl()); | ||
RegisterParticleFactoriesEvent.EVENT.invoker().registerParticleFactories(new RegisterParticleFactoriesEventImpl()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/DedicatedServer.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,15 @@ | ||
package dev.upcraft.sparkweave.fabric.entrypoint; | ||
|
||
import dev.upcraft.sparkweave.api.annotation.CalledByReflection; | ||
import dev.upcraft.sparkweave.api.entrypoint.DedicatedServerEntryPoint; | ||
import dev.upcraft.sparkweave.entrypoint.EntrypointHelper; | ||
import net.fabricmc.api.DedicatedServerModInitializer; | ||
|
||
@CalledByReflection | ||
public class DedicatedServer implements DedicatedServerModInitializer { | ||
|
||
@Override | ||
public void onInitializeServer() { | ||
EntrypointHelper.fireEntrypoints(DedicatedServerEntryPoint.class, DedicatedServerEntryPoint::onInitializeServer); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Fabric/src/main/java/dev/upcraft/sparkweave/fabric/entrypoint/Main.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,43 @@ | ||
package dev.upcraft.sparkweave.fabric.entrypoint; | ||
|
||
import dev.upcraft.sparkweave.api.annotation.CalledByReflection; | ||
import dev.upcraft.sparkweave.api.entrypoint.MainEntryPoint; | ||
import dev.upcraft.sparkweave.api.event.CommandEvents; | ||
import dev.upcraft.sparkweave.api.platform.services.RegistryService; | ||
import dev.upcraft.sparkweave.api.registry.block.BlockItemProvider; | ||
import dev.upcraft.sparkweave.entrypoint.EntrypointHelper; | ||
import dev.upcraft.sparkweave.logging.SparkweaveLogging; | ||
import dev.upcraft.sparkweave.registry.SparkweaveCommandArgumentTypes; | ||
import dev.upcraft.sparkweave.scheduler.ScheduledTaskQueue; | ||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; | ||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; | ||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; | ||
import net.minecraft.core.Registry; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
|
||
@CalledByReflection | ||
public class Main implements ModInitializer { | ||
|
||
@Override | ||
public void onInitialize() { | ||
RegistryService.get().visitRegistry(BuiltInRegistries.BLOCK, (id, block) -> { | ||
if (block instanceof BlockItemProvider provider) { | ||
Registry.register(BuiltInRegistries.ITEM, id, provider.createItem()); | ||
} | ||
}); | ||
|
||
ServerLifecycleEvents.SERVER_STARTING.register(ScheduledTaskQueue::onServerStarting); | ||
ServerLifecycleEvents.SERVER_STOPPED.register(server -> ScheduledTaskQueue.onServerStopped()); | ||
ServerTickEvents.START_SERVER_TICK.register(server -> ScheduledTaskQueue.onServerTick()); | ||
|
||
CommandRegistrationCallback.EVENT.register((dispatcher, buildContext, environment) -> CommandEvents.REGISTER.invoker().registerCommands(dispatcher, buildContext, environment)); | ||
|
||
var service = RegistryService.get(); | ||
SparkweaveCommandArgumentTypes.ARGUMENT_TYPES.accept(service); | ||
|
||
EntrypointHelper.fireEntrypoints(MainEntryPoint.class, MainEntryPoint::onInitialize); | ||
|
||
SparkweaveLogging.getLogger().debug("System initialized!"); | ||
} | ||
} |
Oops, something went wrong.