Skip to content

Commit

Permalink
Update architectury workspace & patch scrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Killarexe committed Oct 9, 2024
1 parent bf59e88 commit d8125d1
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 153 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
22 changes: 2 additions & 20 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ private static Optional<Item> getScrapItem(Item item) {
public static void scrapUse(Player player, InteractionHand hand, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> callbackInfo) {
ItemStack currentHandStack = player.getItemInHand(hand);
ItemStack otherHandStack = player.getOffhandItem();
if (CEMaps.OXIDATION_MAP_ITEMS.containsValue(currentHandStack.getItem()) && otherHandStack.is(ItemTags.AXES)) {
Optional<Item> scrapItem = getScrapItem(currentHandStack.getItem());
if (scrapItem.isEmpty()) {
callbackInfo.setReturnValue(InteractionResultHolder.fail(currentHandStack));
}
Optional<Item> 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));
Expand Down
73 changes: 22 additions & 51 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'com.github.johnrengelman.shadow' version "7.1.2"
}

architectury {
platformSetupLoomIde()
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 {
Expand All @@ -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"
}
74 changes: 26 additions & 48 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'com.github.johnrengelman.shadow' version "7.1.2"
}

architectury {
Expand All @@ -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 {
Expand All @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item> ITEMS = DeferredRegister.create(BuiltInRegistries.ITEM, CEMod.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(BuiltInRegistries.ITEM, CEMod.MOD_ID);

public static final Supplier<Item> WAXED_COPPER_INGOT = ITEMS.register(
public static final Supplier<Item> WAXED_COPPER_INGOT = ITEMS.register(
"waxed_copper_ingot", () -> new Item(new Item.Properties())
);

Expand All @@ -25,30 +23,19 @@ public class CEItems {
"waxed_weathered_copper_ingot", () -> new Item(new Item.Properties())
);

public static final Supplier<Item> WAXED_OXIDIZED_COPPER_INGOT = ITEMS.register(
public static final Supplier<Item> WAXED_OXIDIZED_COPPER_INGOT = ITEMS.register(
"waxed_oxidized_copper_ingot", () -> new Item(new Item.Properties())
);
);

public static final Supplier<Item> EXPOSED_COPPER_INGOT = ITEMS.register(
"exposed_copper_ingot", () -> new Item(new Item.Properties())
);

public static final Supplier<Item> WEATHERED_COPPER_INGOT = ITEMS.register(
"weathered_copper_ingot", () -> new Item(new Item.Properties())
);

public static final Supplier<Item> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
}
7 changes: 4 additions & 3 deletions neoforge/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
7 changes: 4 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit d8125d1

Please sign in to comment.