Skip to content

Commit

Permalink
Initial 1.20.4 port
Browse files Browse the repository at this point in the history
  • Loading branch information
ramidzkh committed Feb 23, 2024
1 parent 6dd092d commit 2538025
Show file tree
Hide file tree
Showing 29 changed files with 477 additions and 493 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.vscode/
build/
libs/
run/
runs/
147 changes: 63 additions & 84 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("net.neoforged.gradle") version "[6.0.18,6.2)"
id("net.neoforged.gradle.userdev") version "7.0.57"
id("com.matthewprenger.cursegradle") version "1.4.0"
id("com.diffplug.spotless") version "6.22.0"
id("com.modrinth.minotaur") version "2.8.4"
id("com.diffplug.spotless") version "6.23.3"
id("com.modrinth.minotaur") version "2.8.7"
}

group = "me.ramidzkh"
Expand All @@ -19,19 +19,30 @@ repositories {
}
}

maven {
name = "Jared maven"
url = uri("https://maven.blamejared.com/")
exclusiveContent {
forRepository {
maven {
name = "Jared maven"
url = uri("https://maven.blamejared.com")
}
}

content {
filter {
includeGroup("mezz.jei")
includeGroup("mezz.jei")
}
}

maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
exclusiveContent {
forRepository {
maven {
name = "CurseForge"
url = uri("https://www.cursemaven.com")
}
}

filter {
includeGroup("curse.maven")
}
}

Expand All @@ -42,18 +53,20 @@ repositories {
}

dependencies {
minecraft("net.neoforged:forge:${minecraft_version}-${neoforge_version}")
implementation("net.neoforged:neoforge:${neoforge_version}")

// We depend on many AE2 internals, such as using their basic cell drive, thus not using classifier = "api"
implementation(fg.deobf("appeng:appliedenergistics2-forge:${ae2_version}"))
implementation("appeng:appliedenergistics2-neoforge:${ae2_version}")

compileOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:api"))
runtimeOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:all"))
compileOnly("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:api")
runtimeOnly("mekanism:Mekanism:${minecraft_version}-${mekanism_version}:all") {
exclude(group: "com.blamejared.crafttweaker")
}

compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"))
runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}"))
compileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}")

implementation(fg.deobf("curse.maven:jade-324717:${jade_id}"))
compileOnly("curse.maven:jade-324717:${jade_id}")
}

