-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72c5aa9
commit 9489de2
Showing
6 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
kubejs/client_scripts/jei_categories/_jei_category_helper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// priority: 100 | ||
|
||
//Java imports | ||
//Mysterious Conversion recipe type | ||
const ConversionRecipe = Java.loadClass('com.simibubi.create.compat.jei.ConversionRecipe') | ||
//Used for creating Drawable graphics for JEI | ||
const ResourceLocation = Java.loadClass('net.minecraft.resources.ResourceLocation'); | ||
const JEIIDrawableAnimated = Java.loadClass('mezz.jei.api.gui.drawable.IDrawableAnimated'); | ||
//Used to make the FE energy tooltip when hovering over the energy bar | ||
const ThermalStringHelper = Java.loadClass('cofh.lib.util.helpers.StringHelper'); | ||
//Used for to draw block models in jei categories | ||
const Boolean = Java.loadClass('java.lang.Boolean'); | ||
const Axis = Java.loadClass('com.mojang.math.Axis'); | ||
const BlockStateProperties = Java.loadClass('net.minecraft.world.level.block.state.properties.BlockStateProperties'); | ||
const AnimatedKinetics = Java.loadClass('com.simibubi.create.compat.jei.category.animations.AnimatedKinetics'); | ||
|
||
//initialize globals | ||
if (!global.jeiCategories) global.jeiCategories = {} |
103 changes: 103 additions & 0 deletions
103
kubejs/client_scripts/jei_categories/alchemy/alchemy_handlers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
if (!global.jeiCategories.alchemy) global.jeiCategories.alchemy = { | ||
recipeType: null, | ||
resources: { | ||
energyEmpty: null, | ||
energyFull: null, | ||
alchemyArrow: null | ||
}, | ||
handlers: { | ||
verifyRecipe: undefined, | ||
setRecipe: undefined, | ||
draw: undefined, | ||
tooltips: undefined | ||
}, | ||
loadResources: undefined | ||
}; | ||
|
||
global.jeiCategories.alchemy.loadResources = function(guiHelper) { | ||
this.resources.energyEmpty = guiHelper.createDrawable( | ||
new ResourceLocation("cabin:textures/gui/jei/widgets.png"), | ||
0, | ||
0, | ||
14, | ||
18 | ||
); | ||
this.resources.energyFull = guiHelper.createAnimatedDrawable( | ||
guiHelper.createDrawable(new ResourceLocation("cabin:textures/gui/jei/widgets.png"), 14, 0, 14, 18), | ||
40, | ||
JEIIDrawableAnimated.StartDirection.BOTTOM, | ||
false | ||
); | ||
this.resources.alchemyArrow = guiHelper.createDrawable( | ||
new ResourceLocation("cabin:textures/gui/jei/widgets.png"), | ||
28, | ||
0, | ||
42, | ||
18 | ||
); | ||
} | ||
|
||
global.jeiCategories.alchemy.handlers.verifyRecipe = (jeiHelpers, recipe) => { | ||
// IMPORTANT: Always return true or false. If you do not, it could crash the game or cause JEI to not work properly. | ||
if (!recipe) return false; | ||
if (!recipe.data) return false; | ||
if (!recipe.data.input) return false; | ||
if (!recipe.data.output) return false; | ||
|
||
return true; | ||
} | ||
|
||
global.jeiCategories.alchemy.handlers.setRecipe = (jeiHelpers, builder, recipe, focuses) => { | ||
let guiHelper = jeiHelpers.getGuiHelper() | ||
let inputItems = recipe.data.input; | ||
|
||
for(let i=0;i<inputItems.length;++i) { | ||
builder.addSlot("INPUT", 20+(20*i), 45) | ||
.addItemStack(Item.of(inputItems[i])) | ||
.setStandardSlotBackground() | ||
.setBackground(guiHelper.getSlotDrawable(), -1, -1); | ||
} | ||
builder.addSlot("CATALYST", 75, 45) | ||
.addItemStack(Item.of('minecraft:hopper_minecart')); | ||
|
||
builder.addSlot("OUTPUT", 114, 45) | ||
.addItemStack(Item.of(recipe.data.output)) | ||
.setOutputSlotBackground() | ||
.setBackground(guiHelper.getOutputSlot(), -1, -1); | ||
|
||
} | ||
|
||
global.jeiCategories.alchemy.handlers.draw = (jeiHelpers, recipe, recipeSlotsView, guiGraphics, mouseX, mouseY) => { | ||
global.jeiCategories.alchemy.resources.energyEmpty.draw(guiGraphics, 5, 44); | ||
global.jeiCategories.alchemy.resources.energyFull.draw(guiGraphics, 5, 44); | ||
global.jeiCategories.alchemy.resources.alchemyArrow.draw(guiGraphics, 60, 44); | ||
|
||
//I don't fully understand this matrix stuff, most of it is copied from Create | ||
let matrixStack = guiGraphics.pose(); | ||
matrixStack.pushPose(); | ||
matrixStack.translate(2, 22, 200); | ||
matrixStack.translate(75, 5, 0); | ||
matrixStack.mulPose(Axis.XP.rotationDegrees(-15.5)); | ||
matrixStack.mulPose(Axis.YP.rotationDegrees(22.5 + 90)); | ||
|
||
AnimatedKinetics.defaultBlockElement(Block.getBlock('thermal:machine_frame').defaultBlockState()) | ||
.rotateBlock(0, 0, 0) | ||
.scale(20) | ||
.render(guiGraphics); | ||
|
||
matrixStack.translate(0, 20, 0); | ||
|
||
AnimatedKinetics.defaultBlockElement(Block.getBlock('createdeco:green_industrial_iron_lamp').defaultBlockState().setValue(BlockStateProperties.FACING, Direction.DOWN).setValue(BlockStateProperties.LIT, new Boolean(true))) | ||
.rotateBlock(0, 0, 0) | ||
.scale(20) | ||
.render(guiGraphics); | ||
|
||
matrixStack.popPose(); | ||
} | ||
|
||
global.jeiCategories.alchemy.handlers.tooltips = (jeiHelpers, recipe, recipeSlotsView, mouseX, mouseY) => { | ||
if (mouseX>5&&mouseX<18&&mouseY>44&&mouseY<61) { | ||
return [ThermalStringHelper.getTextComponent("info.cofh.energy").append(": " + ThermalStringHelper.format(recipe.data.energy) + " " + ThermalStringHelper.localize("info.cofh.unit_rf"))]; | ||
} | ||
return []; | ||
} |
38 changes: 38 additions & 0 deletions
38
kubejs/client_scripts/jei_categories/alchemy/alchemy_kubejs_events.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
JEIAddedEvents.registerCategories((event) => { | ||
event.custom("kubejs:alchemy", (category) => { | ||
let guiHelper = category.jeiHelpers.getGuiHelper(); | ||
global.jeiCategories.alchemy.recipeType = category.recipeType; | ||
global.jeiCategories.alchemy.loadResources(guiHelper); | ||
|
||
category.title("Alchemical Laser") | ||
.background(guiHelper.createBlankDrawable(146, 70)) | ||
.icon(guiHelper.createDrawableItemStack(Item.of('kubejs:alchemical_laser'))) | ||
.setIsRecipeHandledByCategory((recipe) => { | ||
return global.jeiCategories.alchemy.handlers["verifyRecipe"](category.jeiHelpers, recipe); | ||
}) | ||
.setSetRecipeHandler((builder, recipe, focuses) => { | ||
global.jeiCategories.alchemy.handlers["setRecipe"](category.jeiHelpers, builder, recipe, focuses); | ||
}) | ||
.setDrawHandler((recipe, recipeSlotsView, guiGraphics, mouseX, mouseY) => { | ||
global.jeiCategories.alchemy.handlers["draw"](category.jeiHelpers, recipe, recipeSlotsView, guiGraphics, mouseX, mouseY); | ||
}) | ||
.setTooltipHandler((recipe, recipeSlotsView, mouseX, mouseY) => { | ||
return global.jeiCategories.alchemy.handlers["tooltips"](category.jeiHelpers, recipe, recipeSlotsView, mouseX, mouseY); | ||
}) | ||
}); | ||
}); | ||
|
||
JEIAddedEvents.registerRecipeCatalysts(event => { | ||
let addRecipeCatalyst = function(ingredient, recipeTypes) { | ||
return event.data["addRecipeCatalyst(net.minecraft.world.item.ItemStack,mezz.jei.api.recipe.RecipeType[])"](ingredient, recipeTypes); | ||
} | ||
addRecipeCatalyst(Item.of('thermal:machine_frame'), [global.jeiCategories.alchemy.recipeType]); | ||
addRecipeCatalyst(Item.of('kubejs:alchemical_laser'), [global.jeiCategories.alchemy.recipeType]); | ||
addRecipeCatalyst(Item.of('minecraft:hopper_minecart'), [global.jeiCategories.alchemy.recipeType]); | ||
}) | ||
|
||
JEIAddedEvents.registerRecipes((event) => { | ||
event.custom("kubejs:alchemy") | ||
.add({input: ["thermal:flux_magnet", "minecraft:basalt"], output: "thermal:basalz_rod", energy: 80}) | ||
.add({input: ["ae2:entropy_manipulator", "minecraft:snowball"], output: "thermal:blizz_rod", energy: 160}); | ||
}); |
5 changes: 0 additions & 5 deletions
5
...s/client_scripts/mysterious_conversion.js → ...s/jei_categories/mysterious_conversion.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.