mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Merge pull request #2788 from jaredlll08/mc1.18/dev
Fixed using ShapedRecipe instead of IShapedRecipe and restrictive shapeless check.
This commit is contained in:
commit
d522ec70a3
4 changed files with 21 additions and 16 deletions
|
@ -31,6 +31,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.item.crafting.*;
|
import net.minecraft.world.item.crafting.*;
|
||||||
import net.minecraft.world.level.ItemLike;
|
import net.minecraft.world.level.ItemLike;
|
||||||
|
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -94,7 +95,7 @@ public class CreateJEI implements IModPlugin {
|
||||||
.build(),
|
.build(),
|
||||||
|
|
||||||
autoShapeless = register("automatic_shapeless", MixingCategory::autoShapeless)
|
autoShapeless = register("automatic_shapeless", MixingCategory::autoShapeless)
|
||||||
.recipes(r -> r.getSerializer() == RecipeSerializer.SHAPELESS_RECIPE && r.getIngredients()
|
.recipes(r -> r instanceof CraftingRecipe && !(r instanceof IShapedRecipe<?>) && r.getIngredients()
|
||||||
.size() > 1 && !MechanicalPressTileEntity.canCompress(r) && !AllRecipeTypes.isManualRecipe(r),
|
.size() > 1 && !MechanicalPressTileEntity.canCompress(r) && !AllRecipeTypes.isManualRecipe(r),
|
||||||
BasinRecipe::convertShapeless)
|
BasinRecipe::convertShapeless)
|
||||||
.catalyst(AllBlocks.MECHANICAL_MIXER::get)
|
.catalyst(AllBlocks.MECHANICAL_MIXER::get)
|
||||||
|
@ -173,10 +174,10 @@ public class CreateJEI implements IModPlugin {
|
||||||
.build(),
|
.build(),
|
||||||
|
|
||||||
autoShaped = register("automatic_shaped", MechanicalCraftingCategory::new)
|
autoShaped = register("automatic_shaped", MechanicalCraftingCategory::new)
|
||||||
.recipes(r -> r.getSerializer() == RecipeSerializer.SHAPELESS_RECIPE && r.getIngredients()
|
.recipes(r -> r instanceof CraftingRecipe && !(r instanceof IShapedRecipe<?>) && r.getIngredients()
|
||||||
.size() == 1)
|
.size() == 1)
|
||||||
.recipes(r -> (r.getType() == RecipeType.CRAFTING
|
.recipes(r -> (r.getType() == RecipeType.CRAFTING
|
||||||
&& r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.getType()) && (r instanceof ShapedRecipe)
|
&& r.getType() != AllRecipeTypes.MECHANICAL_CRAFTING.getType()) && (r instanceof IShapedRecipe<?>)
|
||||||
&& !AllRecipeTypes.isManualRecipe(r))
|
&& !AllRecipeTypes.isManualRecipe(r))
|
||||||
.catalyst(AllBlocks.MECHANICAL_CRAFTER::get)
|
.catalyst(AllBlocks.MECHANICAL_CRAFTER::get)
|
||||||
.enableWhen(c -> c.allowRegularCraftingInCrafter)
|
.enableWhen(c -> c.allowRegularCraftingInCrafter)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.world.item.TooltipFlag;
|
||||||
import net.minecraft.world.item.crafting.CraftingRecipe;
|
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||||
import net.minecraft.world.item.crafting.Ingredient;
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
import net.minecraft.world.item.crafting.ShapedRecipe;
|
||||||
|
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||||
|
|
||||||
public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRecipe> {
|
public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRecipe> {
|
||||||
|
|
||||||
|
@ -86,11 +87,11 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getWidth(CraftingRecipe recipe) {
|
private static int getWidth(CraftingRecipe recipe) {
|
||||||
return recipe instanceof ShapedRecipe ? ((ShapedRecipe) recipe).getWidth() : 1;
|
return recipe instanceof IShapedRecipe<?> ? ((IShapedRecipe<?>) recipe).getRecipeWidth() : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getHeight(CraftingRecipe recipe) {
|
private static int getHeight(CraftingRecipe recipe) {
|
||||||
return recipe instanceof ShapedRecipe ? ((ShapedRecipe) recipe).getHeight() : 1;
|
return recipe instanceof IShapedRecipe<?> ? ((IShapedRecipe<?>) recipe).getRecipeHeight() : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.crafting.CraftingRecipe;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
|
@ -40,6 +41,7 @@ import net.minecraft.world.phys.AABB;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
@ -237,7 +239,7 @@ public class MechanicalMixerTileEntity extends BasinOperatingTileEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <C extends Container> boolean matchStaticFilters(Recipe<C> r) {
|
protected <C extends Container> boolean matchStaticFilters(Recipe<C> r) {
|
||||||
return ((r.getSerializer() == RecipeSerializer.SHAPELESS_RECIPE
|
return ((r instanceof CraftingRecipe && !(r instanceof IShapedRecipe<?>)
|
||||||
&& AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients()
|
&& AllConfigs.SERVER.recipes.allowShapelessInMixer.get() && r.getIngredients()
|
||||||
.size() > 1
|
.size() > 1
|
||||||
&& !MechanicalPressTileEntity.canCompress(r)) && !AllRecipeTypes.isManualRecipe(r)
|
&& !MechanicalPressTileEntity.canCompress(r)) && !AllRecipeTypes.isManualRecipe(r)
|
||||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.world.item.crafting.Ingredient.Value;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
import net.minecraft.world.item.crafting.ShapedRecipe;
|
import net.minecraft.world.item.crafting.ShapedRecipe;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraftforge.common.crafting.IShapedRecipe;
|
||||||
import net.minecraftforge.common.crafting.MultiItemValue;
|
import net.minecraftforge.common.crafting.MultiItemValue;
|
||||||
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
@ -79,12 +80,12 @@ public class BlueprintItem extends Item {
|
||||||
inv.setStackInSlot(i, ItemStack.EMPTY);
|
inv.setStackInSlot(i, ItemStack.EMPTY);
|
||||||
inv.setStackInSlot(9, recipe.getResultItem());
|
inv.setStackInSlot(9, recipe.getResultItem());
|
||||||
|
|
||||||
if (recipe instanceof ShapedRecipe) {
|
if (recipe instanceof IShapedRecipe) {
|
||||||
ShapedRecipe shapedRecipe = (ShapedRecipe) recipe;
|
IShapedRecipe<?> shapedRecipe = (IShapedRecipe<?>) recipe;
|
||||||
for (int row = 0; row < shapedRecipe.getHeight(); row++)
|
for (int row = 0; row < shapedRecipe.getRecipeHeight(); row++)
|
||||||
for (int col = 0; col < shapedRecipe.getWidth(); col++)
|
for (int col = 0; col < shapedRecipe.getRecipeWidth(); col++)
|
||||||
inv.setStackInSlot(row * 3 + col,
|
inv.setStackInSlot(row * 3 + col,
|
||||||
convertIngredientToFilter(ingredients.get(row * shapedRecipe.getWidth() + col)));
|
convertIngredientToFilter(ingredients.get(row * shapedRecipe.getRecipeWidth() + col)));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < ingredients.size(); i++)
|
for (int i = 0; i < ingredients.size(); i++)
|
||||||
inv.setStackInSlot(i, convertIngredientToFilter(ingredients.get(i)));
|
inv.setStackInSlot(i, convertIngredientToFilter(ingredients.get(i)));
|
||||||
|
|
Loading…
Reference in a new issue