Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dependencies {
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation group: 'com.illusivesoulworks.spectrelib', name: 'spectrelib-common', version: "${spectrelib_version}"
implementation group: 'com.electronwill.night-config', name: 'core', version: '3.6.5'
compileOnly "mezz.jei:jei-1.19.2-common-api:${jei_version}"
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public <T extends Recipe<C>, C extends Container> Optional<T> getRecipe(RecipeTy

@Override
public void selectRecipe(@Nonnull Recipe<?> recipe) {
this.cachedSelection = null;
super.selectRecipe(recipe);
this.syncPlayerRecipeData();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (C) 2020-2022 Illusive Soulworks
*
* Polymorph is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Polymorph is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Polymorph. If not, see <https://www.gnu.org/licenses/>.
*/

package com.illusivesoulworks.polymorph.common.integration;

import com.illusivesoulworks.polymorph.PolymorphConstants;
import com.illusivesoulworks.polymorph.client.recipe.RecipesWidget;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.recipe.transfer.IRecipeTransferContext;
import mezz.jei.api.recipe.transfer.IRecipeTransferListener;
import mezz.jei.api.recipe.transfer.RecipeTransferResult;
import mezz.jei.api.registration.IRecipeTransferRegistration;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Recipe;

@JeiPlugin
public final class PolymorphJeiPlugin implements IModPlugin {

@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(PolymorphConstants.MOD_ID, "recipe_transfer");
}

@Override
public void registerRecipeTransferHandlers(IRecipeTransferRegistration registration) {
registration.addRecipeTransferListener(new PolymorphRecipeTransferListener());
}

private static final class PolymorphRecipeTransferListener
implements IRecipeTransferListener {

@Override
public void afterRecipeTransfer(IRecipeTransferContext<?, ?> context,
RecipeTransferResult result) {
if (result == RecipeTransferResult.SUCCESS &&
context.getRecipe() instanceof Recipe<?> recipe) {
RecipesWidget.get().ifPresent(widget -> widget.selectRecipe(recipe.getId()));
}
}
}
}
4 changes: 3 additions & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ dependencies {
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation project(":common")
implementation group: 'com.electronwill.night-config', name: 'core', version: '3.6.5'
compileOnly "mezz.jei:jei-1.19.2-common-api:${jei_version}"
testCompileOnly "mezz.jei:jei-1.19.2-common-api:${jei_version}"

include group: 'com.illusivesoulworks.spectrelib', name: 'spectrelib-fabric', version: "${spectrelib_version}"

Expand Down Expand Up @@ -72,7 +74,7 @@ processResources {
filesMatching("fabric.mod.json") {
expand 'version': project.version, 'fabric_mc_version_range': project.fabric_mc_version_range, 'license': project.license,
'mod_id': project.mod_id, 'mod_author': project.mod_author, 'mod_description': project.mod_description,
'mod_name': project.mod_name, 'issue_tracker': project.issue_tracker
'mod_name': project.mod_name, 'issue_tracker': project.issue_tracker, 'jei_version': project.jei_version
}

filesMatching("pack.mcmeta") {
Expand Down
6 changes: 6 additions & 0 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
],
"cardinal-components": [
"com.illusivesoulworks.polymorph.common.components.PolymorphFabricComponents"
],
"jei_mod_plugin": [
"com.illusivesoulworks.polymorph.common.integration.PolymorphJeiPlugin"
]
},
"custom": {
Expand All @@ -40,5 +43,8 @@
"fabric": "*",
"minecraft": "${fabric_mc_version_range}",
"java": ">=17"
},
"suggests": {
"jei": ">=${jei_version}"
}
}
4 changes: 3 additions & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ dependencies {
implementation fg.deobf("curse.maven:fastfurnace-299540:${file_fastfurnace}")
implementation fg.deobf("curse.maven:fastsuite-475117:${file_fastsuite}")
implementation fg.deobf("curse.maven:placebo-283644:${file_placebo}")
compileOnly "mezz.jei:jei-1.19.2-common-api:${jei_version}"
testCompileOnly "mezz.jei:jei-1.19.2-common-api:${jei_version}"

implementation fg.deobf(group: 'com.illusivesoulworks.spectrelib', name: 'spectrelib-forge', version: "${spectrelib_range}")
jarJar fg.deobf(group: 'com.illusivesoulworks.spectrelib', name: 'spectrelib-forge', version: "${spectrelib_range}") {
Expand All @@ -137,7 +139,7 @@ def replaceResources = tasks.register("replaceResources", Copy) {
include "META-INF/mods.toml"
expand 'version': version, 'forge_mc_version_range': forge_mc_version_range, 'forge_version_range': forge_version_range,
'license': license, 'mod_id': mod_id, 'mod_author': mod_author, 'mod_description': mod_description,
'mod_name': mod_name, 'issue_tracker': issue_tracker
'mod_name': mod_name, 'issue_tracker': issue_tracker, 'jei_version': jei_version
}
it.from(project(":common").sourceSets.main.resources) {
include "pack.mcmeta"
Expand Down
6 changes: 6 additions & 0 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ ${mod_description}
versionRange="${forge_mc_version_range}"
ordering="NONE"
side="BOTH"
[[dependencies.polymorph]]
modId="jei"
mandatory=false
versionRange="[${jei_version},)"
ordering="NONE"
side="BOTH"
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ file_fastworkbench=4029996
file_fastfurnace=4028348
file_fastsuite=4028357
file_placebo=4028341
jei_version=11.63.0.1078

# Fabric
fabric_version=0.75.1+1.19.2
Expand Down