Skip to content

Commit

Permalink
Run configs are fucked, but i couldnt care less for now
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Jan 3, 2024
1 parent eb77064 commit 0fd0e34
Show file tree
Hide file tree
Showing 172 changed files with 180 additions and 5,470 deletions.
13 changes: 2 additions & 11 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ base {
archivesName = "${mod_name}-common-${minecraft_version}"
}

loom {
splitEnvironmentSourceSets()

mods {
"do_a_barrel_roll" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}
}

dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings "net.fabricmc:yarn:${yarn_version}:v2"
Expand All @@ -31,6 +20,8 @@ dependencies {
exclude group: "net.fabricmc"
}

compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}"))

implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:${project.mixin_squared_version}"))
}

Expand Down
23 changes: 0 additions & 23 deletions common/src/client/resources/do-a-barrel-roll.client.mixins.json

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 3 additions & 15 deletions common/src/main/java/nl/enjarai/doabarrelroll/DoABarrelRoll.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import nl.enjarai.cicada.api.conversation.ConversationManager;
import nl.enjarai.cicada.api.util.CicadaEntrypoint;
import nl.enjarai.cicada.api.util.JsonSource;
import nl.enjarai.cicada.api.util.ProperLogger;
import nl.enjarai.doabarrelroll.api.event.ServerEvents;
import nl.enjarai.doabarrelroll.config.ModConfigServer;
import nl.enjarai.doabarrelroll.net.HandshakeServer;
import nl.enjarai.doabarrelroll.net.ServerConfigHolder;
import nl.enjarai.doabarrelroll.platform.Services;
import org.slf4j.Logger;

