-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split integration parts from original
- Loading branch information
1 parent
2e39c6e
commit c3884c4
Showing
41 changed files
with
1,334 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,11 @@ run/ | |
.cache | ||
.kotlin | ||
docs | ||
libs/ | ||
|
||
# java | ||
|
||
hs_err_*.log | ||
replay_*.log | ||
*.hprof | ||
*.jfr | ||
*.jfr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/client/kotlin/hiiragi283/ragium/integration/RIKeyBinds.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package hiiragi283.ragium.integration | ||
|
||
import hiiragi283.ragium.api.RagiumAPI | ||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper | ||
import net.minecraft.client.option.KeyBinding | ||
import org.lwjgl.glfw.GLFW | ||
|
||
object RIKeyBinds { | ||
const val CATEGORY: String = "category.${RagiumAPI.MOD_ID}.${RagiumAPI.MOD_ID}" | ||
|
||
@JvmField | ||
val OPEN_BACKPACK: KeyBinding = KeyBindingHelper.registerKeyBinding( | ||
KeyBinding(keyId("open_backpack"), GLFW.GLFW_KEY_O, CATEGORY), | ||
) | ||
|
||
@JvmStatic | ||
private fun keyId(name: String): String = "key.${RagiumAPI.MOD_ID}.$name" | ||
} |
32 changes: 32 additions & 0 deletions
32
src/client/kotlin/hiiragi283/ragium/integration/RagiumClientIntegration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package hiiragi283.ragium.integration | ||
|
||
import hiiragi283.ragium.api.extension.isModLoaded | ||
import hiiragi283.ragium.common.RagiumContents | ||
import hiiragi283.ragium.integration.accessories.HTOpenBackpackPayload | ||
import hiiragi283.ragium.integration.patchouli.RagiumPatchouliInit | ||
import io.wispforest.accessories.api.AccessoriesCapability | ||
import net.fabricmc.api.ClientModInitializer | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking | ||
import net.minecraft.client.MinecraftClient | ||
|
||
object RagiumClientIntegration : ClientModInitializer { | ||
override fun onInitializeClient() { | ||
RIKeyBinds | ||
|
||
if (isModLoaded("accessories")) { | ||
ClientTickEvents.END_CLIENT_TICK.register { client: MinecraftClient -> | ||
while (RIKeyBinds.OPEN_BACKPACK.wasPressed()) { | ||
val capability: AccessoriesCapability = client.player?.accessoriesCapability() ?: break | ||
if (capability.isEquipped(RagiumContents.Misc.BACKPACK.asItem())) { | ||
ClientPlayNetworking.send(HTOpenBackpackPayload) | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (isModLoaded("patchouli")) { | ||
RagiumPatchouliInit.init() | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/client/kotlin/hiiragi283/ragium/integration/data/RIDataGenerator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package hiiragi283.ragium.integration.data | ||
|
||
import hiiragi283.ragium.integration.data.recipe.TRRecipeProvider | ||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator | ||
|
||
object RIDataGenerator : DataGeneratorEntrypoint { | ||
override fun onInitializeDataGenerator(fabricDataGenerator: FabricDataGenerator) { | ||
val pack: FabricDataGenerator.Pack = fabricDataGenerator.createPack() | ||
// server | ||
pack.addProvider(::RIRecipeProvider) | ||
pack.addProvider(::TRRecipeProvider) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/client/kotlin/hiiragi283/ragium/integration/data/RIRecipeProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package hiiragi283.ragium.integration.data | ||
|
||
import hiiragi283.ragium.api.RagiumAPI | ||
import hiiragi283.ragium.api.data.recipe.HTShapelessRecipeJsonBuilder | ||
import hiiragi283.ragium.common.RagiumContents | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput | ||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider | ||
import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions | ||
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags | ||
import net.minecraft.data.server.recipe.RecipeExporter | ||
import net.minecraft.item.Items | ||
import net.minecraft.registry.RegistryWrapper | ||
import net.minecraft.util.Identifier | ||
import vazkii.patchouli.common.item.ItemModBook | ||
import java.util.concurrent.CompletableFuture | ||
|
||
class RIRecipeProvider( | ||
output: FabricDataOutput, | ||
completableFuture: CompletableFuture<RegistryWrapper.WrapperLookup> | ||
) : FabricRecipeProvider(output, completableFuture) { | ||
override fun getRecipeIdentifier(identifier: Identifier): Identifier = RagiumAPI.id(identifier.path) | ||
|
||
override fun generate(exporter: RecipeExporter) { | ||
HTShapelessRecipeJsonBuilder | ||
.create(ItemModBook.forBook(RagiumAPI.id("ragi_wiki"))) | ||
.input(Items.BOOK) | ||
.input(RagiumContents.RawMaterials.CRUDE_RAGINITE) | ||
.input(ConventionalItemTags.IRON_INGOTS) | ||
.offerTo(withConditions(exporter, ResourceConditions.allModsLoaded("patchouli"))) | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
src/client/kotlin/hiiragi283/ragium/integration/data/recipe/TRRecipeProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package hiiragi283.ragium.integration.data.recipe | ||
|
||
import hiiragi283.ragium.api.RagiumAPI | ||
import hiiragi283.ragium.api.extension.splitWith | ||
import hiiragi283.ragium.common.RagiumContents | ||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput | ||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider | ||
import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags | ||
import net.minecraft.data.server.recipe.RecipeExporter | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.recipe.Ingredient | ||
import net.minecraft.registry.RegistryWrapper | ||
import net.minecraft.util.Identifier | ||
import reborncore.common.crafting.RebornRecipe | ||
import reborncore.common.crafting.SizedIngredient | ||
import techreborn.init.ModRecipes | ||
import techreborn.recipe.recipes.BlastFurnaceRecipe | ||
import java.util.concurrent.CompletableFuture | ||
|
||
@Suppress("UnstableApiUsage") | ||
class TRRecipeProvider( | ||
output: FabricDataOutput, | ||
completableFuture: CompletableFuture<RegistryWrapper.WrapperLookup> | ||
) : FabricRecipeProvider(output, completableFuture) { | ||
override fun getName(): String = "Recipes/Tech Reborn" | ||
|
||
override fun getRecipeIdentifier(identifier: Identifier): Identifier = RagiumAPI.id(identifier.splitWith('/')) | ||
|
||
override fun generate(exporter: RecipeExporter) { | ||
exporter.accept( | ||
id("blast_furnace/ragi_steel_ingot"), | ||
BlastFurnaceRecipe( | ||
ModRecipes.BLAST_FURNACE, | ||
listOf( | ||
SizedIngredient(1, Ingredient.fromTag(ConventionalItemTags.IRON_INGOTS)), | ||
SizedIngredient(4, Ingredient.ofItems(RagiumContents.Dusts.RAGINITE)) | ||
), | ||
listOf( | ||
ItemStack(RagiumContents.Ingots.RAGI_STEEL) | ||
), | ||
128, | ||
20 * 10, | ||
1700 | ||
), | ||
null | ||
) | ||
|
||
exporter.accept( | ||
id("alloy_smelter/ragi_alloy_ingot"), | ||
RebornRecipe.Default( | ||
ModRecipes.ALLOY_SMELTER, | ||
listOf( | ||
SizedIngredient(1, Ingredient.fromTag(ConventionalItemTags.COPPER_INGOTS)), | ||
SizedIngredient(4, Ingredient.ofItems(RagiumContents.Dusts.CRUDE_RAGINITE)) | ||
), | ||
listOf( | ||
ItemStack(RagiumContents.Ingots.RAGI_ALLOY) | ||
), | ||
6, | ||
20 * 10, | ||
), | ||
null | ||
) | ||
} | ||
|
||
private fun id(path: String): Identifier = Identifier.of("techreborn", path) | ||
} |
24 changes: 24 additions & 0 deletions
24
src/client/kotlin/hiiragi283/ragium/integration/jade/HTEnergyNetworkProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package hiiragi283.ragium.integration.jade | ||
|
||
import hiiragi283.ragium.api.extension.energyNetwork | ||
import hiiragi283.ragium.api.world.HTEnergyNetwork | ||
import hiiragi283.ragium.common.init.RagiumTranslationKeys | ||
import net.minecraft.client.MinecraftClient | ||
import net.minecraft.text.Text | ||
import net.minecraft.util.Identifier | ||
import snownee.jade.api.BlockAccessor | ||
import snownee.jade.api.IBlockComponentProvider | ||
import snownee.jade.api.ITooltip | ||
import snownee.jade.api.config.IPluginConfig | ||
|
||
object HTEnergyNetworkProvider : IBlockComponentProvider { | ||
// IBlockComponentProvider // | ||
|
||
override fun getUid(): Identifier = RagiumJadePlugin.NETWORK_INTERFACE | ||
|
||
override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { | ||
MinecraftClient.getInstance().server?.getWorld(accessor.level.registryKey)?.energyNetwork?.let { network: HTEnergyNetwork -> | ||
tooltip.add(Text.translatable(RagiumTranslationKeys.PROVIDER_JADE_NETWORK_INTERFACE, network.amount)) | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
src/client/kotlin/hiiragi283/ragium/integration/jade/HTMachineProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package hiiragi283.ragium.integration.jade | ||
|
||
import com.mojang.serialization.Codec | ||
import com.mojang.serialization.MapCodec | ||
import hiiragi283.ragium.api.inventory.HTSimpleInventory | ||
import hiiragi283.ragium.api.machine.HTMachineEntity | ||
import hiiragi283.ragium.api.machine.HTMachineTier | ||
import hiiragi283.ragium.api.machine.HTMachineType | ||
import hiiragi283.ragium.api.machine.HTMachineTypeRegistry | ||
import hiiragi283.ragium.api.machine.multiblock.HTMultiblockController | ||
import hiiragi283.ragium.common.init.RagiumTranslationKeys | ||
import net.minecraft.nbt.NbtCompound | ||
import net.minecraft.text.Text | ||
import net.minecraft.util.Identifier | ||
import net.minecraft.util.math.Vec2f | ||
import snownee.jade.api.BlockAccessor | ||
import snownee.jade.api.IBlockComponentProvider | ||
import snownee.jade.api.IServerDataProvider | ||
import snownee.jade.api.ITooltip | ||
import snownee.jade.api.config.IPluginConfig | ||
import snownee.jade.api.ui.IElementHelper | ||
import kotlin.jvm.optionals.getOrNull | ||
|
||
object HTMachineProvider : IBlockComponentProvider, IServerDataProvider<BlockAccessor> { | ||
@JvmField | ||
val TYPE: MapCodec<HTMachineType> = HTMachineTypeRegistry.CODEC.fieldOf("type") | ||
|
||
@JvmField | ||
val TIER: MapCodec<HTMachineTier> = HTMachineTier.CODEC.fieldOf("tier") | ||
|
||
@JvmField | ||
val INVENTORY: MapCodec<HTSimpleInventory> = HTSimpleInventory.CODEC.fieldOf("inventory") | ||
|
||
@JvmField | ||
val TICK: MapCodec<Int> = Codec.INT.fieldOf("tick") | ||
|
||
@JvmField | ||
val MAX_TICK: MapCodec<Int> = Codec.INT.fieldOf("maxTick") | ||
|
||
@JvmField | ||
val PREVIEW: MapCodec<Boolean> = Codec.BOOL.fieldOf("preview") | ||
|
||
// IBlockComponentProvider // | ||
|
||
override fun getUid(): Identifier = RagiumJadePlugin.MACHINE | ||
|
||
override fun appendTooltip(tooltip: ITooltip, accessor: BlockAccessor, config: IPluginConfig) { | ||
val type: HTMachineType = accessor | ||
.readData(TYPE) | ||
.getOrNull() | ||
?: return | ||
val tier: HTMachineTier = accessor | ||
.readData(TIER) | ||
.orElse(HTMachineTier.PRIMITIVE) | ||
type.appendTooltip( | ||
tooltip::add, | ||
tier, | ||
) | ||
|
||
val progress: Int = accessor.readData(TICK).orElse(0) | ||
val maxProgress: Int = accessor.readData(MAX_TICK).orElse(tier.tickRate) | ||
val helper: IElementHelper = IElementHelper.get() | ||
accessor.readData(INVENTORY).ifPresent { inventory: HTSimpleInventory -> | ||
if (!inventory.isEmpty) { | ||
tooltip.add(helper.item(inventory.getStack(0))) | ||
tooltip.append(helper.item(inventory.getStack(1))) | ||
tooltip.append(helper.item(inventory.getStack(2))) | ||
tooltip.append(helper.spacer(4, 0)) | ||
tooltip.append(helper.progress(progress.toFloat() / maxProgress.toFloat()).translate(Vec2f(-2.0f, 0.0f))) | ||
tooltip.append(helper.item(inventory.getStack(4))) | ||
tooltip.append(helper.item(inventory.getStack(5))) | ||
tooltip.append(helper.item(inventory.getStack(6))) | ||
} | ||
} | ||
|
||
val showPreview: Boolean = accessor.readData(PREVIEW).getOrNull() ?: return | ||
tooltip.add(Text.translatable(RagiumTranslationKeys.MACHINE_SHOW_PREVIEW, showPreview)) | ||
} | ||
|
||
// IServerDataProvider // | ||
|
||
override fun appendServerData(nbt: NbtCompound, accessor: BlockAccessor) { | ||
accessor.machineEntity?.let { machine: HTMachineEntity -> | ||
accessor.writeData(TYPE, machine.machineType) | ||
accessor.writeData(TIER, machine.tier) | ||
accessor.writeData(INVENTORY, machine.parent) | ||
accessor.writeData(TICK, machine.propertyDelegate.get(0)) | ||
accessor.writeData(MAX_TICK, machine.propertyDelegate.get(1)) | ||
if (machine is HTMultiblockController) { | ||
accessor.writeData(PREVIEW, machine.showPreview) | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/client/kotlin/hiiragi283/ragium/integration/jade/JadeExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package hiiragi283.ragium.integration.jade | ||
|
||
import hiiragi283.ragium.api.machine.HTMachineEntity | ||
import hiiragi283.ragium.common.block.entity.HTMetaMachineBlockEntity | ||
import net.minecraft.block.Block | ||
import snownee.jade.api.* | ||
|
||
// IWailaPlugin // | ||
|
||
fun IWailaCommonRegistration.registerBlock(provider: IServerDataProvider<BlockAccessor>, block: Block) { | ||
registerBlockDataProvider(provider, block::class.java) | ||
} | ||
|
||
fun IWailaClientRegistration.registerBlock(provider: IBlockComponentProvider, block: Block) { | ||
registerBlockComponent(provider, block::class.java) | ||
} | ||
|
||
// BlockAccessor // | ||
|
||
val BlockAccessor.machineEntity: HTMachineEntity? | ||
get() = (blockEntity as? HTMetaMachineBlockEntity)?.machineEntity |
Oops, something went wrong.