/** * Call this with an interval (in ticks) to find out if the current tick is the one you want to do some work. This is staggered so the work of different TEs * is stretched out over time. * * @see #shouldDoWorkThisTick(int, int) If you need to offset work ticks */ protected boolean shouldDoWorkThisTick(int interval) { return shouldDoWorkThisTick(interval, 0); }
protected boolean shouldDoWorkThisTick(@Nonnull World world, @Nonnull BlockPos pos, int interval) { T te = getTileEntity(world, pos); if (te == null) { return world.getTotalWorldTime() % interval == 0; } else { return te.shouldDoWorkThisTick(interval); } }
protected boolean shouldDoWorkThisTick(@Nonnull World world, @Nonnull BlockPos pos, int interval, int offset) { T te = getTileEntity(world, pos); if (te == null) { return (world.getTotalWorldTime() + offset) % interval == 0; } else { return te.shouldDoWorkThisTick(interval, offset); } }