public class DoABarrelRoll implements CicadaEntrypoint {
public class DoABarrelRoll {
public static final String MODID = "do_a_barrel_roll";
public static final Logger LOGGER = ProperLogger.getLogger(MODID);
public static final Logger LOGGER = Services.PLATFORM.getLogger();

public static ServerConfigHolder<ModConfigServer> CONFIG_HOLDER;
public static HandshakeServer HANDSHAKE_SERVER;
Expand All @@ -33,13 +30,4 @@ public static void init() {
ModConfigServer.CODEC, ModConfigServer.DEFAULT, ServerEvents::updateServerConfig);
HANDSHAKE_SERVER = new HandshakeServer(CONFIG_HOLDER, player -> !ModConfigServer.canModify(player));
}

@Override
public void registerConversations(ConversationManager conversationManager) {
conversationManager.registerSource(
JsonSource.fromUrl("https://raw.githubusercontent.com/enjarai/do-a-barrel-roll/1.20.2/dev/src/main/resources/cicada/do-a-barrel-roll/conversations.json")
.or(JsonSource.fromResource("cicada/do-a-barrel-roll/conversations.json")),
LOGGER::info
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.text.Text;
import nl.enjarai.doabarrelroll.DoABarrelRoll;
import nl.enjarai.doabarrelroll.net.SyncableConfig;
import nl.enjarai.doabarrelroll.net.ValidatableConfig;
import nl.enjarai.doabarrelroll.platform.Services;

public record ModConfigServer(boolean allowThrusting,
boolean forceEnabled,
Expand Down Expand Up @@ -37,11 +37,12 @@ public Text getSyncTimeoutMessage() {

@Override
public LimitedModConfigServer getLimited(ServerPlayNetworkHandler handler) {
return Permissions.check(handler.getPlayer(), DoABarrelRoll.MODID + ".ignore_config", 2) ? LimitedModConfigServer.OPERATOR : this;
return Services.PLATFORM.checkPermission(handler, DoABarrelRoll.MODID + ".ignore_config", 2)
? LimitedModConfigServer.OPERATOR : this;
}

public static boolean canModify(ServerPlayNetworkHandler net) {
return Permissions.check(net.getPlayer(), DoABarrelRoll.MODID + ".configure", 3);
return Services.PLATFORM.checkPermission(net, DoABarrelRoll.MODID + ".configure", 3);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package nl.enjarai.doabarrelroll.fabric;

import com.bawnorton.mixinsquared.api.MixinCanceller;
import com.bawnorton.mixinsquared.tools.MixinAnnotationReader;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import nl.enjarai.doabarrelroll.DoABarrelRoll;
import nl.enjarai.doabarrelroll.config.ModConfigServer;
import nl.enjarai.doabarrelroll.fabric.net.HandshakeServerFabric;

import java.util.List;

public class DoABarrelRollFabric implements ModInitializer, MixinCanceller {
public class DoABarrelRollFabric implements ModInitializer {
@Override
public void onInitialize() {
// Init server and client common code.
Expand All @@ -20,19 +14,4 @@ public void onInitialize() {
// both client and server to ensure everything works in LAN worlds as well.
HandshakeServerFabric.init();
}

@Override
public boolean shouldCancel(List<String> targetClassNames, String mixinClassName) {
if (mixinClassName.equals("com.anthonyhilyard.equipmentcompare.mixin.KeyMappingMixin") && MixinAnnotationReader.getPriority(mixinClassName) == 1000) {
DoABarrelRoll.LOGGER.warn("Equipment Compare detected, disabling their overly invasive keybinding mixin. Report any relevant issues to them.");
DoABarrelRoll.LOGGER.warn("If the author of Equipment Compare is reading this: see #31 on your github. Once the issue is resolved, you can set the priority of this mixin to anything other than 1000 to stop it being disabled.");
return true;
}
if (mixinClassName.equals("me.fzzyhmstrs.keybind_fix.mixins.KeybindingMixin") && MixinAnnotationReader.getPriority(mixinClassName) == 1000) {
DoABarrelRoll.LOGGER.warn("Keybind Fix detected, disabling their overly invasive keybinding mixin (Ironic, I know). Report any relevant issues to them.");
DoABarrelRoll.LOGGER.warn("If the author of Keybind Fix is reading this: please don't use unconditionally cancelled injects... try looking into MixinExtras! Once the issue is resolved, you can set the priority of this mixin to anything other than 1000 to stop it being disabled.");
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package nl.enjarai.doabarrelroll.fabric;

import com.bawnorton.mixinsquared.api.MixinCanceller;
import com.bawnorton.mixinsquared.tools.MixinAnnotationReader;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import nl.enjarai.doabarrelroll.DoABarrelRoll;
import nl.enjarai.doabarrelroll.DoABarrelRollClient;
import nl.enjarai.doabarrelroll.ModKeybindings;
import nl.enjarai.doabarrelroll.config.ModConfig;
import nl.enjarai.doabarrelroll.fabric.net.HandshakeClientFabric;
import nl.enjarai.doabarrelroll.util.StarFoxUtil;

import java.util.List;

public class DoABarrelRollFabricClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package nl.enjarai.doabarrelroll.platform.services;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import org.slf4j.Logger;

public interface PlatformHelper {
/**
Expand All @@ -10,6 +12,10 @@ public interface PlatformHelper {
*/
String getPlatformName();

Logger getLogger();

boolean checkPermission(ServerPlayNetworkHandler source, String permission, int defaultPermissionLevel);

/**
* Gets the name of the environment type as a string.
*
Expand Down
13 changes: 13 additions & 0 deletions common/src/main/resources/do_a_barrel_roll.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
"roll.entity.PlayerEntityMixin"
],
"client": [
"client.ClientPlayerEntityMixin",
"client.InGameHudMixin",
"client.LivingEntityMixin",
"client.PlayerEntityMixin",
"client.key.KeyBindingEntryMixin",
"client.key.KeyBindingMixin",
"client.roll.CameraMixin",
"client.roll.DebugHudMixin",
"client.roll.GameRendererMixin",
"client.roll.MouseMixin",
"client.roll.PlayerEntityRendererMixin",
"client.roll.entity.AbstractClientPlayerEntityMixin",
"client.roll.entity.ClientPlayerEntityMixin"
],
"server": [
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package nl.enjarai.doabarrelroll;

import nl.enjarai.cicada.api.conversation.ConversationManager;
import nl.enjarai.cicada.api.util.CicadaEntrypoint;
import nl.enjarai.cicada.api.util.JsonSource;

public class CicadaInitializer implements CicadaEntrypoint {
@Override
public void registerConversations(ConversationManager conversationManager) {
conversationManager.registerSource(
JsonSource.fromUrl("https://raw.githubusercontent.com/enjarai/do-a-barrel-roll/master/src/main/resources/cicada/do_a_barrel_roll/conversations.json")
.or(JsonSource.fromResource("cicada/do_a_barrel_roll/conversations.json")),
DoABarrelRoll.LOGGER::info
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package nl.enjarai.doabarrelroll;

import com.bawnorton.mixinsquared.api.MixinCanceller;
import com.bawnorton.mixinsquared.tools.MixinAnnotationReader;

import java.util.List;

public class DABRMixinCanceller implements MixinCanceller {
@Override
public boolean shouldCancel(List<String> targetClassNames, String mixinClassName) {
if (mixinClassName.equals("com.anthonyhilyard.equipmentcompare.mixin.KeyMappingMixin") && MixinAnnotationReader.getPriority(mixinClassName) == 1000) {
DoABarrelRoll.LOGGER.warn("Equipment Compare detected, disabling their overly invasive keybinding mixin. Report any relevant issues to them.");
DoABarrelRoll.LOGGER.warn("If the author of Equipment Compare is reading this: see #31 on your github. Once the issue is resolved, you can set the priority of this mixin to anything other than 1000 to stop it being disabled.");
return true;
}
// if (mixinClassName.equals("me.fzzyhmstrs.keybind_fix.mixins.KeybindingMixin") && MixinAnnotationReader.getPriority(mixinClassName) == 1000) {
// DoABarrelRoll.LOGGER.warn("Keybind Fix detected, disabling their overly invasive keybinding mixin (Ironic, I know). Report any relevant issues to them.");
// DoABarrelRoll.LOGGER.warn("If the author of Keybind Fix is reading this: please don't use unconditionally cancelled injects... try looking into MixinExtras! Once the issue is resolved, you can set the priority of this mixin to anything other than 1000 to stop it being disabled.");
// return true;
// }
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
package nl.enjarai.doabarrelroll.platform;

import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import nl.enjarai.cicada.api.util.ProperLogger;
import nl.enjarai.doabarrelroll.DoABarrelRoll;
import nl.enjarai.doabarrelroll.platform.services.PlatformHelper;
import org.slf4j.Logger;

public class FabricPlatformHelper implements PlatformHelper {
@Override
public String getPlatformName() {
return "Fabric";
}

@Override
public Logger getLogger() {
return ProperLogger.getLogger(DoABarrelRoll.MODID);
}

@Override
public boolean checkPermission(ServerPlayNetworkHandler source, String permission, int defaultPermissionLevel) {
return Permissions.check(source.getPlayer(), permission, defaultPermissionLevel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"minVersion": "0.8",
"package": "nl.enjarai.doabarrelroll.compat.cameraoverhaul.mixin",
"plugin": "nl.enjarai.doabarrelroll.compat.cameraoverhaul.CameraOverhaulPlugin",
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17",
"client": [
"CameraSystemMixin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"minVersion": "0.8",
"package": "nl.enjarai.doabarrelroll.compat.controlify.mixin",
"plugin": "nl.enjarai.doabarrelroll.compat.controlify.ControlifyPlugin",
"refmap": "${mod_id}.refmap.json",
"compatibilityLevel": "JAVA_17",
"client": [
"InGameInputHandlerMixin"
Expand Down
8 changes: 5 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@
"nl.enjarai.doabarrelroll.compat.modmenu.ModMenuIntegration"
],
"cicada": [
"nl.enjarai.doabarrelroll.DoABarrelRoll"
"nl.enjarai.doabarrelroll.CicadaInitializer"
],
"controlify": [
"nl.enjarai.doabarrelroll.compat.controlify.ControlifyCompat"
],
"mixinsquared": [
"nl.enjarai.doabarrelroll.fabric.DoABarrelRollFabric"
"nl.enjarai.doabarrelroll.DABRMixinCanceller"
]
},
"mixins": [
"${mod_id}.mixins.json",
"${mod_id}.fabric.mixins.json"
"${mod_id}.fabric.mixins.json",
"${mod_id}.compat.cameraoverhaul.mixins.json",
"${mod_id}.compat.controlify.mixins.json"
],
"accessWidener": "${mod_id}.accesswidener",

Expand Down
10 changes: 6 additions & 4 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ dependencies {

compileOnly project(":common")

modImplementation("dev.isxander.yacl:yet-another-config-lib-forge:${project.yacl_version}") {
exclude group: "net.fabricmc"
}
modImplementation("dev.isxander.yacl:yet-another-config-lib-forge:${project.yacl_version}")

implementation(include("com.github.bawnorton.mixinsquared:mixinsquared-forge:${project.mixin_squared_version}"))
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${project.mixin_extras_version}"))
implementation(include("io.github.llamalad7:mixinextras-forge:${project.mixin_extras_version}"))
}

tasks.withType(JavaCompile).configureEach {
Expand All @@ -73,6 +72,9 @@ tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}

// Prevent forge from shouting at me for not having javadocs everywhere
javadoc.enabled = false

processResources {
from project(":common").sourceSets.main.resources
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package nl.enjarai.doabarrelroll;

import net.minecraftforge.fml.common.Mod;

@Mod(DoABarrelRoll.MODID)
public class DoABarrelRollForge {
}
Loading

0 comments on commit 0fd0e34

Please sign in to comment.