Skip to content

Commit

Permalink
fix item combiner menus without a result slot
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jan 20, 2024
1 parent 044561d commit 6284b45
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<SlotDefinition> 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<SlotDefinition> slots = new ArrayList<>();

public ModifiedItemCombinerMenuSlotDefinition.Builder withSlot(int pSlotIndex, int pX, int pY, Predicate<ItemStack> 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));
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
public net.minecraft.client.gui.components.AbstractSelectionList$Entry
public net.minecraft.world.inventory.ItemCombinerMenuSlotDefinition <init>(Ljava/util/List;Lnet/minecraft/world/inventory/ItemCombinerMenuSlotDefinition$SlotDefinition;)V # ItemCombinerMenuSlotDefinition

0 comments on commit 6284b45

Please sign in to comment.