From 39c3423d77723f8c619d5d99815fd831547dcad5 Mon Sep 17 00:00:00 2001 From: Dimaguy Date: Tue, 3 Sep 2024 13:06:27 +0100 Subject: [PATCH] Add Plethora Protection Move to 1.20.1 Rename to rcc-protection --- build.gradle | 68 ++++++++++++++++++- gradle.properties | 14 ++-- .../protection/RCCProtection.java | 2 +- .../protection/mixin/FlanCCProtect.java} | 22 +----- .../protection/mixin/FlanPlethoraProtect.java | 24 +++++++ src/main/resources/fabric.mod.json | 8 +-- src/main/resources/rcc-protection.mixins.json | 5 +- 7 files changed, 106 insertions(+), 37 deletions(-) rename src/main/java/{ct => cc/reconnected}/protection/RCCProtection.java (95%) rename src/main/java/{ct/protection/mixin/CCTurtleProtect.java => cc/reconnected/protection/mixin/FlanCCProtect.java} (53%) create mode 100644 src/main/java/cc/reconnected/protection/mixin/FlanPlethoraProtect.java diff --git a/build.gradle b/build.gradle index 3324aa2..2945fde 100644 --- a/build.gradle +++ b/build.gradle @@ -16,10 +16,71 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. + mavenLocal() maven { name = "Flemmli97" url "https://gitlab.com/api/v4/projects/21830712/packages/maven" } + mavenLocal { + content { + includeModule("io.sc3", "sc-library") + includeModule("io.sc3", "sc-peripherals") + } + } + + maven { + url = uri("https://repo.lem.sh/releases") + content { + includeGroup("io.sc3") + } + } + + maven { + name = "squiddev" + url "https://maven.squiddev.cc" + content { + includeGroup("cc.tweaked") + includeModule("org.squiddev", "Cobalt") + } + } + + maven { + name = "shedaniel" + url "https://maven.shedaniel.me" + // cloth-config + content { + includeGroup("me.shedaniel.cloth") + includeGroup("me.shedaniel.cloth.api") + } + } + + maven { + name = "terraformersmc" + url "https://maven.terraformersmc.com" + // Trinkets, mod-menu + content { + includeModule("dev.emi", "trinkets") + includeGroup("com.terraformersmc") + } + } + + maven { + name = "ladysnake" + url = "https://maven.ladysnake.org/releases" + // Cardinal Components API (dependency of Trinkets) + content { + includeGroup("dev.onyxstudios.cardinal-components-api") + } + } + + maven { + name = "sonatype" + url "https://oss.sonatype.org/content/repositories/snapshots" + // fabric-permissions-api (dependency of sc-goodies) + content { + includeModule("me.lucko", "fabric-permissions-api") + } + } } dependencies { @@ -36,6 +97,7 @@ dependencies { modRuntimeOnly("io.github.flemmli97:flan:${flan_mcversion}-${flan_version}-fabric") { transitive = false //Remove this if you want to have all those optional dependencies } + modImplementation("io.sc3:Plethora-Fabric:1.12.0") } processResources { @@ -47,7 +109,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - it.options.release = 21 + it.options.release = 17 } java { @@ -56,8 +118,8 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } jar { diff --git a/gradle.properties b/gradle.properties index 220447b..112f257 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,17 +4,17 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 -loader_version=0.16.2 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 +loader_version=0.16.3 # Mod Properties -mod_version=1.0.0 +mod_version=1.1.0 maven_group=cc.reconnected.protection archives_base_name=rcc-protection # Dependencies -fabric_version=0.102.1+1.21.1 +fabric_version=0.92.2+1.20.1 -flan_mcversion=1.21 -flan_version=1.10.7 \ No newline at end of file +flan_mcversion=1.20.1 +flan_version=1.10.8 \ No newline at end of file diff --git a/src/main/java/ct/protection/RCCProtection.java b/src/main/java/cc/reconnected/protection/RCCProtection.java similarity index 95% rename from src/main/java/ct/protection/RCCProtection.java rename to src/main/java/cc/reconnected/protection/RCCProtection.java index a2dfff7..916fab9 100644 --- a/src/main/java/ct/protection/RCCProtection.java +++ b/src/main/java/cc/reconnected/protection/RCCProtection.java @@ -1,4 +1,4 @@ -package ct.protection; +package cc.reconnected.protection; import net.fabricmc.api.ModInitializer; diff --git a/src/main/java/ct/protection/mixin/CCTurtleProtect.java b/src/main/java/cc/reconnected/protection/mixin/FlanCCProtect.java similarity index 53% rename from src/main/java/ct/protection/mixin/CCTurtleProtect.java rename to src/main/java/cc/reconnected/protection/mixin/FlanCCProtect.java index 379cc80..045ce91 100644 --- a/src/main/java/ct/protection/mixin/CCTurtleProtect.java +++ b/src/main/java/cc/reconnected/protection/mixin/FlanCCProtect.java @@ -1,12 +1,8 @@ -package ct.protection.mixin; +package cc.reconnected.protection.mixin; -import com.mojang.logging.LogUtils; import io.github.flemmli97.flan.api.ClaimHandler; -import io.github.flemmli97.flan.api.data.IPermissionContainer; -import io.github.flemmli97.flan.api.data.IPermissionStorage; import io.github.flemmli97.flan.api.permission.BuiltinPermission; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.MinecraftDedicatedServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -17,23 +13,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(MinecraftDedicatedServer.class) -public class CCTurtleProtect { +public class FlanCCProtect { @Inject(at = @At("HEAD"), method = "isSpawnProtected", cancellable = true) private void InjectSpawn(ServerWorld world, BlockPos pos, PlayerEntity player, CallbackInfoReturnable cir) { - //bad way of doing it, this uses non-api methods - MinecraftServer server = world.getServer(); - IPermissionStorage storage = ClaimHandler.getPermissionStorage(world); - IPermissionContainer claim = storage.getForPermissionCheck(pos); - LogUtils.getLogger().info(String.valueOf(player.getUuid())); - cir.setReturnValue(!claim.canInteract((ServerPlayerEntity) player, BuiltinPermission.BREAK, pos)); - /* - try { cir.setReturnValue(!ClaimHandler.canInteract((ServerPlayerEntity) player, pos, BuiltinPermission.BREAK)); - } catch (NullPointerException e) { - // Do nothing because this is likely just the claim not existing - cir.setReturnValue(false); - } - - */ } } \ No newline at end of file diff --git a/src/main/java/cc/reconnected/protection/mixin/FlanPlethoraProtect.java b/src/main/java/cc/reconnected/protection/mixin/FlanPlethoraProtect.java new file mode 100644 index 0000000..cdc95e3 --- /dev/null +++ b/src/main/java/cc/reconnected/protection/mixin/FlanPlethoraProtect.java @@ -0,0 +1,24 @@ +package cc.reconnected.protection.mixin; + +import io.github.flemmli97.flan.api.ClaimHandler; +import io.github.flemmli97.flan.api.permission.BuiltinPermission; +import io.sc3.plethora.gameplay.modules.laser.LaserEntity; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.network.ServerPlayerEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(LaserEntity.class) +public abstract class FlanPlethoraProtect { + @Shadow protected abstract PlayerEntity getShooterPlayer(); + + @Inject(at = @At("HEAD"), method = "canDamageEntity", cancellable = true) + private void InjectDamageEntity(Entity entity, CallbackInfoReturnable cir) { + if (entity.isPlayer()) cir.setReturnValue(!ClaimHandler.canInteract((ServerPlayerEntity) getShooterPlayer(), entity.getBlockPos(), BuiltinPermission.HURTPLAYER)); + else cir.setReturnValue(!ClaimHandler.canInteract((ServerPlayerEntity) getShooterPlayer(), entity.getBlockPos(), BuiltinPermission.HURTANIMAL)); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 31a5e94..f059f3d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,16 +16,16 @@ "environment": "*", "entrypoints": { "main": [ - "ct.protection.RCCProtection" + "cc.reconnected.protection.RCCProtection" ] }, "mixins": [ "rcc-protection.mixins.json" ], "depends": { - "fabricloader": ">=0.15.11", - "minecraft": "~1.21", - "java": ">=21", + "fabricloader": ">=0.16.3", + "minecraft": "~1.20.1", + "java": ">=17", "fabric-api": "*" }, "suggests": { diff --git a/src/main/resources/rcc-protection.mixins.json b/src/main/resources/rcc-protection.mixins.json index ed0cbb6..6b43e34 100644 --- a/src/main/resources/rcc-protection.mixins.json +++ b/src/main/resources/rcc-protection.mixins.json @@ -1,9 +1,10 @@ { "required": true, "package": "cc.reconnected.protection.mixin", - "compatibilityLevel": "JAVA_21", + "compatibilityLevel": "JAVA_17", "mixins": [ - "CCTurtleProtect" + "FlanCCProtect", + "FlanPlethoraProtect" ], "injectors": { "defaultRequire": 1