Class SimpleTicket<T>
java.lang.Object
net.neoforged.neoforge.common.ticket.SimpleTicket<T>
- Type Parameters:
T- The type that will be used to check if your ticket matches
- Direct Known Subclasses:
AABBTicket
Common class for a simple ticket based system.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ITicketManager<T>[]protected booleanprivate @Nullable ITicketManager<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidforEachManager(Consumer<ITicketManager<T>> consumer) protected final ITicketManager<T>[]protected final ITicketManager<T> voidRemoves the ticket from the managing system.booleanisValid()Checks if your ticket is still registered in the system.abstract booleanfinal voidsetManager(ITicketManager<T> masterManager, ITicketManager<T>... dummyManagers) Internal method that sets the collection from the managing system.booleanunload(ITicketManager<T> unloadingManager) Called by the managing system when a ticket wishes to unload all of it's tickets, e.g.voidvalidate()Re-adds your ticket to the system.
-
Field Details
-
masterManager
-
dummyManagers
-
isValid
protected boolean isValid
-
-
Constructor Details
-
SimpleTicket
public SimpleTicket()
-
-
Method Details
-
setManager
@SafeVarargs public final void setManager(ITicketManager<T> masterManager, ITicketManager<T>... dummyManagers) Internal method that sets the collection from the managing system.
Should not be called if you just want to register a ticket to a system like theFarmlandWaterManager -
isValid
public boolean isValid()Checks if your ticket is still registered in the system. -
invalidate
public void invalidate()Removes the ticket from the managing system. After this call, any calls toisValid()should return false unless it is registered again usingvalidate() -
unload
Called by the managing system when a ticket wishes to unload all of it's tickets, e.g. on chunk unload
The ticket must not remove itself from the manager that is calling the unload! The ticket must ensure that it removes itself from all of it's dummies when returning true- Parameters:
unloadingManager- The manager that is unloading this ticket- Returns:
- true if this ticket can be removed, false if not.
-
validate
public void validate()Re-adds your ticket to the system. -
matches
-
forEachManager
-
getMasterManager
-
getDummyManagers
-