Allow players to research even blocked research in creative

This commit is contained in:
DBotThePony 2022-09-22 19:58:48 +07:00
parent ba4122dd09
commit 5e95a97704
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 9 additions and 10 deletions

View File

@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.core.getKeyNullable
import ru.dbotthepony.mc.otm.registry.MRegistry
open class AndroidFeatureType<T : AndroidFeature> {
private val factory: (AndroidFeatureType<T>, MatteryPlayerCapability) -> T
protected val factory: (AndroidFeatureType<T>, MatteryPlayerCapability) -> T
constructor(factory: (MatteryPlayerCapability) -> T) : super() {
this.factory = { _, capability -> factory.invoke(capability) }

View File

@ -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<CompoundTag> {
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

View File

@ -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()
}