public class ServerTickScheduler<T> extends Object implements TickScheduler<T>
Modifier and Type | Field and Description |
---|---|
private List<ScheduledTick<T>> |
consumedTickActions |
private Queue<ScheduledTick<T>> |
currentTickActions |
private Function<T,Identifier> |
idToName |
protected Predicate<T> |
invalidObjPredicate |
private Set<ScheduledTick<T>> |
scheduledTickActions |
private TreeSet<ScheduledTick<T>> |
scheduledTickActionsInOrder |
private Consumer<ScheduledTick<T>> |
tickConsumer |
private ServerWorld |
world |
Constructor and Description |
---|
ServerTickScheduler(ServerWorld world,
Predicate<T> invalidObjPredicate,
Function<T,Identifier> idToName,
Consumer<ScheduledTick<T>> consumer) |
Modifier and Type | Method and Description |
---|---|
private void |
addScheduledTick(ScheduledTick<T> scheduledTick) |
void |
copyScheduledTicks(BlockBox box,
BlockPos offset) |
List<ScheduledTick<T>> |
getScheduledTicks(BlockBox bounds,
boolean updateState,
boolean getStaleTicks) |
List<ScheduledTick<T>> |
getScheduledTicksInChunk(ChunkPos chunkPos,
boolean updateState,
boolean getStaleTicks) |
int |
getTicks() |
boolean |
isScheduled(BlockPos pos,
T object) |
boolean |
isTicking(BlockPos pos,
T object) |
void |
schedule(BlockPos pos,
T object,
int delay,
TickPriority priority) |
private static <T> ListTag |
serializeScheduledTicks(Function<T,Identifier> identifierProvider,
Iterable<ScheduledTick<T>> scheduledTicks,
long time) |
void |
tick() |
ListTag |
toTag(ChunkPos chunkPos) |
private List<ScheduledTick<T>> |
transferTicksInBounds(List<ScheduledTick<T>> dst,
Collection<ScheduledTick<T>> src,
BlockBox bounds,
boolean move) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
schedule
private final Function<T,Identifier> idToName
private final Set<ScheduledTick<T>> scheduledTickActions
private final TreeSet<ScheduledTick<T>> scheduledTickActionsInOrder
private final ServerWorld world
private final Queue<ScheduledTick<T>> currentTickActions
private final List<ScheduledTick<T>> consumedTickActions
private final Consumer<ScheduledTick<T>> tickConsumer
public ServerTickScheduler(ServerWorld world, Predicate<T> invalidObjPredicate, Function<T,Identifier> idToName, Consumer<ScheduledTick<T>> consumer)
public void tick()
public boolean isTicking(BlockPos pos, T object)
isTicking
in interface TickScheduler<T>
public List<ScheduledTick<T>> getScheduledTicksInChunk(ChunkPos chunkPos, boolean updateState, boolean getStaleTicks)
public List<ScheduledTick<T>> getScheduledTicks(BlockBox bounds, boolean updateState, boolean getStaleTicks)
@Nullable private List<ScheduledTick<T>> transferTicksInBounds(@Nullable List<ScheduledTick<T>> dst, Collection<ScheduledTick<T>> src, BlockBox bounds, boolean move)
private static <T> ListTag serializeScheduledTicks(Function<T,Identifier> identifierProvider, Iterable<ScheduledTick<T>> scheduledTicks, long time)
public boolean isScheduled(BlockPos pos, T object)
isScheduled
in interface TickScheduler<T>
public void schedule(BlockPos pos, T object, int delay, TickPriority priority)
schedule
in interface TickScheduler<T>
private void addScheduledTick(ScheduledTick<T> scheduledTick)
public int getTicks()