From 7960b71768b24fdff50283d06f640ba1d84aa948 Mon Sep 17 00:00:00 2001 From: mt1006 Date: Mon, 28 Oct 2024 22:24:41 +0100 Subject: [PATCH] Version 1.2 --- .gitignore | 39 ++++---- CHANGELOG.txt | 5 ++ build.gradle | 84 ++++++++++-------- common/build.gradle | 18 ++++ .../mt1006/irondoorkey/IronDoorKeyCommon.java | 16 ++++ .../mt1006/irondoorkey/IronDoorKeyItem.java | 52 +++++++++-- .../assets/irondoorkey/lang/en_us.json | 0 .../assets/irondoorkey/lang/pl_pl.json | 0 .../models/item/iron_door_key.json | 0 .../textures/item/iron_door_key.png | Bin .../recipes/tools/iron_door_key.json | 28 ++++++ .../irondoorkey/recipe/iron_door_key.json | 2 +- .../data/irondoorkey/tags/block/openable.json | 0 {src => common/src}/main/resources/logo.png | Bin fabric/build.gradle | 16 ++++ .../mt1006/irondoorkey/IronDoorKeyMod.java | 11 +-- fabric/src/main/resources/fabric.mod.json | 32 +++++++ forge/build.gradle | 29 ++++++ .../mt1006/irondoorkey/IronDoorKeyMod.java | 33 +++++++ forge/src/main/resources/META-INF/mods.toml | 27 ++++++ forge/src/main/resources/pack.mcmeta | 7 ++ gradle.properties | 60 +++++++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- neoforge/build.gradle | 25 ++++++ .../mt1006/irondoorkey/IronDoorKeyMod.java | 31 +++++++ .../resources/META-INF/neoforge.mods.toml | 27 ++++++ settings.gradle | 14 ++- src/main/resources/fabric.mod.json | 32 ------- 28 files changed, 462 insertions(+), 128 deletions(-) create mode 100644 common/build.gradle create mode 100644 common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyCommon.java rename {src => common/src}/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java (65%) rename {src => common/src}/main/resources/assets/irondoorkey/lang/en_us.json (100%) rename {src => common/src}/main/resources/assets/irondoorkey/lang/pl_pl.json (100%) rename {src => common/src}/main/resources/assets/irondoorkey/models/item/iron_door_key.json (100%) rename {src => common/src}/main/resources/assets/irondoorkey/textures/item/iron_door_key.png (100%) create mode 100644 common/src/main/resources/data/irondoorkey/advancement/recipes/tools/iron_door_key.json rename {src => common/src}/main/resources/data/irondoorkey/recipe/iron_door_key.json (91%) rename {src => common/src}/main/resources/data/irondoorkey/tags/block/openable.json (100%) rename {src => common/src}/main/resources/logo.png (100%) create mode 100644 fabric/build.gradle rename {src => fabric/src}/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java (59%) create mode 100644 fabric/src/main/resources/fabric.mod.json create mode 100644 forge/build.gradle create mode 100644 forge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java create mode 100644 forge/src/main/resources/META-INF/mods.toml create mode 100644 forge/src/main/resources/pack.mcmeta create mode 100644 neoforge/build.gradle create mode 100644 neoforge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java create mode 100644 neoforge/src/main/resources/META-INF/neoforge.mods.toml delete mode 100644 src/main/resources/fabric.mod.json diff --git a/.gitignore b/.gitignore index c476faf..ef99bd2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,37 @@ # gradle - .gradle/ build/ -out/ -classes/ - -# eclipse - -*.launch # idea - -.idea/ -*.iml +out/ *.ipr *.iws +*.iml +.idea/* +!.idea/scopes -# vscode +# eclipse +eclipse +*.launch +.settings +.metadata +.classpath +.project +# vscode .settings/ .vscode/ -bin/ .classpath .project -# macos - -*.DS_Store - -# fabric - -run/ - # java - hs_err_*.log replay_*.log *.hprof *.jfr + +# other +run/ +runs/ +bin/ +classes/ diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1915bc3..5f0030e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,8 @@ +===Version 1.2=== +-Fixed opening non-openable fence gates with Iron Door Key not emitting sound and rotating fence gate in any direction depending on player rotation. +-Obtaining Redstone Dust now gives player Iron Door Key recipe. +-Iron door key recipe is now properly placed in equipment category, instead of building. + ===Version 1.1.1=== -Version information is no longer sent to logs during startup. -Warning message for unopenable block being declared as openable now properly includes "FenceGateBlock" as class of blocks possible to open. diff --git a/build.gradle b/build.gradle index 1cc98c1..2f5b982 100644 --- a/build.gradle +++ b/build.gradle @@ -1,46 +1,56 @@ -plugins +subprojects { - id "fabric-loom" version "1.7-SNAPSHOT" -} + apply plugin: "java" + java.toolchain.languageVersion = JavaLanguageVersion.of(java_version) -version = project.mod_version -group = project.maven_group - -base -{ - archivesName = "${project.archives_base_name}-FABRIC-${project.minecraft_version}" -} - -repositories -{ - maven { url = "https://maven.parchmentmc.org/" } -} - -dependencies -{ - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings loom.layered() + base { - officialMojangMappings() - parchment("org.parchmentmc.data:parchment-${project.mappings_version}@zip") + archivesName = "${mod_jar_name}-${project.name.toUpperCase()}-${minecraft_version}" } - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" -} - -processResources -{ - inputs.property "version", project.version - filesMatching("fabric.mod.json") { expand "version": project.version } -} + processResources + { + var replaceProperties = + [ + "mod_name" : mod_name, + "mod_jar_name" : mod_jar_name, + "mod_id" : mod_id, + "mod_group" : mod_group, + "mod_author" : mod_author, + "version" : version, + "license" : license, + "homepage" : homepage, + "source_url" : source_url, + "issue_tracker" : issue_tracker, + "mod_description" : mod_description, + "minecraft_version" : minecraft_version, + "java_version" : java_version, + "version_range_fabric" : version_range_fabric, + "version_range_forge" : version_range_forge, + "version_range_neoforge" : version_range_neoforge, + "fabric_loader_version" : fabric_loader_version, + "fabric_api_version" : fabric_api_version, + "forge_version" : forge_version, + "neoforge_version" : neoforge_version, + ] + + filesMatching(["pack.mcmeta", "fabric.mod.json", "META-INF/mods.toml", "META-INF/neoforge.mods.toml", "*.mixins.json"]) + { + expand replaceProperties + } + inputs.properties replaceProperties + } -tasks.withType(JavaCompile).configureEach { it.options.release = 21 } + tasks.withType(JavaCompile).configureEach { it.options.encoding = "UTF-8" } -java -{ - withSourcesJar() + if (project.name != "common") + { + dependencies + { + compileOnly project(":common") + } - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + processResources { from project(":common").sourceSets.main.resources } + tasks.named("compileJava", JavaCompile) { source project(":common").sourceSets.main.allSource } + } } \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..a8e9807 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,18 @@ +plugins +{ + id "fabric-loom" version "${fabric_loom_version}" +} + +repositories +{ + maven { url = "https://maven.parchmentmc.org/" } +} + +dependencies +{ + minecraft "com.mojang:minecraft:${minecraft_version}" + mappings loom.layered { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip") + } +} \ No newline at end of file diff --git a/common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyCommon.java b/common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyCommon.java new file mode 100644 index 0000000..f6348df --- /dev/null +++ b/common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyCommon.java @@ -0,0 +1,16 @@ +package com.mt1006.irondoorkey; + +import com.mojang.logging.LogUtils; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.block.Block; +import org.slf4j.Logger; + +public class IronDoorKeyCommon +{ + public static final String MOD_ID = "irondoorkey"; + public static final Logger LOGGER = LogUtils.getLogger(); + + public static final TagKey OPENABLE = TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(MOD_ID, "openable")); +} diff --git a/src/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java b/common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java similarity index 65% rename from src/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java rename to common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java index 23f7f33..e0a4454 100644 --- a/src/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java +++ b/common/src/main/java/com/mt1006/irondoorkey/IronDoorKeyItem.java @@ -1,7 +1,6 @@ package com.mt1006.irondoorkey; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -14,13 +13,20 @@ import net.minecraft.world.level.block.TrapDoorBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockSetType; +import net.minecraft.world.level.block.state.properties.WoodType; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.Fluids; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + public class IronDoorKeyItem extends Item { + private static boolean fenceGateSoundUsed = false; + private static @Nullable Field fenceGateTypeField = null; + public IronDoorKeyItem() { super(new Item.Properties()); @@ -32,7 +38,7 @@ public IronDoorKeyItem() BlockPos blockPos = ctx.getClickedPos(); BlockState blockState = level.getBlockState(blockPos); - if (!blockState.is(IronDoorKeyMod.OPENABLE)) { return InteractionResult.PASS; } + if (!blockState.is(IronDoorKeyCommon.OPENABLE)) { return InteractionResult.PASS; } Block blockType = blockState.getBlock(); if (blockType instanceof DoorBlock) @@ -49,11 +55,11 @@ else if (blockType instanceof TrapDoorBlock) else if (blockType instanceof FenceGateBlock) { // redundant in vanilla, added for better mod support, e.g. with SecurityCraft - openFenceGate(ctx.getPlayer(), level, blockPos, blockState); + openFenceGate(ctx.getPlayer(), level, blockPos, blockState, (FenceGateBlock)blockType); return InteractionResult.sidedSuccess(level.isClientSide); } - IronDoorKeyMod.LOGGER.warn("Failed to open the block - " + + IronDoorKeyCommon.LOGGER.warn("Failed to open the block - " + "it has \"openable\" tag, but isn't instance of DoorBlock, TrapDoorBlock or FenceGateBlock"); return InteractionResult.PASS; } @@ -74,7 +80,7 @@ private static void openTrapDoor(@Nullable Player player, Level level, BlockPos level.gameEvent(player, isOpen ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, blockPos); } - private static void openFenceGate(@Nullable Player player, Level level, BlockPos blockPos, BlockState blockState) + private static void openFenceGate(@Nullable Player player, Level level, BlockPos blockPos, BlockState blockState, FenceGateBlock blockType) { boolean wasOpen = blockState.getValue(FenceGateBlock.OPEN); if (wasOpen) @@ -84,13 +90,43 @@ private static void openFenceGate(@Nullable Player player, Level level, BlockPos } else { - Direction direction = player != null ? player.getDirection() : blockState.getValue(FenceGateBlock.FACING); - BlockState newBlockState = blockState.setValue(FenceGateBlock.OPEN, true).setValue(FenceGateBlock.FACING, direction); + BlockState newBlockState = blockState.setValue(FenceGateBlock.OPEN, true); + if (player != null && player.getDirection().getOpposite() == blockState.getValue(FenceGateBlock.FACING)) + { + newBlockState = newBlockState.setValue(FenceGateBlock.FACING, player.getDirection()); + } level.setBlock(blockPos, newBlockState, 10); } boolean isOpen = !wasOpen; - level.levelEvent(player, isOpen ? 1008 : 1014, blockPos, 0); + playFenceGateSound(player, level, blockPos, blockType, isOpen); level.gameEvent(player, isOpen ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, blockPos); } + + private static void playFenceGateSound(@Nullable Player player, Level level, BlockPos blockPos, FenceGateBlock blockType, boolean isOpen) + { + if (fenceGateTypeField == null) + { + if (fenceGateSoundUsed) { return; } + fenceGateSoundUsed = true; + + for (Field field : FenceGateBlock.class.getDeclaredFields()) + { + if (field.getType() == WoodType.class && !Modifier.isStatic(field.getModifiers())) + { + fenceGateTypeField = field; + field.setAccessible(true); + break; + } + } + if (fenceGateTypeField == null) { return; } + } + + WoodType woodType; + try { woodType = (WoodType)fenceGateTypeField.get(blockType); } + catch (Exception exception) { return; } + + level.playSound(player, blockPos, isOpen ? woodType.fenceGateOpen() : woodType.fenceGateClose(), + SoundSource.BLOCKS, 1.0f, level.getRandom().nextFloat() * 0.1f + 0.9f); + } } diff --git a/src/main/resources/assets/irondoorkey/lang/en_us.json b/common/src/main/resources/assets/irondoorkey/lang/en_us.json similarity index 100% rename from src/main/resources/assets/irondoorkey/lang/en_us.json rename to common/src/main/resources/assets/irondoorkey/lang/en_us.json diff --git a/src/main/resources/assets/irondoorkey/lang/pl_pl.json b/common/src/main/resources/assets/irondoorkey/lang/pl_pl.json similarity index 100% rename from src/main/resources/assets/irondoorkey/lang/pl_pl.json rename to common/src/main/resources/assets/irondoorkey/lang/pl_pl.json diff --git a/src/main/resources/assets/irondoorkey/models/item/iron_door_key.json b/common/src/main/resources/assets/irondoorkey/models/item/iron_door_key.json similarity index 100% rename from src/main/resources/assets/irondoorkey/models/item/iron_door_key.json rename to common/src/main/resources/assets/irondoorkey/models/item/iron_door_key.json diff --git a/src/main/resources/assets/irondoorkey/textures/item/iron_door_key.png b/common/src/main/resources/assets/irondoorkey/textures/item/iron_door_key.png similarity index 100% rename from src/main/resources/assets/irondoorkey/textures/item/iron_door_key.png rename to common/src/main/resources/assets/irondoorkey/textures/item/iron_door_key.png diff --git a/common/src/main/resources/data/irondoorkey/advancement/recipes/tools/iron_door_key.json b/common/src/main/resources/data/irondoorkey/advancement/recipes/tools/iron_door_key.json new file mode 100644 index 0000000..8f7b5f5 --- /dev/null +++ b/common/src/main/resources/data/irondoorkey/advancement/recipes/tools/iron_door_key.json @@ -0,0 +1,28 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": + { + "has_redstone": { + "conditions": + { + "items": [{ "items": "minecraft:redstone" }] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": + { + "conditions": { "recipe": "irondoorkey:iron_door_key" }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_redstone" + ] + ], + "rewards": + { + "recipes": [ "irondoorkey:iron_door_key" ] + } +} \ No newline at end of file diff --git a/src/main/resources/data/irondoorkey/recipe/iron_door_key.json b/common/src/main/resources/data/irondoorkey/recipe/iron_door_key.json similarity index 91% rename from src/main/resources/data/irondoorkey/recipe/iron_door_key.json rename to common/src/main/resources/data/irondoorkey/recipe/iron_door_key.json index 87f0eca..b3c95c3 100644 --- a/src/main/resources/data/irondoorkey/recipe/iron_door_key.json +++ b/common/src/main/resources/data/irondoorkey/recipe/iron_door_key.json @@ -1,6 +1,6 @@ { "type": "minecraft:crafting_shaped", - "category": "building", + "category": "equipment", "key": { "#": { "item": "minecraft:iron_nugget" }, diff --git a/src/main/resources/data/irondoorkey/tags/block/openable.json b/common/src/main/resources/data/irondoorkey/tags/block/openable.json similarity index 100% rename from src/main/resources/data/irondoorkey/tags/block/openable.json rename to common/src/main/resources/data/irondoorkey/tags/block/openable.json diff --git a/src/main/resources/logo.png b/common/src/main/resources/logo.png similarity index 100% rename from src/main/resources/logo.png rename to common/src/main/resources/logo.png diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..bce6950 --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,16 @@ +plugins +{ + id "fabric-loom" version "${fabric_loom_version}" +} + +dependencies +{ + minecraft "com.mojang:minecraft:${minecraft_version}" + mappings loom.layered { + officialMojangMappings() + parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip") + } + + modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" +} \ No newline at end of file diff --git a/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java b/fabric/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java similarity index 59% rename from src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java rename to fabric/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java index 871aee6..fd67d05 100644 --- a/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java +++ b/fabric/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java @@ -1,29 +1,20 @@ package com.mt1006.irondoorkey; -import com.mojang.logging.LogUtils; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.TagKey; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; -import net.minecraft.world.level.block.Block; -import org.slf4j.Logger; public class IronDoorKeyMod implements ModInitializer { - public static final String MOD_ID = "irondoorkey"; - public static final Logger LOGGER = LogUtils.getLogger(); - private static final Item ITEM_IRON_DOOR_KEY = new IronDoorKeyItem(); - public static final TagKey OPENABLE = TagKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(MOD_ID, "openable")); @Override public void onInitialize() { - Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath(MOD_ID, "iron_door_key"), ITEM_IRON_DOOR_KEY); + Registry.register(BuiltInRegistries.ITEM, ResourceLocation.fromNamespaceAndPath(IronDoorKeyCommon.MOD_ID, "iron_door_key"), ITEM_IRON_DOOR_KEY); ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register((content) -> content.accept(ITEM_IRON_DOOR_KEY)); } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..c231cbc --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,32 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "version": "${version}", + + "name": "${mod_name}", + "description": "${mod_description}", + "authors": ["${mod_author}"], + "contact": + { + "homepage": "${homepage}", + "sources": "${source_url}", + "issues": "${issue_tracker}" + }, + + "license": "${license}", + "icon": "logo.png", + + "environment": "*", + "entrypoints": + { + "main": ["com.mt1006.irondoorkey.IronDoorKeyMod"] + }, + + "depends": + { + "minecraft": "${version_range_fabric}", + "fabricloader": ">=0.16.0", + "fabric-api": "*", + "java": ">=${java_version}" + } +} \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle new file mode 100644 index 0000000..c4939fc --- /dev/null +++ b/forge/build.gradle @@ -0,0 +1,29 @@ +plugins +{ + id "net.minecraftforge.gradle" version "${forge_gradle_version}" +} + +minecraft +{ + mappings channel: "official", version: minecraft_version + reobf = false + + runs + { + client + server + } +} + +dependencies +{ + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + implementation("net.sf.jopt-simple:jopt-simple:5.0.4") { version { strictly "5.0.4" } } +} + +sourceSets.each +{ + def dir = layout.buildDirectory.dir("sourcesSets/$it.name") + it.output.resourcesDir = dir + it.java.destinationDirectory = dir +} \ No newline at end of file diff --git a/forge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java b/forge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java new file mode 100644 index 0000000..19badbb --- /dev/null +++ b/forge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java @@ -0,0 +1,33 @@ +package com.mt1006.irondoorkey; + +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.Item; +import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +@Mod(IronDoorKeyCommon.MOD_ID) +public class IronDoorKeyMod +{ + private static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, IronDoorKeyCommon.MOD_ID); + private static final RegistryObject ITEM_IRON_DOOR_KEY = ITEMS.register("iron_door_key", IronDoorKeyItem::new); + + public IronDoorKeyMod(FMLJavaModLoadingContext context) + { + IEventBus eventBus = context.getModEventBus(); + ITEMS.register(eventBus); + eventBus.addListener(this::creativeModeTabSetup); + } + + private void creativeModeTabSetup(BuildCreativeModeTabContentsEvent event) + { + if (event.getTabKey().equals(CreativeModeTabs.TOOLS_AND_UTILITIES)) + { + event.accept(IronDoorKeyMod.ITEM_IRON_DOOR_KEY); + } + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..5465566 --- /dev/null +++ b/forge/src/main/resources/META-INF/mods.toml @@ -0,0 +1,27 @@ +modLoader="javafml" +loaderVersion="*" +license="${license}" +issueTrackerURL="${issue_tracker}" + +[[mods]] +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${homepage}" +logoFile="logo.png" +authors="${mod_author}" +description='''${mod_description}''' + +[[dependencies.${mod_id}]] + modId="forge" + mandatory=true + versionRange="*" + ordering="NONE" + side="BOTH" + +[[dependencies.${mod_id}]] + modId="minecraft" + mandatory=true + versionRange="${version_range_forge}" + ordering="NONE" + side="BOTH" \ No newline at end of file diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..b830a2b --- /dev/null +++ b/forge/src/main/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": + { + "description": "${mod_name}", + "pack_format": 8 + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e432371..21c0ebe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,18 +1,48 @@ -# Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G -org.gradle.parallel=true +# Mod info +mod_name=Iron Door Key +mod_jar_name=IronDoorKey +mod_id=irondoorkey +mod_group=com.mt1006.irondoorkey +mod_author=mt1006 +version=1.2 +license=LGPL-3.0-only +homepage=https://modrinth.com/mod/iron-door-key +source_url=https://github.com/mt1006/mc-irondoorkey-mod +issue_tracker=https://github.com/mt1006/mc-irondoorkey-mod/issues +mod_description=Adds iron door key. It can be used to open iron doors and trapdoors. -# Fabric Properties - # https://fabricmc.net/develop - # https://parchmentmc.org/docs/getting-started - minecraft_version=1.21.1 - loader_version=0.16.5 - mappings_version=1.21:2024.07.28 +# Minecraft and Java +minecraft_version=1.21.1 +java_version=21 -# Mod Properties - mod_version=1.1.1 - maven_group=com.mt1006.irondoorkey - archives_base_name=IronDoorKey +# Requires +version_range_fabric=>=1.21 <1.21.2 +version_range_forge=[1.21.1,1.21.2) +version_range_neoforge=[1.21,1.21.2) -# Dependencies - fabric_version=0.104.0+1.21.1 +# Loaders +# https://github.com/FabricMC/fabric-loader/releases +# https://modrinth.com/mod/fabric-api/versions?c=release +# https://files.minecraftforge.net/net/minecraftforge/forge/ +# https://projects.neoforged.net/neoforged/neoforge +fabric_loader_version=0.16.8 +fabric_api_version=0.107.0+1.21.1 +forge_version=52.0.24 +neoforge_version=21.1.73 + +# Mappings +# https://parchmentmc.org/docs/getting-started +parchment_minecraft=1.21 +parchment_version=2024.07.28 + +# Gradle dependencies +# https://github.com/FabricMC/fabric-loom/releases +# https://files.minecraftforge.net/net/minecraftforge/gradle/ForgeGradle/index.html +# https://projects.neoforged.net/neoforged/ModDevGradle +fabric_loom_version=1.8-SNAPSHOT +forge_gradle_version=[6.0.29,6.2) +neoforge_moddev_version=2.0.42-beta + +# Gradle configuration +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0aaefbc..df97d72 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..ff293f0 --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,25 @@ +plugins +{ + id "net.neoforged.moddev" version "${neoforge_moddev_version}" +} + +neoForge +{ + version = neoforge_version + parchment + { + minecraftVersion = parchment_minecraft + mappingsVersion = parchment_version + } + + runs + { + client { client() } + server { server() } + } + + mods + { + "${mod_id}" { sourceSet sourceSets.main } + } +} \ No newline at end of file diff --git a/neoforge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java b/neoforge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java new file mode 100644 index 0000000..223e60f --- /dev/null +++ b/neoforge/src/main/java/com/mt1006/irondoorkey/IronDoorKeyMod.java @@ -0,0 +1,31 @@ +package com.mt1006.irondoorkey; + +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.Item; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; +import net.neoforged.neoforge.registries.DeferredHolder; +import net.neoforged.neoforge.registries.DeferredRegister; + +@Mod(IronDoorKeyCommon.MOD_ID) +public class IronDoorKeyMod +{ + private static final DeferredRegister ITEMS = DeferredRegister.create(BuiltInRegistries.ITEM, IronDoorKeyCommon.MOD_ID); + private static final DeferredHolder ITEM_IRON_DOOR_KEY = ITEMS.register("iron_door_key", IronDoorKeyItem::new); + + public IronDoorKeyMod(IEventBus eventBus) + { + ITEMS.register(eventBus); + eventBus.addListener(this::creativeModeTabSetup); + } + + private void creativeModeTabSetup(BuildCreativeModeTabContentsEvent event) + { + if (event.getTabKey().equals(CreativeModeTabs.TOOLS_AND_UTILITIES)) + { + event.accept(IronDoorKeyMod.ITEM_IRON_DOOR_KEY.get()); + } + } +} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..1a2a3cd --- /dev/null +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,27 @@ +modLoader="javafml" +loaderVersion="*" +license="${license}" +issueTrackerURL="${issue_tracker}" + +[[mods]] +modId="${mod_id}" +version="${version}" +displayName="${mod_name}" +displayURL="${homepage}" +logoFile="logo.png" +authors="${mod_author}" +description='''${mod_description}''' + +[[dependencies.${mod_id}]] + modId="neoforge" + type="required" + versionRange="*" + ordering="NONE" + side="BOTH" + +[[dependencies.${mod_id}]] + modId="minecraft" + type="required" + versionRange="${version_range_neoforge}" + ordering="NONE" + side="BOTH" \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 3a692cb..7dd73d7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,8 +2,16 @@ pluginManagement { repositories { - mavenCentral() gradlePluginPortal() - maven { url = "https://maven.fabricmc.net/" } + maven { url = "https://maven.fabricmc.net" } + maven { url = "https://maven.minecraftforge.net" } + maven { url = "https://maven.neoforged.net/releases/" } } -} \ No newline at end of file +} + +plugins +{ + id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0" +} + +include "common", "fabric", "forge", "neoforge" \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100644 index 06153a8..0000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "schemaVersion": 1, - "id": "irondoorkey", - "version": "${version}", - - "name": "Iron Door Key", - "description": "Adds iron door key. It can be used to open iron doors and trapdoors.", - "authors": ["mt1006"], - "contact": - { - "homepage": "https://modrinth.com/mod/iron-door-key", - "sources": "https://github.com/mt1006/mc-irondoorkey-mod", - "issues": "https://github.com/mt1006/mc-irondoorkey-mod/issues" - }, - - "license": "LGPL-3.0-only", - "icon": "logo.png", - - "environment": "*", - "entrypoints": - { - "main": ["com.mt1006.irondoorkey.IronDoorKeyMod"] - }, - - "depends": - { - "minecraft": ">=1.21", - "fabricloader": ">=0.15.0", - "fabric-api": "*", - "java": ">=21" - } -}