Class CompositeHolderSet<T>
java.lang.Object
net.minecraftforge.registries.holdersets.CompositeHolderSet<T>
- All Implemented Interfaces:
Iterable<Holder<T>>
,HolderSet<T>
,IForgeHolderSet<T>
,ICustomHolderSet<T>
- Direct Known Subclasses:
AndHolderSet
,OrHolderSet
Composite holdersets have component holdersets and possibly owner holdersets
(which have this holderset as a component).
When their component holderset(s) invalidate, they clear any cached data and then
invalidate their owner holdersets.
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.core.HolderSet
HolderSet.Direct<T>, HolderSet.ListBacked<T>, HolderSet.Named<T>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addInvalidationListener
(Runnable runnable) Adds a callback to run when this holderset's contents invalidate (i.e.boolean
Returns immutable Set of Holders given this composite holderset's component holdersets.get
(int i) getList()
getRandomElement
(RandomSource rand) getSet()
private void
boolean
isValidInRegistry
(Registry<T> registry) iterator()
int
size()
stream()
unwrap()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraftforge.registries.holdersets.ICustomHolderSet
type
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
owners
-
components
-
set
-
list
-
-
Constructor Details
-
CompositeHolderSet
-
-
Method Details
-
createSet
Returns immutable Set of Holders given this composite holderset's component holdersets.- Returns:
- immutable Set of Holders given this composite holderset's component holdersets
-
getComponents
-
getSet
-
getList
-
addInvalidationListener
Description copied from interface:IForgeHolderSet
Adds a callback to run when this holderset's contents invalidate (i.e. because tags were rebound).
The intended usage and use case is with composite holdersets that need to cache sets/list based on other holdersets, which may be mutable (because they are tag-based or themselves composite holdersets). Composite holdersets should use this to add callbacks to each of their component holdersets when constructed.
- Specified by:
addInvalidationListener
in interfaceIForgeHolderSet<T>
- Parameters:
runnable
- Runnable to invoke when this component holderset's contents are no longer valid. This runnable should only clear caches and allow them to be lazily reevaluated later, as not all tag holdersets may have been rebound when this is called. This runnable should also invalidate all of the caller's listeners.
-
invalidate
private void invalidate() -
stream
-
size
public int size() -
unwrap
-
getRandomElement
- Specified by:
getRandomElement
in interfaceHolderSet<T>
-
get
-
contains
-
isValidInRegistry
- Specified by:
isValidInRegistry
in interfaceHolderSet<T>
-
iterator
-