Skyriis Posted September 21, 2022 Posted September 21, 2022 Hey Guys, i'm working on a BlockEntity which processes Items into "Molten Material" and one or two Molten Material(s) into a (new) Item. Right now i'm working with custom json files in my data folder for the processing: Molten Material Class: Spoiler @RequiredArgsConstructor @ToString public class KilnMoltenMaterial { public static final Codec<KilnMoltenMaterial> CODEC = RecordCodecBuilder.create(instance -> instance.group( Codec.BOOL.fieldOf("rightBar").forGetter(KilnMoltenMaterial::isRightBar), ResourceLocation.CODEC.fieldOf("moltenType").forGetter(KilnMoltenMaterial::getMoltenType), Codec.INT.fieldOf("red").forGetter(KilnMoltenMaterial::getRed), Codec.INT.fieldOf("green").forGetter(KilnMoltenMaterial::getGreen), Codec.INT.fieldOf("blue").forGetter(KilnMoltenMaterial::getBlue), Codec.INT.fieldOf("alpha").forGetter(KilnMoltenMaterial::getAlpha) ).apply(instance, KilnMoltenMaterial::new)); @Getter private final boolean rightBar; @Getter private final ResourceLocation moltenType; @Getter private final int red; @Getter private final int green; @Getter private final int blue; @Getter private final int alpha; } ItemStack -> MoltenMaterial "Recipe" class: Spoiler @RequiredArgsConstructor(staticName = "of") @ToString public class KilnMeltingRecipe { public static final Codec<KilnMeltingRecipe> CODEC = RecordCodecBuilder.create(instance -> instance.group( ItemStack.CODEC.fieldOf("input").forGetter(KilnMeltingRecipe::getInput), ResourceLocation.CODEC.fieldOf("outputTypeId").forGetter(KilnMeltingRecipe::getOutputID), Codec.INT.fieldOf("outputAmount").forGetter(KilnMeltingRecipe::getOutputAmount) ).apply(instance, KilnMeltingRecipe::new) ); @Getter private final ItemStack input; @Getter private final ResourceLocation outputID; // Molten Material Type ID @Getter private final int outputAmount; } MoltenMaterial(s) -> ItemStack "Recipe" class: Spoiler @RequiredArgsConstructor @ToString public class KilnMixingRecipe implements Comparable<KilnMixingRecipe> { public static final ResourceLocation EMPTY = new ResourceLocation("minecraft:air"); public static final Codec<KilnMixingRecipe> CODEC = RecordCodecBuilder.create(instance -> instance.group( ResourceLocation.CODEC.optionalFieldOf("leftInput", EMPTY).forGetter(KilnMixingRecipe::getLeftInput), Codec.INT.optionalFieldOf("leftInputAmount", 0).forGetter(KilnMixingRecipe::getLeftInputAmount), ResourceLocation.CODEC.optionalFieldOf("rightInput", EMPTY).forGetter(KilnMixingRecipe::getRightInput), Codec.INT.optionalFieldOf("rightInputAmount", 0).forGetter(KilnMixingRecipe::getRightInputAmount), ItemStack.CODEC.fieldOf("output").forGetter(KilnMixingRecipe::getOutput) ).apply(instance, KilnMixingRecipe::new) ); @Getter private final ResourceLocation leftInput; @Getter private final int leftInputAmount; @Getter private final ResourceLocation rightInput; @Getter private final int rightInputAmount; @Getter private final ItemStack output; public static KilnMixingRecipe of(ItemStack output, @Nullable ResourceLocation leftInput, int leftInputAmount, @Nullable ResourceLocation rightInput, int rightInputAmount) { return new KilnMixingRecipe(leftInput == null ? EMPTY : leftInput, leftInput == null ? 0 : leftInputAmount, rightInput == null ? EMPTY : rightInput, rightInput == null ? 0 : rightInputAmount, output); } public boolean hasMoltenMaterial(KilnMoltenMaterial moltenMaterial) { if (moltenMaterial.isRightBar()) { return this.rightInput.equals(moltenMaterial.getMoltenType()); } else { return this.leftInput.equals(moltenMaterial.getMoltenType()); } } public boolean isLeftInputEmpty() { return this.leftInput.equals(EMPTY); } public boolean isRightInputEmpty() { return this.rightInput.equals(EMPTY); } @Override public int compareTo(@NotNull KilnMixingRecipe kilnMixing) { int inputAmountLeft = Integer.compare(this.rightInputAmount, kilnMixing.rightInputAmount); if (inputAmountLeft != 0) return inputAmountLeft; return Integer.compare(this.leftInputAmount, kilnMixing.leftInputAmount); } } Screenshots: Spoiler Iron Ore -> Molten Iron Molten Iron -> Iron Nugget (the button allows us to switch to the Iron Ingot Recipe) The thing is... i want to use JEI to display my Recipes but that's only possible if i make the melting and smelting classes to true recipes but i got no clue how to check the "MoltenMaterial" values from the BlockEntity within the Recipe class Quote
Potato5 Posted September 21, 2022 Posted September 21, 2022 why would a recipe depend on a block entity? you know there could be several around filled with different combinations of materials. i don't get what you want so how about you do this - make a jei plugin that adds one dummy recipe; then work up from there. if you don't know how, look at the source of some mod that adds recipes (farmer's delight, etc.), there are many on github. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.