Skip to content

Commit

Permalink
WItemSlot: Add getters for native slots and slot ids
Browse files Browse the repository at this point in the history
Closes #247.
  • Loading branch information
Juuxel committed Aug 14, 2024
1 parent 493463e commit ef46775
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/io/github/cottonmc/cotton/gui/widget/WItemSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import io.github.cottonmc.cotton.gui.widget.focus.FocusModel;
import io.github.cottonmc.cotton.gui.widget.icon.Icon;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnmodifiableView;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -409,6 +411,25 @@ protected ValidatedSlot createSlotPeer(Inventory inventory, int index, int x, in
return new ValidatedSlot(inventory, index, x, y);
}

/**
* {@return an unmodifiable list containing the current slot peers}
*
* @since 11.1.0
*/
public @UnmodifiableView List<? extends ValidatedSlot> getPeers() {
return Collections.unmodifiableList(peers);
}

/**
* Gets the starting {@linkplain net.minecraft.screen.slot.Slot#id ID} for the slot peers.
*
* @return the starting ID for the slot peers, or -1 if this slot widget has no peers
* @since 11.1.0
*/
public int getPeerStartId() {
return !peers.isEmpty() ? peers.getFirst().id : -1;
}

/**
* Gets this slot widget's background painter.
*
Expand Down

0 comments on commit ef46775

Please sign in to comment.