Skip to content

Commit

Permalink
1.19.4 blegh
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Jan 24, 2025
1 parent 4fb50dc commit 64e041a
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public Identifier getId() {
private static final Map<FurnitureRecipe, List<EmiStack>> outputs = new HashMap<>();
public static List<EmiStack> getOutputEntries(FurnitureRecipe recipe) {
if (!outputs.containsKey(recipe))
outputs.put(recipe, recipe.getInnerRecipes().stream().map(FurnitureRecipe.CraftableFurnitureRecipe::getOutput).map(EmiStack::of).collect(Collectors.toList()));
outputs.put(recipe, recipe.getInnerRecipes().stream().map(FurnitureRecipe.CraftableFurnitureRecipe::getRecipeOuput).map(EmiStack::of).collect(Collectors.toList()));
return outputs.get(recipe);
}

static Map<ItemStack, List<ItemStack>> itemStackListMap = new HashMap<>();
public static List<ItemStack> collectIngredientsFromRecipe(FurnitureRecipe.CraftableFurnitureRecipe recipe) {
if (itemStackListMap.containsKey(recipe.getOutput())) return itemStackListMap.get(recipe.getOutput());
if (itemStackListMap.containsKey(recipe.getRecipeOuput())) return itemStackListMap.get(recipe.getRecipeOuput());

List<Ingredient> ingredients = recipe.getIngredients();
HashMap<Item, Integer> containedItems = new HashMap<>();
Expand All @@ -119,7 +119,7 @@ public static List<ItemStack> collectIngredientsFromRecipe(FurnitureRecipe.Craft
}
}

itemStackListMap.put(recipe.getOutput(), listOfList);
itemStackListMap.put(recipe.getRecipeOuput(), listOfList);
return listOfList;
}

