diff --git a/build.gradle.kts b/build.gradle.kts index 21580e0..4354b39 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ import com.modrinth.minotaur.TaskModrinthSyncBody import net.darkhax.curseforgegradle.TaskPublishCurseForge -import org.spongepowered.asm.gradle.plugins.MixinExtension import java.time.LocalDateTime val mod_id: String by extra @@ -50,11 +49,6 @@ apply(plugin = "net.minecraftforge.gradle") apply(plugin = "kotlin") apply(plugin = "org.spongepowered.mixin") -configure { - add(sourceSets.main.get(), "${mod_id}.refmap.json") - config("${mod_id}.mixins.json") -} - val artifactGroup = "com.possible_triangle" base { archivesName.set("$mod_id-$mod_version") @@ -70,7 +64,6 @@ java { minecraft { mappings(mappings_channel, mc_version) - accessTransformer(file("src/main/resources/META-INF/accesstransformer.cfg")) runs { create("client") { @@ -100,7 +93,6 @@ minecraft { it.arg("-mixin.config=create.mixins.json") it.arg("-mixin.config=flywheel.mixins.json") - it.arg("-mixin.config=${mod_id}.mixins.json") it.property("mixin.env.remapRefMap", "true") it.property("mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg") @@ -172,12 +164,12 @@ dependencies { implementation(fg.deobf("curse.maven:create-328085:${create_version}")) implementation(fg.deobf("com.jozufozu.flywheel:flywheel-forge-${mc_version}:${flywheel_version}")) - implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")) if (!isCI) { runtimeOnly(fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")) // Only here to test jetpack+elytra combination behaviour + runtimeOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}")) runtimeOnly(fg.deobf("top.theillusivec4.caelus:caelus-forge:${caelus_version}")) runtimeOnly(fg.deobf("curse.maven:elytra-slot-317716:${elytra_slot_version}")) } @@ -207,7 +199,6 @@ tasks.withType { "Implementation-Version" to mod_version, "Implementation-Vendor" to "examplemodsareus", "Implementation-Timestamp" to LocalDateTime.now().toString(), - "MixinConfigs" to "${mod_id}.mixins.json", ) ) } diff --git a/gradle.properties b/gradle.properties index 5a3c69d..59594dd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ mod_name=Create Jetpack mod_author=possible_triangle jei_version=9.7.0.209 -flywheel_version=0.6.8.a-99 -create_version=4547147 +flywheel_version=0.6.9-101 +create_version=4625533 registrate_version=MC1.18.2-1.1.3 flightlib_version=0.1.0 diff --git a/src/main/java/com/possible_triangle/create_jetpack/mixins/.gitkeep b/src/main/java/com/possible_triangle/create_jetpack/mixins/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/java/com/possible_triangle/create_jetpack/mixins/BackTankUtilMixin.java b/src/main/java/com/possible_triangle/create_jetpack/mixins/BackTankUtilMixin.java deleted file mode 100644 index 65d0a71..0000000 --- a/src/main/java/com/possible_triangle/create_jetpack/mixins/BackTankUtilMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.possible_triangle.create_jetpack.mixins; - -import com.possible_triangle.create_jetpack.compat.CuriosCompat; -import com.simibubi.create.AllTags; -import com.simibubi.create.content.equipment.armor.BacktankUtil; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = BacktankUtil.class, remap = false) -public class BackTankUtilMixin { - - @Inject(at = @At("HEAD"), cancellable = true, method = "get(Lnet/minecraft/world/entity/LivingEntity;)Lnet/minecraft/world/item/ItemStack;") - private static void provideCuriosAir(LivingEntity entity, CallbackInfoReturnable cir) { - var stacks = CuriosCompat.INSTANCE.getCuriosStacksSafe(entity); - stacks.stream() - .filter(AllTags.AllItemTags.PRESSURIZED_AIR_SOURCES::matches) - .findFirst().ifPresent(cir::setReturnValue); - } - -} diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/client/ControlsDisplay.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/client/ControlsDisplay.kt index 1475179..bca7213 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/client/ControlsDisplay.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/client/ControlsDisplay.kt @@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiComponent import net.minecraft.network.chat.TranslatableComponent import net.minecraft.resources.ResourceLocation +import net.minecraft.world.item.ItemStack import net.minecraft.world.phys.Vec2 import net.minecraftforge.client.gui.ForgeIngameGui import net.minecraftforge.client.gui.IIngameOverlay @@ -114,7 +115,7 @@ object ControlsDisplay : IIngameOverlay { } val blink = player.level.gameTime % 20 < 5 - val airSource = BacktankUtil.get(player) + val airSource = BacktankUtil.getAllWithAir(player).firstOrNull() ?: ItemStack.EMPTY val maxAir = BacktankUtil.maxAir(airSource) val air = BacktankUtil.getAir(airSource) val barHeight = ceil(air / maxAir * 14).toInt() diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/compat/CuriosCompat.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/compat/CuriosCompat.kt deleted file mode 100644 index 1fda9ba..0000000 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/compat/CuriosCompat.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.possible_triangle.create_jetpack.compat - -import net.minecraft.world.entity.LivingEntity -import net.minecraft.world.item.ItemStack -import net.minecraftforge.fml.ModList -import top.theillusivec4.curios.api.CuriosCapability - -object CuriosCompat { - - fun getCuriosStacksSafe(entity: LivingEntity): List { - if (!ModList.get().isLoaded("curios")) return emptyList() - - val curios = entity.getCapability(CuriosCapability.INVENTORY) - return curios.map { - it.curios.values.flatMap { handler -> - val slots = 0 until handler.slots - slots.map { index -> - handler.stacks.getStackInSlot(index) - } - } - }.orElseGet(::emptyList) - } - - -} \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt index 0c4ff58..39cfa2d 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/config/ServerConfig.kt @@ -15,6 +15,7 @@ interface IServerConfig { val swimModifier: Double val elytraBoostEnabled: Boolean fun isAllowed(ench: Enchantment): Boolean + val curioSlots: Collection } data class SyncedConfig( @@ -26,6 +27,7 @@ data class SyncedConfig( override val hoverSpeed: Double, override val swimModifier: Double, override val elytraBoostEnabled: Boolean, + override val curioSlots: Collection, ) : IServerConfig { override fun isAllowed(ench: Enchantment) = true } @@ -64,4 +66,7 @@ class ServerConfig(builder: ForgeConfigSpec.Builder) : IServerConfig { val contained = enchantmentsList.get().map(::ResourceLocation).any { key == it } return contained != enchantmentsIsBlacklist.get() } + + private val curiosSlotList = builder.defineList("curios.allowed_slots", listOf("back")) { true } + override val curioSlots: List get() = curiosSlotList.get() } \ No newline at end of file diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt index 83985a1..f685f7c 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/config/SyncConfigMessage.kt @@ -20,6 +20,7 @@ class SyncConfigMessage (private val config: IServerConfig) { hoverSpeed = buf.readDouble(), swimModifier = buf.readDouble(), elytraBoostEnabled = buf.readBoolean(), + curioSlots = buf.readList(FriendlyByteBuf::readUtf) ) return SyncConfigMessage(config) } @@ -34,6 +35,7 @@ class SyncConfigMessage (private val config: IServerConfig) { buf.writeDouble(config.hoverSpeed) buf.writeDouble(config.swimModifier) buf.writeBoolean(config.elytraBoostEnabled) + buf.writeCollection(config.curioSlots, FriendlyByteBuf::writeUtf) } fun handle(context: Supplier) { diff --git a/src/main/kotlin/com/possible_triangle/create_jetpack/item/BrassJetpack.kt b/src/main/kotlin/com/possible_triangle/create_jetpack/item/BrassJetpack.kt index 1376a08..b4a5344 100644 --- a/src/main/kotlin/com/possible_triangle/create_jetpack/item/BrassJetpack.kt +++ b/src/main/kotlin/com/possible_triangle/create_jetpack/item/BrassJetpack.kt @@ -84,16 +84,14 @@ class BrassJetpack(properties: Properties, blockItem: ItemEntry source.slot == EquipmentSlot.CHEST - is CuriosSource -> source.slot == "back" + is CuriosSource -> Configs.SERVER.curioSlots.contains(source.slot) else -> false } } override fun isUsable(context: Context): Boolean { - val tank = BacktankUtil.get(context.entity) - if (tank.isEmpty) return false + val tank = BacktankUtil.getAllWithAir(context.entity).firstOrNull() ?: return false val air = BacktankUtil.getAir(tank) - if (air <= 0F) return false val cost = BacktankUtil.maxAirWithoutEnchants().toFloat() / usesPerTank(context) return air >= cost } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg deleted file mode 100644 index f49277f..0000000 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ /dev/null @@ -1,2 +0,0 @@ -public net.minecraft.server.network.ServerGamePacketListenerImpl f_9737_ # aboveGroundTickCount -public net.minecraft.client.renderer.entity.EntityRendererManager field_178637_m # playerRenderer \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index b08c9db..f7757ea 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -27,6 +27,6 @@ side = "BOTH" [[dependencies.${mod_id}]] modId = "create" mandatory = true -versionRange = "[0.5.1.a,)" +versionRange = "[0.5.1.c,)" ordering = "NONE" side = "BOTH" diff --git a/src/main/resources/create_jetpack.mixins.json b/src/main/resources/create_jetpack.mixins.json deleted file mode 100644 index 007c2c6..0000000 --- a/src/main/resources/create_jetpack.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "com.possible_triangle.create_jetpack.mixins", - "compatibilityLevel": "JAVA_8", - "minVersion": "0.8", - "refmap": "${mod_id}.refmap.json", - "mixins": [ - "BackTankUtilMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file