Skip to main content

calculate_redstone_signal_from_container

Function calculate_redstone_signal_from_container 

Source
pub fn calculate_redstone_signal_from_container(
    container: &dyn Container,
) -> i32
Expand description

Calculates the redstone comparator signal strength (0-15) from a container.

Based on Java’s AbstractContainerMenu.getRedstoneSignalFromContainer. The signal is proportional to how full the container is:

  • 0 = empty
  • 1-14 = partially filled (linear interpolation)
  • 15 = completely full

§Arguments

  • container - The container to calculate the signal for

§Returns

Signal strength from 0 to 15