public abstract class ScreenHandler extends Object
Modifier and Type | Field and Description |
---|---|
private short |
actionId |
private List<ScreenHandlerListener> |
listeners |
private List<Property> |
properties |
private int |
quickCraftButton |
private Set<Slot> |
quickCraftSlots |
private int |
quickCraftStage |
private Set<PlayerEntity> |
restrictedPlayers |
List<Slot> |
slots |
int |
syncId |
private DefaultedList<ItemStack> |
trackedStacks
A list of item stacks that is used for tracking changes in
sendContentUpdates() . |
private ScreenHandlerType<?> |
type |
Modifier | Constructor and Description |
---|---|
protected |
ScreenHandler(ScreenHandlerType<?> type,
int syncId) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ScreenHandlerListener listener) |
protected void |
addProperties(PropertyDelegate propertyDelegate) |
protected Property |
addProperty(Property property) |
protected Slot |
addSlot(Slot slot) |
static int |
calculateComparatorOutput(BlockEntity entity) |
static int |
calculateComparatorOutput(Inventory inventory) |
static void |
calculateStackSize(Set<Slot> slots,
int mode,
ItemStack stack,
int stackSize) |
boolean |
canInsertIntoSlot(ItemStack stack,
Slot slot) |
boolean |
canInsertIntoSlot(Slot slot) |
static boolean |
canInsertItemIntoSlot(Slot slot,
ItemStack stack,
boolean allowOverflow) |
static boolean |
canStacksCombine(ItemStack first,
ItemStack second) |
abstract boolean |
canUse(PlayerEntity player) |
protected static boolean |
canUse(ScreenHandlerContext context,
PlayerEntity player,
Block block) |
protected static void |
checkDataCount(PropertyDelegate data,
int expectedCount)
Checks that the size of the
data is at least as large as the expectedCount . |
protected static void |
checkSize(Inventory inventory,
int expectedSize)
Checks that the size of the provided inventory is at least as large as the
expectedSize . |
void |
close(PlayerEntity player) |
protected void |
dropInventory(PlayerEntity player,
World world,
Inventory inventory) |
protected void |
endQuickCraft() |
short |
getNextActionId(PlayerInventory playerInventory) |
Slot |
getSlot(int index) |
DefaultedList<ItemStack> |
getStacks() |
ScreenHandlerType<?> |
getType() |
protected boolean |
insertItem(ItemStack stack,
int startIndex,
int endIndex,
boolean fromLast) |
boolean |
isNotRestricted(PlayerEntity player) |
private ItemStack |
method_30010(int int2,
int int3,
SlotActionType slotActionType,
PlayerEntity playerEntity) |
boolean |
onButtonClick(PlayerEntity player,
int id) |
void |
onContentChanged(Inventory inventory) |
ItemStack |
onSlotClick(int int2,
int int3,
SlotActionType actionType,
PlayerEntity playerEntity)
Performs a slot click.
|
static int |
packQuickCraftData(int quickCraftStage,
int buttonId) |
void |
removeListener(ScreenHandlerListener listener) |
void |
sendContentUpdates()
Sends updates to listeners if any properties or slot stacks have changed.
|
void |
setPlayerRestriction(PlayerEntity player,
boolean unrestricted) |
void |
setProperty(int id,
int value) |
void |
setStackInSlot(int slot,
ItemStack stack) |
static boolean |
shouldQuickCraftContinue(int stage,
PlayerEntity player) |
ItemStack |
transferSlot(PlayerEntity player,
int index) |
static int |
unpackQuickCraftButton(int quickCraftData) |
static int |
unpackQuickCraftStage(int quickCraftData) |
void |
updateSlotStacks(List<ItemStack> stacks) |
private final DefaultedList<ItemStack> trackedStacks
sendContentUpdates()
.@Nullable private final ScreenHandlerType<?> type
public final int syncId
@Environment(value=CLIENT) private short actionId
private int quickCraftStage
private int quickCraftButton
private final List<ScreenHandlerListener> listeners
private final Set<PlayerEntity> restrictedPlayers
protected ScreenHandler(@Nullable ScreenHandlerType<?> type, int syncId)
protected static boolean canUse(ScreenHandlerContext context, PlayerEntity player, Block block)
public ScreenHandlerType<?> getType()
protected static void checkSize(Inventory inventory, int expectedSize)
expectedSize
.IllegalArgumentException
- if the inventory size is smaller than expectedSize
protected static void checkDataCount(PropertyDelegate data, int expectedCount)
data
is at least as large as the expectedCount
.IllegalArgumentException
- if the data
has a smaller size than expectedCount
protected void addProperties(PropertyDelegate propertyDelegate)
public void addListener(ScreenHandlerListener listener)
@Environment(value=CLIENT) public void removeListener(ScreenHandlerListener listener)
public DefaultedList<ItemStack> getStacks()
public void sendContentUpdates()
public boolean onButtonClick(PlayerEntity player, int id)
public Slot getSlot(int index)
public ItemStack transferSlot(PlayerEntity player, int index)
public ItemStack onSlotClick(int int2, int int3, SlotActionType actionType, PlayerEntity playerEntity)
actionType
- The type of slot click. Check the docs for each SlotActionType value for detailsprivate ItemStack method_30010(int int2, int int3, SlotActionType slotActionType, PlayerEntity playerEntity)
public void close(PlayerEntity player)
protected void dropInventory(PlayerEntity player, World world, Inventory inventory)
public void onContentChanged(Inventory inventory)
public void setStackInSlot(int slot, ItemStack stack)
public void setProperty(int id, int value)
@Environment(value=CLIENT) public short getNextActionId(PlayerInventory playerInventory)
public boolean isNotRestricted(PlayerEntity player)
public void setPlayerRestriction(PlayerEntity player, boolean unrestricted)
public abstract boolean canUse(PlayerEntity player)
protected boolean insertItem(ItemStack stack, int startIndex, int endIndex, boolean fromLast)
public static int unpackQuickCraftButton(int quickCraftData)
public static int unpackQuickCraftStage(int quickCraftData)
@Environment(value=CLIENT) public static int packQuickCraftData(int quickCraftStage, int buttonId)
public static boolean shouldQuickCraftContinue(int stage, PlayerEntity player)
protected void endQuickCraft()
public static boolean canInsertItemIntoSlot(@Nullable Slot slot, ItemStack stack, boolean allowOverflow)
public static void calculateStackSize(Set<Slot> slots, int mode, ItemStack stack, int stackSize)
public boolean canInsertIntoSlot(Slot slot)
public static int calculateComparatorOutput(@Nullable BlockEntity entity)