sourceSets {
Expand All @@ -65,85 +78,51 @@ sourceSets {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

////////////////////
// Forge/Minecraft
minecraft {
mappings(channel: "official", version: "${minecraft_version}")

/**
* Configures properties common to all run configurations
*/
def commonRunProperties = {
workingDirectory(project.file("run"))

property("forge.logging.console.level", "debug")
property("fml.earlyprogresswindow", "false")
jvmArgs("--add-opens", "java.base/sun.security.util=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/java.util.jar=ALL-UNNAMED")

// See https://github.com/Vazkii/Patchouli#mixin-troubleshooting
property("mixin.env.remapRefMap", "true")
property("mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg")
// property "mixin.debug.export", "true"

mods {
appmek {
source(sourceSets.main)
}
}
// Minecraft
runs {
configureEach {
systemProperty("forge.logging.console.level", "debug")
modSource(project.sourceSets.main)
}

runs {
client {
with(commonRunProperties)
}
client {
}

server {
with(commonRunProperties)
}
server {
programArgument '--nogui'
}

data {
with(commonRunProperties)
args("--mod", "appmek", "--all", "--output", file("src/generated/resources/"), "--existing", file("src/main/resources"))
}
data {
programArguments.addAll "--mod", "appmek", "--all", "--output", file("src/generated/resources/").getAbsolutePath(), "--existing", file("src/main/resources/").getAbsolutePath()
}
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.release.set(17)
}

processResources {
inputs.property("version", project.version)

exclude(".cache")

filesMatching("META-INF/mods.toml") {
expand("version": project.version)
}
}

jar {
finalizedBy("reobfJar")

from(sourceSets.main.output.classesDirs)
from(sourceSets.main.output.resourcesDir)

manifest {
attributes([
"Specification-Title" : "Applied Mekanistics",
"Specification-Vendor" : "ramidzkh",
"Specification-Version" : "${project.version}",
"Implementation-Title" : "${project.name}",
"Implementation-Version" : "${project.version}",
"Implementation-Vendor" : "ramidzkh",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
version: version,
loader_version_range: loader_version_range,
neo_version_range: neo_version_range,
ae2_version_range: ae2_version_range,
mekanism_version_range: mekanism_version_range,
]
inputs.properties(replaceProperties)

filesMatching(["META-INF/mods.toml"]) {
expand replaceProperties
}
}

Expand Down
20 changes: 13 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
minecraft_version=1.20.1
neoforge_version=47.1.79
ae2_version=15.0.11
mekanism_version=10.4.0.14
jei_version=15.2.0.27
jade_id=4768593
minecraft_version=1.20.4
neoforge_version=20.4.118-beta
ae2_version=17.0.5-beta
mekanism_version=10.4.6.homebaked
jei_version=17.0.0.30
jade_id=4980188

org.gradle.daemon=false
loader_version_range=[2,)
neo_version_range=[20.4,)
ae2_version_range=[17.0.0,18.0.0)
mekanism_version_range=[10.4.0,10.5.0)

org.gradle.caching=true
org.gradle.parallel=true

# Temp fix for Spotless / Remove Unused Imports:
# https://github.com/diffplug/spotless/issues/834
Expand Down
58 changes: 35 additions & 23 deletions src/main/java/me/ramidzkh/mekae2/AMItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredItem;
import net.neoforged.neoforge.registries.DeferredRegister;

import me.ramidzkh.mekae2.ae2.ChemicalP2PTunnelPart;
import me.ramidzkh.mekae2.item.ChemicalPortableCellItem;
import me.ramidzkh.mekae2.item.ChemicalStorageCell;

import appeng.api.parts.PartModels;
import appeng.block.AEBaseBlock;
import appeng.block.AEBaseBlockItem;
import appeng.items.AEBaseItem;
import appeng.items.materials.MaterialItem;
import appeng.items.parts.PartItem;
import appeng.items.parts.PartModelsHelper;
Expand All @@ -26,8 +29,7 @@ public class AMItems {

private static final DeferredRegister<CreativeModeTab> TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB,
AppliedMekanistics.ID);
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS,
AppliedMekanistics.ID);
private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(AppliedMekanistics.ID);

public static void initialize(IEventBus bus) {
TABS.register(bus);
Expand All @@ -42,62 +44,72 @@ private static Item.Properties properties() {
return new Item.Properties();
}

public static final RegistryObject<CreativeModeTab> CREATIVE_TAB = TABS.register("main",
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> CREATIVE_TAB = TABS.register("main",
() -> CreativeModeTab.builder()
.title(AMText.CREATIVE_TAB.formatted())
.icon(() -> new ItemStack(AMItems.CHEMICAL_CELL_64K.get()))
.displayItems((params, output) -> {
for (var entry : ITEMS.getEntries()) {
output.accept(entry.get());
var item = entry.get();

// For block items, the block controls the creative tab
if (item instanceof AEBaseBlockItem baseItem
&& baseItem.getBlock() instanceof AEBaseBlock baseBlock) {
baseBlock.addToMainCreativeTab(output);
} else if (item instanceof AEBaseItem baseItem) {
baseItem.addToMainCreativeTab(output);
} else {
output.accept(item);
}
}
})
.build());

public static final RegistryObject<Item> CHEMICAL_CELL_HOUSING = ITEMS.register("chemical_cell_housing",
public static final DeferredItem<Item> CHEMICAL_CELL_HOUSING = ITEMS.register("chemical_cell_housing",
AMItems::basic);

public static final RegistryObject<Item> CHEMICAL_CELL_CREATIVE = ITEMS.register("creative_chemical_cell",
public static final DeferredItem<Item> CHEMICAL_CELL_CREATIVE = ITEMS.register("creative_chemical_cell",
() -> new CreativeCellItem(properties().stacksTo(1).rarity(Rarity.EPIC)));

public static final RegistryObject<Item> CHEMICAL_CELL_1K = ITEMS.register("chemical_storage_cell_1k",
public static final DeferredItem<Item> CHEMICAL_CELL_1K = ITEMS.register("chemical_storage_cell_1k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_1K, CHEMICAL_CELL_HOUSING.get()));
public static final RegistryObject<Item> CHEMICAL_CELL_4K = ITEMS.register("chemical_storage_cell_4k",
public static final DeferredItem<Item> CHEMICAL_CELL_4K = ITEMS.register("chemical_storage_cell_4k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_4K, CHEMICAL_CELL_HOUSING.get()));
public static final RegistryObject<Item> CHEMICAL_CELL_16K = ITEMS.register("chemical_storage_cell_16k",
public static final DeferredItem<Item> CHEMICAL_CELL_16K = ITEMS.register("chemical_storage_cell_16k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_16K, CHEMICAL_CELL_HOUSING.get()));
public static final RegistryObject<Item> CHEMICAL_CELL_64K = ITEMS.register("chemical_storage_cell_64k",
public static final DeferredItem<Item> CHEMICAL_CELL_64K = ITEMS.register("chemical_storage_cell_64k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_64K, CHEMICAL_CELL_HOUSING.get()));
public static final RegistryObject<Item> CHEMICAL_CELL_256K = ITEMS.register("chemical_storage_cell_256k",
public static final DeferredItem<Item> CHEMICAL_CELL_256K = ITEMS.register("chemical_storage_cell_256k",
() -> new ChemicalStorageCell(properties().stacksTo(1), StorageTier.SIZE_256K,
CHEMICAL_CELL_HOUSING.get()));

public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_1K = ITEMS.register(
public static final DeferredItem<Item> PORTABLE_CHEMICAL_CELL_1K = ITEMS.register(
"portable_chemical_storage_cell_1k",
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE,
StorageTier.SIZE_1K, properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_4K = ITEMS.register(
public static final DeferredItem<Item> PORTABLE_CHEMICAL_CELL_4K = ITEMS.register(
"portable_chemical_storage_cell_4k", () -> new ChemicalPortableCellItem(18,
AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_4K, properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_16K = ITEMS.register(
public static final DeferredItem<Item> PORTABLE_CHEMICAL_CELL_16K = ITEMS.register(
"portable_chemical_storage_cell_16k",
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_16K,
properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_64K = ITEMS.register(
public static final DeferredItem<Item> PORTABLE_CHEMICAL_CELL_64K = ITEMS.register(
"portable_chemical_storage_cell_64k",
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_64K,
properties().stacksTo(1), 0));
public static final RegistryObject<Item> PORTABLE_CHEMICAL_CELL_256K = ITEMS.register(
public static final DeferredItem<Item> PORTABLE_CHEMICAL_CELL_256K = ITEMS.register(
"portable_chemical_storage_cell_256k",
() -> new ChemicalPortableCellItem(18, AMMenus.PORTABLE_CHEMICAL_CELL_TYPE, StorageTier.SIZE_256K,
properties().stacksTo(1), 0));

public static final RegistryObject<PartItem<ChemicalP2PTunnelPart>> CHEMICAL_P2P_TUNNEL = Util.make(() -> {
public static final DeferredItem<PartItem<ChemicalP2PTunnelPart>> CHEMICAL_P2P_TUNNEL = Util.make(() -> {
PartModels.registerModels(PartModelsHelper.createModels(ChemicalP2PTunnelPart.class));
return ITEMS.register("chemical_p2p_tunnel",
() -> new PartItem<>(properties(), ChemicalP2PTunnelPart.class, ChemicalP2PTunnelPart::new));
});

public static RegistryObject<Item> get(Tier tier) {
public static DeferredItem<Item> get(Tier tier) {
return switch (tier) {
case _1K -> CHEMICAL_CELL_1K;
case _4K -> CHEMICAL_CELL_4K;
Expand All @@ -107,7 +119,7 @@ public static RegistryObject<Item> get(Tier tier) {
};
}

public static RegistryObject<Item> getPortableCell(Tier tier) {
public static DeferredItem<Item> getPortableCell(Tier tier) {
return switch (tier) {
case _1K -> PORTABLE_CHEMICAL_CELL_1K;
case _4K -> PORTABLE_CHEMICAL_CELL_4K;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/ramidzkh/mekae2/AMMenus.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package me.ramidzkh.mekae2;

import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;

import appeng.api.implementations.menuobjects.IPortableTerminal;
import appeng.client.gui.me.common.MEStorageScreen;
Expand Down
Loading

0 comments on commit 2538025

Please sign in to comment.