Allow players to research even blocked research in creative
This commit is contained in:
parent
ba4122dd09
commit
5e95a97704
@ -9,7 +9,7 @@ import ru.dbotthepony.mc.otm.core.getKeyNullable
|
|||||||
import ru.dbotthepony.mc.otm.registry.MRegistry
|
import ru.dbotthepony.mc.otm.registry.MRegistry
|
||||||
|
|
||||||
open class AndroidFeatureType<T : AndroidFeature> {
|
open class AndroidFeatureType<T : AndroidFeature> {
|
||||||
private val factory: (AndroidFeatureType<T>, MatteryPlayerCapability) -> T
|
protected val factory: (AndroidFeatureType<T>, MatteryPlayerCapability) -> T
|
||||||
|
|
||||||
constructor(factory: (MatteryPlayerCapability) -> T) : super() {
|
constructor(factory: (MatteryPlayerCapability) -> T) : super() {
|
||||||
this.factory = { _, capability -> factory.invoke(capability) }
|
this.factory = { _, capability -> factory.invoke(capability) }
|
||||||
|
@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream
|
|||||||
import net.minecraft.ChatFormatting
|
import net.minecraft.ChatFormatting
|
||||||
import net.minecraft.nbt.CompoundTag
|
import net.minecraft.nbt.CompoundTag
|
||||||
import net.minecraft.network.chat.Component
|
import net.minecraft.network.chat.Component
|
||||||
|
import net.minecraft.world.entity.player.Player
|
||||||
import net.minecraft.world.item.ItemStack
|
import net.minecraft.world.item.ItemStack
|
||||||
import net.minecraftforge.common.util.INBTSerializable
|
import net.minecraftforge.common.util.INBTSerializable
|
||||||
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
import ru.dbotthepony.mc.otm.capability.MatteryPlayerCapability
|
||||||
@ -14,6 +15,8 @@ import java.io.DataInputStream
|
|||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability: MatteryPlayerCapability) : INBTSerializable<CompoundTag> {
|
abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability: MatteryPlayerCapability) : INBTSerializable<CompoundTag> {
|
||||||
|
val ply: Player get() = capability.ply
|
||||||
|
|
||||||
val synchronizer = FieldSynchronizer()
|
val synchronizer = FieldSynchronizer()
|
||||||
|
|
||||||
var isResearched by synchronizer.bool()
|
var isResearched by synchronizer.bool()
|
||||||
@ -67,7 +70,7 @@ abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability:
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPrerequisitesResearched || isAnyBlockerResearched) {
|
if (!isPrerequisitesResearched || (!ply.isCreative && isAnyBlockerResearched)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,11 +143,7 @@ abstract class AndroidResearch(val type: AndroidResearchType<*>, val capability:
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force) {
|
if (force || canResearch && consumeResearchCost(false)) {
|
||||||
onResearched()
|
|
||||||
isResearched = true
|
|
||||||
return true
|
|
||||||
} else if (consumeResearchCost(false)) {
|
|
||||||
onResearched()
|
onResearched()
|
||||||
isResearched = true
|
isResearched = true
|
||||||
return true
|
return true
|
||||||
|
@ -291,10 +291,10 @@ private class AndroidResearchButton(
|
|||||||
|
|
||||||
if (node.isResearched) {
|
if (node.isResearched) {
|
||||||
AndroidStationScreen.RESEARCHED.setSystemColor()
|
AndroidStationScreen.RESEARCHED.setSystemColor()
|
||||||
} else if (node.canResearch) {
|
|
||||||
AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor()
|
|
||||||
} else if (node.isAnyBlockerResearchedIndirect) {
|
} else if (node.isAnyBlockerResearchedIndirect) {
|
||||||
AndroidStationScreen.ALREADY_BLOCKED.setSystemColor()
|
AndroidStationScreen.ALREADY_BLOCKED.setSystemColor()
|
||||||
|
} else if (node.canResearch) {
|
||||||
|
AndroidStationScreen.CAN_BE_RESEARCHED.setSystemColor()
|
||||||
} else {
|
} else {
|
||||||
AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor()
|
AndroidStationScreen.CAN_NOT_BE_RESEARCHED.setSystemColor()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user