diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt index c4630ae21..1203326ed 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidFeatureType.kt @@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.core.getKeyNullable import ru.dbotthepony.mc.otm.registry.MRegistry open class AndroidFeatureType { - private val factory: (AndroidFeatureType, MatteryPlayerCapability) -> T + protected val factory: (AndroidFeatureType, MatteryPlayerCapability) -> T constructor(factory: (MatteryPlayerCapability) -> T) : super() { this.factory = { _, capability -> factory.invoke(capability) } @@ -40,4 +40,4 @@ open class AndroidFeatureType { open val displayId: String by lazy { registryName?.let { "android_feature.${it.namespace}.${it.path}" } ?: "android_feature.null.null" } -} \ No newline at end of file +} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt index c1c49004f..9e4a81881 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/android/AndroidResearch.kt @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import net.minecraft.ChatFormatting import net.minecraft.nbt.CompoundTag import net.minecraft.network.chat.Component +import net.minecraft.world.entity.player.Player import net.minecraft.world.item.ItemStack import net.minecraftforge.common.util.INBTSerializable import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability @@ -14,6 +15,8 @@ import java.io.DataInputStream import java.io.InputStream abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability: MatteryPlayerCapability) : INBTSerializable { + val ply: Player get() = capability.ply + val synchronizer = FieldSynchronizer() var isResearched by synchronizer.bool() @@ -67,7 +70,7 @@ abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability: return false } - if (!isPrerequisitesResearched || isAnyBlockerResearched) { + if (!isPrerequisitesResearched || (!ply.isCreative && isAnyBlockerResearched)) { return false } @@ -140,11 +143,7 @@ abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability: return false } - if (force) { - onResearched() - isResearched = true - return true - } else if (consumeResearchCost(false)) { + if (force || canResearch && consumeResearchCost(false)) { onResearched() isResearched = true return true diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index 6f63c1349..ec18d9c39 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -291,10 +291,10 @@ private class AndroidResearchButton( if (node.isResearched) { AndroidStationScreen.RESEARCHED.setSystemColor() - } else if (node.canResearch) { - AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor() } else if (node.isAnyBlockerResearchedIndirect) { AndroidStationScreen.ALREADY_BLOCKED.setSystemColor() + } else if (node.canResearch) { + AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor() } else { AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor() }