Class ProgressBarComponent<T extends IComponentHarness>

java.lang.Object
com.hrznstudio.titanium.component.progress.ProgressBarComponent<T>
All Implemented Interfaces:
IScreenAddonProvider, IContainerAddonProvider, net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>

public class ProgressBarComponent<T extends IComponentHarness> extends Object implements net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>, IScreenAddonProvider, IContainerAddonProvider
  • Constructor Details

    • ProgressBarComponent

      public ProgressBarComponent(int posX, int posY, int maxProgress)
    • ProgressBarComponent

      public ProgressBarComponent(int posX, int posY, int progress, int maxProgress)
  • Method Details

    • setOnFinishWork

      public ProgressBarComponent<T> setOnFinishWork(Runnable runnable)
      Sets a runnable to be executed when the bar is completed
      Parameters:
      runnable - The runnable
      Returns:
      Self
    • setOnTickWork

      public ProgressBarComponent<T> setOnTickWork(Runnable runnable)
      Sets a runnable to be executed every time the bar ticks
      Parameters:
      runnable - The runnable
      Returns:
      Self
    • setOnStart

      public ProgressBarComponent<T> setOnStart(Runnable runnable)
      Sets a runnable to be executed every time the bar starts from 0
      Parameters:
      runnable - The runnable
      Returns:
      Self
    • setComponentHarness

      public ProgressBarComponent<T> setComponentHarness(T componentHarness)
      Sets the tile where this bar is running
      Parameters:
      componentHarness - The tile
      Returns:
      Self
    • getComponentHarness

      public T getComponentHarness()
      Gets the tile where this bar is running
      Returns:
      The tile
    • getCanReset

      public Predicate<T> getCanReset()
      Gets if the bar can reset
      Returns:
      True if the bar can be reseted
    • setCanReset

      public ProgressBarComponent<T> setCanReset(Predicate<T> canReset)
      Sets if the the bar can be reseted when the progress is completed
      Parameters:
      canReset - A Predicate
      Returns:
      Self
    • getIncreaseType

      public boolean getIncreaseType()
    • setIncreaseType

      public ProgressBarComponent<T> setIncreaseType(boolean increaseType)
      Changes how the progress bar behaves when working
      Parameters:
      increaseType - True if the progress bar increases when working, false if the progress bar decreases when working
      Returns:
      itself
    • tickBar

      public void tickBar()
      Ticks the bar so it can increase if possible, managed by MultiProgressBarHandler.update()
    • getPosX

      public int getPosX()
      Gets where the bar is located in the X
      Returns:
      the x position
    • getPosY

      public int getPosY()
      Gets where the bar is located in the X
      Returns:
      the y position
    • getCanIncrease

      public Predicate<T> getCanIncrease()
      Gets if the progress can be increased
      Returns:
      A predicate
    • setCanIncrease

      public ProgressBarComponent<T> setCanIncrease(Predicate<T> canIncrease)
      Sets a predicate to check if the bar can be increased
      Parameters:
      canIncrease - A predicate
      Returns:
      Self
    • getProgress

      public int getProgress()
      Gets the current progress
      Returns:
      The progress
    • setProgress

      public void setProgress(int progress)
      Sets the progress bar progress
      Parameters:
      progress - The progress to set
    • getMaxProgress

      public int getMaxProgress()
      Gets the max progress of the bar
      Returns:
      The bas progress
    • setMaxProgress

      public ProgressBarComponent<T> setMaxProgress(int maxProgress)
      Sets the max progress of the bar
      Parameters:
      maxProgress - The max progress
      Returns:
      Self
    • getTickingTime

      public int getTickingTime()
      Gets how often the bar ticks
      Returns:
      The tick the bar tries to increase
    • setTickingTime

      public ProgressBarComponent<T> setTickingTime(int tickingTime)
      Sets how often the bar ticks
      Parameters:
      tickingTime - The ticking time
      Returns:
      Self
    • getProgressIncrease

      public int getProgressIncrease()
      Gets how much the bar increases when it can increase progress
      Returns:
      The amount it increases
    • setProgressIncrease

      public ProgressBarComponent<T> setProgressIncrease(int progressIncrease)
      Sets how much the bar will increase when it can increase
      Parameters:
      progressIncrease - The increase amount
      Returns:
      Self
    • getBarDirection

      public ProgressBarComponent.BarDirection getBarDirection()
      Gets the bar direction
      Returns:
      The bar direction
    • setBarDirection

      public ProgressBarComponent<T> setBarDirection(ProgressBarComponent.BarDirection direction)
      Sets the direction render for the bar in the gui
      Parameters:
      direction - The bar direction
      Returns:
      Self
    • getColor

      public net.minecraft.world.item.DyeColor getColor()
      Gets the color of the bar
      Returns:
      the color
    • setColor

      public ProgressBarComponent<T> setColor(net.minecraft.world.item.DyeColor color)
      Set the color of the progress bar
      Parameters:
      color - the color
      Returns:
      Self
    • getScreenAddons

      public List<IFactory<? extends IScreenAddon>> getScreenAddons()
      Gets the Gui Addons that it will be added to the machine GUI
      Specified by:
      getScreenAddons in interface IScreenAddonProvider
      Returns:
      A list of GUI addon factories
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT()
      Specified by:
      serializeNBT in interface net.minecraftforge.common.util.INBTSerializable<T extends IComponentHarness>
    • deserializeNBT

      public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt)
      Specified by:
      deserializeNBT in interface net.minecraftforge.common.util.INBTSerializable<T extends IComponentHarness>
    • onStart

      public void onStart()
    • getContainerAddons

      public List<IFactory<? extends IContainerAddon>> getContainerAddons()
      Specified by:
      getContainerAddons in interface IContainerAddonProvider