Expand Down Expand Up @@ -160,7 +160,7 @@ public SlotWidget getInputWidget(int slot, int x, int y) {
public SlotWidget getOutputWidget(int x, int y) {
return new GeneratedSlotWidget((r -> {
int selectedRecipe = r.nextInt(recipe.getInnerRecipes().size());
return EmiIngredient.of(Ingredient.ofStacks(recipe.getInnerRecipes().get(selectedRecipe).getOutput()), recipe.getOutputCount());
return EmiIngredient.of(Ingredient.ofStacks(recipe.getInnerRecipes().get(selectedRecipe).getRecipeOuput()), recipe.getInnerRecipes().get(selectedRecipe).getRecipeOuput().getCount());
}), unique, x, y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void setRecipe(@NotNull IRecipeLayoutBuilder builder, FurnitureRecipe rec

Map<ItemStack, List<List<ItemStack>>> itemStackListMap = new HashMap<>();
public List<List<ItemStack>> collectIngredientsFromRecipe(FurnitureRecipe.CraftableFurnitureRecipe recipe) {
if (itemStackListMap.containsKey(recipe.getOutput())) return itemStackListMap.get(recipe.getOutput());
if (itemStackListMap.containsKey(recipe.getRecipeOuput())) return itemStackListMap.get(recipe.getRecipeOuput());

List<Ingredient> ingredients = recipe.getIngredients();
HashMap<Item, Integer> containedItems = new HashMap<>();
Expand All @@ -156,14 +156,14 @@ public List<List<ItemStack>> collectIngredientsFromRecipe(FurnitureRecipe.Crafta
}
}

itemStackListMap.put(recipe.getOutput(), listOfList);
itemStackListMap.put(recipe.getRecipeOuput(), listOfList);
return listOfList;
}

private final Map<FurnitureRecipe, List<ItemStack>> outputs = new HashMap<>();
public List<ItemStack> getOutputEntries(FurnitureRecipe recipe) {
if (!outputs.containsKey(recipe))
outputs.put(recipe, recipe.getInnerRecipes().stream().map(FurnitureRecipe.CraftableFurnitureRecipe::getOutput).toList());
outputs.put(recipe, recipe.getInnerRecipes().stream().map(FurnitureRecipe.CraftableFurnitureRecipe::getRecipeOuput).toList());
return outputs.get(recipe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FurnitureDisplay implements Display {
private int itemsPerInnerRecipe;
public FurnitureDisplay(FurnitureRecipe recipe) {
this.recipe = recipe;
this.itemsPerInnerRecipe = recipe.getIngredients().size(MinecraftClient.getInstance().world.getRegistryManager());
this.itemsPerInnerRecipe = recipe.getIngredients().size();
}

private final List<EntryIngredient> inputs = new ArrayList<>();
Expand Down Expand Up @@ -95,7 +95,7 @@ public int itemsPerInnerRecipe() {
@Override
public List<EntryIngredient> getOutputEntries() {
if (outputs.isEmpty())
outputs.addAll(recipe.getInnerRecipes().stream().map(FurnitureRecipe.CraftableFurnitureRecipe::getOutput).map(EntryIngredients::of).toList());
outputs.addAll(recipe.getInnerRecipes().stream().map(FurnitureRecipe.CraftableFurnitureRecipe::getRecipeOuput).map(EntryIngredients::of).toList());
return outputs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ boolean craft() {
if (!this.availableRecipes.isEmpty() && this.isInBounds(this.availableRecipes, this.selectedRecipe.get())) {
FurnitureRecipe.CraftableFurnitureRecipe simpleFurnitureRecipe = this.sortedRecipes.get(this.selectedRecipe.get());
if (simpleFurnitureRecipe.matches(playerInventory, playerInventory.player.world)) {
simpleFurnitureRecipe.craftAndRemoveItems(playerInventory);
simpleFurnitureRecipe.craftAndRemoveItems(playerInventory, playerInventory.player.world.getRegistryManager());
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
Expand Down Expand Up @@ -129,7 +130,7 @@ public boolean matches(PlayerInventory inventory, World world) {
}

@Override
public List<CraftableFurnitureRecipe> getAvailableOutputs(PlayerInventory inventory) {
public List<CraftableFurnitureRecipe> getAvailableOutputs(PlayerInventory inventory, DynamicRegistryManager registryManager) {
constructInnerRecipes();
List<CraftableFurnitureRecipe> stacks = Lists.newArrayList();
for (Identifier id : furnitureInnerRecipes.keySet()) {
Expand Down Expand Up @@ -157,7 +158,7 @@ public String outputClass() {
}

@Override
public ItemStack craft(PlayerInventory inventory) {
public ItemStack craft(PlayerInventory inventory, DynamicRegistryManager registryManager) {
PaladinFurnitureMod.GENERAL_LOGGER.warn("Something has tried to craft a dynamic furniture recipe without context");
return ItemStack.EMPTY;
}
Expand All @@ -168,7 +169,7 @@ public boolean fits(int width, int height) {
}

@Override
public ItemStack getOutput() {
public ItemStack getOutput(DynamicRegistryManager registryManager) {
PaladinFurnitureMod.GENERAL_LOGGER.warn("Something has tried to get the output of a dynamic furniture recipe without context");
return ItemStack.EMPTY;
}
Expand Down Expand Up @@ -196,7 +197,7 @@ public List<Identifier> getSupportedVariants() {
}

@Override
public int getOutputCount() {
public int getOutputCount(DynamicRegistryManager registryManager) {
return furnitureOutput.getOutputCount();
}

Expand Down Expand Up @@ -225,7 +226,7 @@ public List<? extends CraftableFurnitureRecipe> getInnerRecipesForVariant(Identi


@Override
public String getName() {
public String getName(DynamicRegistryManager registryManager) {
return outputClass().replaceAll("(?<=[a-z])(?=[A-Z])", " ");
}

Expand All @@ -247,10 +248,12 @@ public FurnitureInnerRecipe(DynamicFurnitureRecipe parentRecipe, ItemStack outpu
parentRecipe.outputItemToInnerRecipe.put(output.getItem(), this);
}

public ItemStack getOutput() {
@Override
public ItemStack getOutput(DynamicRegistryManager registryManager) {
return output;
}

@Override
public List<Ingredient> getIngredients() {
return combinedIngredients;
}
Expand Down Expand Up @@ -280,9 +283,14 @@ public FurnitureRecipe parent() {
}

@Override
public ItemStack craft(PlayerInventory inventory) {
public ItemStack craft(PlayerInventory inventory, DynamicRegistryManager registryManager) {
return output.copy();
}

@Override
public ItemStack getRecipeOuput() {
return output;
}
}

public static class FurnitureOutput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ default RecipeType<?> getType() {

String outputClass();

default List<CraftableFurnitureRecipe> getAvailableOutputs(PlayerInventory inventory) {
default List<CraftableFurnitureRecipe> getAvailableOutputs(PlayerInventory inventory, DynamicRegistryManager registryManager) {
return getInnerRecipes();
}

Expand All @@ -55,31 +55,33 @@ default int getMaxInnerRecipeSize() {
return getIngredients().size();
}

default int getOutputCount() {
return getOutput().getCount();
default int getOutputCount(DynamicRegistryManager registryManager) {
return getOutput(registryManager).getCount();
}

default List<? extends CraftableFurnitureRecipe> getInnerRecipesForVariant(Identifier identifier) {
return Collections.singletonList(getInnerRecipes().get(0));
}

default String getName() {
return getOutput().getName().getString();
default String getName(DynamicRegistryManager registryManager) {
return getOutput(registryManager).getName().getString();
}

interface CraftableFurnitureRecipe extends Comparable<CraftableFurnitureRecipe> {
List<Ingredient> getIngredients();
ItemStack getOutput();
ItemStack craft(PlayerInventory inventory);
ItemStack getOutput(DynamicRegistryManager registryManager);
ItemStack craft(PlayerInventory inventory, DynamicRegistryManager registryManager);
boolean matches(PlayerInventory playerInventory, World world);
FurnitureRecipe parent();
ItemStack getRecipeOuput();

@Override
default int compareTo(@NotNull FurnitureRecipe.CraftableFurnitureRecipe o) {
return getOutput().toString().compareTo(o.getOutput().toString());
return getRecipeOuput().toString().compareTo(o.getRecipeOuput().toString());
}

default ItemStack craftAndRemoveItems(PlayerInventory playerInventory) {
ItemStack output = getOutput().copy();
default ItemStack craftAndRemoveItems(PlayerInventory playerInventory, DynamicRegistryManager registryManager) {
ItemStack output = getOutput(registryManager).copy();
List<Ingredient> ingredients = getIngredients();
for (Ingredient ingredient : ingredients) {
for (ItemStack stack : ingredient.getMatchingStacks()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.nbt.NbtOps;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.recipe.*;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registries;
import net.minecraft.util.Identifier;
import net.minecraft.util.JsonHelper;
Expand Down Expand Up @@ -63,9 +64,14 @@ public FurnitureRecipe parent() {
return this;
}

@Override
public ItemStack getRecipeOuput() {
return output;
}


@Override
public ItemStack craft(PlayerInventory playerInventory) {
public ItemStack craft(PlayerInventory playerInventory, DynamicRegistryManager registryManager) {
if (this.output.getNbt() != null && this.output.getNbt().isEmpty()) {
ItemStack stack = this.output.copy();
stack.setNbt(null);
Expand All @@ -85,7 +91,7 @@ public String getGroup() {
}

@Override
public ItemStack getOutput() {
public ItemStack getOutput(DynamicRegistryManager registryManager) {
return this.output;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void run() throws IOException {


PFMMCMetaProvider metaProvider = new PFMMCMetaProvider(this);
metaProvider.setInfo(new PFMMCMetaProvider.PackInfo(PackType.RESOURCE, "PFM-Assets"));
metaProvider.setInfo(new PFMMCMetaProvider.PackInfo(ResourceType.CLIENT_RESOURCES, "PFM-Assets"));
providers.add(metaProvider);
providers.add(new PFMBlockstateModelProvider(this));
providers.add(new PFMLangProvider(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void run() throws IOException {
providers.add(new PFMRecipeProvider(this));

PFMMCMetaProvider metaProvider = new PFMMCMetaProvider(this);
metaProvider.setInfo(new PFMMCMetaProvider.PackInfo(PackType.DATA, "PFM-Data"));
metaProvider.setInfo(new PFMMCMetaProvider.PackInfo(ResourceType.SERVER_DATA, "PFM-Data"));
providers.add(metaProvider);
this.setTotalCount(providers.size());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public void setup(World level, IVariableProvider variables) {
ItemStack icon = recipe.createIcon();
return IVariable.from(icon);
} else if (key.equals("text")) {
return IVariable.wrap(recipe.getOutputCount() + "x$(br)" + recipe.getName());
return IVariable.wrap(recipe.getOutputCount(level.getRegistryManager()) + "x$(br)" + recipe.getName(level.getRegistryManager()));
} else if (key.equals("icount")) {
return IVariable.wrap(recipe.getOutputCount());
return IVariable.wrap(recipe.getOutputCount(level.getRegistryManager()));
} else if (key.equals("iname")) {
return IVariable.wrap(recipe.getName());
return IVariable.wrap(recipe.getName(level.getRegistryManager()));
}
}
return IVariable.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public void setup(World level, IVariableProvider variables) {
ItemStack icon = recipe.createIcon();
return IVariable.from(icon);
} else if (key.equals("text")) {
return IVariable.wrap(recipe.getOutputCount() + "x$(br)" + recipe.getName());
return IVariable.wrap(recipe.getOutputCount(level.getRegistryManager()) + "x$(br)" + recipe.getName(level.getRegistryManager()));
} else if (key.equals("icount")) {
return IVariable.wrap(recipe.getOutputCount());
return IVariable.wrap(recipe.getOutputCount(level.getRegistryManager()));
} else if (key.equals("iname")) {
return IVariable.wrap(recipe.getName());
return IVariable.wrap(recipe.getName(level.getRegistryManager()));
}
}
return IVariable.empty();
Expand Down

0 comments on commit 64e041a

Please sign in to comment.