Skip to content

Commit

Permalink
Initial port to 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Apr 25, 2024
1 parent c53a41c commit 6eb4b06
Show file tree
Hide file tree
Showing 743 changed files with 8,878 additions and 11,027 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL"

on:
push:
branches: [ "1.20.4" ]
branches: [ "1.20.5" ]
pull_request:
branches: [ "1.20.4" ]
branches: [ "1.20.5" ]
types:
- synchronize
- opened
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
java-version: 21

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gametests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "Run Game Tests"

on:
push:
branches: [ "1.20.4" ]
branches: [ "1.20.5" ]
pull_request:
branches: [ "1.20.4" ]
branches: [ "1.20.5" ]
types:
- synchronize
- opened
Expand All @@ -23,10 +23,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: 21
distribution: 'temurin'

- name: Build with Gradle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
build/neoForm
~/.gradle
.gradle
- name: Set up JDK 17
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: 21
distribution: 'temurin'
settings-path: ${{ github.workspace }} # location for the settings.xml file

Expand Down
2 changes: 1 addition & 1 deletion annotation-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {
}

dependencies {
implementation "com.blamejared.crafttweaker:CraftTweaker-neoforge-${minecraft_version}:${crafttweaker_version}"
implementation "com.blamejared.crafttweaker:CraftTweaker-neoforge-${previous_minor_minecraft_version}:${crafttweaker_version}"
//Version of GSON used by vanilla (and thus packed and already downloaded)
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation "com.squareup:javapoet:1.13.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <p>
* Technically we violate this with the Wrapping methods, but if new methods are added to a wrapper, a manually triggered full rebuild should catch it.
*/
@SupportedSourceVersion(SourceVersion.RELEASE_17)
@SupportedSourceVersion(SourceVersion.RELEASE_21)
@SupportedAnnotationTypes({
MekAnnotationProcessors.ANNOTATION_COMPUTER_METHOD,
MekAnnotationProcessors.ANNOTATION_SYNTHETIC_COMPUTER_METHOD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* Gathering (Gradle) annotation processor which generates a ComputerMethodRegistry for the Factories generated by the {@link ComputerMethodProcessor} processor.
*/
@SupportedSourceVersion(SourceVersion.RELEASE_17)
@SupportedSourceVersion(SourceVersion.RELEASE_21)
@SupportedAnnotationTypes(MekAnnotationProcessors.COMPUTER_METHOD_FACTORY_ANNOTATION_CLASSNAME)
@SupportedOptions(MekAnnotationProcessors.MODULE_OPTION)
public class MethodFactoryProcessor extends AbstractProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ public Set<String> getSupportedAnnotationTypes() {

@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.RELEASE_17;
return SourceVersion.RELEASE_21;
}
}
38 changes: 22 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def setupTasks(SourceSet sourceSet) {
outputs.upToDateWhen { false }
def modsToml = copySpec {
from(sourceSet.resources) {
include "META-INF/mods.toml"
include "META-INF/neoforge.mods.toml"
expand versionProperties
}
}
Expand All @@ -234,7 +234,7 @@ def setupTasks(SourceSet sourceSet) {
tasks.named(sourceSet.getProcessResourcesTaskName(), ProcessResources).configure { ProcessResources process ->
setGroup("process resources")
process.duplicatesStrategy(DuplicatesStrategy.FAIL)
process.exclude('META-INF/mods.toml')
process.exclude('META-INF/neoforge.mods.toml')
process.from("${projectDir}") { include 'logo.png' }
//Depend on the compile task so that we can map the computer methods as needed
dependsOn(compileTask)
Expand Down Expand Up @@ -274,7 +274,8 @@ project.base.archivesName = "Mekanism"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of("${java_version}"))
vendor.set(JvmVendorSpec.JETBRAINS)
//TODO - 1.20.5: Figure out why jetbrains jdk isn't found by foojay when requesting java 21 even though they have a release for JDK 21
//vendor.set(JvmVendorSpec.JETBRAINS)
}
withSourcesJar()
}
Expand Down Expand Up @@ -424,16 +425,17 @@ dependencies {
//We use https://github.com/quicktheories/QuickTheories to allow for implementing property based testing
testImplementation "org.quicktheories:quicktheories:${quicktheories_version}"

compileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
compileOnly("mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}")
compileOnly("mezz.jei:jei-${previous_minor_minecraft_version}-common-api:${jei_version}")
compileOnly("mezz.jei:jei-${previous_minor_minecraft_version}-neoforge-api:${jei_version}")
if (recipe_viewer == "jei" || recipe_viewer == "hybrid") {
runtimeOnly("mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}")
//TODO - 1.20.5: Re-enable when JEI updates
//runtimeOnly("mezz.jei:jei-${previous_minor_minecraft_version}-neoforge:${jei_version}")
}

compileOnly("dev.emi:emi-neoforge:${emi_version}+${minecraft_version}:api")
compileOnly("dev.emi:emi-neoforge:${emi_version}+${previous_minor_minecraft_version}:api")

if (recipe_viewer == "emi" || recipe_viewer == "hybrid") {
runtimeOnly("dev.emi:emi-neoforge:${emi_version}+${minecraft_version}")
runtimeOnly("dev.emi:emi-neoforge:${emi_version}+${previous_minor_minecraft_version}")
}

//TODO - 1.19: Re-enable once https://github.com/Chisel-Team/ConnectedTexturesMod/pull/204 is merged
Expand All @@ -448,14 +450,16 @@ dependencies {
transitive = false
}*/
compileOnly("curse.maven:jade-api-324717:${jade_api_id}")
runtimeOnly("curse.maven:jade-324717:${jade_id}")
//TODO - 1.20.5: Re-enable when Jade updates
//runtimeOnly("curse.maven:jade-324717:${jade_id}")
compileOnly("mcp.mobius.waila:wthit-api:neo-${wthit_version}")

implementation("com.blamejared.crafttweaker:CraftTweaker-neoforge-${minecraft_version}:${crafttweaker_version}")
//TODO - 1.20.5: Switch back to implementation when it updates
compileOnly("com.blamejared.crafttweaker:CraftTweaker-neoforge-${previous_minor_minecraft_version}:${crafttweaker_version}")
//TODO - 1.20.2: move back to implementation
compileOnly("com.blamejared.jeitweaker:JeiTweaker-forge-${previous_minecraft_version}:${jeitweaker_version}")

compileOnly("dev.gigaherz.jsonthings:JsonThings-${minecraft_version}:${json_things_version}")
compileOnly("dev.gigaherz.jsonthings:JsonThings-${previous_minor_minecraft_version}:${json_things_version}")

//Mods we have dependencies on but don't bother loading into the dev environment
//compileOnly("curse.maven:projecte-api-226410:${projecte_api_id}")
Expand All @@ -464,15 +468,17 @@ dependencies {
compileOnly("top.theillusivec4.curios:curios-neoforge:${curios_version}:api")
compileOnly("com.blamejared.recipestages:RecipeStages:${recipe_stages_version}")
compileOnly("curse.maven:opencomputers2-437654:${oc2_id}")
compileOnly("cc.tweaked:cc-tweaked-${minecraft_version}-forge-api:${cc_tweaked_version}")
compileOnly("cc.tweaked:cc-tweaked-${previous_minor_minecraft_version}-forge-api:${cc_tweaked_version}")
//runtimeOnly("cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cc_tweaked_version}")
compileOnly("curse.maven:female-gender-forge-481655:${wildfire_gender_mod_id}")

//Dependencies for data generators for mod compat reference
datagenMainImplementation("appeng:appliedenergistics2-neoforge:${ae2_version}")
datagenMainRuntimeOnly("com.github.glitchfiend:GlitchCore-neoforge:${minecraft_version}-${glitchcore_version}")
datagenMainRuntimeOnly("com.github.glitchfiend:TerraBlender-neoforge:${minecraft_version}-${terrablender_version}")
datagenMainImplementation("com.github.glitchfiend:BiomesOPlenty-neoforge:${minecraft_version}-${biomesoplenty_version}")
//TODO - 1.20.5: Switch back to datagenMainImplementation
datagenMainCompileOnly("appeng:appliedenergistics2-neoforge:${ae2_version}")
//TODO - 1.20.5: Switch back to datagenMainImplementation
//datagenMainRuntimeOnly("com.github.glitchfiend:GlitchCore-neoforge:${previous_minor_minecraft_version}-${glitchcore_version}")
//datagenMainRuntimeOnly("com.github.glitchfiend:TerraBlender-neoforge:${previous_minor_minecraft_version}-${terrablender_version}")
datagenMainCompileOnly("com.github.glitchfiend:BiomesOPlenty-neoforge:${previous_minor_minecraft_version}-${biomesoplenty_version}")
//TODO - 1.20.2: Switch back to datagenMainImplementation
datagenMainCompileOnly("curse.maven:biomes-youll-go-247560:${byg_id}")
//TODO - 1.20.2: Switch back to datagenMainImplementation
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/groovy/mekanism/MergeJars.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MergeJars {

static List<String> getGeneralPathsToExclude(Project project, List<SourceSet> sourceSets) {
List<String> toExclude = new ArrayList<>()
toExclude.add('META-INF/mods.toml')
toExclude.add('META-INF/neoforge.mods.toml')
toExclude.add('META-INF/accesstransformer.cfg')
//This file doesn't exist until compile time
toExclude.add('META-INF/services/mekanism.common.integration.computer.IComputerMethodRegistry')
Expand Down Expand Up @@ -57,7 +57,7 @@ class MergeJars {
}

static void merge(Project project, List<SourceSet> sourceSets) {
//Generate folders, merge the access transformers and mods.toml files
//Generate folders, merge the access transformers and neoforge.mods.toml files
project.mkdir("$project.buildDir/generated/META-INF")
mergeBasic(project, sourceSets, 'META-INF/accesstransformer.cfg', (text, fileText) -> text + "\n" + fileText)
mergeModsTOML(project, sourceSets)
Expand All @@ -77,7 +77,7 @@ class MergeJars {
static List<Closure> getGeneratedClosures(Map<String, ?> versionProperties) {
List<Closure> generated = new ArrayList<>()
generated.add({ CopySpec c ->
c.include('META-INF/mods.toml')
c.include('META-INF/neoforge.mods.toml')
c.expand(versionProperties)
})
generated.add({ CopySpec c ->
Expand All @@ -87,7 +87,7 @@ class MergeJars {
}

private static void mergeModsTOML(Project project, List<SourceSet> sourceSets) {
mergeBasic(project, sourceSets, 'META-INF/mods.toml', (text, fileText) -> {
mergeBasic(project, sourceSets, 'META-INF/neoforge.mods.toml', (text, fileText) -> {
//Add all but the first four lines (which are duplicated between the files)
String[] lines = fileText.split("\n")
for (int i = 4; i < lines.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions docs/Development.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Development

Mekanism is developed for Minecraft 1.20.4 using NeoForge.
Mekanism is developed for Minecraft 1.20.5 using NeoForge.

## Prerequisites

* Gradle - Version 8.7 is known to work, your mileage with other versions may vary
* JDK - Version 17 is the target as that is what Mojang ships, but to run gradle you must use a minimum of JDK 11.
* JDK - Version 21 is the target as that is what Mojang ships, but to run gradle you must use a minimum of JDK 11.

## Directory Structure

Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx4G

java_version=17
minecraft_version=1.20.4
java_version=21
minecraft_version=1.20.5
#Used as a helper for porting when deps we use have not updated yet
previous_minecraft_version=1.20.1
previous_minor_minecraft_version=1.20.2
previous_minor_minecraft_version=1.20.4
loader_version_range=[2,)
forge_version=20.4.232
forge_version=20.5.3-beta
mod_version=10.5.19
#This determines the minimum version of forge required to use Mekanism
# Only bump it whenever we need access to a feature in forge that is not available in earlier versions
forge_version_range=[20.4.223,)
minecraft_version_range=[1.20.4]
forge_version_range=[20.5.1-beta,)
minecraft_version_range=[1.20.5]
#This specifies what type of release it will be uploaded to CurseForge and Modrinth as
# options are: alpha, beta, release
release_type=beta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import mekanism.additions.common.item.ItemBalloon;
import mekanism.additions.common.item.ItemWalkieTalkie.WalkieData;
import mekanism.additions.common.registries.AdditionsBlocks;
import mekanism.additions.common.registries.AdditionsDataComponents;
import mekanism.additions.common.registries.AdditionsEntityTypes;
import mekanism.additions.common.registries.AdditionsItems;
import mekanism.api.text.EnumColor;
Expand All @@ -25,15 +26,15 @@
import net.minecraft.client.renderer.entity.WitherSkeletonRenderer;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
import net.neoforged.neoforge.client.event.ModelEvent.BakingCompleted;
import net.neoforged.neoforge.client.event.ModelEvent.RegisterAdditional;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;

@Mod.EventBusSubscriber(modid = MekanismAdditions.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = MekanismAdditions.MODID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
public class AdditionsClientRegistration {

private AdditionsClientRegistration() {
Expand All @@ -42,8 +43,8 @@ private AdditionsClientRegistration() {
@SubscribeEvent
public static void init(FMLClientSetupEvent event) {
event.enqueueWork(() -> ClientRegistrationUtil.setPropertyOverride(AdditionsItems.WALKIE_TALKIE, MekanismAdditions.rl("channel"), (stack, world, entity, seed) -> {
WalkieData data = WalkieData.get(stack);
return data != null && data.isRunning() ? data.getChannel() : 0;
WalkieData data = stack.getOrDefault(AdditionsDataComponents.WALKIE_DATA, WalkieData.DEFAULT);
return data.running() ? data.channel() : 0;
}));
}

Expand Down
33 changes: 20 additions & 13 deletions src/additions/java/mekanism/additions/common/MekanismAdditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import mekanism.additions.common.block.BlockObsidianTNT;
import mekanism.additions.common.config.MekanismAdditionsConfig;
import mekanism.additions.common.entity.baby.EntityBabyStray;
import mekanism.additions.common.registries.AdditionsAttachmentTypes;
import mekanism.additions.common.registries.AdditionsBiomeModifierSerializers;
import mekanism.additions.common.registries.AdditionsBlocks;
import mekanism.additions.common.registries.AdditionsCreativeTabs;
import mekanism.additions.common.registries.AdditionsDataComponents;
import mekanism.additions.common.registries.AdditionsEntityTypes;
import mekanism.additions.common.registries.AdditionsItems;
import mekanism.additions.common.registries.AdditionsSounds;
Expand All @@ -23,7 +23,7 @@
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.entity.SpawnPlacementTypes;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.DispenserBlock;
Expand All @@ -36,6 +36,7 @@
import net.neoforged.fml.event.config.ModConfigEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.SpawnPlacementRegisterEvent;
import net.neoforged.neoforge.event.server.ServerStartingEvent;
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -65,7 +66,8 @@ public MekanismAdditions(ModContainer modContainer, IEventBus modEventBus) {

modEventBus.addListener(this::commonSetup);
modEventBus.addListener(this::onConfigLoad);
AdditionsAttachmentTypes.ATTACHMENT_TYPES.register(modEventBus);
modEventBus.addListener(this::spawnPlacements);
AdditionsDataComponents.DATA_COMPONENTS.register(modEventBus);
AdditionsItems.ITEMS.register(modEventBus);
AdditionsBlocks.BLOCKS.register(modEventBus);
AdditionsCreativeTabs.CREATIVE_TABS.register(modEventBus);
Expand All @@ -74,7 +76,7 @@ public MekanismAdditions(ModContainer modContainer, IEventBus modEventBus) {
AdditionsBiomeModifierSerializers.BIOME_MODIFIER_SERIALIZERS.register(modEventBus);
AdditionsStructureModifierSerializers.STRUCTURE_MODIFIER_SERIALIZERS.register(modEventBus);

//Set our version number to match the mods.toml file, which matches the one in our build.gradle
//Set our version number to match the neoforge.mods.toml file, which matches the one in our build.gradle
versionNumber = new Version(modContainer);
}

Expand Down Expand Up @@ -104,13 +106,6 @@ public void launchClient() {

private void commonSetup(FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
//Setup some stuff related to entities
//Register spawn controls for the baby entities based on the vanilla spawn controls
registerSpawnControls(AdditionsEntityTypes.BABY_CREEPER, AdditionsEntityTypes.BABY_ENDERMAN, AdditionsEntityTypes.BABY_SKELETON,
AdditionsEntityTypes.BABY_WITHER_SKELETON);
//Slightly different restrictions for the baby stray, as strays have a slightly different spawn restriction
SpawnPlacements.register(AdditionsEntityTypes.BABY_STRAY.get(), SpawnPlacements.Type.ON_GROUND,
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EntityBabyStray::spawnRestrictions);
//Dispenser behavior
DispenserBlock.registerBehavior(AdditionsBlocks.OBSIDIAN_TNT, new DefaultDispenseItemBehavior() {
@NotNull
Expand All @@ -130,10 +125,22 @@ protected ItemStack execute(@NotNull BlockSource source, @NotNull ItemStack stac
Mekanism.logger.info("Loaded 'Mekanism: Additions' module.");
}

//TODO - 1.20.5: Do we want to move the spawn placements to being registered as part of mek entity type creation like we do for attributes
private void spawnPlacements(SpawnPlacementRegisterEvent event) {
//Setup some stuff related to entities
//Register spawn controls for the baby entities based on the vanilla spawn controls
registerSpawnControls(event, AdditionsEntityTypes.BABY_CREEPER, AdditionsEntityTypes.BABY_ENDERMAN, AdditionsEntityTypes.BABY_SKELETON,
AdditionsEntityTypes.BABY_WITHER_SKELETON);
//Slightly different restrictions for the baby stray, as strays have a slightly different spawn restriction
event.register(AdditionsEntityTypes.BABY_STRAY.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EntityBabyStray::spawnRestrictions,
SpawnPlacementRegisterEvent.Operation.AND);
}

@SafeVarargs
private static void registerSpawnControls(Supplier<? extends EntityType<? extends Monster>>... entityTypeROs) {
private static void registerSpawnControls(SpawnPlacementRegisterEvent event, Supplier<? extends EntityType<? extends Monster>>... entityTypeROs) {
for (Supplier<? extends EntityType<? extends Monster>> entityTypeRO : entityTypeROs) {
SpawnPlacements.register(entityTypeRO.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Monster::checkMonsterSpawnRules);
event.register(entityTypeRO.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Monster::checkMonsterSpawnRules,
SpawnPlacementRegisterEvent.Operation.AND);
}
}

Expand Down
Loading

0 comments on commit 6eb4b06

Please sign in to comment.