diff --git a/README.md b/README.md index 5ffdbd9..f7ed947 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,4 @@ The major feature is the rusty copper ingots. **Copper ingots can now be oxidixe [![Curseforge](http://cf.way2muchnoise.eu/full_907528_downloads.svg)](https://www.curseforge.com/minecraft/mc-mods/copper-extension) [![ModRinth](https://img.shields.io/modrinth/dt/11Hgyyey?logo=modrinth)](https://modrinth.com/mod/copper-extension) -Copper Extension is available on Forge and Fabric*(soon)* for version 1.20.1 and further on [Curseforge](https://www.curseforge.com/minecraft/mc-mods/copper-extension) and [Modrinth](https://modrinth.com/mod/copper-extension) +Copper Extension is available on Forge and Fabric for version 1.20.1 and further on [Curseforge](https://www.curseforge.com/minecraft/mc-mods/copper-extension) and [Modrinth](https://modrinth.com/mod/copper-extension) diff --git a/common/build.gradle b/common/build.gradle index f6bc170..03bbca3 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,25 +1,7 @@ architectury { - common(rootProject.enabled_platforms.split(",")) -} - -loom { - accessWidenerPath = file("src/main/resources/copper_extension.accesswidener") + common rootProject.enabled_platforms.split(',') } dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - - // modApi "dev.architectury:architectury:${rootProject.architectury_version}" -} - -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } - - repositories { - } + modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" } diff --git a/common/src/main/java/github/killarexe/copper_extension/CEActions.java b/common/src/main/java/github/killarexe/copper_extension/CEActions.java index 5414d4e..b3fcfc2 100644 --- a/common/src/main/java/github/killarexe/copper_extension/CEActions.java +++ b/common/src/main/java/github/killarexe/copper_extension/CEActions.java @@ -61,11 +61,8 @@ private static Optional getScrapItem(Item item) { public static void scrapUse(Player player, InteractionHand hand, CallbackInfoReturnable> callbackInfo) { ItemStack currentHandStack = player.getItemInHand(hand); ItemStack otherHandStack = player.getOffhandItem(); - if (CEMaps.OXIDATION_MAP_ITEMS.containsValue(currentHandStack.getItem()) && otherHandStack.is(ItemTags.AXES)) { - Optional scrapItem = getScrapItem(currentHandStack.getItem()); - if (scrapItem.isEmpty()) { - callbackInfo.setReturnValue(InteractionResultHolder.fail(currentHandStack)); - } + Optional scrapItem = getScrapItem(currentHandStack.getItem()); + if (scrapItem.isPresent() && otherHandStack.is(ItemTags.AXES)) { if (player instanceof ServerPlayer serverPlayer && !player.getCooldowns().isOnCooldown(otherHandStack.getItem())) { scrap(scrapItem.get(), currentHandStack, otherHandStack, serverPlayer, serverPlayer.isShiftKeyDown() ? currentHandStack.getCount() : 1); callbackInfo.setReturnValue(InteractionResultHolder.success(currentHandStack)); diff --git a/fabric/build.gradle b/fabric/build.gradle index 2e6f179..0388c47 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id 'com.github.johnrengelman.shadow' version "7.1.2" } architectury { @@ -7,26 +7,36 @@ architectury { fabric() } -loom { - accessWidenerPath = project(":common").loom.accessWidenerPath -} - configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentFabric.extendsFrom common + + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" + modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version" - // modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionFabric') +} - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} + +remapJar { + input.set shadowJar.archiveFile } processResources { @@ -47,45 +57,6 @@ processResources { } } -shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier = "dev-shadow" -} - -remapJar { - injectAccessWidener = true - input.set shadowJar.archiveFile - dependsOn shadowJar -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} - base { archivesName = archives_base_name + "-fabric" } diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 639de0b..3fe90f6 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id 'com.github.johnrengelman.shadow' version "7.1.2" } architectury { @@ -8,24 +8,41 @@ architectury { } configurations { - common - shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common + developmentNeoForge.extendsFrom common + + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } repositories { - maven { url "https://maven.neoforged.net/"} + maven { + name = 'NeoForged' + url = 'https://maven.neoforged.net/releases' + } } dependencies { - neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}" + neoForge "net.neoforged:neoforge:$rootProject.neoforge_version" - // modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge') +} + +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false } +remapJar { + input.set shadowJar.archiveFile } processResources { @@ -49,45 +66,6 @@ processResources { } } -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - archiveClassifier = "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} - base { archivesName = archives_base_name + "-neoforge" } diff --git a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/event/CEEvents.java b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/event/CEEvents.java index e211ad3..d31b88a 100644 --- a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/event/CEEvents.java +++ b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/event/CEEvents.java @@ -1,20 +1,36 @@ package github.killarexe.copper_extension.neoforge.event; +import github.killarexe.copper_extension.CEMaps; import github.killarexe.copper_extension.neoforge.CENeoForge; import github.killarexe.copper_extension.neoforge.registry.CEItems; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; public class CEEvents { public static void registerEvents(IEventBus bus) { CENeoForge.LOGGER.debug("Initiliazing Copper Extension Events..."); - bus.addListener(CEEvents::addItemsToCreativeTabsEvent); + bus.addListener(CEEvents::addItemsToCreativeTabsEvent); + bus.addListener(CEEvents::commonSetupEvent); CENeoForge.LOGGER.debug("Copper Extension Events Initiliazed!"); } - private static void addItemsToCreativeTabsEvent(BuildCreativeModeTabContentsEvent event) { + private static void commonSetupEvent(FMLCommonSetupEvent event) { + event.enqueueWork(() -> { + CEMaps.OXIDATION_MAP_ITEMS.put(Items.COPPER_INGOT, CEItems.EXPOSED_COPPER_INGOT.get()); + CEMaps.OXIDATION_MAP_ITEMS.put(CEItems.EXPOSED_COPPER_INGOT.get(), CEItems.WEATHERED_COPPER_INGOT.get()); + CEMaps.OXIDATION_MAP_ITEMS.put(CEItems.WEATHERED_COPPER_INGOT.get(), CEItems.OXIDIZED_COPPER_INGOT.get()); + CEMaps.WAXING_MAP_ITEMS.put(Items.COPPER_INGOT, CEItems.WAXED_COPPER_INGOT.get()); + CEMaps.WAXING_MAP_ITEMS.put(CEItems.EXPOSED_COPPER_INGOT.get(), CEItems.WAXED_EXPOSED_COPPER_INGOT.get()); + CEMaps.WAXING_MAP_ITEMS.put(CEItems.WEATHERED_COPPER_INGOT.get(), CEItems.WAXED_WEATHERED_COPPER_INGOT.get()); + CEMaps.WAXING_MAP_ITEMS.put(CEItems.OXIDIZED_COPPER_INGOT.get(), CEItems.WAXED_OXIDIZED_COPPER_INGOT.get()); + }); + } + + private static void addItemsToCreativeTabsEvent(BuildCreativeModeTabContentsEvent event) { if(event.getTabKey() == CreativeModeTabs.INGREDIENTS) { event.acceptAll(CEItems.ITEMS.getEntries().stream().map(item -> new ItemStack(item.get())).toList()); } diff --git a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CEItems.java b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CEItems.java index e1c6565..90d734c 100644 --- a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CEItems.java +++ b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CEItems.java @@ -2,18 +2,16 @@ import java.util.function.Supplier; -import github.killarexe.copper_extension.CEMaps; import github.killarexe.copper_extension.CEMod; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; import net.neoforged.bus.api.IEventBus; import net.neoforged.neoforge.registries.DeferredRegister; public class CEItems { - public static final DeferredRegister ITEMS = DeferredRegister.create(BuiltInRegistries.ITEM, CEMod.MOD_ID); + public static final DeferredRegister ITEMS = DeferredRegister.create(BuiltInRegistries.ITEM, CEMod.MOD_ID); - public static final Supplier WAXED_COPPER_INGOT = ITEMS.register( + public static final Supplier WAXED_COPPER_INGOT = ITEMS.register( "waxed_copper_ingot", () -> new Item(new Item.Properties()) ); @@ -25,30 +23,19 @@ public class CEItems { "waxed_weathered_copper_ingot", () -> new Item(new Item.Properties()) ); - public static final Supplier WAXED_OXIDIZED_COPPER_INGOT = ITEMS.register( + public static final Supplier WAXED_OXIDIZED_COPPER_INGOT = ITEMS.register( "waxed_oxidized_copper_ingot", () -> new Item(new Item.Properties()) - ); + ); public static final Supplier EXPOSED_COPPER_INGOT = ITEMS.register( "exposed_copper_ingot", () -> new Item(new Item.Properties()) ); - + public static final Supplier WEATHERED_COPPER_INGOT = ITEMS.register( "weathered_copper_ingot", () -> new Item(new Item.Properties()) ); - + public static final Supplier OXIDIZED_COPPER_INGOT = ITEMS.register( "oxidized_copper_ingot", () -> new Item(new Item.Properties()) ); - - public static void register(IEventBus bus) { - ITEMS.register(bus); - CEMaps.OXIDATION_MAP_ITEMS.put(Items.COPPER_INGOT, EXPOSED_COPPER_INGOT.get()); - CEMaps.OXIDATION_MAP_ITEMS.put(EXPOSED_COPPER_INGOT.get(), WEATHERED_COPPER_INGOT.get()); - CEMaps.OXIDATION_MAP_ITEMS.put(WEATHERED_COPPER_INGOT.get(), OXIDIZED_COPPER_INGOT.get()); - CEMaps.WAXING_MAP_ITEMS.put(Items.COPPER_INGOT, WAXED_COPPER_INGOT.get()); - CEMaps.WAXING_MAP_ITEMS.put(EXPOSED_COPPER_INGOT.get(), WAXED_EXPOSED_COPPER_INGOT.get()); - CEMaps.WAXING_MAP_ITEMS.put(WEATHERED_COPPER_INGOT.get(), WAXED_WEATHERED_COPPER_INGOT.get()); - CEMaps.WAXING_MAP_ITEMS.put(OXIDIZED_COPPER_INGOT.get(), OXIDIZED_COPPER_INGOT.get()); - } } diff --git a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CERegistries.java b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CERegistries.java index 74400ab..9de90d7 100644 --- a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CERegistries.java +++ b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/registry/CERegistries.java @@ -7,7 +7,7 @@ public class CERegistries { public static void register(IEventBus bus) { CENeoForge.LOGGER.debug("Initializing Copper Extension Items..."); CEGameRules.register(); - CEItems.register(bus); + CEItems.ITEMS.register(bus); CENeoForge.LOGGER.debug("Copper Extension Items Initialized!"); } } diff --git a/neoforge/update.json b/neoforge/update.json index 787c4a5..0ca8b84 100644 --- a/neoforge/update.json +++ b/neoforge/update.json @@ -4,12 +4,13 @@ "1.3.0": "Added rusted coppers, crafts and beehive feature..." }, "1.21": { - "1.3.1": "Update to 1.21 and add crafts." + "1.3.1": "Update to 1.21 and add crafts.", + "1.4.0": "Add russian translation. Patch beehive interaction with items. Add Copper blocks interactions. Rewrite the Wax/Oxidation/Scrapping system." }, "promos": { "1.20.6-lastest": "1.3.0", "1.20.6-recommended": "1.3.0", - "1.21-lastest": "1.3.1", - "1.21-recommended": "1.3.1" + "1.21-lastest": "1.4.0", + "1.21-recommended": "1.4.0" } } diff --git a/settings.gradle b/settings.gradle index 0f55fcb..d8934d3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,12 +3,13 @@ pluginManagement { maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } maven { url "https://maven.neoforged.net/" } + maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } } +rootProject.name = "copper-extension" + include("common") include("fabric") -include("neoforge") - -rootProject.name = "copper-extension" +include("neoforge") \ No newline at end of file