From 1e68decf62cc886574f06229fe6e937807411e54 Mon Sep 17 00:00:00 2001 From: Aly Date: Sun, 13 Dec 2020 17:10:41 -0800 Subject: [PATCH] Add real blocks and items --- build.gradle | 10 ++- gradle.properties | 6 +- .../bug/monadmachines/mixin/ExampleMixin.java | 16 ----- .../kotlin/tf/bug/monadmachines/ExampleMod.kt | 25 -------- .../tf/bug/monadmachines/MonadMachines.kt | 24 ++++++++ .../tf/bug/monadmachines/ProgramCard.kt | 11 ++++ .../bug/monadmachines/ProgramWorkstation.kt | 15 +++++ .../monadmachines/books/IntroToComputing.kt | 58 ++++++++++++++++++ .../blockstates/program_workstation.json | 5 ++ .../assets/monadmachines/lang/en_us.json | 13 ++++ .../models/block/program_workstation.json | 6 ++ .../models/item/intro_to_computing.json | 6 ++ .../models/item/program_card.json | 6 ++ .../models/item/program_workstation.json | 3 + .../textures/block/program_workstation.png | Bin 0 -> 1003 bytes .../textures/item/intro_to_computing.png | Bin 0 -> 622 bytes .../textures/item/program_card.png | Bin 0 -> 812 bytes .../intro_to_computing/book.json | 8 +++ .../recipes/intro_to_computing.json | 14 +++++ .../monadmachines/recipes/program_card.json | 18 ++++++ .../recipes/program_workstation.json | 17 +++++ src/main/resources/fabric.mod.json | 16 +++-- src/main/resources/monadmachines.mixins.json | 13 ---- 23 files changed, 226 insertions(+), 64 deletions(-) delete mode 100644 src/main/java/tf/bug/monadmachines/mixin/ExampleMixin.java delete mode 100644 src/main/kotlin/tf/bug/monadmachines/ExampleMod.kt create mode 100644 src/main/kotlin/tf/bug/monadmachines/MonadMachines.kt create mode 100644 src/main/kotlin/tf/bug/monadmachines/ProgramCard.kt create mode 100644 src/main/kotlin/tf/bug/monadmachines/ProgramWorkstation.kt create mode 100644 src/main/kotlin/tf/bug/monadmachines/books/IntroToComputing.kt create mode 100644 src/main/resources/assets/monadmachines/blockstates/program_workstation.json create mode 100644 src/main/resources/assets/monadmachines/lang/en_us.json create mode 100644 src/main/resources/assets/monadmachines/models/block/program_workstation.json create mode 100644 src/main/resources/assets/monadmachines/models/item/intro_to_computing.json create mode 100644 src/main/resources/assets/monadmachines/models/item/program_card.json create mode 100644 src/main/resources/assets/monadmachines/models/item/program_workstation.json create mode 100644 src/main/resources/assets/monadmachines/textures/block/program_workstation.png create mode 100644 src/main/resources/assets/monadmachines/textures/item/intro_to_computing.png create mode 100644 src/main/resources/assets/monadmachines/textures/item/program_card.png create mode 100644 src/main/resources/data/monadmachines/patchouli_books/intro_to_computing/book.json create mode 100644 src/main/resources/data/monadmachines/recipes/intro_to_computing.json create mode 100644 src/main/resources/data/monadmachines/recipes/program_card.json create mode 100644 src/main/resources/data/monadmachines/recipes/program_workstation.json delete mode 100644 src/main/resources/monadmachines.mixins.json diff --git a/build.gradle b/build.gradle index 00e40de..9f5a600 100644 --- a/build.gradle +++ b/build.gradle @@ -17,10 +17,13 @@ minecraft { repositories { maven { url = "http://maven.fabricmc.net/" } + + // for Patchouli + maven { url 'https://maven.blamejared.com' } } dependencies { - //to change the versions see the gradle.properties file + // to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" @@ -30,8 +33,9 @@ dependencies { modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" - // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. - // You may need to force-disable transitiveness on them. + // Patchouli + // modCompileOnly "vazkii.patchouli:Patchouli:1.16.4-48-FABRIC:api" + modImplementation "vazkii.patchouli:Patchouli:1.16.4-48-FABRIC" } processResources { diff --git a/gradle.properties b/gradle.properties index 0ef48b1..cb3cda3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.10.8 #Fabric api - fabric_version=0.26.1+1.16 + fabric_version=0.28.1+1.16 loom_version=0.5-SNAPSHOT @@ -18,5 +18,5 @@ org.gradle.jvmargs=-Xmx1G archives_base_name = monadmachines # Kotlin - kotlin_version=1.4.0 - fabric_kotlin_version=1.4.0+build.1 + kotlin_version=1.4.21 + fabric_kotlin_version=1.4.21+build.1 diff --git a/src/main/java/tf/bug/monadmachines/mixin/ExampleMixin.java b/src/main/java/tf/bug/monadmachines/mixin/ExampleMixin.java deleted file mode 100644 index be3ead3..0000000 --- a/src/main/java/tf/bug/monadmachines/mixin/ExampleMixin.java +++ /dev/null @@ -1,16 +0,0 @@ -package tf.bug.monadmachines.mixin; - -import net.minecraft.client.gui.screen.TitleScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(TitleScreen.class) -// Mixins HAVE to be written in java due to constraints in the mixin system. -public class ExampleMixin { - @Inject(at = @At("HEAD"), method = "init()V") - private void init(CallbackInfo info) { - System.out.println("This line is printed by an example mod mixin!"); - } -} diff --git a/src/main/kotlin/tf/bug/monadmachines/ExampleMod.kt b/src/main/kotlin/tf/bug/monadmachines/ExampleMod.kt deleted file mode 100644 index bec161b..0000000 --- a/src/main/kotlin/tf/bug/monadmachines/ExampleMod.kt +++ /dev/null @@ -1,25 +0,0 @@ -package tf.bug.monadmachines - -import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings -import net.minecraft.block.Block -import net.minecraft.block.Material -import net.minecraft.item.BlockItem -import net.minecraft.item.Item -import net.minecraft.item.ItemGroup -import net.minecraft.util.Identifier -import net.minecraft.util.registry.Registry - -val EXAMPLE_BLOCK: Block = Block(FabricBlockSettings.of(Material.METAL)) -val EXAMPLE_BLOCKITEM: BlockItem = BlockItem(EXAMPLE_BLOCK, Item.Settings().group(ItemGroup.MISC)) - -@Suppress("unused") -fun init() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. - - println("Hello Fabric world!") - - Registry.register(Registry.BLOCK, Identifier("monadmachines", "example"), EXAMPLE_BLOCK) - Registry.register(Registry.ITEM, Identifier("monadmachines", "example"), EXAMPLE_BLOCKITEM) -} diff --git a/src/main/kotlin/tf/bug/monadmachines/MonadMachines.kt b/src/main/kotlin/tf/bug/monadmachines/MonadMachines.kt new file mode 100644 index 0000000..a1bef1b --- /dev/null +++ b/src/main/kotlin/tf/bug/monadmachines/MonadMachines.kt @@ -0,0 +1,24 @@ +package tf.bug.monadmachines + +import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder +import net.minecraft.item.ItemGroup +import net.minecraft.item.ItemStack +import net.minecraft.util.Identifier +import net.minecraft.util.registry.Registry +import tf.bug.monadmachines.books.IntroToComputing + +val MONADMACHINES_ITEMGROUP: ItemGroup = FabricItemGroupBuilder.build( + Identifier("monadmachines", "group") +) { ItemStack(ProgramWorkstation) } + +@Suppress("unused") +fun init() { + Registry.register(Registry.ITEM, IntroToComputing.id, IntroToComputing) + + Registry.register(Registry.BLOCK, ProgramWorkstation.id, ProgramWorkstation) + Registry.register(Registry.ITEM, ProgramWorkstation.id, ProgramWorkstation.item) + + Registry.register(Registry.ITEM, ProgramCard.id, ProgramCard) + + +} diff --git a/src/main/kotlin/tf/bug/monadmachines/ProgramCard.kt b/src/main/kotlin/tf/bug/monadmachines/ProgramCard.kt new file mode 100644 index 0000000..c4ad449 --- /dev/null +++ b/src/main/kotlin/tf/bug/monadmachines/ProgramCard.kt @@ -0,0 +1,11 @@ +package tf.bug.monadmachines + +import net.fabricmc.fabric.api.item.v1.FabricItemSettings +import net.minecraft.item.Item +import net.minecraft.util.Identifier + +object ProgramCard : Item(FabricItemSettings().group(MONADMACHINES_ITEMGROUP)) { + + val id = Identifier("monadmachines", "program_card") + +} diff --git a/src/main/kotlin/tf/bug/monadmachines/ProgramWorkstation.kt b/src/main/kotlin/tf/bug/monadmachines/ProgramWorkstation.kt new file mode 100644 index 0000000..d5aa287 --- /dev/null +++ b/src/main/kotlin/tf/bug/monadmachines/ProgramWorkstation.kt @@ -0,0 +1,15 @@ +package tf.bug.monadmachines + +import net.fabricmc.fabric.api.`object`.builder.v1.block.FabricBlockSettings +import net.minecraft.block.Block +import net.minecraft.block.Material +import net.minecraft.item.BlockItem +import net.minecraft.item.Item +import net.minecraft.util.Identifier + +object ProgramWorkstation : Block(FabricBlockSettings.of(Material.METAL)) { + + val id = Identifier("monadmachines", "program_workstation") + val item = BlockItem(this, Item.Settings().group(MONADMACHINES_ITEMGROUP)) + +} diff --git a/src/main/kotlin/tf/bug/monadmachines/books/IntroToComputing.kt b/src/main/kotlin/tf/bug/monadmachines/books/IntroToComputing.kt new file mode 100644 index 0000000..4e7cae9 --- /dev/null +++ b/src/main/kotlin/tf/bug/monadmachines/books/IntroToComputing.kt @@ -0,0 +1,58 @@ +package tf.bug.monadmachines.books + +import net.fabricmc.loader.api.FabricLoader +import net.minecraft.client.item.TooltipContext +import net.minecraft.entity.player.PlayerEntity +import net.minecraft.item.Item +import net.minecraft.item.ItemStack +import net.minecraft.server.network.ServerPlayerEntity +import net.minecraft.text.Text +import net.minecraft.text.TextColor +import net.minecraft.text.TranslatableText +import net.minecraft.util.* +import net.minecraft.world.World +import tf.bug.monadmachines.MONADMACHINES_ITEMGROUP +import vazkii.patchouli.api.PatchouliAPI + +object IntroToComputing : Item(Settings().group(MONADMACHINES_ITEMGROUP)) { + + val id = Identifier("monadmachines", "intro_to_computing") + + fun getEdition(): Text { + return if(FabricLoader.getInstance().isModLoaded("patchouli")) { + PatchouliAPI.get().getSubtitle(id) + } else { + val text = TranslatableText("monadmachines.no_patchouli_tooltip") + text.style = text.style.withColor(TextColor.fromFormatting(Formatting.RED)) + text + } + } + + override fun appendTooltip( + stack: ItemStack, + world: World?, + tooltip: MutableList, + context: TooltipContext + ) { + super.appendTooltip(stack, world, tooltip, context) + + tooltip.add(getEdition().shallowCopy().formatted(Formatting.GRAY)) + } + + override fun use(world: World, user: PlayerEntity, hand: Hand): TypedActionResult { + val itemStack = user.getStackInHand(hand) + + if(user is ServerPlayerEntity) { + if(FabricLoader.getInstance().isModLoaded("patchouli")) { + PatchouliAPI.get().openBookGUI(user, id) + } else { + val text = TranslatableText("monadmachines.no_patchouli_message") + text.style = text.style.withColor(TextColor.fromFormatting(Formatting.RED)) + user.sendSystemMessage(text, Util.NIL_UUID) + } + } + + return TypedActionResult(ActionResult.SUCCESS, itemStack) + } + +} \ No newline at end of file diff --git a/src/main/resources/assets/monadmachines/blockstates/program_workstation.json b/src/main/resources/assets/monadmachines/blockstates/program_workstation.json new file mode 100644 index 0000000..0c23256 --- /dev/null +++ b/src/main/resources/assets/monadmachines/blockstates/program_workstation.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "monadmachines:block/program_workstation" } + } +} diff --git a/src/main/resources/assets/monadmachines/lang/en_us.json b/src/main/resources/assets/monadmachines/lang/en_us.json new file mode 100644 index 0000000..9b43668 --- /dev/null +++ b/src/main/resources/assets/monadmachines/lang/en_us.json @@ -0,0 +1,13 @@ +{ + "monadmachines.no_patchouli_tooltip": "Patchouli not found!", + "monadmachines.no_patchouli_message": "Patchouli was not detected to be loaded! Please install the mod, or check your logs for any errors that might cause it to not load.", + + "item.monadmachines.intro_to_computing": "Intro to Computing", + "monadmachines.intro_to_computing.landing": "Getting Started with MonadMachines", + + "itemGroup.monadmachines.group": "MonadMachines", + + "block.monadmachines.program_workstation": "Program Workstation", + + "item.monadmachines.program_card": "Program Card" +} diff --git a/src/main/resources/assets/monadmachines/models/block/program_workstation.json b/src/main/resources/assets/monadmachines/models/block/program_workstation.json new file mode 100644 index 0000000..e38ed01 --- /dev/null +++ b/src/main/resources/assets/monadmachines/models/block/program_workstation.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "monadmachines:block/program_workstation" + } +} diff --git a/src/main/resources/assets/monadmachines/models/item/intro_to_computing.json b/src/main/resources/assets/monadmachines/models/item/intro_to_computing.json new file mode 100644 index 0000000..72afbb2 --- /dev/null +++ b/src/main/resources/assets/monadmachines/models/item/intro_to_computing.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "monadmachines:item/intro_to_computing" + } +} diff --git a/src/main/resources/assets/monadmachines/models/item/program_card.json b/src/main/resources/assets/monadmachines/models/item/program_card.json new file mode 100644 index 0000000..4ca5c50 --- /dev/null +++ b/src/main/resources/assets/monadmachines/models/item/program_card.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "monadmachines:item/program_card" + } +} diff --git a/src/main/resources/assets/monadmachines/models/item/program_workstation.json b/src/main/resources/assets/monadmachines/models/item/program_workstation.json new file mode 100644 index 0000000..cf2ff3b --- /dev/null +++ b/src/main/resources/assets/monadmachines/models/item/program_workstation.json @@ -0,0 +1,3 @@ +{ + "parent": "monadmachines:block/program_workstation" +} diff --git a/src/main/resources/assets/monadmachines/textures/block/program_workstation.png b/src/main/resources/assets/monadmachines/textures/block/program_workstation.png new file mode 100644 index 0000000000000000000000000000000000000000..1061930cf93a33bdae92be38730ca35fb0338b54 GIT binary patch literal 1003 zcmVEX>4Tx04R}tkv&MmKpe$i(~2T34i*$~$WWauh)QvkDi*;)X)CnqU~=gfG-*gu zTpR`0f`cE6RR0!X5l%$?&0I>U6f~epZjx!l!D0spGZ8%bi*RvAdYQX zI_G`jFe^(6@j3B?K^G)`z4FwhiYo&F~0000PbVXQnLvL+uWo~o;Lvm$dbY)~9cWHEJAV*0}P*;Ht7XSbO z)k#D_R4C7VklRkz|E7z1ZVN@)tywk?Ga za-Cae&j+$R0{}NVzTIxEwM68-Ke@->k1AIWcMqKN(^mj6#fgYgOxQHdJkOo$mSeWJ znpEHSd7dxu!dwj9;DSR$EbB6(Y;l{LO_<^^4AV3%aEen1L6b%y#5~SY%EcWH2Sh}~ z|6vG$arXM}l~$`&N{KPHxaa5R)3V#`7U-R0z`XaQv;s)T@qA0|;pm)8bHaI=waUEn z=L3whQwOx)@2$1fRfQVsbqxrDi>~VmQ$!xz(YIZjsqEwX!#O*SBRS_danXuA&)c?5 zEC~_}SaWEIXdFi*e0zVJr#VtE#!yVL?|LGR0wF+3X_hkrI`8agtE;LxG(LJ~9ph}W Z(+_IT_D4V9#18-f002ovPDHLkV1f($$(8^B literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/monadmachines/textures/item/intro_to_computing.png b/src/main/resources/assets/monadmachines/textures/item/intro_to_computing.png new file mode 100644 index 0000000000000000000000000000000000000000..78e252ecf3a67df3aa8765b2400773ce48ed63a6 GIT binary patch literal 622 zcmV-!0+IcRP)EX>4Tx04R}tkv&MmKpe$iQ>8^(9IPPXkfAzR5EXHhDi*;)X)CnqU~=gfG-*gu zTpR`0f`cE6RR%KKJJcD+QAQK9P8i>4rtTK|Hf* z>74h8Bdjbb#OK8023?T&k?XR{Z=6dG3p_JoWYhD+5n{2_#c~(3vY`@B6Gs(QqkJLf zvch?bvs$gQ_C5IvLj`Rm!*!Y?NMH#`q#!~@9TikzAx5i4iitGs$36VRjz2{%nOqex zax9<*6_Voz|AXJ%n#HL}Hz^bcdS7h&V-yJN0jdyW16NwdUuy!hpQJZB zTJ#9$-v%zOJDR))T zjFl*R-Q(TC?%w`A)9&vFMd5OlsXN$>00006VoOIv0RI30001*5eDeSR010qNS#tmY zE+YT{E+YYWr9XB6000McNliruugjN6m02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{002fwL_t(I%VS`m5HOEX>4Tx04R}tkv&MmKpe$i(~2T34i*$~$WWauh)QvkDi*;)X)CnqU~=gfG-*gu zTpR`0f`cE6RR0!X5l%$?&0I>U6f~epZjx!l!D0spGZ8%bi*RvAdYQX zI_G`jFe^(6@j3B?K^G)`eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{009I^L_t(I%k7d)N&`U_RnVw0&!{jpJF*1bQK|D(m zBpbz5cH)7|^l!NcM)$hRw=0VGiuWkE@n_`sFin%S)(9aGW5jz;&Kd7LW`=W)oHHUq z-}ji=kHKcMv8Rs*IITDyk96J>Gj!gVYhzG{h)`>z>pd#)^7@7Y*lxF1@qYgdfQcaK z^K$)sMns4)A}B2vQZAHIaMLu|NSkQ4GofG5T;u^sy;2f=0.8.7", "fabric": "*", "fabric-language-kotlin": "*", "minecraft": "1.16.x" + }, + "recommends": { + "patchouli": "*" + }, + "suggests": { + "modmenu": "*", + "polymorph": "*" } } diff --git a/src/main/resources/monadmachines.mixins.json b/src/main/resources/monadmachines.mixins.json deleted file mode 100644 index 217a98e..0000000 --- a/src/main/resources/monadmachines.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "package": "tf.bug.monadmachines.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - ], - "client": [ - "ExampleMixin" - ], - "injectors": { - "defaultRequire": 1 - } -}