Skip to content

Commit

Permalink
Complete Insurance Mechanism
Browse files Browse the repository at this point in the history
- Added Active Transformer Explosion Core
- Added Insurance Counter and its things
- Fixed localization problems
  • Loading branch information
Taskeren committed Aug 22, 2024
1 parent b3437f6 commit c5561aa
Show file tree
Hide file tree
Showing 23 changed files with 1,046 additions and 118 deletions.
30 changes: 21 additions & 9 deletions addon.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,11 @@ private static String applyColorFormatting(String str, String symbol = '&') {

String.metaClass.applyColorFormat = { String symbol = '&' -> applyColorFormatting((String) delegate, symbol) }

tasks.build {
// make sure the language file is up-to-date when building.
// but you still need to self-update it when running dev clients (e.g. `runClient21`).
dependsOn "generatedLanguageFiles"
}

tasks.register("generateLanguageFiles") {
group = "overpowered"

def outputFilenameComment = false

doLast {
def sources = [sourceSets.main.allSource]
// the locales to be recognized
Expand Down Expand Up @@ -71,7 +67,11 @@ tasks.register("generateLanguageFiles") {
line = line.trimStart()

// find the keyword
if (line.startsWith("// #tr ")) {
if (line.startsWith("// #tr! ")) {
key = line.substring("// #tr! ".length()).toLowerCase(Locale.US)
value[key] = [:]
state = 1
} else if (line.startsWith("// #tr ")) {
key = line.substring("// #tr ".length())
value[key] = [:]
state = 1
Expand Down Expand Up @@ -99,8 +99,10 @@ tasks.register("generateLanguageFiles") {
}

// put file name
languages.forEach { String lang ->
languageFileBuilders[lang].append("# ${rootDir.relativePath(file)}").append("\n")
if(outputFilenameComment) {
languages.forEach { String lang ->
languageFileBuilders[lang].append("# ${rootDir.relativePath(file)}").append("\n")
}
}
// put kv pairs
value.forEach { k, localizedValues ->
Expand All @@ -125,3 +127,13 @@ tasks.register("generateLanguageFiles") {
file("${rootDir}/src/main/resources/assets/Overpowered/lang/zh_TW.lang").write(languageFileBuilders["tw"].toString(), "UTF-8")
}
}

tasks.build {
// make sure the language file is up-to-date when building.
// but you still need to self-update it when running dev clients (e.g. `runClient21`).
dependsOn tasks.generateLanguageFiles
}

tasks.processResources {
dependsOn tasks.generateLanguageFiles
}
5 changes: 5 additions & 0 deletions src/main/kotlin/cn/taskeren/op/forge/CommonInit.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.taskeren.op.forge

import cn.taskeren.op.OP_Logger
import cn.taskeren.op.forge.config.OP_Config
import cn.taskeren.op.gt.init.OP_GTRegistrar
import cn.taskeren.op.gt.item.OP_GeneratedItem
import cn.taskeren.op.mc.command.CommandInsurance
Expand All @@ -11,10 +12,14 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent
import cpw.mods.fml.common.event.FMLPreInitializationEvent
import cpw.mods.fml.common.event.FMLServerStartingEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.config.Configuration

sealed class CommonInit : OP_Logger {

open fun preInit(e: FMLPreInitializationEvent) {
// init config
OP_Config.init(Configuration(e.suggestedConfigurationFile))

logger.debug("Initializing Generated Items")
OP_GeneratedItem

Expand Down
30 changes: 30 additions & 0 deletions src/main/kotlin/cn/taskeren/op/forge/config/OP_Config.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cn.taskeren.op.forge.config

import net.minecraftforge.common.config.Configuration
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

object OP_Config {

lateinit var config: Configuration

var allowRefundByCommand by boolean("allow-refund-by-command", "insurance", false, "Set to true if allows refund by command. The command still requires permission of level 4.")

fun init(config: Configuration) {
this.config = config
}

private fun boolean(name: String, category: String, defaultValue: Boolean, comment: String): ReadWriteProperty<Any, Boolean> {
return object : ReadWriteProperty<Any, Boolean> {
override fun getValue(thisRef: Any, property: KProperty<*>): Boolean {
return config.getBoolean(name, category, defaultValue, comment)
}

override fun setValue(thisRef: Any, property: KProperty<*>, value: Boolean) {
config.getCategory(category)[name]?.set(value)
config.save()
}
}
}

}
4 changes: 4 additions & 0 deletions src/main/kotlin/cn/taskeren/op/gt/IdItemContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ fun IdItemContainer.registerItem(block: (id: Int) -> ItemStack) = apply {
fun IdItemContainer.addRecipe(recipeMap: IRecipeMap, block: GT_RecipeBuilder.(defaultItem: ItemStack) -> Unit) = apply {
GT_Values.RA.stdBuilder().apply { block(get(1)) }.addTo(recipeMap)
}

fun IdItemContainer.addRecipeSimple(block: (defaultItem: ItemStack) -> Unit) = apply {
block(get(1))
}
59 changes: 37 additions & 22 deletions src/main/kotlin/cn/taskeren/op/gt/init/OP_GTRegistrar.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package cn.taskeren.op.gt.init

import cn.taskeren.op.gt.addRecipe
import cn.taskeren.op.gt.addRecipeSimple
import cn.taskeren.op.gt.registerMachine
import cn.taskeren.op.gt.single.OP_ActiveTransformerRack
import cn.taskeren.op.gt.single.OP_BalancedOutputHatch
import cn.taskeren.op.gt.single.OP_DebugEnergyHatch
import cn.taskeren.op.gt.single.OP_InsuranceCounter
import cn.taskeren.op.gt.single.OP_OverpowerMachine
import cn.taskeren.op.gt.single.OP_UniHatch
import cn.taskeren.op.gt.utils.PatternRecipeBuilder
import cn.taskeren.op.gt.utils.PatternRecipeBuilder.X
import gregtech.api.enums.GT_Values
import gregtech.api.enums.ItemList
import gregtech.api.enums.Materials
import gregtech.api.enums.TierEU
import gregtech.api.recipe.RecipeMaps
import gregtech.api.util.GT_ModHandler
import gregtech.api.util.GT_RecipeBuilder
import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList

object OP_GTRegistrar {

Expand All @@ -21,28 +27,37 @@ object OP_GTRegistrar {
}

private fun registerSingleMachines() {
// #tr OP_NameOverpowerMachine
// #tr gt.blockmachines.overpower_machine.name
// #en Incredible Malicious Machine Overpowering System
// #zh 超级绝绝子机器强化系统
OP_MachineItemList.OverpowerMachine.registerMachine {
OP_OverpowerMachine(it, "OP_NameOverpowerMachine", "Incredible Malicious Machine Overpowering System", 9)
OP_OverpowerMachine(it, "overpower_machine", "Incredible Malicious Machine Overpowering System", 9)
}

// #tr OP_NameActiveTransformerRack
// #tr gt.blockmachines.active_transformer_rack.name
// #en Active Transformer Rack
// #zh 有源变压器机械架
// #tw 有源變壓器機械架
OP_MachineItemList.ActiveTransformerRack.registerMachine {
OP_ActiveTransformerRack(it, "OP_NameActiveTransformerRack", "Active Transformer Rack", 9)
OP_ActiveTransformerRack(it, "active_transformer_rack", "Active Transformer Rack", 9)
}

// #tr gt.blockmachines.insurance_counter.name
// #en Galactic Inc. Insurance Counter
// #zh 星际保险公司柜台
OP_MachineItemList.InsuranceCounter.registerMachine {
OP_InsuranceCounter(it, "insurance_counter", "Galactic Inc. Insurance Counter", 1)
}.addRecipeSimple {
GT_ModHandler.addCraftingRecipe(it, PatternRecipeBuilder.format(1, arrayOf("WCW", "XHX", "WCW", 'W', X.WIRE, 'C', X.CIRCUIT, 'X', GregtechItemList.TransmissionComponent_LV, 'H', X.HULL)))
}

// region UniHatch

// #tr OP_NameUniHatch_ULV
// #tr gt.blockmachines.uni_hatch_ulv.name
// #en UniHatch ULV
// #zh 组合式输入仓 ULV
OP_MachineItemList.UniHatch_ULV.registerMachine {
OP_UniHatch(it, "OP_NameUniHatch_ULV", "UniHatch ULV", 0)
OP_UniHatch(it, "uni_hatch_ulv", "UniHatch ULV", 0)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hull_ULV.get(1), ItemList.Hatch_Input_Bus_ULV.get(1), ItemList.Hatch_Input_ULV.get(1))
fluidInputs(Materials.Glue.getFluid(2L * GT_RecipeBuilder.INGOTS))
Expand All @@ -56,11 +71,11 @@ object OP_GTRegistrar {
duration(8 * GT_RecipeBuilder.SECONDS)
eut(TierEU.RECIPE_ULV)
}
// #tr OP_NameUniHatch_LV
// #tr gt.blockmachines.uni_hatch_lv.name
// #en UniHatch LV
// #zh 组合式输入仓 LV
OP_MachineItemList.UniHatch_LV.registerMachine {
OP_UniHatch(it, "OP_NameUniHatch_LV", "UniHatch LV", 1)
OP_UniHatch(it, "uni_hatch_lv", "UniHatch LV", 1)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hull_LV.get(1), ItemList.Hatch_Input_Bus_LV.get(1), ItemList.Hatch_Input_LV.get(1))
fluidInputs(Materials.AdvancedGlue.getFluid(4L * GT_RecipeBuilder.INGOTS))
Expand All @@ -74,11 +89,11 @@ object OP_GTRegistrar {
duration(8 * GT_RecipeBuilder.SECONDS)
eut(TierEU.RECIPE_LV)
}
// #tr OP_NameUniHatch_MV
// #tr gt.blockmachines.uni_hatch_mv.name
// #en UniHatch MV
// #zh 组合式输入仓 MV
OP_MachineItemList.UniHatch_MV.registerMachine {
OP_UniHatch(it, "OP_NameUniHatch_MV", "UniHatch MV", 2)
OP_UniHatch(it, "uni_hatch_mv", "UniHatch MV", 2)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hull_MV.get(1), ItemList.Hatch_Input_Bus_MV.get(1), ItemList.Hatch_Input_MV.get(1))
fluidInputs(Materials.Plastic.getMolten(16L * GT_RecipeBuilder.INGOTS))
Expand All @@ -92,11 +107,11 @@ object OP_GTRegistrar {
duration(8 * GT_RecipeBuilder.SECONDS)
eut(TierEU.RECIPE_MV)
}
// #tr OP_NameUniHatch_HV
// #tr gt.blockmachines.uni_hatch_hv.name
// #en UniHatch HV
// #zh 组合式输入仓 HV
OP_MachineItemList.UniHatch_HV.registerMachine {
OP_UniHatch(it, "OP_NameUniHatch_HV", "UniHatch HV", 3)
OP_UniHatch(it, "uni_hatch_hv", "UniHatch HV", 3)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hull_HV.get(1), ItemList.Hatch_Input_Bus_HV.get(1), ItemList.Hatch_Input_HV.get(1))
fluidInputs(Materials.PolyvinylChloride.getMolten(24L * GT_RecipeBuilder.INGOTS))
Expand All @@ -110,11 +125,11 @@ object OP_GTRegistrar {
duration(8 * GT_RecipeBuilder.SECONDS)
eut(TierEU.RECIPE_HV)
}
// #tr OP_NameUniHatch_EV
// #tr gt.blockmachines.uni_hatch_ev.name
// #en UniHatch EV
// #zh 组合式输入仓 EV
OP_MachineItemList.UniHatch_EV.registerMachine {
OP_UniHatch(it, "OP_NameUniHatch_EV", "UniHatch EV", 4)
OP_UniHatch(it, "uni_hatch_ev", "UniHatch EV", 4)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hull_EV.get(1), ItemList.Hatch_Input_Bus_EV.get(1), ItemList.Hatch_Input_EV.get(1))
fluidInputs(Materials.Polytetrafluoroethylene.getMolten(32L * GT_RecipeBuilder.INGOTS))
Expand All @@ -133,33 +148,33 @@ object OP_GTRegistrar {

// region Balanced Output Hatch

// #tr OP_NameBalancedOutputHatch_HV
// #tr gt.blockmachines.balanced_output_hatch_hv.name
// #en Balanced Output Hatch HV
// #zh 平衡输出仓 HV
OP_MachineItemList.BalancedOutputHatch_HV.registerMachine {
OP_BalancedOutputHatch(it, "OP_NameBalancedOutputHatch_HV", "Balanced Output Hatch HV", 3)
OP_BalancedOutputHatch(it, "balanced_output_hatch_hv", "Balanced Output Hatch HV", 3)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hatch_Output_HV.get(1), ItemList.Cover_FluidStorageMonitor.get(1), ItemList.Cover_Controller.get(1))
itemOutputs(it)
duration(8 * GT_RecipeBuilder.SECONDS)
eut(TierEU.RECIPE_HV)
}
// #tr OP_NameBalancedOutputHatch_LuV
// #tr gt.blockmachines.balanced_output_hatch_luv.name
// #en Balanced Output Hatch LuV
// #zh 平衡输出仓 LuV
OP_MachineItemList.BalancedOutputHatch_LuV.registerMachine {
OP_BalancedOutputHatch(it, "OP_NameBalancedOutputHatch_LuV", "Balanced Output Hatch LuV", 6)
OP_BalancedOutputHatch(it, "balanced_output_hatch_luv", "Balanced Output Hatch LuV", 6)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hatch_Output_LuV.get(1), ItemList.Cover_FluidStorageMonitor.get(1), ItemList.Cover_Controller.get(1))
itemOutputs(it)
duration(8 * GT_RecipeBuilder.SECONDS)
eut(TierEU.RECIPE_HV)
}
// #tr OP_NameBalancedOutputHatch_UHV
// #tr gt.blockmachines.balanced_output_hatch_uhv.name
// #en Balanced Output Hatch UHV
// #zh 平衡输出仓 UHV
OP_MachineItemList.BalancedOutputHatch_UHV.registerMachine {
OP_BalancedOutputHatch(it, "OP_NameBalancedOutputHatch_UHV", "Balanced Output Hatch HV", 9)
OP_BalancedOutputHatch(it, "balanced_output_hatch_uhv", "Balanced Output Hatch HV", 9)
}.addRecipe(RecipeMaps.assemblerRecipes) {
itemInputs(ItemList.Hatch_Output_MAX.get(1), ItemList.Cover_FluidStorageMonitor.get(1), ItemList.Cover_Controller.get(1))
itemOutputs(it)
Expand All @@ -169,12 +184,12 @@ object OP_GTRegistrar {

// endregion

// #tr OP_NameDebugEnergyHatch
// #tr gt.blockmachines.debug_energy_hatch.name
// #en Ascendant Realm Paracausal Manipulating Unit
// #zh 上维领域超因果单元
// #tw 高等維度超因果單元
OP_MachineItemList.DebugEnergyHatch.registerMachine {
OP_DebugEnergyHatch(it, "OP_NameDebugEnergyHatch", "Ascendant Realm Paracausal Manipulating Unit")
OP_DebugEnergyHatch(it, "debug_energy_hatch", "Ascendant Realm Paracausal Manipulating Unit")
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/cn/taskeren/op/gt/init/OP_ItemList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ enum class OP_ItemList(override val id: Short) : IdItemContainer, OP_Logger {

DyingBioChip(1),
CertifiedElectrician(2),
InsuranceReceipt(3),
ActiveTransformerExplosionCore(4),

;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum class OP_MachineItemList(override val id: Short) : IdItemContainer, OP_Logg

OverpowerMachine(14301),
ActiveTransformerRack(14302),
InsuranceCounter(14303),

UniHatch_ULV(17500),
UniHatch_LV(17501),
Expand Down
26 changes: 26 additions & 0 deletions src/main/kotlin/cn/taskeren/op/gt/item/OP_GeneratedItem.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cn.taskeren.op.gt.item

import cn.taskeren.op.gt.init.OP_ItemList
import cn.taskeren.op.gt.item.impl.ActiveTransformerExplosionCoreItemBehaviour
import cn.taskeren.op.gt.item.impl.InsuranceReceiptItemBehaviour
import cn.taskeren.op.gt.registerItem
import gregtech.api.items.GT_MetaGenerated_Item_X32

Expand All @@ -13,11 +15,35 @@ object OP_GeneratedItem : GT_MetaGenerated_Item_X32("metaitem.op") {

init {
OP_ItemList.DyingBioChip.registerItem {
// #tr gt.metaitem.op.32001.name
// #en Dying Bio Chip

// #tr gt.metaitem.op.32001.tooltip
// #en Squeezed Living Bio Chip

addItem(it, "Dying Bio Chip", "Squeezed Living Bio Chip")
}
OP_ItemList.CertifiedElectrician.registerItem {
// #tr gt.metaitem.op.32002.name
// #en Certified Electrician
// #zh 电工资格证
// #tr gt.metaitem.op.32002.tooltip
// #en Proof of your qualifications on Electrical Engineering
// #zh 证明你在电气工程的资历
addItem(it, "Certified Electrician", "Proof of your qualifications on Electrical Engineering")
}
OP_ItemList.InsuranceReceipt.registerItem {
// #tr gt.metaitem.op.32003.name
// #en Insurance Receipt
// #zh 保险单
addItem(it, "Insurance Receipt", "", InsuranceReceiptItemBehaviour)
}
OP_ItemList.ActiveTransformerExplosionCore.registerItem {
// #tr gt.metaitem.op.32004.name
// #en Active Transformer Explosion Core
// #zh 有源变压器爆炸核心
addItem(it, "Active Transformer Explosion Core", "", ActiveTransformerExplosionCoreItemBehaviour)
}
}

}
Loading

0 comments on commit c5561aa

Please sign in to comment.