From 6284b45618b018f774515588cecda5a3bc6d6d5e Mon Sep 17 00:00:00 2001 From: cheaterpaul Date: Sat, 20 Jan 2024 14:46:27 +0100 Subject: [PATCH] fix item combiner menus without a result slot --- .../inventory/AltarInfusionMenu.java | 3 +- .../inventory/HunterTrainerMenu.java | 3 +- ...odifiedItemCombinerMenuSlotDefinition.java | 37 +++++++++++++++++++ .../resources/META-INF/accesstransformer.cfg | 3 +- 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/main/java/de/teamlapen/vampirism/inventory/ModifiedItemCombinerMenuSlotDefinition.java diff --git a/src/main/java/de/teamlapen/vampirism/inventory/AltarInfusionMenu.java b/src/main/java/de/teamlapen/vampirism/inventory/AltarInfusionMenu.java index 45ce4b726a..d57f74097b 100644 --- a/src/main/java/de/teamlapen/vampirism/inventory/AltarInfusionMenu.java +++ b/src/main/java/de/teamlapen/vampirism/inventory/AltarInfusionMenu.java @@ -84,11 +84,10 @@ public void createResultSlot(@NotNull ItemCombinerMenuSlotDefinition definition) } public static ItemCombinerMenuSlotDefinition createInputSlotDefinition() { - return ItemCombinerMenuSlotDefinition.create() + return ModifiedItemCombinerMenuSlotDefinition.createWithoutResult() .withSlot(0, 44, 34, stack -> stack.is(ModTags.Items.PURE_BLOOD)) .withSlot(1, 80, 34, stack -> stack.is(ModItems.HUMAN_HEART.get())) .withSlot(2, 116, 34, stack -> stack.is(ModItems.VAMPIRE_BOOK.get())) - .withResultSlot(0, 0, 0) .build(); } } diff --git a/src/main/java/de/teamlapen/vampirism/inventory/HunterTrainerMenu.java b/src/main/java/de/teamlapen/vampirism/inventory/HunterTrainerMenu.java index 623e33fbdb..893b86b47e 100644 --- a/src/main/java/de/teamlapen/vampirism/inventory/HunterTrainerMenu.java +++ b/src/main/java/de/teamlapen/vampirism/inventory/HunterTrainerMenu.java @@ -65,11 +65,10 @@ public void createResult() { @Override protected @NotNull ItemCombinerMenuSlotDefinition createInputSlotDefinitions() { - return ItemCombinerMenuSlotDefinition.create() + return ModifiedItemCombinerMenuSlotDefinition.createWithoutResult() .withSlot(0, 27, 26, stack -> this.lvlRequirement.filter(req -> req.ironQuantity() > 0).isPresent() && stack.is(Items.IRON_INGOT)) .withSlot(1, 57, 26, stack -> this.lvlRequirement.filter(req -> req.goldQuantity() > 0).isPresent() && stack.is(Items.GOLD_INGOT)) .withSlot(2, 86, 26, stack -> this.lvlRequirement.map(req -> req.tableRequirement().resultIntelItem().get()).filter(stack::is).isPresent()) - .withResultSlot(0, 0, 0) .build(); } diff --git a/src/main/java/de/teamlapen/vampirism/inventory/ModifiedItemCombinerMenuSlotDefinition.java b/src/main/java/de/teamlapen/vampirism/inventory/ModifiedItemCombinerMenuSlotDefinition.java new file mode 100644 index 0000000000..3af6f2ece6 --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/inventory/ModifiedItemCombinerMenuSlotDefinition.java @@ -0,0 +1,37 @@ +package de.teamlapen.vampirism.inventory; + +import net.minecraft.world.inventory.ItemCombinerMenuSlotDefinition; +import net.minecraft.world.item.ItemStack; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; + +public class ModifiedItemCombinerMenuSlotDefinition extends ItemCombinerMenuSlotDefinition { + + public ModifiedItemCombinerMenuSlotDefinition(List pSlots, SlotDefinition pResultSlot) { + super(pSlots, pResultSlot); + } + + public static ModifiedItemCombinerMenuSlotDefinition.Builder createWithoutResult() { + return new ModifiedItemCombinerMenuSlotDefinition.Builder(); + } + + @Override + public int getResultSlotIndex() { + return this.getResultSlot().slotIndex(); + } + + public static class Builder { + private final List slots = new ArrayList<>(); + + public ModifiedItemCombinerMenuSlotDefinition.Builder withSlot(int pSlotIndex, int pX, int pY, Predicate pMayPlace) { + this.slots.add(new SlotDefinition(pSlotIndex, pX, pY, pMayPlace)); + return this; + } + + public ModifiedItemCombinerMenuSlotDefinition build() { + return new ModifiedItemCombinerMenuSlotDefinition(this.slots, new SlotDefinition(this.slots.size()-1, 0, 0, (p_266823_) -> false)); + } + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 6eab914769..9df1909059 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -140,4 +140,5 @@ public net.minecraft.client.renderer.entity.layers.RenderLayer m_117376_(Lnet/mi public net.minecraft.client.model.PlayerModel f_103373_ # cloak public net.minecraft.client.gui.screens.achievement.StatsScreen$GeneralStatisticsList public net.minecraft.client.gui.screens.achievement.StatsScreen$GeneralStatisticsList$Entry -public net.minecraft.client.gui.components.AbstractSelectionList$Entry \ No newline at end of file +public net.minecraft.client.gui.components.AbstractSelectionList$Entry +public net.minecraft.world.inventory.ItemCombinerMenuSlotDefinition (Ljava/util/List;Lnet/minecraft/world/inventory/ItemCombinerMenuSlotDefinition$SlotDefinition;)V # ItemCombinerMenuSlotDefinition \ No newline at end of file