Add real blocks and items
This commit is contained in:
parent
fa20f5bc9d
commit
1e68decf62
23 changed files with 226 additions and 64 deletions
10
build.gradle
10
build.gradle
|
@ -17,10 +17,13 @@ minecraft {
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = "http://maven.fabricmc.net/" }
|
maven { url = "http://maven.fabricmc.net/" }
|
||||||
|
|
||||||
|
// for Patchouli
|
||||||
|
maven { url 'https://maven.blamejared.com' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||||
|
@ -30,8 +33,9 @@ dependencies {
|
||||||
|
|
||||||
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
|
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.
|
// Patchouli
|
||||||
// You may need to force-disable transitiveness on them.
|
// modCompileOnly "vazkii.patchouli:Patchouli:1.16.4-48-FABRIC:api"
|
||||||
|
modImplementation "vazkii.patchouli:Patchouli:1.16.4-48-FABRIC"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
|
|
@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||||
loader_version=0.10.8
|
loader_version=0.10.8
|
||||||
|
|
||||||
#Fabric api
|
#Fabric api
|
||||||
fabric_version=0.26.1+1.16
|
fabric_version=0.28.1+1.16
|
||||||
|
|
||||||
loom_version=0.5-SNAPSHOT
|
loom_version=0.5-SNAPSHOT
|
||||||
|
|
||||||
|
@ -18,5 +18,5 @@ org.gradle.jvmargs=-Xmx1G
|
||||||
archives_base_name = monadmachines
|
archives_base_name = monadmachines
|
||||||
|
|
||||||
# Kotlin
|
# Kotlin
|
||||||
kotlin_version=1.4.0
|
kotlin_version=1.4.21
|
||||||
fabric_kotlin_version=1.4.0+build.1
|
fabric_kotlin_version=1.4.21+build.1
|
||||||
|
|
|
@ -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!");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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)
|
|
||||||
}
|
|
24
src/main/kotlin/tf/bug/monadmachines/MonadMachines.kt
Normal file
24
src/main/kotlin/tf/bug/monadmachines/MonadMachines.kt
Normal file
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
11
src/main/kotlin/tf/bug/monadmachines/ProgramCard.kt
Normal file
11
src/main/kotlin/tf/bug/monadmachines/ProgramCard.kt
Normal file
|
@ -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")
|
||||||
|
|
||||||
|
}
|
15
src/main/kotlin/tf/bug/monadmachines/ProgramWorkstation.kt
Normal file
15
src/main/kotlin/tf/bug/monadmachines/ProgramWorkstation.kt
Normal file
|
@ -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))
|
||||||
|
|
||||||
|
}
|
|
@ -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<Text>,
|
||||||
|
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<ItemStack> {
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": { "model": "monadmachines:block/program_workstation" }
|
||||||
|
}
|
||||||
|
}
|
13
src/main/resources/assets/monadmachines/lang/en_us.json
Normal file
13
src/main/resources/assets/monadmachines/lang/en_us.json
Normal file
|
@ -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"
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "monadmachines:block/program_workstation"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "monadmachines:item/intro_to_computing"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"parent": "item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "monadmachines:item/program_card"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"parent": "monadmachines:block/program_workstation"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 1,003 B |
Binary file not shown.
After Width: | Height: | Size: 622 B |
Binary file not shown.
After Width: | Height: | Size: 812 B |
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "item.monadmachines.intro_to_computing",
|
||||||
|
"landing_text": "monadmachines.intro_to_computing.landing",
|
||||||
|
"version": 1,
|
||||||
|
"dont_generate_book": true,
|
||||||
|
"custom_book_item": "monadmachines:intro_to_computing",
|
||||||
|
"creative_tab": "monadmachines.group"
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "minecraft:book"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "minecraft:iron_ingot"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "monadmachines:intro_to_computing"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"EII",
|
||||||
|
"II "
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"E": {
|
||||||
|
"item": "minecraft:end_crystal"
|
||||||
|
},
|
||||||
|
"I": {
|
||||||
|
"item": "minecraft:iron_ingot"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "monadmachines:program_card"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "minecraft:cartography_table"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "minecraft:writable_book"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "minecraft:gold_block"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "monadmachines:program_workstation"
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,16 +19,24 @@
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"tf.bug.monadmachines.ExampleModKt::init"
|
{
|
||||||
|
"adapter": "kotlin",
|
||||||
|
"value": "tf.bug.monadmachines.MonadMachinesKt::init"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [],
|
||||||
"monadmachines.mixins.json"
|
|
||||||
],
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.8.7",
|
"fabricloader": ">=0.8.7",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"fabric-language-kotlin": "*",
|
"fabric-language-kotlin": "*",
|
||||||
"minecraft": "1.16.x"
|
"minecraft": "1.16.x"
|
||||||
|
},
|
||||||
|
"recommends": {
|
||||||
|
"patchouli": "*"
|
||||||
|
},
|
||||||
|
"suggests": {
|
||||||
|
"modmenu": "*",
|
||||||
|
"polymorph": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"package": "tf.bug.monadmachines.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [
|
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
"ExampleMixin"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue